From 4749abeb4c230a04397595d6577a07918cba38d8 Mon Sep 17 00:00:00 2001 From: frank mcmanus Date: Sat, 7 Dec 2019 15:39:00 -0500 Subject: [PATCH] Reinstall ts for gatsby --- .cache/babelState.json | 48 + .cache/redux.state | Bin 39881 -> 39038 bytes gatsby-config.js | 1 - .../plugin-syntax-typescript/lib/index.js | 12 +- .../plugin-syntax-typescript/package.json | 24 +- .../plugin-transform-typescript/lib/enum.js | 12 +- .../plugin-transform-typescript/lib/index.js | 129 +- .../lib/decorators.js | 70 +- .../lib/fields.js | 151 +- .../lib/index.js | 24 +- .../lib/misc.js | 42 +- .../package.json | 36 +- .../plugin-transform-typescript/package.json | 43 +- .../@babel/preset-typescript/lib/index.js | 49 +- .../@babel/preset-typescript/package.json | 28 +- .../@babel/preset-typescript/src/index.js | 29 +- .../jsx-compat/ts-invalid/options.json | 2 +- node_modules/@mdx-js/react/package.json | 18 +- node_modules/@types/react-dom/package.json | 5 +- node_modules/@types/react/README.md | 12 +- node_modules/@types/react/global.d.ts | 3 + node_modules/@types/react/index.d.ts | 47 +- node_modules/@types/react/package.json | 42 +- .../gatsby-plugin-tslint/package.json | 1 + .../gatsby-plugin-typescript/CHANGELOG.md | 32 + .../gatsby-plugin-typescript/README.md | 4 + .../gatsby-plugin-typescript/gatsby-node.js | 9 + .../@babel/runtime/helpers/AsyncGenerator.js | 2 +- .../runtime/helpers/asyncGeneratorDelegate.js | 5 + .../runtime/helpers/esm/AsyncGenerator.js | 2 +- .../helpers/esm/asyncGeneratorDelegate.js | 5 + .../helpers/esm/initializerWarningHelper.js | 2 +- .../helpers/esm/interopRequireWildcard.js | 27 +- .../runtime/helpers/esm/objectSpread.js | 2 +- .../runtime/helpers/esm/objectSpread2.js | 4 +- .../helpers/initializerWarningHelper.js | 2 +- .../runtime/helpers/interopRequireWildcard.js | 27 +- .../@babel/runtime/helpers/objectSpread.js | 2 +- .../@babel/runtime/helpers/objectSpread2.js | 4 +- .../node_modules/@babel/runtime/package.json | 31 +- .../CHANGELOG.md | 22 + .../index.js | 43 +- .../package.json | 28 +- .../gatsby-plugin-typescript/package.json | 28 +- node_modules/react/build-info.json | 10 +- node_modules/react/cjs/react.development.js | 943 +- .../react/cjs/react.production.min.js | 32 +- node_modules/react/package.json | 33 +- node_modules/react/umd/react.development.js | 5126 +-- .../react/umd/react.production.min.js | 51 +- node_modules/react/umd/react.profiling.min.js | 63 +- .../tslint-config-prettier/package.json | 3 +- node_modules/tslint-loader/package.json | 3 +- .../tslint-plugin-prettier/package.json | 3 +- .../node_modules/tsutils/package.json | 23 +- node_modules/tslint-react/package.json | 3 +- node_modules/tslint/CHANGELOG.md | 4 + node_modules/tslint/lib/linter.js | 2 +- .../node_modules/builtin-modules/package.json | 23 +- node_modules/tslint/package.json | 13 +- node_modules/typescript/.yarnrc | 1 - node_modules/typescript/README.md | 54 +- .../lib/cs/diagnosticMessages.generated.json | 2 +- .../lib/de/diagnosticMessages.generated.json | 2 +- .../lib/es/diagnosticMessages.generated.json | 4 +- .../lib/fr/diagnosticMessages.generated.json | 6 +- .../lib/ja/diagnosticMessages.generated.json | 30 +- .../lib/ko/diagnosticMessages.generated.json | 4 +- node_modules/typescript/lib/lib.dom.d.ts | 383 +- .../typescript/lib/lib.dom.iterable.d.ts | 32 +- .../typescript/lib/lib.es2015.collection.d.ts | 8 +- .../typescript/lib/lib.es2015.core.d.ts | 14 +- .../typescript/lib/lib.es2015.promise.d.ts | 22 +- .../typescript/lib/lib.es2017.object.d.ts | 2 +- .../lib/lib.es2018.asyncgenerator.d.ts | 2 +- .../lib/lib.es2018.asynciterable.d.ts | 2 +- .../typescript/lib/lib.es2018.intl.d.ts | 6 +- .../typescript/lib/lib.es2019.array.d.ts | 6 +- .../typescript/lib/lib.es2019.string.d.ts | 16 +- .../typescript/lib/lib.es2019.symbol.d.ts | 12 +- .../typescript/lib/lib.es2020.string.d.ts | 12 +- .../lib/lib.es2020.symbol.wellknown.d.ts | 22 +- node_modules/typescript/lib/lib.es5.d.ts | 4372 +-- .../typescript/lib/lib.esnext.bigint.d.ts | 650 +- node_modules/typescript/lib/lib.esnext.d.ts | 2 +- .../typescript/lib/lib.esnext.intl.d.ts | 2 +- .../typescript/lib/lib.webworker.d.ts | 42 +- .../lib/pl/diagnosticMessages.generated.json | 10 +- node_modules/typescript/lib/protocol.d.ts | 41 +- .../pt-br/diagnosticMessages.generated.json | 2 +- .../lib/ru/diagnosticMessages.generated.json | 30 +- .../lib/tr/diagnosticMessages.generated.json | 2 +- node_modules/typescript/lib/tsc.js | 20042 +++++----- node_modules/typescript/lib/tsserver.js | 30677 +++++++++------- .../typescript/lib/tsserverlibrary.d.ts | 1376 +- .../typescript/lib/tsserverlibrary.js | 30502 ++++++++------- node_modules/typescript/lib/typescript.d.ts | 1277 +- node_modules/typescript/lib/typescript.js | 29968 ++++++++------- .../typescript/lib/typescriptServices.d.ts | 1277 +- .../typescript/lib/typescriptServices.js | 29968 ++++++++------- .../typescript/lib/typingsInstaller.js | 22627 +++++++----- .../zh-cn/diagnosticMessages.generated.json | 4 +- .../zh-tw/diagnosticMessages.generated.json | 64 +- node_modules/typescript/package.json | 38 +- package-lock.json | 290 +- package.json | 27 +- src/components/NotFound.tsx | 16 +- src/pages/past-meetups.tsx | 12 +- tsconfig.json | 9 + tslint.json | 11 - 110 files changed, 106049 insertions(+), 75375 deletions(-) delete mode 100644 node_modules/typescript/.yarnrc delete mode 100644 tslint.json diff --git a/.cache/babelState.json b/.cache/babelState.json index cf43e1825..98c1e9c3d 100644 --- a/.cache/babelState.json +++ b/.cache/babelState.json @@ -5,6 +5,18 @@ { "name": "@babel/plugin-proposal-object-rest-spread", "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js", + "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js", + "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-numeric-separator/lib/index.js", + "options": {} } ], "presets": [ @@ -25,6 +37,18 @@ { "name": "@babel/plugin-proposal-object-rest-spread", "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js", + "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js", + "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-numeric-separator/lib/index.js", + "options": {} } ], "presets": [ @@ -45,6 +69,18 @@ { "name": "@babel/plugin-proposal-object-rest-spread", "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js", + "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js", + "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-numeric-separator/lib/index.js", + "options": {} } ], "presets": [ @@ -65,6 +101,18 @@ { "name": "@babel/plugin-proposal-object-rest-spread", "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-optional-chaining/lib/index.js", + "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-nullish-coalescing-operator/lib/index.js", + "options": {} + }, + { + "name": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-proposal-numeric-separator/lib/index.js", + "options": {} } ], "presets": [ diff --git a/.cache/redux.state b/.cache/redux.state index 95b71b5ea872a8432600620079fa2aa65faf33a2..f84222e3d823841094ca2bd540075b137c25a1fc 100644 GIT binary patch delta 3624 zcmbVOYit}>7526AD*tN0aNA2F7xf>5%?`(I* zNn9s#QW>Z~qH0goCXR#}9zqmaQcWcgP)dYQML;kzXF z70PWTmDR!P4HfM2(95`H)HAZ5@z0>_6RLhXO{()|u|1ND?XT&%437JJ@Fah))m(SQ zx1#001cx_b%SF25P4=GMcSSE#uFerk;IT;s;%y}`d;j$XRJwJ3z9c%O zDSBG=GR36h6f-o9Q#05kXuAxo6QKR7uFTqO6R6$O7^y@*9#b<@n8?OWwjy~q<4$Sm zC*(@TYbaSQW6ITxJAn)=*VNjcv^=?o@fhY@3dc)J2>?yj%>(bQw(O1YU~a&&i3&sr zy2}%6VrbcI)3!5yp#AU>_*VOF(74y?k!>=Y=`Bvft5Xx!mwC;#!bfdnkZM}*AU4}8 z=Hw`bwiD|mlC5yO@$ea9jEXrhi?bTBGVhuy2=m+P%E?>qxX5oOEsr)s+>spNF{V*A zlatl=;T!i(<|H6qCvlf*_kNYj<6bWu>WzTVat(gpHI#3NU_?k_7K?()3alauJjW$i zmF2OJ6jj70Ik-|H!Jm(Q7pt5>X)TEjGkh8+^51d*>IbR<#L--t)5yL#2<>pGuLv&j2drNWd}-B}o*E2L zK|T_}h*OfH6pba+4uOqwD9I)g(S)iZfycIh#r1BnoqLl9*R7#<%N&fB6>9r;ro4}; zgwA>aZVrbjHS4!j;p*|R zpob&V#qhZ?kyQKFzE)Z;hd+%8q|CbU)<9)G!vMVAQymb((J)V>TvP;9$<&I3V@ZjN zDzOO93(;6KDvC*jIz&NGBdo-BBo$l2)(9Qi+a47vZ$XLNe9k=pL6v0k0JzT(Sp zG4Ww#(}f3Dg3_Via>a5gi#yxMHt&V1bkjpv*R>-;(Lbm>ctt*pM2`i={Jb7p0G zP(@gj6kZ~SDM~acL=;}(lo%UDtQ28Y0X|3_f;Z+qth`Dy0rEaI&ACDCDa?2{i4Q`5 zwyubmhFG>!%7b)r>;1`;LNbHaz(HIgro=04SPbMQ+ViS=l zmk<#rN!BYbyg^YzF!kaM*U-EhxTP+5Yq1c%@X|A6w*2BhowaT_`b8fczqGi#=Lj?` bJ?$a;nSOXui^C(A%i&*3FOt2_Uhe!Kn7&bq delta 3640 zcmb_eU2Ggz753fP_1f`2b`m>@oz3+o_PW{a%)X@P>&TjF%v90tRZn$*~7jrYy*#ho> zYg<}-7jC$`b^_PriFr&jju&vXNu9NG&CC^<1pH9+b(SVOF8LQZ>DV%HFHShvENpCC zLd?MrUd5YO18{eKQ$+*(39m!pq<6W3E6QV^cuIM^bT0T8?_yQo4NanD)z?KSaApX$k99VC)N@sgJo=nnptKjx0e~L^4?zua9Egvz49mE?ZlbT@^bKH^UR&F&&m*! z*nK}$ zLEHVwYT=}3faBm&SmIb1zB#zfy}r;Z`m3k-h!{!0%kd!myH|!crpC)1*(J$DmLmTWWl0Uk(}EsOsIf#?BC0M$6(u35vVr}# z9GBurIDK%8w=LF5HuhvS99&HTI6uDKp&?XBgXi8fIEcqr9Di(zH{Np5;cSi;iJiGs zpwBH3nupg#+U{`P@IvKvY}C3gz$ORoOlq1H7*FlV7U1#W&T1bYVURi`7LvYIkcg`n zvQ|5&P%~J?-eMM#F-!w{3nWi*!?;Oj4KuKtn0a=hk6C;+hdb;HwcQ7-k68TqeH-DW za2^sH0-O-x8Kpa2W&9)F(o(-eWL5EDk}GD2tC8YlXN|zNxgvRIGQ>Fwxmw=_Z}_5c zbE>VZg3Uw_W17ZmjDAs<)pU$dUJzv(i)uGB$WxOZ(0=8DIOGYTDV4DEYs z$(8Fz*PsBeYqBIsL=kl*E@(tZ6Dh6h2~AhTcsiy#+KW|cZ>7n^y#C3tD-8^Zg-&L3 zACkU3s1rW7c?y0qvA*6vB}fs)?bK@c%|xG%b?QhBe7IjiYv7}JM?=k&7!jh8s1vV; z!Bj75gk!0Yr`dpwkM_drsWphXZR$bP2LDWnXdPUBAPA%5t*9Md*wG26*=hrv8|Tp` z=o-fGpIx;LekWx_a58ooFu?cKRlAWm3k2X;cQ;HNXhRr|9f+eKTsqL(w5_Z|pF1%D zO{_(|aQ#3J>Vx$YA+#Nm6JgIt1d5XZpCc$9&P~Rck-an7hhp%z$taQ_^jHWbAobXm z2G^MeIy-TbMrYy8huWcy?e@UPiSIZ>4*Jx-|})8a8zkp)d40-T~d;o|HKxTuHW##}S} zO7Ecw-Tpxt;K3q+FBREsMKD$9w|k>`GdxZ#st zc=OC4+?@Br5jcy6;X3@n$D%j|=-B~yz0eAq&V6HH-w1fmKjp5;mj~h9^Ivm!j=DQ< RUTB6NTsY4%?D~5D{{Tl8R$Kr8 diff --git a/gatsby-config.js b/gatsby-config.js index c957edfd1..b225d5d15 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -18,7 +18,6 @@ module.exports = { `gatsby-transformer-sharp`, `gatsby-plugin-sharp`, `gatsby-plugin-typescript`, - `gatsby-plugin-tslint`, { resolve: `gatsby-plugin-manifest`, options: { diff --git a/node_modules/@babel/plugin-syntax-typescript/lib/index.js b/node_modules/@babel/plugin-syntax-typescript/lib/index.js index 304ea46c7..402ce0847 100644 --- a/node_modules/@babel/plugin-syntax-typescript/lib/index.js +++ b/node_modules/@babel/plugin-syntax-typescript/lib/index.js @@ -5,15 +5,7 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); - - _helperPluginUtils = function () { - return data; - }; - - return data; -} +var _helperPluginUtils = require("@babel/helper-plugin-utils"); function removePlugin(plugins, name) { const indices = []; @@ -30,7 +22,7 @@ function removePlugin(plugins, name) { } } -var _default = (0, _helperPluginUtils().declare)((api, { +var _default = (0, _helperPluginUtils.declare)((api, { isTSX }) => { api.assertVersion(7); diff --git a/node_modules/@babel/plugin-syntax-typescript/package.json b/node_modules/@babel/plugin-syntax-typescript/package.json index 2b6acd4e3..d26fc9372 100644 --- a/node_modules/@babel/plugin-syntax-typescript/package.json +++ b/node_modules/@babel/plugin-syntax-typescript/package.json @@ -1,27 +1,27 @@ { - "_from": "@babel/plugin-syntax-typescript@^7.2.0", - "_id": "@babel/plugin-syntax-typescript@7.3.3", + "_from": "@babel/plugin-syntax-typescript@^7.7.4", + "_id": "@babel/plugin-syntax-typescript@7.7.4", "_inBundle": false, - "_integrity": "sha512-dGwbSMA1YhVS8+31CnPR7LB4pcbrzcV99wQzby4uAfrkZPYZlQ7ImwdpzLqi6Z6IL02b8IAL379CaMwo0x5Lag==", + "_integrity": "sha512-77blgY18Hud4NM1ggTA8xVT/dBENQf17OpiToSa2jSmEY3fWXD2jwrdVlO4kq5yzUTeF15WSQ6b4fByNvJcjpQ==", "_location": "/@babel/plugin-syntax-typescript", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "@babel/plugin-syntax-typescript@^7.2.0", + "raw": "@babel/plugin-syntax-typescript@^7.7.4", "name": "@babel/plugin-syntax-typescript", "escapedName": "@babel%2fplugin-syntax-typescript", "scope": "@babel", - "rawSpec": "^7.2.0", + "rawSpec": "^7.7.4", "saveSpec": null, - "fetchSpec": "^7.2.0" + "fetchSpec": "^7.7.4" }, "_requiredBy": [ "/@babel/plugin-transform-typescript" ], - "_resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.3.3.tgz", - "_shasum": "a7cc3f66119a9f7ebe2de5383cce193473d65991", - "_spec": "@babel/plugin-syntax-typescript@^7.2.0", + "_resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.7.4.tgz", + "_shasum": "5d037ffa10f3b25a16f32570ebbe7a8c2efa304b", + "_spec": "@babel/plugin-syntax-typescript@^7.7.4", "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-transform-typescript", "bundleDependencies": false, "dependencies": { @@ -30,9 +30,9 @@ "deprecated": false, "description": "Allow parsing of TypeScript syntax", "devDependencies": { - "@babel/core": "^7.3.3" + "@babel/core": "^7.7.4" }, - "gitHead": "d1fe2d05f4c468640facf40565e30f7110757f2d", + "gitHead": "75767d87cb147709b9bd9b99bf44daa6688874a9", "keywords": [ "babel-plugin", "typescript" @@ -50,5 +50,5 @@ "type": "git", "url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-typescript" }, - "version": "7.3.3" + "version": "7.7.4" } diff --git a/node_modules/@babel/plugin-transform-typescript/lib/enum.js b/node_modules/@babel/plugin-transform-typescript/lib/enum.js index aad14f9c9..f58f7244e 100644 --- a/node_modules/@babel/plugin-transform-typescript/lib/enum.js +++ b/node_modules/@babel/plugin-transform-typescript/lib/enum.js @@ -135,14 +135,13 @@ function translateEnumValues(path, t) { } function evaluate(expr, seen) { - if (expr.type === "StringLiteral") { - return expr.value; - } - return evalConstant(expr); function evalConstant(expr) { switch (expr.type) { + case "StringLiteral": + return expr.value; + case "UnaryExpression": return evalUnaryExpression(expr); @@ -158,6 +157,11 @@ function evaluate(expr, seen) { case "Identifier": return seen[expr.name]; + case "TemplateLiteral": + if (expr.quasis.length === 1) { + return expr.quasis[0].value.cooked; + } + default: return undefined; } diff --git a/node_modules/@babel/plugin-transform-typescript/lib/index.js b/node_modules/@babel/plugin-transform-typescript/lib/index.js index 1d161f8a0..5dde591fc 100644 --- a/node_modules/@babel/plugin-transform-typescript/lib/index.js +++ b/node_modules/@babel/plugin-transform-typescript/lib/index.js @@ -49,10 +49,76 @@ function registerGlobalType(programScope, name) { var _default = (0, _helperPluginUtils.declare)((api, { jsxPragma = "React", - allowNamespaces = false + allowNamespaces = false, + allowDeclareFields = false }) => { api.assertVersion(7); const JSX_ANNOTATION_REGEX = /\*?\s*@jsx\s+([^\s]+)/; + const classMemberVisitors = { + field(path) { + const { + node + } = path; + + if (!allowDeclareFields && node.declare) { + throw path.buildCodeFrameError(`The 'declare' modifier is only allowed when the 'allowDeclareFields' option of ` + `@babel/plugin-transform-typescript or @babel/preset-typescript is enabled.`); + } + + if (node.definite || node.declare) { + if (node.value) { + throw path.buildCodeFrameError(`Definietly assigned fields and fields with the 'declare' modifier cannot` + ` be initialized here, but only in the constructor`); + } + + path.remove(); + } else if (!allowDeclareFields && !node.value && !node.decorators) { + path.remove(); + } + + if (node.accessibility) node.accessibility = null; + if (node.abstract) node.abstract = null; + if (node.readonly) node.readonly = null; + if (node.optional) node.optional = null; + if (node.typeAnnotation) node.typeAnnotation = null; + }, + + method({ + node + }) { + if (node.accessibility) node.accessibility = null; + if (node.abstract) node.abstract = null; + if (node.optional) node.optional = null; + }, + + constructor(path, classPath) { + if (path.node.accessibility) path.node.accessibility = null; + const parameterProperties = []; + + for (const param of path.node.params) { + if (param.type === "TSParameterProperty" && !PARSED_PARAMS.has(param.parameter)) { + PARSED_PARAMS.add(param.parameter); + parameterProperties.push(param.parameter); + } + } + + if (parameterProperties.length) { + const assigns = parameterProperties.map(p => { + let id; + + if (_core.types.isIdentifier(p)) { + id = p; + } else if (_core.types.isAssignmentPattern(p) && _core.types.isIdentifier(p.left)) { + id = p.left; + } else { + throw path.buildCodeFrameError("Parameter properties can not be destructuring patterns."); + } + + return _core.template.statement.ast`this.${id} = ${id}`; + }); + (0, _helperCreateClassFeaturesPlugin.injectInitialization)(classPath, path, assigns); + } + } + + }; return { name: "transform-typescript", inherits: _pluginSyntaxTypescript.default, @@ -177,27 +243,6 @@ var _default = (0, _helperPluginUtils.declare)((api, { if (node.definite) node.definite = null; }, - ClassMethod(path) { - const { - node - } = path; - if (node.accessibility) node.accessibility = null; - if (node.abstract) node.abstract = null; - if (node.optional) node.optional = null; - }, - - ClassProperty(path) { - const { - node - } = path; - if (node.accessibility) node.accessibility = null; - if (node.abstract) node.abstract = null; - if (node.readonly) node.readonly = null; - if (node.optional) node.optional = null; - if (node.definite) node.definite = null; - if (node.typeAnnotation) node.typeAnnotation = null; - }, - TSIndexSignature(path) { path.remove(); }, @@ -222,42 +267,14 @@ var _default = (0, _helperPluginUtils.declare)((api, { if (node.implements) node.implements = null; if (node.abstract) node.abstract = null; path.get("body.body").forEach(child => { - const childNode = child.node; - - if (_core.types.isClassMethod(childNode, { - kind: "constructor" - })) { - const parameterProperties = []; - - for (const param of childNode.params) { - if (param.type === "TSParameterProperty" && !PARSED_PARAMS.has(param.parameter)) { - PARSED_PARAMS.add(param.parameter); - parameterProperties.push(param.parameter); - } - } - - if (parameterProperties.length) { - const assigns = parameterProperties.map(p => { - let id; - - if (_core.types.isIdentifier(p)) { - id = p; - } else if (_core.types.isAssignmentPattern(p) && _core.types.isIdentifier(p.left)) { - id = p.left; - } else { - throw path.buildCodeFrameError("Parameter properties can not be destructuring patterns."); - } - - return _core.template.statement.ast`this.${id} = ${id}`; - }); - (0, _helperCreateClassFeaturesPlugin.injectInitialization)(path, child, assigns); + if (child.isClassMethod()) { + if (child.node.kind === "constructor") { + classMemberVisitors.constructor(child, path); + } else { + classMemberVisitors.method(child, path); } } else if (child.isClassProperty()) { - childNode.typeAnnotation = null; - - if (!childNode.value && !childNode.decorators) { - child.remove(); - } + classMemberVisitors.field(child, path); } }); }, diff --git a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/decorators.js b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/decorators.js index 2188c4d2d..9abed3bfd 100644 --- a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/decorators.js +++ b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/decorators.js @@ -7,35 +7,11 @@ exports.hasOwnDecorators = hasOwnDecorators; exports.hasDecorators = hasDecorators; exports.buildDecoratedClass = buildDecoratedClass; -function _core() { - const data = require("@babel/core"); +var _core = require("@babel/core"); - _core = function () { - return data; - }; - - return data; -} - -function _helperReplaceSupers() { - const data = _interopRequireDefault(require("@babel/helper-replace-supers")); - - _helperReplaceSupers = function () { - return data; - }; +var _helperReplaceSupers = _interopRequireDefault(require("@babel/helper-replace-supers")); - return data; -} - -function _helperFunctionName() { - const data = _interopRequireDefault(require("@babel/helper-function-name")); - - _helperFunctionName = function () { - return data; - }; - - return data; -} +var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -49,18 +25,18 @@ function hasDecorators(node) { function prop(key, value) { if (!value) return null; - return _core().types.objectProperty(_core().types.identifier(key), value); + return _core.types.objectProperty(_core.types.identifier(key), value); } function method(key, body) { - return _core().types.objectMethod("method", _core().types.identifier(key), [], _core().types.blockStatement(body)); + return _core.types.objectMethod("method", _core.types.identifier(key), [], _core.types.blockStatement(body)); } function takeDecorators(node) { let result; if (node.decorators && node.decorators.length > 0) { - result = _core().types.arrayExpression(node.decorators.map(decorator => decorator.expression)); + result = _core.types.arrayExpression(node.decorators.map(decorator => decorator.expression)); } node.decorators = undefined; @@ -70,10 +46,10 @@ function takeDecorators(node) { function getKey(node) { if (node.computed) { return node.key; - } else if (_core().types.isIdentifier(node.key)) { - return _core().types.stringLiteral(node.key.name); + } else if (_core.types.isIdentifier(node.key)) { + return _core.types.stringLiteral(node.key.name); } else { - return _core().types.stringLiteral(String(node.key.value)); + return _core.types.stringLiteral(String(node.key.value)); } } @@ -88,7 +64,7 @@ function extractElementDescriptor(classRef, superRef, path) { throw path.buildCodeFrameError(`Private ${isMethod ? "methods" : "fields"} in decorated classes are not supported yet.`); } - new (_helperReplaceSupers().default)({ + new _helperReplaceSupers.default({ methodPath: path, methodNode: node, objectRef: classRef, @@ -97,26 +73,26 @@ function extractElementDescriptor(classRef, superRef, path) { scope, file: this }, true).replace(); - const properties = [prop("kind", _core().types.stringLiteral(isMethod ? node.kind : "field")), prop("decorators", takeDecorators(node)), prop("static", node.static && _core().types.booleanLiteral(true)), prop("key", getKey(node))].filter(Boolean); + const properties = [prop("kind", _core.types.stringLiteral(isMethod ? node.kind : "field")), prop("decorators", takeDecorators(node)), prop("static", node.static && _core.types.booleanLiteral(true)), prop("key", getKey(node))].filter(Boolean); if (isMethod) { const id = node.computed ? null : node.key; - _core().types.toExpression(node); + _core.types.toExpression(node); - properties.push(prop("value", (0, _helperFunctionName().default)({ + properties.push(prop("value", (0, _helperFunctionName.default)({ node, id, scope }) || node)); } else if (node.value) { - properties.push(method("value", _core().template.statements.ast`return ${node.value}`)); + properties.push(method("value", _core.template.statements.ast`return ${node.value}`)); } else { properties.push(prop("value", scope.buildUndefinedNode())); } path.remove(); - return _core().types.objectExpression(properties); + return _core.types.objectExpression(properties); } function addDecorateHelper(file) { @@ -143,7 +119,7 @@ function buildDecoratedClass(ref, path, elements, file) { superClass } = node; node.type = "ClassDeclaration"; - if (!node.id) node.id = _core().types.cloneNode(ref); + if (!node.id) node.id = _core.types.cloneNode(ref); let superId; if (superClass) { @@ -153,14 +129,14 @@ function buildDecoratedClass(ref, path, elements, file) { const classDecorators = takeDecorators(node); - const definitions = _core().types.arrayExpression(elements.map(extractElementDescriptor.bind(file, node.id, superId))); + const definitions = _core.types.arrayExpression(elements.map(extractElementDescriptor.bind(file, node.id, superId))); - let replacement = _core().template.expression.ast` + let replacement = _core.template.expression.ast` ${addDecorateHelper(file)}( - ${classDecorators || _core().types.nullLiteral()}, + ${classDecorators || _core.types.nullLiteral()}, function (${initializeId}, ${superClass ? superId : null}) { ${node} - return { F: ${_core().types.cloneNode(node.id)}, d: ${definitions} }; + return { F: ${_core.types.cloneNode(node.id)}, d: ${definitions} }; }, ${superClass} ) @@ -168,16 +144,16 @@ function buildDecoratedClass(ref, path, elements, file) { let classPathDesc = "arguments.1.body.body.0"; if (!isStrict) { - replacement.arguments[1].body.directives.push(_core().types.directive(_core().types.directiveLiteral("use strict"))); + replacement.arguments[1].body.directives.push(_core.types.directive(_core.types.directiveLiteral("use strict"))); } if (isDeclaration) { - replacement = _core().template.ast`let ${ref} = ${replacement}`; + replacement = _core.template.ast`let ${ref} = ${replacement}`; classPathDesc = "declarations.0.init." + classPathDesc; } return { - instanceNodes: [_core().template.statement.ast`${initializeId}(this)`], + instanceNodes: [_core.template.statement.ast`${initializeId}(this)`], wrapClass(path) { path.replaceWith(replacement); diff --git a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/fields.js b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/fields.js index e540cb73d..c018fa9bc 100644 --- a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/fields.js +++ b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/fields.js @@ -8,49 +8,21 @@ exports.buildPrivateNamesNodes = buildPrivateNamesNodes; exports.transformPrivateNamesUsage = transformPrivateNamesUsage; exports.buildFieldsInitNodes = buildFieldsInitNodes; -function _core() { - const data = require("@babel/core"); +var _core = require("@babel/core"); - _core = function () { - return data; - }; - - return data; -} - -function _helperReplaceSupers() { - const data = _interopRequireWildcard(require("@babel/helper-replace-supers")); - - _helperReplaceSupers = function () { - return data; - }; - - return data; -} +var _helperReplaceSupers = _interopRequireWildcard(require("@babel/helper-replace-supers")); -function _helperMemberExpressionToFunctions() { - const data = _interopRequireDefault(require("@babel/helper-member-expression-to-functions")); +var _helperMemberExpressionToFunctions = _interopRequireDefault(require("@babel/helper-member-expression-to-functions")); - _helperMemberExpressionToFunctions = function () { - return data; - }; - - return data; -} - -function _helperOptimiseCallExpression() { - const data = _interopRequireDefault(require("@babel/helper-optimise-call-expression")); +var _helperOptimiseCallExpression = _interopRequireDefault(require("@babel/helper-optimise-call-expression")); - _helperOptimiseCallExpression = function () { - return data; - }; - - return data; -} +var ts = _interopRequireWildcard(require("./typescript")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } +function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function buildPrivateNamesMap(props) { const privateNamesMap = new Map(); @@ -99,17 +71,17 @@ function buildPrivateNamesNodes(privateNamesMap, loose, state) { const isAccessor = getId || setId; if (loose) { - initNodes.push(_core().template.statement.ast` + initNodes.push(_core.template.statement.ast` var ${id} = ${state.addHelper("classPrivateFieldLooseKey")}("${name}") `); } else if (isMethod && !isStatic) { if (isAccessor) { - initNodes.push(_core().template.statement.ast`var ${id} = new WeakMap();`); + initNodes.push(_core.template.statement.ast`var ${id} = new WeakMap();`); } else { - initNodes.push(_core().template.statement.ast`var ${id} = new WeakSet();`); + initNodes.push(_core.template.statement.ast`var ${id} = new WeakSet();`); } } else if (!isStatic) { - initNodes.push(_core().template.statement.ast`var ${id} = new WeakMap();`); + initNodes.push(_core.template.statement.ast`var ${id} = new WeakMap();`); } } @@ -152,9 +124,9 @@ const privateNameVisitor = { }; -const privateNameInnerVisitor = _core().traverse.visitors.merge([{ +const privateNameInnerVisitor = _core.traverse.visitors.merge([{ PrivateName: privateNameVisitor.PrivateName -}, _helperReplaceSupers().environmentVisitor]); +}, _helperReplaceSupers.environmentVisitor]); const privateNameHandlerSpec = { memoise(member, count) { @@ -179,10 +151,10 @@ const privateNameHandlerSpec = { } = member.node; if (this.memoiser.has(object)) { - return _core().types.cloneNode(this.memoiser.get(object)); + return _core.types.cloneNode(this.memoiser.get(object)); } - return _core().types.cloneNode(object); + return _core.types.cloneNode(object); }, get(member) { @@ -206,18 +178,18 @@ const privateNameHandlerSpec = { if (isStatic) { const helperName = isMethod && !isAccessor ? "classStaticPrivateMethodGet" : "classStaticPrivateFieldSpecGet"; - return _core().types.callExpression(file.addHelper(helperName), [this.receiver(member), _core().types.cloneNode(classRef), _core().types.cloneNode(id)]); + return _core.types.callExpression(file.addHelper(helperName), [this.receiver(member), _core.types.cloneNode(classRef), _core.types.cloneNode(id)]); } if (isMethod) { if (isAccessor) { - return _core().types.callExpression(file.addHelper("classPrivateFieldGet"), [this.receiver(member), _core().types.cloneNode(id)]); + return _core.types.callExpression(file.addHelper("classPrivateFieldGet"), [this.receiver(member), _core.types.cloneNode(id)]); } - return _core().types.callExpression(file.addHelper("classPrivateMethodGet"), [this.receiver(member), _core().types.cloneNode(id), _core().types.cloneNode(methodId)]); + return _core.types.callExpression(file.addHelper("classPrivateMethodGet"), [this.receiver(member), _core.types.cloneNode(id), _core.types.cloneNode(methodId)]); } - return _core().types.callExpression(file.addHelper("classPrivateFieldGet"), [this.receiver(member), _core().types.cloneNode(id)]); + return _core.types.callExpression(file.addHelper("classPrivateFieldGet"), [this.receiver(member), _core.types.cloneNode(id)]); }, set(member, value) { @@ -240,18 +212,18 @@ const privateNameHandlerSpec = { if (isStatic) { const helperName = isMethod && !isAccessor ? "classStaticPrivateMethodSet" : "classStaticPrivateFieldSpecSet"; - return _core().types.callExpression(file.addHelper(helperName), [this.receiver(member), _core().types.cloneNode(classRef), _core().types.cloneNode(id), value]); + return _core.types.callExpression(file.addHelper(helperName), [this.receiver(member), _core.types.cloneNode(classRef), _core.types.cloneNode(id), value]); } if (isMethod) { if (setId) { - return _core().types.callExpression(file.addHelper("classPrivateFieldSet"), [this.receiver(member), _core().types.cloneNode(id), value]); + return _core.types.callExpression(file.addHelper("classPrivateFieldSet"), [this.receiver(member), _core.types.cloneNode(id), value]); } - return _core().types.callExpression(file.addHelper("classPrivateMethodSet"), []); + return _core.types.callExpression(file.addHelper("classPrivateMethodSet"), []); } - return _core().types.callExpression(file.addHelper("classPrivateFieldSet"), [this.receiver(member), _core().types.cloneNode(id), value]); + return _core.types.callExpression(file.addHelper("classPrivateFieldSet"), [this.receiver(member), _core.types.cloneNode(id), value]); }, destructureSet(member) { @@ -265,12 +237,12 @@ const privateNameHandlerSpec = { const { id } = privateNamesMap.get(name); - return _core().types.memberExpression(_core().types.callExpression(file.addHelper("classPrivateFieldDestructureSet"), [this.receiver(member), _core().types.cloneNode(id)]), _core().types.identifier("value")); + return _core.types.memberExpression(_core.types.callExpression(file.addHelper("classPrivateFieldDestructureSet"), [this.receiver(member), _core.types.cloneNode(id)]), _core.types.identifier("value")); }, call(member, args) { this.memoise(member, 1); - return (0, _helperOptimiseCallExpression().default)(this.get(member), this.receiver(member), args); + return (0, _helperOptimiseCallExpression.default)(this.get(member), this.receiver(member), args); } }; @@ -286,7 +258,7 @@ const privateNameHandlerLoose = { const { name } = member.node.property.id; - member.replaceWith(_core().template.expression`BASE(REF, PROP)[PROP]`({ + member.replaceWith(_core.template.expression`BASE(REF, PROP)[PROP]`({ BASE: file.addHelper("classPrivateFieldLooseBase"), REF: object, PROP: privateNamesMap.get(name).id @@ -304,7 +276,7 @@ function transformPrivateNamesUsage(ref, path, privateNamesMap, loose, state) { file: state }, privateNameHandlerLoose)); } else { - (0, _helperMemberExpressionToFunctions().default)(body, privateNameVisitor, Object.assign({ + (0, _helperMemberExpressionToFunctions.default)(body, privateNameVisitor, Object.assign({ privateNamesMap, classRef: ref, file: state @@ -317,7 +289,7 @@ function buildPrivateFieldInitLoose(ref, prop, privateNamesMap) { id } = privateNamesMap.get(prop.node.key.id.name); const value = prop.node.value || prop.scope.buildUndefinedNode(); - return _core().template.statement.ast` + return _core.template.statement.ast` Object.defineProperty(${ref}, ${id}, { // configurable is false by default // enumerable is false by default @@ -332,7 +304,7 @@ function buildPrivateInstanceFieldInitSpec(ref, prop, privateNamesMap) { id } = privateNamesMap.get(prop.node.key.id.name); const value = prop.node.value || prop.scope.buildUndefinedNode(); - return _core().template.statement.ast`${id}.set(${ref}, { + return _core.template.statement.ast`${id}.set(${ref}, { // configurable is always false for private elements // enumerable is always false for private elements writable: true, @@ -355,7 +327,7 @@ function buildPrivateStaticFieldInitSpec(prop, privateNamesMap) { privateNamesMap.set(prop.node.key.id.name, Object.assign({}, privateName, { initAdded: true })); - return _core().template.statement.ast` + return _core.template.statement.ast` var ${id.name} = { // configurable is false by default // enumerable is false by default @@ -367,7 +339,7 @@ function buildPrivateStaticFieldInitSpec(prop, privateNamesMap) { } const value = prop.node.value || prop.scope.buildUndefinedNode(); - return _core().template.statement.ast` + return _core.template.statement.ast` var ${id} = { // configurable is false by default // enumerable is false by default @@ -389,7 +361,7 @@ function buildPrivateMethodInitLoose(ref, prop, privateNamesMap) { if (initAdded) return; if (methodId) { - return _core().template.statement.ast` + return _core.template.statement.ast` Object.defineProperty(${ref}, ${id}, { // configurable is false by default // enumerable is false by default @@ -405,7 +377,7 @@ function buildPrivateMethodInitLoose(ref, prop, privateNamesMap) { privateNamesMap.set(prop.node.key.id.name, Object.assign({}, privateName, { initAdded: true })); - return _core().template.statement.ast` + return _core.template.statement.ast` Object.defineProperty(${ref}, ${id}, { // configurable is false by default // enumerable is false by default @@ -432,7 +404,7 @@ function buildPrivateInstanceMethodInitSpec(ref, prop, privateNamesMap) { privateNamesMap.set(prop.node.key.id.name, Object.assign({}, privateName, { initAdded: true })); - return _core().template.statement.ast` + return _core.template.statement.ast` ${id}.set(${ref}, { get: ${getId ? getId.name : prop.scope.buildUndefinedNode()}, set: ${setId ? setId.name : prop.scope.buildUndefinedNode()} @@ -440,7 +412,7 @@ function buildPrivateInstanceMethodInitSpec(ref, prop, privateNamesMap) { `; } - return _core().template.statement.ast`${id}.add(${ref})`; + return _core.template.statement.ast`${id}.add(${ref})`; } function buildPublicFieldInitLoose(ref, prop) { @@ -449,7 +421,7 @@ function buildPublicFieldInitLoose(ref, prop) { computed } = prop.node; const value = prop.node.value || prop.scope.buildUndefinedNode(); - return _core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.memberExpression(ref, key, computed || _core().types.isLiteral(key)), value)); + return _core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.memberExpression(ref, key, computed || _core.types.isLiteral(key)), value)); } function buildPublicFieldInitSpec(ref, prop, state) { @@ -458,7 +430,7 @@ function buildPublicFieldInitSpec(ref, prop, state) { computed } = prop.node; const value = prop.node.value || prop.scope.buildUndefinedNode(); - return _core().types.expressionStatement(_core().types.callExpression(state.addHelper("defineProperty"), [ref, computed || _core().types.isLiteral(key) ? key : _core().types.stringLiteral(key.name), value])); + return _core.types.expressionStatement(_core.types.callExpression(state.addHelper("defineProperty"), [ref, computed || _core.types.isLiteral(key) ? key : _core.types.stringLiteral(key.name), value])); } function buildPrivateStaticMethodInitLoose(ref, prop, state, privateNamesMap) { @@ -477,7 +449,7 @@ function buildPrivateStaticMethodInitLoose(ref, prop, state, privateNamesMap) { privateNamesMap.set(prop.node.key.id.name, Object.assign({}, privateName, { initAdded: true })); - return _core().template.statement.ast` + return _core.template.statement.ast` Object.defineProperty(${ref}, ${id}, { // configurable is false by default // enumerable is false by default @@ -488,7 +460,7 @@ function buildPrivateStaticMethodInitLoose(ref, prop, state, privateNamesMap) { `; } - return _core().template.statement.ast` + return _core.template.statement.ast` Object.defineProperty(${ref}, ${id}, { // configurable is false by default // enumerable is false by default @@ -516,7 +488,7 @@ function buildPrivateMethodDeclaration(prop, privateNamesMap, loose = false) { async } = prop.node; - const methodValue = _core().types.functionExpression(methodId, params, body, generator, async); + const methodValue = _core.types.functionExpression(methodId, params, body, generator, async); const isGetter = getId && !getterDeclared && params.length === 0; const isSetter = setId && !setterDeclared && params.length > 0; @@ -525,37 +497,37 @@ function buildPrivateMethodDeclaration(prop, privateNamesMap, loose = false) { privateNamesMap.set(prop.node.key.id.name, Object.assign({}, privateName, { getterDeclared: true })); - return _core().types.variableDeclaration("var", [_core().types.variableDeclarator(getId, methodValue)]); + return _core.types.variableDeclaration("var", [_core.types.variableDeclarator(getId, methodValue)]); } if (isSetter) { privateNamesMap.set(prop.node.key.id.name, Object.assign({}, privateName, { setterDeclared: true })); - return _core().types.variableDeclaration("var", [_core().types.variableDeclarator(setId, methodValue)]); + return _core.types.variableDeclaration("var", [_core.types.variableDeclarator(setId, methodValue)]); } if (isStatic && !loose) { - return _core().types.variableDeclaration("var", [_core().types.variableDeclarator(id, _core().types.functionExpression(id, params, body, generator, async))]); + return _core.types.variableDeclaration("var", [_core.types.variableDeclarator(id, _core.types.functionExpression(id, params, body, generator, async))]); } - return _core().types.variableDeclaration("var", [_core().types.variableDeclarator(methodId, methodValue)]); + return _core.types.variableDeclaration("var", [_core.types.variableDeclarator(methodId, methodValue)]); } -const thisContextVisitor = _core().traverse.visitors.merge([{ +const thisContextVisitor = _core.traverse.visitors.merge([{ ThisExpression(path, state) { state.needsClassRef = true; - path.replaceWith(_core().types.cloneNode(state.classRef)); + path.replaceWith(_core.types.cloneNode(state.classRef)); } -}, _helperReplaceSupers().environmentVisitor]); +}, _helperReplaceSupers.environmentVisitor]); function replaceThisContext(path, ref, superRef, file, loose) { const state = { classRef: ref, needsClassRef: false }; - const replacer = new (_helperReplaceSupers().default)({ + const replacer = new _helperReplaceSupers.default({ methodPath: path, isLoose: loose, superRef, @@ -563,7 +535,7 @@ function replaceThisContext(path, ref, superRef, file, loose) { getObjectRef() { state.needsClassRef = true; - return path.node.static ? ref : _core().types.memberExpression(ref, _core().types.identifier("prototype")); + return path.node.static ? ref : _core.types.memberExpression(ref, _core.types.identifier("prototype")); } }); @@ -582,6 +554,7 @@ function buildFieldsInitNodes(ref, superRef, props, privateNamesMap, state, loos let needsClassRef = false; for (const prop of props) { + ts.assertFieldTransformed(prop); const isStatic = prop.node.static; const isInstance = !isStatic; const isPrivate = prop.isPrivate(); @@ -597,7 +570,7 @@ function buildFieldsInitNodes(ref, superRef, props, privateNamesMap, state, loos switch (true) { case isStatic && isPrivate && isField && loose: needsClassRef = true; - staticNodes.push(buildPrivateFieldInitLoose(_core().types.cloneNode(ref), prop, privateNamesMap)); + staticNodes.push(buildPrivateFieldInitLoose(_core.types.cloneNode(ref), prop, privateNamesMap)); break; case isStatic && isPrivate && isField && !loose: @@ -607,29 +580,29 @@ function buildFieldsInitNodes(ref, superRef, props, privateNamesMap, state, loos case isStatic && isPublic && isField && loose: needsClassRef = true; - staticNodes.push(buildPublicFieldInitLoose(_core().types.cloneNode(ref), prop)); + staticNodes.push(buildPublicFieldInitLoose(_core.types.cloneNode(ref), prop)); break; case isStatic && isPublic && isField && !loose: needsClassRef = true; - staticNodes.push(buildPublicFieldInitSpec(_core().types.cloneNode(ref), prop, state)); + staticNodes.push(buildPublicFieldInitSpec(_core.types.cloneNode(ref), prop, state)); break; case isInstance && isPrivate && isField && loose: - instanceNodes.push(buildPrivateFieldInitLoose(_core().types.thisExpression(), prop, privateNamesMap)); + instanceNodes.push(buildPrivateFieldInitLoose(_core.types.thisExpression(), prop, privateNamesMap)); break; case isInstance && isPrivate && isField && !loose: - instanceNodes.push(buildPrivateInstanceFieldInitSpec(_core().types.thisExpression(), prop, privateNamesMap)); + instanceNodes.push(buildPrivateInstanceFieldInitSpec(_core.types.thisExpression(), prop, privateNamesMap)); break; case isInstance && isPrivate && isMethod && loose: - instanceNodes.unshift(buildPrivateMethodInitLoose(_core().types.thisExpression(), prop, privateNamesMap)); + instanceNodes.unshift(buildPrivateMethodInitLoose(_core.types.thisExpression(), prop, privateNamesMap)); staticNodes.push(buildPrivateMethodDeclaration(prop, privateNamesMap, loose)); break; case isInstance && isPrivate && isMethod && !loose: - instanceNodes.unshift(buildPrivateInstanceMethodInitSpec(_core().types.thisExpression(), prop, privateNamesMap)); + instanceNodes.unshift(buildPrivateInstanceMethodInitSpec(_core.types.thisExpression(), prop, privateNamesMap)); staticNodes.push(buildPrivateMethodDeclaration(prop, privateNamesMap, loose)); break; @@ -641,16 +614,16 @@ function buildFieldsInitNodes(ref, superRef, props, privateNamesMap, state, loos case isStatic && isPrivate && isMethod && loose: needsClassRef = true; - staticNodes.push(buildPrivateStaticMethodInitLoose(_core().types.cloneNode(ref), prop, state, privateNamesMap)); + staticNodes.push(buildPrivateStaticMethodInitLoose(_core.types.cloneNode(ref), prop, state, privateNamesMap)); staticNodes.unshift(buildPrivateMethodDeclaration(prop, privateNamesMap, loose)); break; case isInstance && isPublic && isField && loose: - instanceNodes.push(buildPublicFieldInitLoose(_core().types.thisExpression(), prop)); + instanceNodes.push(buildPublicFieldInitLoose(_core.types.thisExpression(), prop)); break; case isInstance && isPublic && isField && !loose: - instanceNodes.push(buildPublicFieldInitSpec(_core().types.thisExpression(), prop, state)); + instanceNodes.push(buildPublicFieldInitSpec(_core.types.thisExpression(), prop, state)); break; default: @@ -673,7 +646,7 @@ function buildFieldsInitNodes(ref, superRef, props, privateNamesMap, state, loos path.scope.push({ id: ref }); - path.replaceWith(_core().types.assignmentExpression("=", _core().types.cloneNode(ref), path.node)); + path.replaceWith(_core.types.assignmentExpression("=", _core.types.cloneNode(ref), path.node)); } else if (!path.node.id) { path.node.id = ref; } diff --git a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/index.js b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/index.js index 1e665b534..9bd9ca03f 100644 --- a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/index.js +++ b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/index.js @@ -17,25 +17,9 @@ Object.defineProperty(exports, "FEATURES", { } }); -function _helperFunctionName() { - const data = _interopRequireDefault(require("@babel/helper-function-name")); +var _helperFunctionName = _interopRequireDefault(require("@babel/helper-function-name")); - _helperFunctionName = function () { - return data; - }; - - return data; -} - -function _helperSplitExportDeclaration() { - const data = _interopRequireDefault(require("@babel/helper-split-export-declaration")); - - _helperSplitExportDeclaration = function () { - return data; - }; - - return data; -} +var _helperSplitExportDeclaration = _interopRequireDefault(require("@babel/helper-split-export-declaration")); var _fields = require("./fields"); @@ -138,7 +122,7 @@ function createClassFeaturePlugin({ let ref; if (path.isClassExpression() || !path.node.id) { - (0, _helperFunctionName().default)(path); + (0, _helperFunctionName.default)(path); ref = path.scope.generateUidIdentifier("class"); } else { ref = path.node.id; @@ -191,7 +175,7 @@ function createClassFeaturePlugin({ if (decl.isClassDeclaration() && (0, _decorators.hasDecorators)(decl.node)) { if (decl.node.id) { - (0, _helperSplitExportDeclaration().default)(path); + (0, _helperSplitExportDeclaration.default)(path); } else { decl.node.type = "ClassExpression"; } diff --git a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/misc.js b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/misc.js index bcc2ea1e3..30fc120f1 100644 --- a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/misc.js +++ b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/lib/misc.js @@ -6,27 +6,11 @@ Object.defineProperty(exports, "__esModule", { exports.injectInitialization = injectInitialization; exports.extractComputedKeys = extractComputedKeys; -function _core() { - const data = require("@babel/core"); +var _core = require("@babel/core"); - _core = function () { - return data; - }; +var _helperReplaceSupers = require("@babel/helper-replace-supers"); - return data; -} - -function _helperReplaceSupers() { - const data = require("@babel/helper-replace-supers"); - - _helperReplaceSupers = function () { - return data; - }; - - return data; -} - -const findBareSupers = _core().traverse.visitors.merge([{ +const findBareSupers = _core.traverse.visitors.merge([{ Super(path) { const { node, @@ -40,7 +24,7 @@ const findBareSupers = _core().traverse.visitors.merge([{ } } -}, _helperReplaceSupers().environmentVisitor]); +}, _helperReplaceSupers.environmentVisitor]); const referenceVisitor = { "TSTypeAnnotation|TypeAnnotation"(path) { @@ -56,30 +40,30 @@ const referenceVisitor = { }; -const classFieldDefinitionEvaluationTDZVisitor = _core().traverse.visitors.merge([{ +const classFieldDefinitionEvaluationTDZVisitor = _core.traverse.visitors.merge([{ ReferencedIdentifier(path) { if (this.classBinding && this.classBinding === path.scope.getBinding(path.node.name)) { const classNameTDZError = this.file.addHelper("classNameTDZError"); - const throwNode = _core().types.callExpression(classNameTDZError, [_core().types.stringLiteral(path.node.name)]); + const throwNode = _core.types.callExpression(classNameTDZError, [_core.types.stringLiteral(path.node.name)]); - path.replaceWith(_core().types.sequenceExpression([throwNode, path.node])); + path.replaceWith(_core.types.sequenceExpression([throwNode, path.node])); path.skip(); } } -}, _helperReplaceSupers().environmentVisitor]); +}, _helperReplaceSupers.environmentVisitor]); function injectInitialization(path, constructor, nodes, renamer) { if (!nodes.length) return; const isDerived = !!path.node.superClass; if (!constructor) { - const newConstructor = _core().types.classMethod("constructor", _core().types.identifier("constructor"), [], _core().types.blockStatement([])); + const newConstructor = _core.types.classMethod("constructor", _core.types.identifier("constructor"), [], _core.types.blockStatement([])); if (isDerived) { - newConstructor.params = [_core().types.restElement(_core().types.identifier("args"))]; - newConstructor.body.body.push(_core().template.statement.ast`super(...args)`); + newConstructor.params = [_core.types.restElement(_core.types.identifier("args"))]; + newConstructor.body.body.push(_core.template.statement.ast`super(...args)`); } [constructor] = path.get("body").unshiftContainer("body", newConstructor); @@ -119,8 +103,8 @@ function extractComputedKeys(ref, path, computedPaths, file) { id: ident, kind: "let" }); - declarations.push(_core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.cloneNode(ident), computedNode.key))); - computedNode.key = _core().types.cloneNode(ident); + declarations.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.cloneNode(ident), computedNode.key))); + computedNode.key = _core.types.cloneNode(ident); } } diff --git a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/package.json b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/package.json index 1239a4e5a..f08e69499 100644 --- a/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/package.json +++ b/node_modules/@babel/plugin-transform-typescript/node_modules/@babel/helper-create-class-features-plugin/package.json @@ -1,27 +1,27 @@ { - "_from": "@babel/helper-create-class-features-plugin@^7.6.0", - "_id": "@babel/helper-create-class-features-plugin@7.6.0", + "_from": "@babel/helper-create-class-features-plugin@^7.7.4", + "_id": "@babel/helper-create-class-features-plugin@7.7.4", "_inBundle": false, - "_integrity": "sha512-O1QWBko4fzGju6VoVvrZg0RROCVifcLxiApnGP3OWfWzvxRZFCoBD81K5ur5e3bVY2Vf/5rIJm8cqPKn8HUJng==", + "_integrity": "sha512-l+OnKACG4uiDHQ/aJT8dwpR+LhCJALxL0mJ6nzjB25e5IPwqV1VOsY7ah6UB1DG+VOXAIMtuC54rFJGiHkxjgA==", "_location": "/@babel/plugin-transform-typescript/@babel/helper-create-class-features-plugin", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "@babel/helper-create-class-features-plugin@^7.6.0", + "raw": "@babel/helper-create-class-features-plugin@^7.7.4", "name": "@babel/helper-create-class-features-plugin", "escapedName": "@babel%2fhelper-create-class-features-plugin", "scope": "@babel", - "rawSpec": "^7.6.0", + "rawSpec": "^7.7.4", "saveSpec": null, - "fetchSpec": "^7.6.0" + "fetchSpec": "^7.7.4" }, "_requiredBy": [ "/@babel/plugin-transform-typescript" ], - "_resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.6.0.tgz", - "_shasum": "769711acca889be371e9bc2eb68641d55218021f", - "_spec": "@babel/helper-create-class-features-plugin@^7.6.0", + "_resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.7.4.tgz", + "_shasum": "fce60939fd50618610942320a8d951b3b639da2d", + "_spec": "@babel/helper-create-class-features-plugin@^7.7.4", "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/plugin-transform-typescript", "author": { "name": "The Babel Team", @@ -29,20 +29,20 @@ }, "bundleDependencies": false, "dependencies": { - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-member-expression-to-functions": "^7.5.5", - "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/helper-function-name": "^7.7.4", + "@babel/helper-member-expression-to-functions": "^7.7.4", + "@babel/helper-optimise-call-expression": "^7.7.4", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.5.5", - "@babel/helper-split-export-declaration": "^7.4.4" + "@babel/helper-replace-supers": "^7.7.4", + "@babel/helper-split-export-declaration": "^7.7.4" }, "deprecated": false, "description": "Compile class public and private fields, private methods and decorators to ES6", "devDependencies": { - "@babel/core": "^7.6.0", - "@babel/helper-plugin-test-runner": "^7.0.0" + "@babel/core": "^7.7.4", + "@babel/helper-plugin-test-runner": "^7.7.4" }, - "gitHead": "cbd5a26e57758e3f748174ff84aa570e8780e85d", + "gitHead": "75767d87cb147709b9bd9b99bf44daa6688874a9", "keywords": [ "babel", "babel-plugin" @@ -60,5 +60,5 @@ "type": "git", "url": "https://github.com/babel/babel/tree/master/packages/babel-helper-create-class-features-plugin" }, - "version": "7.6.0" + "version": "7.7.4" } diff --git a/node_modules/@babel/plugin-transform-typescript/package.json b/node_modules/@babel/plugin-transform-typescript/package.json index 898baabfd..60c7581e6 100644 --- a/node_modules/@babel/plugin-transform-typescript/package.json +++ b/node_modules/@babel/plugin-transform-typescript/package.json @@ -1,48 +1,51 @@ { - "_from": "@babel/plugin-transform-typescript@^7.6.0", - "_id": "@babel/plugin-transform-typescript@7.6.3", + "_from": "@babel/plugin-transform-typescript@^7.7.4", + "_id": "@babel/plugin-transform-typescript@7.7.4", "_inBundle": false, - "_integrity": "sha512-aiWINBrPMSC3xTXRNM/dfmyYuPNKY/aexYqBgh0HBI5Y+WO5oRAqW/oROYeYHrF4Zw12r9rK4fMk/ZlAmqx/FQ==", + "_integrity": "sha512-X8e3tcPEKnwwPVG+vP/vSqEShkwODOEeyQGod82qrIuidwIrfnsGn11qPM1jBLF4MqguTXXYzm58d0dY+/wdpg==", "_location": "/@babel/plugin-transform-typescript", "_phantomChildren": { - "@babel/helper-function-name": "7.1.0", - "@babel/helper-member-expression-to-functions": "7.5.5", - "@babel/helper-optimise-call-expression": "7.0.0", + "@babel/code-frame": "7.5.5", "@babel/helper-plugin-utils": "7.0.0", - "@babel/helper-replace-supers": "7.5.5", - "@babel/helper-split-export-declaration": "7.4.4" + "esutils": "2.0.2", + "globals": "11.12.0", + "jsesc": "2.5.2", + "lodash": "4.17.14", + "ms": "2.1.2", + "source-map": "0.5.7", + "to-fast-properties": "2.0.0" }, "_requested": { "type": "range", "registry": true, - "raw": "@babel/plugin-transform-typescript@^7.6.0", + "raw": "@babel/plugin-transform-typescript@^7.7.4", "name": "@babel/plugin-transform-typescript", "escapedName": "@babel%2fplugin-transform-typescript", "scope": "@babel", - "rawSpec": "^7.6.0", + "rawSpec": "^7.7.4", "saveSpec": null, - "fetchSpec": "^7.6.0" + "fetchSpec": "^7.7.4" }, "_requiredBy": [ "/@babel/preset-typescript" ], - "_resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.6.3.tgz", - "_shasum": "dddb50cf3b8b2ef70b22e5326e9a91f05a1db13b", - "_spec": "@babel/plugin-transform-typescript@^7.6.0", + "_resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.7.4.tgz", + "_shasum": "2974fd05f4e85c695acaf497f432342de9fc0636", + "_spec": "@babel/plugin-transform-typescript@^7.7.4", "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/@babel/preset-typescript", "bundleDependencies": false, "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.6.0", + "@babel/helper-create-class-features-plugin": "^7.7.4", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-syntax-typescript": "^7.2.0" + "@babel/plugin-syntax-typescript": "^7.7.4" }, "deprecated": false, "description": "Transform TypeScript into ES.next", "devDependencies": { - "@babel/core": "^7.6.3", - "@babel/helper-plugin-test-runner": "^7.0.0" + "@babel/core": "^7.7.4", + "@babel/helper-plugin-test-runner": "^7.7.4" }, - "gitHead": "d329156ebc17da01382acb83e212cb4328534ebc", + "gitHead": "75767d87cb147709b9bd9b99bf44daa6688874a9", "keywords": [ "babel-plugin", "typescript" @@ -60,5 +63,5 @@ "type": "git", "url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-typescript" }, - "version": "7.6.3" + "version": "7.7.4" } diff --git a/node_modules/@babel/preset-typescript/lib/index.js b/node_modules/@babel/preset-typescript/lib/index.js index ec39a7f78..5ca0a4581 100644 --- a/node_modules/@babel/preset-typescript/lib/index.js +++ b/node_modules/@babel/preset-typescript/lib/index.js @@ -5,33 +5,18 @@ Object.defineProperty(exports, "__esModule", { }); exports.default = void 0; -function _helperPluginUtils() { - const data = require("@babel/helper-plugin-utils"); +var _helperPluginUtils = require("@babel/helper-plugin-utils"); - _helperPluginUtils = function () { - return data; - }; - - return data; -} - -function _pluginTransformTypescript() { - const data = _interopRequireDefault(require("@babel/plugin-transform-typescript")); - - _pluginTransformTypescript = function () { - return data; - }; - - return data; -} +var _pluginTransformTypescript = _interopRequireDefault(require("@babel/plugin-transform-typescript")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -var _default = (0, _helperPluginUtils().declare)((api, { +var _default = (0, _helperPluginUtils.declare)((api, { jsxPragma, allExtensions = false, isTSX = false, - allowNamespaces + allowNamespaces, + allowDeclareFields }) => { api.assertVersion(7); @@ -47,26 +32,22 @@ var _default = (0, _helperPluginUtils().declare)((api, { throw new Error("isTSX:true requires allExtensions:true"); } + const pluginOptions = isTSX => ({ + jsxPragma, + isTSX, + allowNamespaces, + allowDeclareFields + }); + return { overrides: allExtensions ? [{ - plugins: [[_pluginTransformTypescript().default, { - jsxPragma, - isTSX, - allowNamespaces - }]] + plugins: [[_pluginTransformTypescript.default, pluginOptions(isTSX)]] }] : [{ test: /\.ts$/, - plugins: [[_pluginTransformTypescript().default, { - jsxPragma, - allowNamespaces - }]] + plugins: [[_pluginTransformTypescript.default, pluginOptions(false)]] }, { test: /\.tsx$/, - plugins: [[_pluginTransformTypescript().default, { - jsxPragma, - isTSX: true, - allowNamespaces - }]] + plugins: [[_pluginTransformTypescript.default, pluginOptions(true)]] }] }; }); diff --git a/node_modules/@babel/preset-typescript/package.json b/node_modules/@babel/preset-typescript/package.json index 5cc28e0eb..d2956b175 100644 --- a/node_modules/@babel/preset-typescript/package.json +++ b/node_modules/@babel/preset-typescript/package.json @@ -1,40 +1,40 @@ { - "_from": "@babel/preset-typescript@^7.6.0", - "_id": "@babel/preset-typescript@7.6.0", + "_from": "@babel/preset-typescript@^7.7.2", + "_id": "@babel/preset-typescript@7.7.4", "_inBundle": false, - "_integrity": "sha512-4xKw3tTcCm0qApyT6PqM9qniseCE79xGHiUnNdKGdxNsGUc2X7WwZybqIpnTmoukg3nhPceI5KPNzNqLNeIJww==", + "_integrity": "sha512-rqrjxfdiHPsnuPur0jKrIIGQCIgoTWMTjlbWE69G4QJ6TIOVnnRnIJhUxNTL/VwDmEAVX08Tq3B1nirer5341w==", "_location": "/@babel/preset-typescript", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "@babel/preset-typescript@^7.6.0", + "raw": "@babel/preset-typescript@^7.7.2", "name": "@babel/preset-typescript", "escapedName": "@babel%2fpreset-typescript", "scope": "@babel", - "rawSpec": "^7.6.0", + "rawSpec": "^7.7.2", "saveSpec": null, - "fetchSpec": "^7.6.0" + "fetchSpec": "^7.7.2" }, "_requiredBy": [ "/gatsby-plugin-typescript" ], - "_resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.6.0.tgz", - "_shasum": "25768cb8830280baf47c45ab1a519a9977498c98", - "_spec": "@babel/preset-typescript@^7.6.0", + "_resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.7.4.tgz", + "_shasum": "780059a78e6fa7f7a4c87f027292a86b31ce080a", + "_spec": "@babel/preset-typescript@^7.7.2", "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/gatsby-plugin-typescript", "bundleDependencies": false, "dependencies": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-transform-typescript": "^7.6.0" + "@babel/plugin-transform-typescript": "^7.7.4" }, "deprecated": false, "description": "Babel preset for TypeScript.", "devDependencies": { - "@babel/core": "^7.6.0", - "@babel/helper-plugin-test-runner": "^7.0.0" + "@babel/core": "^7.7.4", + "@babel/helper-plugin-test-runner": "^7.7.4" }, - "gitHead": "cbd5a26e57758e3f748174ff84aa570e8780e85d", + "gitHead": "75767d87cb147709b9bd9b99bf44daa6688874a9", "keywords": [ "babel-preset", "typescript" @@ -52,5 +52,5 @@ "type": "git", "url": "https://github.com/babel/babel/tree/master/packages/babel-preset-typescript" }, - "version": "7.6.0" + "version": "7.7.4" } diff --git a/node_modules/@babel/preset-typescript/src/index.js b/node_modules/@babel/preset-typescript/src/index.js index bb1687e62..f3159543f 100644 --- a/node_modules/@babel/preset-typescript/src/index.js +++ b/node_modules/@babel/preset-typescript/src/index.js @@ -4,13 +4,20 @@ import transformTypeScript from "@babel/plugin-transform-typescript"; export default declare( ( api, - { jsxPragma, allExtensions = false, isTSX = false, allowNamespaces }, + { + jsxPragma, + allExtensions = false, + isTSX = false, + allowNamespaces, + allowDeclareFields, + }, ) => { api.assertVersion(7); if (typeof allExtensions !== "boolean") { throw new Error(".allExtensions must be a boolean, or undefined"); } + if (typeof isTSX !== "boolean") { throw new Error(".isTSX must be a boolean, or undefined"); } @@ -19,13 +26,18 @@ export default declare( throw new Error("isTSX:true requires allExtensions:true"); } + const pluginOptions = isTSX => ({ + jsxPragma, + isTSX, + allowNamespaces, + allowDeclareFields, + }); + return { overrides: allExtensions ? [ { - plugins: [ - [transformTypeScript, { jsxPragma, isTSX, allowNamespaces }], - ], + plugins: [[transformTypeScript, pluginOptions(isTSX)]], }, ] : [ @@ -33,18 +45,13 @@ export default declare( // Only set 'test' if explicitly requested, since it requires that // Babel is being called` test: /\.ts$/, - plugins: [[transformTypeScript, { jsxPragma, allowNamespaces }]], + plugins: [[transformTypeScript, pluginOptions(false)]], }, { // Only set 'test' if explicitly requested, since it requires that // Babel is being called` test: /\.tsx$/, - plugins: [ - [ - transformTypeScript, - { jsxPragma, isTSX: true, allowNamespaces }, - ], - ], + plugins: [[transformTypeScript, pluginOptions(true)]], }, ], }; diff --git a/node_modules/@babel/preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json b/node_modules/@babel/preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json index 4c0aa1246..c11cb6fdf 100644 --- a/node_modules/@babel/preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json +++ b/node_modules/@babel/preset-typescript/test/fixtures/jsx-compat/ts-invalid/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected token, expected \"/<=/>=\" (1:6)" + "throws": "Unexpected token, expected \",\" (1:6)" } diff --git a/node_modules/@mdx-js/react/package.json b/node_modules/@mdx-js/react/package.json index 123d37d63..a1b33e956 100644 --- a/node_modules/@mdx-js/react/package.json +++ b/node_modules/@mdx-js/react/package.json @@ -1,29 +1,29 @@ { - "_from": "@mdx-js/react", + "_from": "@mdx-js/react@^1.5.1", "_id": "@mdx-js/react@1.5.1", "_inBundle": false, "_integrity": "sha512-eF05YysHqtyXerLId0kPKtxmJ3PE60GJJvx1gOguEQndbs94fUeYTVSfBlnXPPAAzvOmVKrZmktIYsBQlVjpOw==", "_location": "/@mdx-js/react", "_phantomChildren": {}, "_requested": { - "type": "tag", + "type": "range", "registry": true, - "raw": "@mdx-js/react", + "raw": "@mdx-js/react@^1.5.1", "name": "@mdx-js/react", "escapedName": "@mdx-js%2freact", "scope": "@mdx-js", - "rawSpec": "", + "rawSpec": "^1.5.1", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "^1.5.1" }, "_requiredBy": [ - "#USER", - "/" + "#DEV:/", + "#USER" ], "_resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-1.5.1.tgz", "_shasum": "e0a9dbdc03826198abd82b29dcee91d661faf8a5", - "_spec": "@mdx-js/react", - "_where": "/Users/frank.mcmanus/Documents/_development/Typescript/website", + "_spec": "@mdx-js/react@^1.5.1", + "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website", "author": { "name": "John Otander", "email": "johnotander@gmail.com", diff --git a/node_modules/@types/react-dom/package.json b/node_modules/@types/react-dom/package.json index 03e71ba15..23a7e0329 100644 --- a/node_modules/@types/react-dom/package.json +++ b/node_modules/@types/react-dom/package.json @@ -17,12 +17,13 @@ "fetchSpec": "^16.9.1" }, "_requiredBy": [ - "/" + "#DEV:/", + "#USER" ], "_resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.4.tgz", "_shasum": "0b58df09a60961dcb77f62d4f1832427513420df", "_spec": "@types/react-dom@^16.9.1", - "_where": "/Users/frank.mcmanus/Documents/_development/Typescript/website", + "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website", "bugs": { "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" }, diff --git a/node_modules/@types/react/README.md b/node_modules/@types/react/README.md index 5a5170766..494203652 100644 --- a/node_modules/@types/react/README.md +++ b/node_modules/@types/react/README.md @@ -5,12 +5,12 @@ This package contains type definitions for React (http://facebook.github.io/react/). # Details -Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react +Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react. -Additional Details - * Last updated: Tue, 24 Sep 2019 21:07:03 GMT - * Dependencies: @types/csstype, @types/prop-types - * Global values: React +### Additional Details + * Last updated: Sat, 23 Nov 2019 20:10:45 GMT + * Dependencies: [@types/csstype](https://npmjs.com/package/@types/csstype), [@types/prop-types](https://npmjs.com/package/@types/prop-types) + * Global values: `React` # Credits -These definitions were written by Asana , AssureSign , Microsoft , John Reilly , Benoit Benezech , Patricio Zavolinsky , Digiguru , Eric Anderson , Dovydas Navickas , Josh Rutherford , Guilherme Hübner , Ferdy Budhidharma , Johann Rakotoharisoa , Olivier Pascal , Martin Hochel , Frank Li , Jessica Franco , Saransh Kataria , Kanitkorn Sujautra , and Sebastian Silbermann . +These definitions were written by Asana (https://asana.com), AssureSign (http://www.assuresign.com), Microsoft (https://microsoft.com), John Reilly (https://github.com/johnnyreilly), Benoit Benezech (https://github.com/bbenezech), Patricio Zavolinsky (https://github.com/pzavolinsky), Digiguru (https://github.com/digiguru), Eric Anderson (https://github.com/ericanderson), Dovydas Navickas (https://github.com/DovydasNavickas), Josh Rutherford (https://github.com/theruther4d), Guilherme Hübner (https://github.com/guilhermehubner), Ferdy Budhidharma (https://github.com/ferdaber), Johann Rakotoharisoa (https://github.com/jrakotoharisoa), Olivier Pascal (https://github.com/pascaloliv), Martin Hochel (https://github.com/hotell), Frank Li (https://github.com/franklixuefei), Jessica Franco (https://github.com/Jessidhia), Saransh Kataria (https://github.com/saranshkataria), Kanitkorn Sujautra (https://github.com/lukyth), Sebastian Silbermann (https://github.com/eps1lon), and Kyle Scully (https://github.com/zieka). diff --git a/node_modules/@types/react/global.d.ts b/node_modules/@types/react/global.d.ts index f1861f22f..6024d950f 100644 --- a/node_modules/@types/react/global.d.ts +++ b/node_modules/@types/react/global.d.ts @@ -2,6 +2,9 @@ React projects that don't include the DOM library need these interfaces to compile. React Native applications use React, but there is no DOM available. The JavaScript runtime is ES6/ES2015 only. These definitions allow such projects to compile with only `--lib ES6`. + +Warning: all of these interfaces are empty. If you want type definitions for various properties +(such as HTMLInputElement.prototype.value), you need to add `--lib DOM` (via command line or tsconfig.json). */ interface Event { } diff --git a/node_modules/@types/react/index.d.ts b/node_modules/@types/react/index.d.ts index 4ab1e67ed..2aa7ee5a5 100644 --- a/node_modules/@types/react/index.d.ts +++ b/node_modules/@types/react/index.d.ts @@ -20,9 +20,14 @@ // Saransh Kataria // Kanitkorn Sujautra // Sebastian Silbermann +// Kyle Scully // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 +// NOTE: Users of the `experimental` builds of React should add a reference +// to 'react/experimental' in their project. See experimental.d.ts's top comment +// for reference and documentation on how exactly to do it. + /// import * as CSS from 'csstype'; @@ -85,6 +90,10 @@ declare namespace React { type ComponentState = any; + /** + * @internal You shouldn't need to use this type since you never see these attributes + * inside your component or have to validate them. + */ interface Attributes { key?: Key; } @@ -333,6 +342,8 @@ declare namespace React { displayName?: string; } function createContext( + // If you thought this should be optional, see + // https://github.com/DefinitelyTyped/DefinitelyTyped/pull/24509#issuecomment-382213106 defaultValue: T, calculateChangedBits?: (prev: T, next: T) => number ): Context; @@ -348,6 +359,12 @@ declare namespace React { /** A fallback react tree to show when a Suspense child (like React.lazy) suspends */ fallback: NonNullable|null; + /** + * Tells React whether to “skip” revealing this boundary during the initial load. + * This API will likely be removed in a future release. + */ + // NOTE: this is unflagged and is respected even in stable builds + unstable_avoidThisFallback?: boolean; } /** * This feature is not yet available for server-side rendering. @@ -412,14 +429,17 @@ declare namespace React { /** * If using the new style context, re-declare this in your class to be the * `React.ContextType` of your `static contextType`. + * Should be used with type annotation or static contextType. * * ```ts * static contextType = MyContext + * // For TS pre-3.7: * context!: React.ContextType + * // For TS 3.7 and above: + * declare context: React.ContextType * ``` * - * @deprecated if used without a type annotation, or without static contextType - * @see https://reactjs.org/docs/legacy-context.html + * @see https://reactjs.org/docs/context.html */ // TODO (TypeScript 3.0): unknown context: any; @@ -1078,7 +1098,7 @@ declare namespace React { } interface FocusEvent extends SyntheticEvent { - relatedTarget: EventTarget; + relatedTarget: EventTarget | null; target: EventTarget & T; } @@ -1131,7 +1151,7 @@ declare namespace React { movementY: number; pageX: number; pageY: number; - relatedTarget: EventTarget; + relatedTarget: EventTarget | null; screenX: number; screenY: number; shiftKey: boolean; @@ -1629,7 +1649,7 @@ declare namespace React { interface HTMLAttributes extends AriaAttributes, DOMAttributes { // React-specific Attributes defaultChecked?: boolean; - defaultValue?: string | string[]; + defaultValue?: string | number | string[]; suppressContentEditableWarning?: boolean; suppressHydrationWarning?: boolean; @@ -1649,10 +1669,9 @@ declare namespace React { style?: CSSProperties; tabIndex?: number; title?: string; + translate?: 'yes' | 'no'; // Unknown - inputMode?: string; - is?: string; radioGroup?: string; // , // WAI-ARIA @@ -1681,6 +1700,18 @@ declare namespace React { results?: number; security?: string; unselectable?: 'on' | 'off'; + + // Living Standard + /** + * Hints at the type of data that might be entered by the user while editing the element or its contents + * @see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-inputmode-attribute + */ + inputMode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'; + /** + * Specify that a standard HTML element should behave like a defined custom built-in element + * @see https://html.spec.whatwg.org/multipage/custom-elements.html#attr-is + */ + is?: string; } interface AllHTMLAttributes extends HTMLAttributes { @@ -2165,6 +2196,7 @@ declare namespace React { headers?: string; rowSpan?: number; scope?: string; + abbr?: string; valign?: "top" | "middle" | "bottom" | "baseline"; } @@ -2174,6 +2206,7 @@ declare namespace React { headers?: string; rowSpan?: number; scope?: string; + abbr?: string; } interface TimeHTMLAttributes extends HTMLAttributes { diff --git a/node_modules/@types/react/package.json b/node_modules/@types/react/package.json index 262f8e671..6f3ae14a9 100644 --- a/node_modules/@types/react/package.json +++ b/node_modules/@types/react/package.json @@ -1,38 +1,39 @@ { - "_args": [ - [ - "@types/react@16.9.3", - "/Users/frankmcmanus/Documents/_dev/Typescript/website" - ] - ], - "_from": "@types/react@16.9.3", - "_id": "@types/react@16.9.3", + "_from": "@types/react@^16.9.3", + "_id": "@types/react@16.9.13", "_inBundle": false, - "_integrity": "sha512-Ogb2nSn+2qQv5opoCv7Ls5yFxtyrdUYxp5G+SWTrlGk7dmFKw331GiezCgEZj9U7QeXJi1CDtws9pdXU1zUL4g==", + "_integrity": "sha512-LikzRslbiufJYHyzbHSW0GrAiff8QYLMBFeZmSxzCYGXKxi8m/1PHX+rsVOwhr7mJNq+VIu2Dhf7U6mjFERK6w==", "_location": "/@types/react", "_phantomChildren": {}, "_requested": { - "type": "version", + "type": "range", "registry": true, - "raw": "@types/react@16.9.3", + "raw": "@types/react@^16.9.3", "name": "@types/react", "escapedName": "@types%2freact", "scope": "@types", - "rawSpec": "16.9.3", + "rawSpec": "^16.9.3", "saveSpec": null, - "fetchSpec": "16.9.3" + "fetchSpec": "^16.9.3" }, "_requiredBy": [ + "#DEV:/", + "#USER", "/@types/reach__router", + "/@types/react-dom", + "/@types/react-native", + "/@types/styled-components", "/auto-bind", "/ink" ], - "_resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.3.tgz", - "_spec": "16.9.3", + "_resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.13.tgz", + "_shasum": "b3ea5dd443f4a680599e2abba8cc66f5e1ce0059", + "_spec": "@types/react@^16.9.3", "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website", "bugs": { "url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues" }, + "bundleDependencies": false, "contributors": [ { "name": "Asana", @@ -113,12 +114,17 @@ { "name": "Sebastian Silbermann", "url": "https://github.com/eps1lon" + }, + { + "name": "Kyle Scully", + "url": "https://github.com/zieka" } ], "dependencies": { "@types/prop-types": "*", "csstype": "^2.2.0" }, + "deprecated": false, "description": "TypeScript definitions for React", "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped#readme", "license": "MIT", @@ -131,7 +137,7 @@ }, "scripts": {}, "typeScriptVersion": "2.8", - "types": "index", - "typesPublisherContentHash": "1a9689b20091fcf81da5f15589a400100d462ffe460d7d148431cdd0a235c7d5", - "version": "16.9.3" + "types": "index.d.ts", + "typesPublisherContentHash": "8b210364cfb98b8b56a7788c5f8fa667ff53f93eb5c90934e24bf36e68ebc397", + "version": "16.9.13" } diff --git a/node_modules/gatsby-plugin-tslint/package.json b/node_modules/gatsby-plugin-tslint/package.json index 8f060001f..bb0146409 100644 --- a/node_modules/gatsby-plugin-tslint/package.json +++ b/node_modules/gatsby-plugin-tslint/package.json @@ -16,6 +16,7 @@ "fetchSpec": "0.0.2" }, "_requiredBy": [ + "#USER", "/" ], "_resolved": "https://registry.npmjs.org/gatsby-plugin-tslint/-/gatsby-plugin-tslint-0.0.2.tgz", diff --git a/node_modules/gatsby-plugin-typescript/CHANGELOG.md b/node_modules/gatsby-plugin-typescript/CHANGELOG.md index d079f4fd0..76c313324 100644 --- a/node_modules/gatsby-plugin-typescript/CHANGELOG.md +++ b/node_modules/gatsby-plugin-typescript/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.1.19](https://github.com/gatsbyjs/gatsby/compare/gatsby-plugin-typescript@2.1.18...gatsby-plugin-typescript@2.1.19) (2019-11-20) + +### Features + +- **gatsby-plugin-typescript:** add support for numeric separa… ([#19610](https://github.com/gatsbyjs/gatsby/issues/19610)) ([2921221](https://github.com/gatsbyjs/gatsby/commit/2921221)) + +## [2.1.18](https://github.com/gatsbyjs/gatsby/compare/gatsby-plugin-typescript@2.1.17...gatsby-plugin-typescript@2.1.18) (2019-11-15) + +**Note:** Version bump only for package gatsby-plugin-typescript + +## [2.1.17](https://github.com/gatsbyjs/gatsby/compare/gatsby-plugin-typescript@2.1.16...gatsby-plugin-typescript@2.1.17) (2019-11-13) + +### Features + +- **gatsby-plugin-typescript:** add support for optional chaining and nullish coalescing operator ([#19302](https://github.com/gatsbyjs/gatsby/issues/19302)) ([0647089](https://github.com/gatsbyjs/gatsby/commit/0647089)) + +## [2.1.16](https://github.com/gatsbyjs/gatsby/compare/gatsby-plugin-typescript@2.1.15...gatsby-plugin-typescript@2.1.16) (2019-11-10) + +**Note:** Version bump only for package gatsby-plugin-typescript + +## [2.1.15](https://github.com/gatsbyjs/gatsby/compare/gatsby-plugin-typescript@2.1.14...gatsby-plugin-typescript@2.1.15) (2019-10-14) + +**Note:** Version bump only for package gatsby-plugin-typescript + +## [2.1.14](https://github.com/gatsbyjs/gatsby/compare/gatsby-plugin-typescript@2.1.13...gatsby-plugin-typescript@2.1.14) (2019-10-14) + +**Note:** Version bump only for package gatsby-plugin-typescript + +## [2.1.13](https://github.com/gatsbyjs/gatsby/compare/gatsby-plugin-typescript@2.1.12...gatsby-plugin-typescript@2.1.13) (2019-10-14) + +**Note:** Version bump only for package gatsby-plugin-typescript + ## [2.1.12](https://github.com/gatsbyjs/gatsby/compare/gatsby-plugin-typescript@2.1.11...gatsby-plugin-typescript@2.1.12) (2019-10-09) **Note:** Version bump only for package gatsby-plugin-typescript diff --git a/node_modules/gatsby-plugin-typescript/README.md b/node_modules/gatsby-plugin-typescript/README.md index ba5a0083a..7106147f6 100644 --- a/node_modules/gatsby-plugin-typescript/README.md +++ b/node_modules/gatsby-plugin-typescript/README.md @@ -63,6 +63,10 @@ compiler is not involved, the following applies: > cannot be compiled to ES.next. Workaround: Convert > to using export default and export const, > and import x, {y} from "z". +> +> Does not support baseUrl. +> Workaround: use [gatsby-plugin-root-import](https://www.gatsbyjs.org/packages/gatsby-plugin-root-import/) +> and configure it to point the baseUrl value (also set baseUrl option in tsconfig.json file). https://babeljs.io/docs/en/babel-plugin-transform-typescript.html diff --git a/node_modules/gatsby-plugin-typescript/gatsby-node.js b/node_modules/gatsby-plugin-typescript/gatsby-node.js index be9c2074b..3830741dc 100644 --- a/node_modules/gatsby-plugin-typescript/gatsby-node.js +++ b/node_modules/gatsby-plugin-typescript/gatsby-node.js @@ -9,6 +9,15 @@ function onCreateBabelConfig({ name: require.resolve(`@babel/preset-typescript`), options }); + actions.setBabelPlugin({ + name: require.resolve(`@babel/plugin-proposal-optional-chaining`) + }); + actions.setBabelPlugin({ + name: require.resolve(`@babel/plugin-proposal-nullish-coalescing-operator`) + }); + actions.setBabelPlugin({ + name: require.resolve(`@babel/plugin-proposal-numeric-separator`) + }); } function onCreateWebpackConfig({ diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/AsyncGenerator.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/AsyncGenerator.js index 0365c4378..5e2373061 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/AsyncGenerator.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/AsyncGenerator.js @@ -29,7 +29,7 @@ function AsyncGenerator(gen) { var wrappedAwait = value instanceof AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { - resume("next", arg); + resume(key === "return" ? "return" : "next", arg); return; } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js index 3fb99659f..c37ecf2c0 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/asyncGeneratorDelegate.js @@ -43,6 +43,11 @@ function _asyncGeneratorDelegate(inner, awaitWrap) { if (typeof inner["return"] === "function") { iter["return"] = function (value) { + if (waiting) { + waiting = false; + return value; + } + return pump("return", value); }; } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/AsyncGenerator.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/AsyncGenerator.js index a4e240299..65361d96e 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/AsyncGenerator.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/AsyncGenerator.js @@ -28,7 +28,7 @@ export default function AsyncGenerator(gen) { var wrappedAwait = value instanceof AwaitValue; Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) { if (wrappedAwait) { - resume("next", arg); + resume(key === "return" ? "return" : "next", arg); return; } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js index c3f586f02..eb56fe59a 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/asyncGeneratorDelegate.js @@ -43,6 +43,11 @@ export default function _asyncGeneratorDelegate(inner, awaitWrap) { if (typeof inner["return"] === "function") { iter["return"] = function (value) { + if (waiting) { + waiting = false; + return value; + } + return pump("return", value); }; } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js index d40ca01c2..30d518cfd 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/initializerWarningHelper.js @@ -1,3 +1,3 @@ export default function _initializerWarningHelper(descriptor, context) { - throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } \ No newline at end of file diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js index f2737fad8..d39be9efa 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/interopRequireWildcard.js @@ -1,3 +1,5 @@ +import _typeof from "../../helpers/esm/typeof"; + function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); @@ -14,6 +16,12 @@ export default function _interopRequireWildcard(obj) { return obj; } + if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { + return { + "default": obj + }; + } + var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { @@ -21,19 +29,16 @@ export default function _interopRequireWildcard(obj) { } var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; - if (obj != null) { - var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; - - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; } } } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/objectSpread.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/objectSpread.js index 918bc8e99..739ea18be 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/objectSpread.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/objectSpread.js @@ -2,7 +2,7 @@ import defineProperty from "./defineProperty"; export default function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; - var ownKeys = Object.keys(source); + var ownKeys = Object.keys(Object(source)); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/objectSpread2.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/objectSpread2.js index 1d3d67f8e..1da08661c 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/objectSpread2.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/esm/objectSpread2.js @@ -19,13 +19,13 @@ export default function _objectSpread2(target) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { - ownKeys(source, true).forEach(function (key) { + ownKeys(Object(source), true).forEach(function (key) { defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { - ownKeys(source).forEach(function (key) { + ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/initializerWarningHelper.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/initializerWarningHelper.js index 56e0c1733..50ec82cd4 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/initializerWarningHelper.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/initializerWarningHelper.js @@ -1,5 +1,5 @@ function _initializerWarningHelper(descriptor, context) { - throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and set to use loose mode. ' + 'To use proposal-class-properties in spec mode with decorators, wait for ' + 'the next major version of decorators in stage 2.'); + throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } module.exports = _initializerWarningHelper; \ No newline at end of file diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/interopRequireWildcard.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/interopRequireWildcard.js index 899bc54f0..68fd84c61 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/interopRequireWildcard.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/interopRequireWildcard.js @@ -1,3 +1,5 @@ +var _typeof = require("../helpers/typeof"); + function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); @@ -14,6 +16,12 @@ function _interopRequireWildcard(obj) { return obj; } + if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { + return { + "default": obj + }; + } + var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { @@ -21,19 +29,16 @@ function _interopRequireWildcard(obj) { } var newObj = {}; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; - if (obj != null) { - var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; - - for (var key in obj) { - if (Object.prototype.hasOwnProperty.call(obj, key)) { - var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; - if (desc && (desc.get || desc.set)) { - Object.defineProperty(newObj, key, desc); - } else { - newObj[key] = obj[key]; - } + if (desc && (desc.get || desc.set)) { + Object.defineProperty(newObj, key, desc); + } else { + newObj[key] = obj[key]; } } } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/objectSpread.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/objectSpread.js index b92340071..8de02d365 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/objectSpread.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/objectSpread.js @@ -3,7 +3,7 @@ var defineProperty = require("./defineProperty"); function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; - var ownKeys = Object.keys(source); + var ownKeys = Object.keys(Object(source)); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/objectSpread2.js b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/objectSpread2.js index 6ad76216e..f067f3ec2 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/objectSpread2.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/helpers/objectSpread2.js @@ -19,13 +19,13 @@ function _objectSpread2(target) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { - ownKeys(source, true).forEach(function (key) { + ownKeys(Object(source), true).forEach(function (key) { defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { - ownKeys(source).forEach(function (key) { + ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/package.json b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/package.json index b6f474f8e..e90a6a131 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/package.json +++ b/node_modules/gatsby-plugin-typescript/node_modules/@babel/runtime/package.json @@ -1,32 +1,35 @@ { - "_from": "@babel/runtime@^7.6.3", - "_id": "@babel/runtime@7.6.3", + "_from": "@babel/runtime@^7.7.2", + "_id": "@babel/runtime@7.7.4", "_inBundle": false, - "_integrity": "sha512-kq6anf9JGjW8Nt5rYfEuGRaEAaH1mkv3Bbu6rYvLOpPh/RusSJXuKPEAoZ7L7gybZkchE8+NV5g9vKF4AGAtsA==", + "_integrity": "sha512-r24eVUUr0QqNZa+qrImUk8fn5SPhHq+IfYvIoIMg0do3GdK9sMdiLKP3GYVVaxpPKORgm8KRKaNTEhAjgIpLMw==", "_location": "/gatsby-plugin-typescript/@babel/runtime", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "@babel/runtime@^7.6.3", + "raw": "@babel/runtime@^7.7.2", "name": "@babel/runtime", "escapedName": "@babel%2fruntime", "scope": "@babel", - "rawSpec": "^7.6.3", + "rawSpec": "^7.7.2", "saveSpec": null, - "fetchSpec": "^7.6.3" + "fetchSpec": "^7.7.2" }, "_requiredBy": [ "/gatsby-plugin-typescript" ], - "_resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.6.3.tgz", - "_shasum": "935122c74c73d2240cafd32ddb5fc2a6cd35cf1f", - "_spec": "@babel/runtime@^7.6.3", + "_resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.4.tgz", + "_shasum": "b23a856751e4bf099262f867767889c0e3fe175b", + "_spec": "@babel/runtime@^7.7.2", "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/gatsby-plugin-typescript", "author": { "name": "Sebastian McKenzie", "email": "sebmck@gmail.com" }, + "bugs": { + "url": "https://github.com/babel/babel/issues" + }, "bundleDependencies": false, "dependencies": { "regenerator-runtime": "^0.13.2" @@ -34,9 +37,10 @@ "deprecated": false, "description": "babel's modular runtime helpers", "devDependencies": { - "@babel/helpers": "^7.6.2" + "@babel/helpers": "^7.7.4" }, - "gitHead": "d329156ebc17da01382acb83e212cb4328534ebc", + "gitHead": "75767d87cb147709b9bd9b99bf44daa6688874a9", + "homepage": "https://babeljs.io/docs/en/next/babel-runtime", "license": "MIT", "name": "@babel/runtime", "publishConfig": { @@ -44,7 +48,8 @@ }, "repository": { "type": "git", - "url": "https://github.com/babel/babel/tree/master/packages/babel-runtime" + "url": "git+https://github.com/babel/babel.git", + "directory": "packages/babel-runtime" }, - "version": "7.6.3" + "version": "7.7.4" } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/CHANGELOG.md b/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/CHANGELOG.md index 1f8337e94..9fe643c7f 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/CHANGELOG.md +++ b/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.7.16](https://github.com/gatsbyjs/gatsby/compare/babel-plugin-remove-graphql-queries@2.7.15...babel-plugin-remove-graphql-queries@2.7.16) (2019-11-15) + +**Note:** Version bump only for package babel-plugin-remove-graphql-queries + +## [2.7.15](https://github.com/gatsbyjs/gatsby/compare/babel-plugin-remove-graphql-queries@2.7.14...babel-plugin-remove-graphql-queries@2.7.15) (2019-11-10) + +**Note:** Version bump only for package babel-plugin-remove-graphql-queries + +## [2.7.14](https://github.com/gatsbyjs/gatsby/compare/babel-plugin-remove-graphql-queries@2.7.13...babel-plugin-remove-graphql-queries@2.7.14) (2019-10-14) + +**Note:** Version bump only for package babel-plugin-remove-graphql-queries + +## [2.7.13](https://github.com/gatsbyjs/gatsby/compare/babel-plugin-remove-graphql-queries@2.7.12...babel-plugin-remove-graphql-queries@2.7.13) (2019-10-14) + +### Features + +- **gatsby:** structured logging ([#14973](https://github.com/gatsbyjs/gatsby/issues/14973)) ([eafb8c6](https://github.com/gatsbyjs/gatsby/commit/eafb8c6)) + +## [2.7.12](https://github.com/gatsbyjs/gatsby/compare/babel-plugin-remove-graphql-queries@2.7.11...babel-plugin-remove-graphql-queries@2.7.12) (2019-10-14) + +**Note:** Version bump only for package babel-plugin-remove-graphql-queries + ## [2.7.11](https://github.com/gatsbyjs/gatsby/compare/babel-plugin-remove-graphql-queries@2.7.10...babel-plugin-remove-graphql-queries@2.7.11) (2019-10-09) **Note:** Version bump only for package babel-plugin-remove-graphql-queries diff --git a/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/index.js b/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/index.js index eb2f62a48..f4713a84a 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/index.js +++ b/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/index.js @@ -3,6 +3,7 @@ exports.__esModule = true; exports.default = _default; exports.getGraphQLTag = getGraphQLTag; +exports.GraphQLSyntaxError = exports.EmptyGraphQLTagError = exports.StringInterpolationNotAllowedError = void 0; /* eslint-disable new-cap */ const graphql = require(`gatsby/graphql`); @@ -11,6 +12,42 @@ const murmurhash = require(`./murmur`); const nodePath = require(`path`); +class StringInterpolationNotAllowedError extends Error { + constructor(interpolationStart, interpolationEnd) { + super(`BabelPluginRemoveGraphQLQueries: String interpolations are not allowed in graphql ` + `fragments. Included fragments should be referenced ` + `as \`...MyModule_foo\`.`); + this.interpolationStart = JSON.parse(JSON.stringify(interpolationStart)); + this.interpolationEnd = JSON.parse(JSON.stringify(interpolationEnd)); + Error.captureStackTrace(this, StringInterpolationNotAllowedError); + } + +} + +exports.StringInterpolationNotAllowedError = StringInterpolationNotAllowedError; + +class EmptyGraphQLTagError extends Error { + constructor(locationOfGraphqlString) { + super(`BabelPluginRemoveGraphQLQueries: Unexpected empty graphql tag.`); + this.templateLoc = locationOfGraphqlString; + Error.captureStackTrace(this, EmptyGraphQLTagError); + } + +} + +exports.EmptyGraphQLTagError = EmptyGraphQLTagError; + +class GraphQLSyntaxError extends Error { + constructor(documentText, originalError, locationOfGraphqlString) { + super(`BabelPluginRemoveGraphQLQueries: GraphQL syntax error in query:\n\n${documentText}\n\nmessage:\n\n${originalError}`); + this.documentText = documentText; + this.originalError = originalError; + this.templateLoc = locationOfGraphqlString; + Error.captureStackTrace(this, GraphQLSyntaxError); + } + +} + +exports.GraphQLSyntaxError = GraphQLSyntaxError; + const isGlobalIdentifier = tag => tag.isIdentifier({ name: `graphql` }) && tag.scope.hasGlobal(`graphql`); @@ -91,7 +128,7 @@ function getGraphQLTag(path) { const quasis = path.node.quasi.quasis; if (quasis.length !== 1) { - throw new Error(`BabelPluginRemoveGraphQL: String interpolations are not allowed in graphql ` + `fragments. Included fragments should be referenced ` + `as \`...MyModule_foo\`.`); + throw new StringInterpolationNotAllowedError(quasis[0].loc.end, quasis[1].loc.start); } const text = quasis[0].value.raw; @@ -101,7 +138,7 @@ function getGraphQLTag(path) { const ast = graphql.parse(text); if (ast.definitions.length === 0) { - throw new Error(`BabelPluginRemoveGraphQL: Unexpected empty graphql tag.`); + throw new EmptyGraphQLTagError(quasis[0].loc); } return { @@ -111,7 +148,7 @@ function getGraphQLTag(path) { isGlobal }; } catch (err) { - throw new Error(`BabelPluginRemoveGraphQLQueries: GraphQL syntax error in query:\n\n${text}\n\nmessage:\n\n${err.message}`); + throw new GraphQLSyntaxError(text, err, quasis[0].loc); } } diff --git a/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/package.json b/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/package.json index de28a4480..58927f7d5 100644 --- a/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/package.json +++ b/node_modules/gatsby-plugin-typescript/node_modules/babel-plugin-remove-graphql-queries/package.json @@ -1,26 +1,26 @@ { - "_from": "babel-plugin-remove-graphql-queries@^2.7.11", - "_id": "babel-plugin-remove-graphql-queries@2.7.11", + "_from": "babel-plugin-remove-graphql-queries@^2.7.16", + "_id": "babel-plugin-remove-graphql-queries@2.7.16", "_inBundle": false, - "_integrity": "sha512-w3PNFlgtn2HIiEb4/67Q1WkRUCPm9o0czT6Ow98E92PtOfeervUgF8z+As66iWXj8snhQCA5nckGzcJ1NEOCsw==", + "_integrity": "sha512-E2/hzXJ4VxxDDptG5ycZlEMoKdi+10NbpbbyYCmNVS1X+RH/baVPZ1x8T91aQauAqpW02uUeHTP0cpqvC2JoLw==", "_location": "/gatsby-plugin-typescript/babel-plugin-remove-graphql-queries", "_phantomChildren": {}, "_requested": { "type": "range", "registry": true, - "raw": "babel-plugin-remove-graphql-queries@^2.7.11", + "raw": "babel-plugin-remove-graphql-queries@^2.7.16", "name": "babel-plugin-remove-graphql-queries", "escapedName": "babel-plugin-remove-graphql-queries", - "rawSpec": "^2.7.11", + "rawSpec": "^2.7.16", "saveSpec": null, - "fetchSpec": "^2.7.11" + "fetchSpec": "^2.7.16" }, "_requiredBy": [ "/gatsby-plugin-typescript" ], - "_resolved": "https://registry.npmjs.org/babel-plugin-remove-graphql-queries/-/babel-plugin-remove-graphql-queries-2.7.11.tgz", - "_shasum": "6090e6a1bc45a39dd056a61762e672dfccc74c10", - "_spec": "babel-plugin-remove-graphql-queries@^2.7.11", + "_resolved": "https://registry.npmjs.org/babel-plugin-remove-graphql-queries/-/babel-plugin-remove-graphql-queries-2.7.16.tgz", + "_shasum": "32b6d305e8f8ee17036840cb31649e8d32453f81", + "_spec": "babel-plugin-remove-graphql-queries@^2.7.16", "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website/node_modules/gatsby-plugin-typescript", "author": { "name": "Jason Quense", @@ -32,15 +32,15 @@ "bundleDependencies": false, "deprecated": false, "devDependencies": { - "@babel/cli": "^7.6.3", - "@babel/core": "^7.6.3", - "babel-preset-gatsby-package": "^0.2.8", + "@babel/cli": "^7.7.0", + "@babel/core": "^7.7.2", + "babel-preset-gatsby-package": "^0.2.11", "cross-env": "^5.2.1" }, "engines": { "node": ">=8.0.0" }, - "gitHead": "904ec39943432d0fd94369e43e0e4de48999aacf", + "gitHead": "e6a30aaadc6949d125eaf4d16c8fb36ebafad10d", "homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/babel-plugin-remove-graphql-queries#readme", "license": "MIT", "main": "index.js", @@ -59,5 +59,5 @@ "prepare": "cross-env NODE_ENV=production npm run build", "watch": "babel -w src --out-dir . --ignore **/__tests__" }, - "version": "2.7.11" + "version": "2.7.16" } diff --git a/node_modules/gatsby-plugin-typescript/package.json b/node_modules/gatsby-plugin-typescript/package.json index fcc2c79e8..099adb24a 100644 --- a/node_modules/gatsby-plugin-typescript/package.json +++ b/node_modules/gatsby-plugin-typescript/package.json @@ -1,8 +1,8 @@ { "_from": "gatsby-plugin-typescript@^2.1.11", - "_id": "gatsby-plugin-typescript@2.1.12", + "_id": "gatsby-plugin-typescript@2.1.19", "_inBundle": false, - "_integrity": "sha512-BdtMMAzFzwBGo7MSPZti315tptYBzVZiiIno+X/qPapkPDhhQIkSt4zM1R5atXHvUOqlYKNo3uVAhb/4T1O4Ng==", + "_integrity": "sha512-SevAhAKUqmZZO+7TNXM2c2BSaHzSx79FBN84UNPCVVq4l7kK1aUdvyYaxjiwYbJzOVjqOkrjLTzjt3I2MUADNA==", "_location": "/gatsby-plugin-typescript", "_phantomChildren": { "regenerator-runtime": "0.13.2" @@ -18,10 +18,11 @@ "fetchSpec": "^2.1.11" }, "_requiredBy": [ + "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/gatsby-plugin-typescript/-/gatsby-plugin-typescript-2.1.12.tgz", - "_shasum": "c6110005671f1f0730ca4d64380f8f9b905154bb", + "_resolved": "https://registry.npmjs.org/gatsby-plugin-typescript/-/gatsby-plugin-typescript-2.1.19.tgz", + "_shasum": "d71905857b7a967a865a40f288870e1b6400d716", "_spec": "gatsby-plugin-typescript@^2.1.11", "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website", "author": { @@ -39,22 +40,25 @@ } ], "dependencies": { - "@babel/preset-typescript": "^7.6.0", - "@babel/runtime": "^7.6.3", - "babel-plugin-remove-graphql-queries": "^2.7.11" + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4", + "@babel/plugin-proposal-numeric-separator": "^7.2.0", + "@babel/plugin-proposal-optional-chaining": "^7.6.0", + "@babel/preset-typescript": "^7.7.2", + "@babel/runtime": "^7.7.2", + "babel-plugin-remove-graphql-queries": "^2.7.16" }, "deprecated": false, "description": "Adds TypeScript support to Gatsby", "devDependencies": { - "@babel/cli": "^7.6.3", - "@babel/core": "^7.6.3", - "babel-preset-gatsby-package": "^0.2.8", + "@babel/cli": "^7.7.0", + "@babel/core": "^7.7.2", + "babel-preset-gatsby-package": "^0.2.11", "cross-env": "^5.2.1" }, "engines": { "node": ">=8.0.0" }, - "gitHead": "904ec39943432d0fd94369e43e0e4de48999aacf", + "gitHead": "138afb4bf6520e39e6e3fcf0a58c693d32e01f5e", "homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-plugin-typescript#readme", "keywords": [ "gatsby", @@ -77,5 +81,5 @@ "prepare": "cross-env NODE_ENV=production npm run build", "watch": "babel -w src --out-dir . --ignore **/__tests__" }, - "version": "2.1.12" + "version": "2.1.19" } diff --git a/node_modules/react/build-info.json b/node_modules/react/build-info.json index e1796b482..c1de63254 100644 --- a/node_modules/react/build-info.json +++ b/node_modules/react/build-info.json @@ -1,8 +1,8 @@ { - "branch": "pull/15226", - "buildNumber": "14079", - "checksum": "4a4c239", - "commit": "297165f1e", + "branch": "master", + "buildNumber": "59518", + "checksum": "6f449c4", + "commit": "b53ea6ca0", "environment": "ci", - "reactVersion": "16.8.5-canary-297165f1e" + "reactVersion": "16.11.0-b53ea6ca0" } diff --git a/node_modules/react/cjs/react.development.js b/node_modules/react/cjs/react.development.js index 8cf06cfdf..03ed1fc8b 100644 --- a/node_modules/react/cjs/react.development.js +++ b/node_modules/react/cjs/react.development.js @@ -1,4 +1,4 @@ -/** @license React v16.8.6 +/** @license React v16.12.0 * react.development.js * * Copyright (c) Facebook, Inc. and its affiliates. @@ -20,40 +20,50 @@ var checkPropTypes = require('prop-types/checkPropTypes'); // TODO: this is special because it gets imported during build. -var ReactVersion = '16.8.6'; +var ReactVersion = '16.12.0'; // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. var hasSymbol = typeof Symbol === 'function' && Symbol.for; - var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; -var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; +var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary +// (unstable) APIs that have been removed. Can we remove the symbols? + var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; +var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; - +var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; +var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; +var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = '@@iterator'; - function getIteratorFn(maybeIterable) { if (maybeIterable === null || typeof maybeIterable !== 'object') { return null; } + var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; + if (typeof maybeIterator === 'function') { return maybeIterator; } + return null; } +// Do not require this module directly! Use normal `invariant` calls with +// template literal strings. The messages will be replaced with error codes +// during build. + /** * Use invariant() to assert state which your program assumes to be true. * @@ -65,40 +75,6 @@ function getIteratorFn(maybeIterable) { * will remain to ensure logic does not differ in production. */ -var validateFormat = function () {}; - -{ - validateFormat = function (format) { - if (format === undefined) { - throw new Error('invariant requires an error message argument'); - } - }; -} - -function invariant(condition, format, a, b, c, d, e, f) { - validateFormat(format); - - if (!condition) { - var error = void 0; - if (format === undefined) { - error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error(format.replace(/%s/g, function () { - return args[argIndex++]; - })); - error.name = 'Invariant Violation'; - } - - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; - } -} - -// Relying on the `invariant()` implementation lets us -// preserve the format and params in the www builds. - /** * Forked from fbjs/warning: * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js @@ -112,12 +88,11 @@ function invariant(condition, format, a, b, c, d, e, f) { * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ - -var lowPriorityWarning = function () {}; +var lowPriorityWarningWithoutStack = function () {}; { var printWarning = function (format) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } @@ -125,9 +100,11 @@ var lowPriorityWarning = function () {}; var message = 'Warning: ' + format.replace(/%s/g, function () { return args[argIndex++]; }); + if (typeof console !== 'undefined') { console.warn(message); } + try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack @@ -136,21 +113,22 @@ var lowPriorityWarning = function () {}; } catch (x) {} }; - lowPriorityWarning = function (condition, format) { + lowPriorityWarningWithoutStack = function (condition, format) { if (format === undefined) { - throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument'); + throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument'); } + if (!condition) { - for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { args[_key2 - 2] = arguments[_key2]; } - printWarning.apply(undefined, [format].concat(args)); + printWarning.apply(void 0, [format].concat(args)); } }; } -var lowPriorityWarning$1 = lowPriorityWarning; +var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack; /** * Similar to invariant but only logs a warning if the condition is not met. @@ -158,35 +136,37 @@ var lowPriorityWarning$1 = lowPriorityWarning; * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ - var warningWithoutStack = function () {}; { warningWithoutStack = function (condition, format) { - for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } if (format === undefined) { throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument'); } + if (args.length > 8) { // Check before the condition to catch violations early. throw new Error('warningWithoutStack() currently supports at most 8 arguments.'); } + if (condition) { return; } + if (typeof console !== 'undefined') { var argsWithFormat = args.map(function (item) { return '' + item; }); - argsWithFormat.unshift('Warning: ' + format); - - // We intentionally don't use spread (or .apply) directly because it + argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it // breaks IE9: https://github.com/facebook/react/issues/13610 + Function.prototype.apply.call(console.error, console, argsWithFormat); } + try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack @@ -208,18 +188,21 @@ function warnNoop(publicInstance, callerName) { { var _constructor = publicInstance.constructor; var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; - var warningKey = componentName + '.' + callerName; + var warningKey = componentName + "." + callerName; + if (didWarnStateUpdateForUnmountedComponent[warningKey]) { return; } + warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName); didWarnStateUpdateForUnmountedComponent[warningKey] = true; } } - /** * This is the abstract API for an update queue. */ + + var ReactNoopUpdateQueue = { /** * Checks whether or not this composite component is mounted. @@ -286,25 +269,26 @@ var ReactNoopUpdateQueue = { }; var emptyObject = {}; + { Object.freeze(emptyObject); } - /** * Base class helpers for the updating state of a component. */ + + function Component(props, context, updater) { this.props = props; - this.context = context; - // If a component has string refs, we will assign a different object later. - this.refs = emptyObject; - // We initialize the default updater but the real one gets injected by the + this.context = context; // If a component has string refs, we will assign a different object later. + + this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the // renderer. + this.updater = updater || ReactNoopUpdateQueue; } Component.prototype.isReactComponent = {}; - /** * Sets a subset of the state. Always use this to mutate * state. You should treat `this.state` as immutable. @@ -330,11 +314,16 @@ Component.prototype.isReactComponent = {}; * @final * @protected */ + Component.prototype.setState = function (partialState, callback) { - !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0; + if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) { + { + throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables."); + } + } + this.updater.enqueueSetState(this, partialState, callback, 'setState'); }; - /** * Forces an update. This should only be invoked when it is known with * certainty that we are **not** in a DOM transaction. @@ -349,28 +338,33 @@ Component.prototype.setState = function (partialState, callback) { * @final * @protected */ + + Component.prototype.forceUpdate = function (callback) { this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); }; - /** * Deprecated APIs. These APIs used to exist on classic React classes but since * we would like to deprecate them, we're not going to move them over to this * modern base class. Instead, we define a getter that warns if it's accessed. */ + + { var deprecatedAPIs = { isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] }; + var defineDeprecationWarning = function (methodName, info) { Object.defineProperty(Component.prototype, methodName, { get: function () { - lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); + lowPriorityWarningWithoutStack$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); return undefined; } }); }; + for (var fnName in deprecatedAPIs) { if (deprecatedAPIs.hasOwnProperty(fnName)) { defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); @@ -379,23 +373,25 @@ Component.prototype.forceUpdate = function (callback) { } function ComponentDummy() {} -ComponentDummy.prototype = Component.prototype; +ComponentDummy.prototype = Component.prototype; /** * Convenience component with default shallow equality check for sCU. */ + function PureComponent(props, context, updater) { this.props = props; - this.context = context; - // If a component has string refs, we will assign a different object later. + this.context = context; // If a component has string refs, we will assign a different object later. + this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; } var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); -pureComponentPrototype.constructor = PureComponent; -// Avoid an extra prototype jump for these methods. +pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. + _assign(pureComponentPrototype, Component.prototype); + pureComponentPrototype.isPureReactComponent = true; // an immutable object with a single mutable value @@ -403,9 +399,11 @@ function createRef() { var refObject = { current: null }; + { Object.seal(refObject); } + return refObject; } @@ -420,6 +418,14 @@ var ReactCurrentDispatcher = { current: null }; +/** + * Keeps track of the current batch's configuration such as how long an update + * should suspend for if it needs to. + */ +var ReactCurrentBatchConfig = { + suspense: null +}; + /** * Keeps track of the current owner. * @@ -435,19 +441,22 @@ var ReactCurrentOwner = { }; var BEFORE_SLASH_RE = /^(.*)[\\\/]/; - var describeComponentFrame = function (name, source, ownerName) { var sourceInfo = ''; + if (source) { var path = source.fileName; var fileName = path.replace(BEFORE_SLASH_RE, ''); + { // In DEV, include code for a common special case: // prefer "folder/index.js" instead of just "index.js". if (/^index\./.test(fileName)) { var match = path.match(BEFORE_SLASH_RE); + if (match) { var pathBeforeSlash = match[1]; + if (pathBeforeSlash) { var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); fileName = folderName + '/' + fileName; @@ -455,23 +464,24 @@ var describeComponentFrame = function (name, source, ownerName) { } } } + sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; } else if (ownerName) { sourceInfo = ' (created by ' + ownerName + ')'; } + return '\n in ' + (name || 'Unknown') + sourceInfo; }; var Resolved = 1; - function refineResolvedLazyComponent(lazyComponent) { return lazyComponent._status === Resolved ? lazyComponent._result : null; } function getWrappedName(outerType, innerType, wrapperName) { var functionName = innerType.displayName || innerType.name || ''; - return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName); + return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); } function getComponentName(type) { @@ -479,58 +489,74 @@ function getComponentName(type) { // Host root, text node or just invalid type. return null; } + { if (typeof type.tag === 'number') { warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); } } + if (typeof type === 'function') { return type.displayName || type.name || null; } + if (typeof type === 'string') { return type; } + switch (type) { - case REACT_CONCURRENT_MODE_TYPE: - return 'ConcurrentMode'; case REACT_FRAGMENT_TYPE: return 'Fragment'; + case REACT_PORTAL_TYPE: return 'Portal'; + case REACT_PROFILER_TYPE: - return 'Profiler'; + return "Profiler"; + case REACT_STRICT_MODE_TYPE: return 'StrictMode'; + case REACT_SUSPENSE_TYPE: return 'Suspense'; + + case REACT_SUSPENSE_LIST_TYPE: + return 'SuspenseList'; } + if (typeof type === 'object') { switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return 'Context.Consumer'; + case REACT_PROVIDER_TYPE: return 'Context.Provider'; + case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, 'ForwardRef'); + case REACT_MEMO_TYPE: return getComponentName(type.type); + case REACT_LAZY_TYPE: { var thenable = type; var resolvedThenable = refineResolvedLazyComponent(thenable); + if (resolvedThenable) { return getComponentName(resolvedThenable); } + + break; } } } + return null; } var ReactDebugCurrentFrame = {}; - var currentlyValidatingElement = null; - function setCurrentlyValidatingElement(element) { { currentlyValidatingElement = element; @@ -542,17 +568,17 @@ function setCurrentlyValidatingElement(element) { ReactDebugCurrentFrame.getCurrentStack = null; ReactDebugCurrentFrame.getStackAddendum = function () { - var stack = ''; + var stack = ''; // Add an extra top frame while an element is being validated - // Add an extra top frame while an element is being validated if (currentlyValidatingElement) { var name = getComponentName(currentlyValidatingElement.type); var owner = currentlyValidatingElement._owner; stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type)); - } + } // Delegate to the injected renderer-specific implementation + - // Delegate to the injected renderer-specific implementation var impl = ReactDebugCurrentFrame.getCurrentStack; + if (impl) { stack += impl() || ''; } @@ -561,9 +587,18 @@ function setCurrentlyValidatingElement(element) { }; } +/** + * Used by act() to track whether you're inside an act() scope. + */ +var IsSomeRendererActing = { + current: false +}; + var ReactSharedInternals = { ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, ReactCurrentOwner: ReactCurrentOwner, + IsSomeRendererActing: IsSomeRendererActing, // Used by renderers to avoid bundling object-assign twice in UMD bundles: assign: _assign }; @@ -592,41 +627,41 @@ var warning = warningWithoutStack$1; if (condition) { return; } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - // eslint-disable-next-line react-internal/warning-and-invariant-args + var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args - for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } - warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack])); + warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack])); }; } var warning$1 = warning; var hasOwnProperty = Object.prototype.hasOwnProperty; - var RESERVED_PROPS = { key: true, ref: true, __self: true, __source: true }; - -var specialPropKeyWarningShown = void 0; -var specialPropRefWarningShown = void 0; +var specialPropKeyWarningShown; +var specialPropRefWarningShown; function hasValidRef(config) { { if (hasOwnProperty.call(config, 'ref')) { var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; + if (getter && getter.isReactWarning) { return false; } } } + return config.ref !== undefined; } @@ -634,11 +669,13 @@ function hasValidKey(config) { { if (hasOwnProperty.call(config, 'key')) { var getter = Object.getOwnPropertyDescriptor(config, 'key').get; + if (getter && getter.isReactWarning) { return false; } } } + return config.key !== undefined; } @@ -649,6 +686,7 @@ function defineKeyPropWarningGetter(props, displayName) { warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); } }; + warnAboutAccessingKey.isReactWarning = true; Object.defineProperty(props, 'key', { get: warnAboutAccessingKey, @@ -663,22 +701,24 @@ function defineRefPropWarningGetter(props, displayName) { warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); } }; + warnAboutAccessingRef.isReactWarning = true; Object.defineProperty(props, 'ref', { get: warnAboutAccessingRef, configurable: true }); } - /** * Factory method to create a new React element. This no longer adheres to - * the class pattern, so do not use new to call it. Also, no instanceof check - * will work. Instead test $$typeof field against Symbol.for('react.element') to check + * the class pattern, so do not use new to call it. Also, instanceof check + * will not work. Instead test $$typeof field against Symbol.for('react.element') to check * if something is a React Element. * * @param {*} type + * @param {*} props * @param {*} key * @param {string|object} ref + * @param {*} owner * @param {*} self A *temporary* helper to detect places where `this` is * different from the `owner` when React.createElement is called, so that we * can warn. We want to get rid of owner and replace string `ref`s with arrow @@ -686,21 +726,19 @@ function defineRefPropWarningGetter(props, displayName) { * change in behavior. * @param {*} source An annotation object (added by a transpiler or otherwise) * indicating filename, line number, and/or other information. - * @param {*} owner - * @param {*} props * @internal */ + + var ReactElement = function (type, key, ref, self, source, owner, props) { var element = { // This tag allows us to uniquely identify this as a React Element $$typeof: REACT_ELEMENT_TYPE, - // Built-in properties that belong on the element type: type, key: key, ref: ref, props: props, - // Record the component responsible for creating this element. _owner: owner }; @@ -710,33 +748,33 @@ var ReactElement = function (type, key, ref, self, source, owner, props) { // an external backing store so that we can freeze the whole object. // This can be replaced with a WeakMap once they are implemented in // commonly used development environments. - element._store = {}; - - // To make comparing ReactElements easier for testing purposes, we make + element._store = {}; // To make comparing ReactElements easier for testing purposes, we make // the validation flag non-enumerable (where possible, which should // include every environment we run tests in), so the test framework // ignores it. + Object.defineProperty(element._store, 'validated', { configurable: false, enumerable: false, writable: true, value: false - }); - // self and source are DEV only properties. + }); // self and source are DEV only properties. + Object.defineProperty(element, '_self', { configurable: false, enumerable: false, writable: false, value: self - }); - // Two elements created in two different places should be considered + }); // Two elements created in two different places should be considered // equal for testing purposes and therefore we hide it from enumeration. + Object.defineProperty(element, '_source', { configurable: false, enumerable: false, writable: false, value: source }); + if (Object.freeze) { Object.freeze(element.props); Object.freeze(element); @@ -745,17 +783,87 @@ var ReactElement = function (type, key, ref, self, source, owner, props) { return element; }; +/** + * https://github.com/reactjs/rfcs/pull/107 + * @param {*} type + * @param {object} props + * @param {string} key + */ + + + +/** + * https://github.com/reactjs/rfcs/pull/107 + * @param {*} type + * @param {object} props + * @param {string} key + */ + +function jsxDEV(type, config, maybeKey, source, self) { + var propName; // Reserved names are extracted + + var props = {}; + var key = null; + var ref = null; // Currently, key can be spread in as a prop. This causes a potential + // issue if key is also explicitly declared (ie.
+ // or
). We want to deprecate key spread, + // but as an intermediary step, we will use jsxDEV for everything except + //
, because we aren't currently able to tell if + // key is explicitly declared to be undefined or not. + + if (maybeKey !== undefined) { + key = '' + maybeKey; + } + + if (hasValidKey(config)) { + key = '' + config.key; + } + + if (hasValidRef(config)) { + ref = config.ref; + } // Remaining properties are added to a new props object + + + for (propName in config) { + if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { + props[propName] = config[propName]; + } + } // Resolve default props + + + if (type && type.defaultProps) { + var defaultProps = type.defaultProps; + + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } + } + } + if (key || ref) { + var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; + + if (key) { + defineKeyPropWarningGetter(props, displayName); + } + + if (ref) { + defineRefPropWarningGetter(props, displayName); + } + } + + return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); +} /** * Create and return a new ReactElement of the given type. * See https://reactjs.org/docs/react-api.html#createelement */ + function createElement(type, config, children) { - var propName = void 0; + var propName; // Reserved names are extracted - // Reserved names are extracted var props = {}; - var key = null; var ref = null; var self = null; @@ -765,61 +873,70 @@ function createElement(type, config, children) { if (hasValidRef(config)) { ref = config.ref; } + if (hasValidKey(config)) { key = '' + config.key; } self = config.__self === undefined ? null : config.__self; - source = config.__source === undefined ? null : config.__source; - // Remaining properties are added to a new props object + source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object + for (propName in config) { if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { props[propName] = config[propName]; } } - } - - // Children can be more than one argument, and those are transferred onto + } // Children can be more than one argument, and those are transferred onto // the newly allocated props object. + + var childrenLength = arguments.length - 2; + if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); + for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 2]; } + { if (Object.freeze) { Object.freeze(childArray); } } + props.children = childArray; - } + } // Resolve default props + - // Resolve default props if (type && type.defaultProps) { var defaultProps = type.defaultProps; + for (propName in defaultProps) { if (props[propName] === undefined) { props[propName] = defaultProps[propName]; } } } + { if (key || ref) { var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; + if (key) { defineKeyPropWarningGetter(props, displayName); } + if (ref) { defineRefPropWarningGetter(props, displayName); } } } + return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); } - /** * Return a function that produces ReactElements of a given type. * See https://reactjs.org/docs/react-api.html#createfactory @@ -828,33 +945,34 @@ function createElement(type, config, children) { function cloneAndReplaceKey(oldElement, newKey) { var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); - return newElement; } - /** * Clone and return a new ReactElement using element as the starting point. * See https://reactjs.org/docs/react-api.html#cloneelement */ + function cloneElement(element, config, children) { - !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0; + if (!!(element === null || element === undefined)) { + { + throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + "."); + } + } + + var propName; // Original props are copied - var propName = void 0; + var props = _assign({}, element.props); // Reserved names are extracted - // Original props are copied - var props = _assign({}, element.props); - // Reserved names are extracted var key = element.key; - var ref = element.ref; - // Self is preserved since the owner is preserved. - var self = element._self; - // Source is preserved since cloneElement is unlikely to be targeted by a + var ref = element.ref; // Self is preserved since the owner is preserved. + + var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a // transpiler, and the original source is probably a better indicator of the // true owner. - var source = element._source; - // Owner will be preserved, unless ref is overridden + var source = element._source; // Owner will be preserved, unless ref is overridden + var owner = element._owner; if (config != null) { @@ -863,15 +981,18 @@ function cloneElement(element, config, children) { ref = config.ref; owner = ReactCurrentOwner.current; } + if (hasValidKey(config)) { key = '' + config.key; - } + } // Remaining properties override existing props + + + var defaultProps; - // Remaining properties override existing props - var defaultProps = void 0; if (element.type && element.type.defaultProps) { defaultProps = element.type.defaultProps; } + for (propName in config) { if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { if (config[propName] === undefined && defaultProps !== undefined) { @@ -882,24 +1003,26 @@ function cloneElement(element, config, children) { } } } - } - - // Children can be more than one argument, and those are transferred onto + } // Children can be more than one argument, and those are transferred onto // the newly allocated props object. + + var childrenLength = arguments.length - 2; + if (childrenLength === 1) { props.children = children; } else if (childrenLength > 1) { var childArray = Array(childrenLength); + for (var i = 0; i < childrenLength; i++) { childArray[i] = arguments[i + 2]; } + props.children = childArray; } return ReactElement(element.type, key, ref, self, source, owner, props); } - /** * Verifies the object is a ReactElement. * See https://reactjs.org/docs/react-api.html#isvalidelement @@ -907,19 +1030,20 @@ function cloneElement(element, config, children) { * @return {boolean} True if `object` is a ReactElement. * @final */ + function isValidElement(object) { return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; } var SEPARATOR = '.'; var SUBSEPARATOR = ':'; - /** * Escape and wrap key so it is safe to use as a reactid * * @param {string} key to be escaped. * @return {string} the escaped key. */ + function escape(key) { var escapeRegex = /[=:]/g; var escaperLookup = { @@ -929,24 +1053,24 @@ function escape(key) { var escapedString = ('' + key).replace(escapeRegex, function (match) { return escaperLookup[match]; }); - return '$' + escapedString; } - /** * TODO: Test that a single child and an array with one item have the same key * pattern. */ -var didWarnAboutMaps = false; +var didWarnAboutMaps = false; var userProvidedKeyEscapeRegex = /\/+/g; + function escapeUserProvidedKey(text) { return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); } var POOL_SIZE = 10; var traverseContextPool = []; + function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) { if (traverseContextPool.length) { var traverseContext = traverseContextPool.pop(); @@ -973,11 +1097,11 @@ function releaseTraverseContext(traverseContext) { traverseContext.func = null; traverseContext.context = null; traverseContext.count = 0; + if (traverseContextPool.length < POOL_SIZE) { traverseContextPool.push(traverseContext); } } - /** * @param {?*} children Children tree container. * @param {!string} nameSoFar Name of the key path so far. @@ -986,6 +1110,8 @@ function releaseTraverseContext(traverseContext) { * process. * @return {!number} The number of children in this subtree. */ + + function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { var type = typeof children; @@ -1004,26 +1130,28 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) case 'number': invokeCallback = true; break; + case 'object': switch (children.$$typeof) { case REACT_ELEMENT_TYPE: case REACT_PORTAL_TYPE: invokeCallback = true; } + } } if (invokeCallback) { - callback(traverseContext, children, - // If it's the only child, treat the name as if it was wrapped in an array + callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array // so that it's consistent if the number of children grows. nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); return 1; } - var child = void 0; - var nextName = void 0; + var child; + var nextName; var subtreeCount = 0; // Count of children found in the current subtree. + var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; if (Array.isArray(children)) { @@ -1034,6 +1162,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) } } else { var iteratorFn = getIteratorFn(children); + if (typeof iteratorFn === 'function') { { // Warn about using Maps as children @@ -1044,8 +1173,9 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) } var iterator = iteratorFn.call(children); - var step = void 0; + var step; var ii = 0; + while (!(step = iterator.next()).done) { child = step.value; nextName = nextNamePrefix + getComponentKey(child, ii++); @@ -1053,17 +1183,23 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) } } else if (type === 'object') { var addendum = ''; + { addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum(); } + var childrenString = '' + children; - invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum); + + { + { + throw Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum); + } + } } } return subtreeCount; } - /** * Traverses children that are typically specified as `props.children`, but * might also be specified through attributes: @@ -1080,6 +1216,8 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) * @param {?*} traverseContext Context for traversal. * @return {!number} The number of children in this subtree. */ + + function traverseAllChildren(children, callback, traverseContext) { if (children == null) { return 0; @@ -1087,7 +1225,6 @@ function traverseAllChildren(children, callback, traverseContext) { return traverseAllChildrenImpl(children, '', callback, traverseContext); } - /** * Generate a key string that identifies a component within a set. * @@ -1095,24 +1232,25 @@ function traverseAllChildren(children, callback, traverseContext) { * @param {number} index Index that is used if a manual key is not provided. * @return {string} */ + + function getComponentKey(component, index) { // Do some typechecking here since we call this blindly. We want to ensure // that we don't block potential future ES APIs. if (typeof component === 'object' && component !== null && component.key != null) { // Explicit key return escape(component.key); - } - // Implicit key determined by the index in the set + } // Implicit key determined by the index in the set + + return index.toString(36); } function forEachSingleChild(bookKeeping, child, name) { var func = bookKeeping.func, context = bookKeeping.context; - func.call(context, child, bookKeeping.count++); } - /** * Iterates through children that are typically specified as `props.children`. * @@ -1125,10 +1263,13 @@ function forEachSingleChild(bookKeeping, child, name) { * @param {function(*, int)} forEachFunc * @param {*} forEachContext Context for forEachContext. */ + + function forEachChildren(children, forEachFunc, forEachContext) { if (children == null) { return children; } + var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext); traverseAllChildren(children, forEachSingleChild, traverseContext); releaseTraverseContext(traverseContext); @@ -1139,34 +1280,34 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) { keyPrefix = bookKeeping.keyPrefix, func = bookKeeping.func, context = bookKeeping.context; - - var mappedChild = func.call(context, child, bookKeeping.count++); + if (Array.isArray(mappedChild)) { mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) { return c; }); } else if (mappedChild != null) { if (isValidElement(mappedChild)) { - mappedChild = cloneAndReplaceKey(mappedChild, - // Keep both the (mapped) and old keys if they differ, just as + mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as // traverseAllChildren used to do for objects as children keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); } + result.push(mappedChild); } } function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { var escapedPrefix = ''; + if (prefix != null) { escapedPrefix = escapeUserProvidedKey(prefix) + '/'; } + var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context); traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); releaseTraverseContext(traverseContext); } - /** * Maps children that are typically specified as `props.children`. * @@ -1180,15 +1321,17 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { * @param {*} context Context for mapFunction. * @return {object} Object containing the ordered map of results. */ + + function mapChildren(children, func, context) { if (children == null) { return children; } + var result = []; mapIntoWithKeyPrefixInternal(children, result, null, func, context); return result; } - /** * Count the number of children that are typically specified as * `props.children`. @@ -1198,18 +1341,21 @@ function mapChildren(children, func, context) { * @param {?*} children Children tree container. * @return {number} The number of children. */ + + function countChildren(children) { return traverseAllChildren(children, function () { return null; }, null); } - /** * Flatten a children object (typically specified as `props.children`) and * return an array with appropriately re-keyed children. * * See https://reactjs.org/docs/react-api.html#reactchildrentoarray */ + + function toArray(children) { var result = []; mapIntoWithKeyPrefixInternal(children, result, null, function (child) { @@ -1217,7 +1363,6 @@ function toArray(children) { }); return result; } - /** * Returns the first child in a collection of children and verifies that there * is only one child in the collection. @@ -1232,8 +1377,15 @@ function toArray(children) { * @return {ReactElement} The first and only `ReactElement` contained in the * structure. */ + + function onlyChild(children) { - !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0; + if (!isValidElement(children)) { + { + throw Error("React.Children.only expected to receive a single React element child."); + } + } + return children; } @@ -1263,12 +1415,10 @@ function createContext(defaultValue, calculateChangedBits) { Provider: null, Consumer: null }; - context.Provider = { $$typeof: REACT_PROVIDER_TYPE, _context: context }; - var hasWarnedAboutUsingNestedContextConsumers = false; var hasWarnedAboutUsingConsumerProvider = false; @@ -1280,8 +1430,8 @@ function createContext(defaultValue, calculateChangedBits) { $$typeof: REACT_CONTEXT_TYPE, _context: context, _calculateChangedBits: context._calculateChangedBits - }; - // $FlowFixMe: Flow complains about not setting a value, which is intentional here + }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here + Object.defineProperties(Consumer, { Provider: { get: function () { @@ -1289,6 +1439,7 @@ function createContext(defaultValue, calculateChangedBits) { hasWarnedAboutUsingConsumerProvider = true; warning$1(false, 'Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?'); } + return context.Provider; }, set: function (_Provider) { @@ -1325,11 +1476,12 @@ function createContext(defaultValue, calculateChangedBits) { hasWarnedAboutUsingNestedContextConsumers = true; warning$1(false, 'Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?'); } + return context.Consumer; } } - }); - // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty + }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty + context.Consumer = Consumer; } @@ -1352,8 +1504,8 @@ function lazy(ctor) { { // In production, this would just set it on the object. - var defaultProps = void 0; - var propTypes = void 0; + var defaultProps; + var propTypes; Object.defineProperties(lazyType, { defaultProps: { configurable: true, @@ -1362,8 +1514,8 @@ function lazy(ctor) { }, set: function (newDefaultProps) { warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); - defaultProps = newDefaultProps; - // Match production behavior more closely: + defaultProps = newDefaultProps; // Match production behavior more closely: + Object.defineProperty(lazyType, 'defaultProps', { enumerable: true }); @@ -1376,8 +1528,8 @@ function lazy(ctor) { }, set: function (newPropTypes) { warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); - propTypes = newPropTypes; - // Match production behavior more closely: + propTypes = newPropTypes; // Match production behavior more closely: + Object.defineProperty(lazyType, 'propTypes', { enumerable: true }); @@ -1396,8 +1548,7 @@ function forwardRef(render) { } else if (typeof render !== 'function') { warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); } else { - !( - // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object + !( // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0; } @@ -1413,9 +1564,8 @@ function forwardRef(render) { } function isValidElementType(type) { - return typeof type === 'string' || typeof type === 'function' || - // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. - type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE); + return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. + type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE); } function memo(type, compare) { @@ -1424,6 +1574,7 @@ function memo(type, compare) { warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); } } + return { $$typeof: REACT_MEMO_TYPE, type: type, @@ -1433,20 +1584,26 @@ function memo(type, compare) { function resolveDispatcher() { var dispatcher = ReactCurrentDispatcher.current; - !(dispatcher !== null) ? invariant(false, 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.') : void 0; + + if (!(dispatcher !== null)) { + { + throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem."); + } + } + return dispatcher; } function useContext(Context, unstable_observedBits) { var dispatcher = resolveDispatcher(); + { - !(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0; + !(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0; // TODO: add a more generic warning for invalid values. - // TODO: add a more generic warning for invalid values. if (Context._context !== undefined) { - var realContext = Context._context; - // Don't deduplicate because this legitimately causes bugs + var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs // and nobody should be using this in existing code. + if (realContext.Consumer === Context) { warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?'); } else if (realContext.Provider === Context) { @@ -1454,55 +1611,79 @@ function useContext(Context, unstable_observedBits) { } } } + return dispatcher.useContext(Context, unstable_observedBits); } - function useState(initialState) { var dispatcher = resolveDispatcher(); return dispatcher.useState(initialState); } - function useReducer(reducer, initialArg, init) { var dispatcher = resolveDispatcher(); return dispatcher.useReducer(reducer, initialArg, init); } - function useRef(initialValue) { var dispatcher = resolveDispatcher(); return dispatcher.useRef(initialValue); } - function useEffect(create, inputs) { var dispatcher = resolveDispatcher(); return dispatcher.useEffect(create, inputs); } - function useLayoutEffect(create, inputs) { var dispatcher = resolveDispatcher(); return dispatcher.useLayoutEffect(create, inputs); } - function useCallback(callback, inputs) { var dispatcher = resolveDispatcher(); return dispatcher.useCallback(callback, inputs); } - function useMemo(create, inputs) { var dispatcher = resolveDispatcher(); return dispatcher.useMemo(create, inputs); } - function useImperativeHandle(ref, create, inputs) { var dispatcher = resolveDispatcher(); return dispatcher.useImperativeHandle(ref, create, inputs); } - function useDebugValue(value, formatterFn) { { var dispatcher = resolveDispatcher(); return dispatcher.useDebugValue(value, formatterFn); } } +var emptyObject$1 = {}; +function useResponder(responder, listenerProps) { + var dispatcher = resolveDispatcher(); + + { + if (responder == null || responder.$$typeof !== REACT_RESPONDER_TYPE) { + warning$1(false, 'useResponder: invalid first argument. Expected an event responder, but instead got %s', responder); + return; + } + } + + return dispatcher.useResponder(responder, listenerProps || emptyObject$1); +} +function useTransition(config) { + var dispatcher = resolveDispatcher(); + return dispatcher.useTransition(config); +} +function useDeferredValue(value, config) { + var dispatcher = resolveDispatcher(); + return dispatcher.useDeferredValue(value, config); +} + +function withSuspenseConfig(scope, config) { + var previousConfig = ReactCurrentBatchConfig.suspense; + ReactCurrentBatchConfig.suspense = config === undefined ? null : config; + + try { + scope(); + } finally { + ReactCurrentBatchConfig.suspense = previousConfig; + } +} /** * ReactElementValidator provides a wrapper around a element factory @@ -1510,38 +1691,50 @@ function useDebugValue(value, formatterFn) { * used only in DEV and could be replaced by a static type checker for languages * that support it. */ - -var propTypesMisspellWarningShown = void 0; +var propTypesMisspellWarningShown; { propTypesMisspellWarningShown = false; } +var hasOwnProperty$1 = Object.prototype.hasOwnProperty; + function getDeclarationErrorAddendum() { if (ReactCurrentOwner.current) { var name = getComponentName(ReactCurrentOwner.current.type); + if (name) { return '\n\nCheck the render method of `' + name + '`.'; } } + return ''; } -function getSourceInfoErrorAddendum(elementProps) { - if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) { - var source = elementProps.__source; +function getSourceInfoErrorAddendum(source) { + if (source !== undefined) { var fileName = source.fileName.replace(/^.*[\\\/]/, ''); var lineNumber = source.lineNumber; return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; } + return ''; } +function getSourceInfoErrorAddendumForProps(elementProps) { + if (elementProps !== null && elementProps !== undefined) { + return getSourceInfoErrorAddendum(elementProps.__source); + } + + return ''; +} /** * Warn if there's no key explicitly set on dynamic arrays of children or * object keys are not valid. This allows us to keep track of children between * updates. */ + + var ownerHasKeyUseWarning = {}; function getCurrentComponentErrorInfo(parentType) { @@ -1549,13 +1742,14 @@ function getCurrentComponentErrorInfo(parentType) { if (!info) { var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; + if (parentName) { - info = '\n\nCheck the top-level render call using <' + parentName + '>.'; + info = "\n\nCheck the top-level render call using <" + parentName + ">."; } } + return info; } - /** * Warn if the element doesn't have an explicit key assigned to it. * This element is in an array. The array could grow and shrink or be @@ -1567,34 +1761,39 @@ function getCurrentComponentErrorInfo(parentType) { * @param {ReactElement} element Element that requires a key. * @param {*} parentType element's parent's type. */ + + function validateExplicitKey(element, parentType) { if (!element._store || element._store.validated || element.key != null) { return; } - element._store.validated = true; + element._store.validated = true; var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); + if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { return; } - ownerHasKeyUseWarning[currentComponentErrorInfo] = true; - // Usually the current owner is the offender, but if it accepts children as a + ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a // property, it may be the creator of the child that's responsible for // assigning it a key. + var childOwner = ''; + if (element && element._owner && element._owner !== ReactCurrentOwner.current) { // Give the component that originally created this child. - childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.'; + childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; } setCurrentlyValidatingElement(element); + { warning$1(false, 'Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner); } + setCurrentlyValidatingElement(null); } - /** * Ensure that every element either is passed in a static location, in an * array with an explicit keys property defined, or in an object literal @@ -1604,13 +1803,17 @@ function validateExplicitKey(element, parentType) { * @param {ReactNode} node Statically passed child of any type. * @param {*} parentType node's parent's type. */ + + function validateChildKeys(node, parentType) { if (typeof node !== 'object') { return; } + if (Array.isArray(node)) { for (var i = 0; i < node.length; i++) { var child = node[i]; + if (isValidElement(child)) { validateExplicitKey(child, parentType); } @@ -1622,12 +1825,14 @@ function validateChildKeys(node, parentType) { } } else if (node) { var iteratorFn = getIteratorFn(node); + if (typeof iteratorFn === 'function') { // Entry iterators used to provide implicit keys, // but now we print a separate warning for them later. if (iteratorFn !== node.entries) { var iterator = iteratorFn.call(node); - var step = void 0; + var step; + while (!(step = iterator.next()).done) { if (isValidElement(step.value)) { validateExplicitKey(step.value, parentType); @@ -1637,30 +1842,34 @@ function validateChildKeys(node, parentType) { } } } - /** * Given an element, validate that its props follow the propTypes definition, * provided by the type. * * @param {ReactElement} element */ + + function validatePropTypes(element) { var type = element.type; + if (type === null || type === undefined || typeof type === 'string') { return; } + var name = getComponentName(type); - var propTypes = void 0; + var propTypes; + if (typeof type === 'function') { propTypes = type.propTypes; - } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || - // Note: Memo only checks outer props here. + } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. // Inner props are checked in the reconciler. type.$$typeof === REACT_MEMO_TYPE)) { propTypes = type.propTypes; } else { return; } + if (propTypes) { setCurrentlyValidatingElement(element); checkPropTypes(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum); @@ -1669,21 +1878,24 @@ function validatePropTypes(element) { propTypesMisspellWarningShown = true; warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown'); } + if (typeof type.getDefaultProps === 'function') { !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0; } } - /** * Given a fragment, validate that it can only be provided with fragment props * @param {ReactElement} fragment */ + + function validateFragmentProps(fragment) { setCurrentlyValidatingElement(fragment); - var keys = Object.keys(fragment.props); + for (var i = 0; i < keys.length; i++) { var key = keys[i]; + if (key !== 'children' && key !== 'key') { warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); break; @@ -1697,52 +1909,144 @@ function validateFragmentProps(fragment) { setCurrentlyValidatingElement(null); } -function createElementWithValidation(type, props, children) { - var validType = isValidElementType(type); - - // We warn in this case but don't throw. We expect the element creation to +function jsxWithValidation(type, props, key, isStaticChildren, source, self) { + var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to // succeed and there will likely be errors in render. + if (!validType) { var info = ''; + if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; } - var sourceInfo = getSourceInfoErrorAddendum(props); + var sourceInfo = getSourceInfoErrorAddendum(source); + if (sourceInfo) { info += sourceInfo; } else { info += getDeclarationErrorAddendum(); } - var typeString = void 0; + var typeString; + if (type === null) { typeString = 'null'; } else if (Array.isArray(type)) { typeString = 'array'; } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { - typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />'; + typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; info = ' Did you accidentally export a JSX literal instead of a component?'; } else { typeString = typeof type; } - warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); + warning$1(false, 'React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); } - var element = createElement.apply(this, arguments); - - // The result can be nullish if a mock or a custom function is used. + var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used. // TODO: Drop this when these are no longer allowed as the type argument. + if (element == null) { return element; + } // Skip key warning if the type isn't valid since our key validation logic + // doesn't expect a non-string/function type and can throw confusing errors. + // We don't want exception behavior to differ between dev and prod. + // (Rendering will throw with a helpful message and as soon as the type is + // fixed, the key warnings will appear.) + + + if (validType) { + var children = props.children; + + if (children !== undefined) { + if (isStaticChildren) { + if (Array.isArray(children)) { + for (var i = 0; i < children.length; i++) { + validateChildKeys(children[i], type); + } + + if (Object.freeze) { + Object.freeze(children); + } + } else { + warning$1(false, 'React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.'); + } + } else { + validateChildKeys(children, type); + } + } + } + + if (hasOwnProperty$1.call(props, 'key')) { + warning$1(false, 'React.jsx: Spreading a key to JSX is a deprecated pattern. ' + 'Explicitly pass a key after spreading props in your JSX call. ' + 'E.g. '); + } + + if (type === REACT_FRAGMENT_TYPE) { + validateFragmentProps(element); + } else { + validatePropTypes(element); + } + + return element; +} // These two functions exist to still get child warnings in dev +// even with the prod transform. This means that jsxDEV is purely +// opt-in behavior for better messages but that we won't stop +// giving you warnings if you use production apis. + +function jsxWithValidationStatic(type, props, key) { + return jsxWithValidation(type, props, key, true); +} +function jsxWithValidationDynamic(type, props, key) { + return jsxWithValidation(type, props, key, false); +} +function createElementWithValidation(type, props, children) { + var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to + // succeed and there will likely be errors in render. + + if (!validType) { + var info = ''; + + if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { + info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; + } + + var sourceInfo = getSourceInfoErrorAddendumForProps(props); + + if (sourceInfo) { + info += sourceInfo; + } else { + info += getDeclarationErrorAddendum(); + } + + var typeString; + + if (type === null) { + typeString = 'null'; + } else if (Array.isArray(type)) { + typeString = 'array'; + } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { + typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; + info = ' Did you accidentally export a JSX literal instead of a component?'; + } else { + typeString = typeof type; + } + + warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); } - // Skip key warning if the type isn't valid since our key validation logic + var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. + // TODO: Drop this when these are no longer allowed as the type argument. + + if (element == null) { + return element; + } // Skip key warning if the type isn't valid since our key validation logic // doesn't expect a non-string/function type and can throw confusing errors. // We don't want exception behavior to differ between dev and prod. // (Rendering will throw with a helpful message and as soon as the type is // fixed, the key warnings will appear.) + + if (validType) { for (var i = 2; i < arguments.length; i++) { validateChildKeys(arguments[i], type); @@ -1757,16 +2061,15 @@ function createElementWithValidation(type, props, children) { return element; } - function createFactoryWithValidation(type) { var validatedFactory = createElementWithValidation.bind(null, type); - validatedFactory.type = type; - // Legacy hook: remove it + validatedFactory.type = type; // Legacy hook: remove it + { Object.defineProperty(validatedFactory, 'type', { enumerable: false, get: function () { - lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); + lowPriorityWarningWithoutStack$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); Object.defineProperty(this, 'type', { value: type }); @@ -1777,54 +2080,157 @@ function createFactoryWithValidation(type) { return validatedFactory; } - function cloneElementWithValidation(element, props, children) { var newElement = cloneElement.apply(this, arguments); + for (var i = 2; i < arguments.length; i++) { validateChildKeys(arguments[i], newElement.type); } + validatePropTypes(newElement); return newElement; } -// Helps identify side effects in begin-phase lifecycle hooks and setState reducers: +var hasBadMapPolyfill; +{ + hasBadMapPolyfill = false; -// In some cases, StrictMode should also double-render lifecycles. -// This can be confusing for tests though, -// And it can be bad for performance in production. -// This feature flag can be used to control the behavior: + try { + var frozenObject = Object.freeze({}); + var testMap = new Map([[frozenObject, null]]); + var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused. + // https://github.com/rollup/rollup/issues/1771 + // TODO: we can remove these if Rollup fixes the bug. + testMap.set(0, 0); + testSet.add(0); + } catch (e) { + // TODO: Consider warning about bad polyfills + hasBadMapPolyfill = true; + } +} -// To preserve the "Pause on caught exceptions" behavior of the debugger, we -// replay the begin phase of a failed component inside invokeGuardedCallback. +function createFundamentalComponent(impl) { + // We use responder as a Map key later on. When we have a bad + // polyfill, then we can't use it as a key as the polyfill tries + // to add a property to the object. + if (true && !hasBadMapPolyfill) { + Object.freeze(impl); + } + var fundamantalComponent = { + $$typeof: REACT_FUNDAMENTAL_TYPE, + impl: impl + }; -// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: + { + Object.freeze(fundamantalComponent); + } + + return fundamantalComponent; +} + +function createEventResponder(displayName, responderConfig) { + var getInitialState = responderConfig.getInitialState, + onEvent = responderConfig.onEvent, + onMount = responderConfig.onMount, + onUnmount = responderConfig.onUnmount, + onRootEvent = responderConfig.onRootEvent, + rootEventTypes = responderConfig.rootEventTypes, + targetEventTypes = responderConfig.targetEventTypes, + targetPortalPropagation = responderConfig.targetPortalPropagation; + var eventResponder = { + $$typeof: REACT_RESPONDER_TYPE, + displayName: displayName, + getInitialState: getInitialState || null, + onEvent: onEvent || null, + onMount: onMount || null, + onRootEvent: onRootEvent || null, + onUnmount: onUnmount || null, + rootEventTypes: rootEventTypes || null, + targetEventTypes: targetEventTypes || null, + targetPortalPropagation: targetPortalPropagation || false + }; // We use responder as a Map key later on. When we have a bad + // polyfill, then we can't use it as a key as the polyfill tries + // to add a property to the object. + + if (true && !hasBadMapPolyfill) { + Object.freeze(eventResponder); + } + + return eventResponder; +} + +function createScope() { + var scopeComponent = { + $$typeof: REACT_SCOPE_TYPE + }; + { + Object.freeze(scopeComponent); + } -// Gather advanced timing metrics for Profiler subtrees. + return scopeComponent; +} +// Helps identify side effects in render-phase lifecycle hooks and setState +// reducers by double invoking them in Strict Mode. -// Trace which interactions trigger each commit. + // To preserve the "Pause on caught exceptions" behavior of the debugger, we +// replay the begin phase of a failed component inside invokeGuardedCallback. + // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: -// Only used in www builds. - // TODO: true? Here it might just be false. + // Gather advanced timing metrics for Profiler subtrees. -// Only used in www builds. + // Trace which interactions trigger each commit. + // SSR experiments -// Only used in www builds. + // Only used in www builds. -// React Fire: prevent the value and checked attributes from syncing -// with their related DOM properties + // Only used in www builds. + // Disable javascript: URL strings in href for XSS protection. -// These APIs will no longer be "unstable" in the upcoming 16.7 release, + // React Fire: prevent the value and checked attributes from syncing +// with their related DOM properties + + // These APIs will no longer be "unstable" in the upcoming 16.7 release, // Control this behavior with a flag to support 16.6 minor releases in the meanwhile. -var enableStableConcurrentModeAPIs = false; + +var exposeConcurrentModeAPIs = false; + // Experimental React Flare event system and event components support. + +var enableFlareAPI = false; // Experimental Host Component support. + +var enableFundamentalAPI = false; // Experimental Scope support. + +var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107 + +var enableJSXTransformAPI = false; // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?) +// Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version + + // For tests, we flush suspense fallbacks in an act scope; +// *except* in some of our own tests, where we test incremental loading states. + + // Add a callback property to suspense to notify which promises are currently +// in the update queue. This allows reporting and tracing of what is causing +// the user to see a loading state. +// Also allows hydration callbacks to fire when a dehydrated boundary gets +// hydrated or deleted. + + // Part of the simplification of React.createElement so we can eventually move +// from React.createElement to React.jsx +// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md + + + + + + // Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance var React = { Children: { @@ -1834,16 +2240,13 @@ var React = { toArray: toArray, only: onlyChild }, - createRef: createRef, Component: Component, PureComponent: PureComponent, - createContext: createContext, forwardRef: forwardRef, lazy: lazy, memo: memo, - useCallback: useCallback, useContext: useContext, useEffect: useEffect, @@ -1854,34 +2257,48 @@ var React = { useReducer: useReducer, useRef: useRef, useState: useState, - Fragment: REACT_FRAGMENT_TYPE, + Profiler: REACT_PROFILER_TYPE, StrictMode: REACT_STRICT_MODE_TYPE, Suspense: REACT_SUSPENSE_TYPE, - createElement: createElementWithValidation, cloneElement: cloneElementWithValidation, createFactory: createFactoryWithValidation, isValidElement: isValidElement, - version: ReactVersion, - - unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE, - unstable_Profiler: REACT_PROFILER_TYPE, - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals }; -// Note: some APIs are added with feature flags. +if (exposeConcurrentModeAPIs) { + React.useTransition = useTransition; + React.useDeferredValue = useDeferredValue; + React.SuspenseList = REACT_SUSPENSE_LIST_TYPE; + React.unstable_withSuspenseConfig = withSuspenseConfig; +} + +if (enableFlareAPI) { + React.unstable_useResponder = useResponder; + React.unstable_createResponder = createEventResponder; +} + +if (enableFundamentalAPI) { + React.unstable_createFundamental = createFundamentalComponent; +} + +if (enableScopeAPI) { + React.unstable_createScope = createScope; +} // Note: some APIs are added with feature flags. // Make sure that stable builds for open source // don't modify the React object to avoid deopts. // Also let's not expose their names in stable builds. -if (enableStableConcurrentModeAPIs) { - React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; - React.Profiler = REACT_PROFILER_TYPE; - React.unstable_ConcurrentMode = undefined; - React.unstable_Profiler = undefined; + +if (enableJSXTransformAPI) { + { + React.jsxDEV = jsxWithValidation; + React.jsx = jsxWithValidationDynamic; + React.jsxs = jsxWithValidationStatic; + } } @@ -1894,6 +2311,8 @@ var React$3 = ( React$2 && React ) || React$2; // TODO: decide on the top-level export form. // This is hacky but makes it work with both Rollup and Jest. + + var react = React$3.default || React$3; module.exports = react; diff --git a/node_modules/react/cjs/react.production.min.js b/node_modules/react/cjs/react.production.min.js index 1cc5fb074..b6230dbae 100644 --- a/node_modules/react/cjs/react.production.min.js +++ b/node_modules/react/cjs/react.production.min.js @@ -1,4 +1,4 @@ -/** @license React v16.8.6 +/** @license React v16.12.0 * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. @@ -7,19 +7,19 @@ * LICENSE file in the root directory of this source tree. */ -'use strict';var k=require("object-assign"),n="function"===typeof Symbol&&Symbol.for,p=n?Symbol.for("react.element"):60103,q=n?Symbol.for("react.portal"):60106,r=n?Symbol.for("react.fragment"):60107,t=n?Symbol.for("react.strict_mode"):60108,u=n?Symbol.for("react.profiler"):60114,v=n?Symbol.for("react.provider"):60109,w=n?Symbol.for("react.context"):60110,x=n?Symbol.for("react.concurrent_mode"):60111,y=n?Symbol.for("react.forward_ref"):60112,z=n?Symbol.for("react.suspense"):60113,aa=n?Symbol.for("react.memo"): -60115,ba=n?Symbol.for("react.lazy"):60116,A="function"===typeof Symbol&&Symbol.iterator;function ca(a,b,d,c,e,g,h,f){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[d,c,e,g,h,f],m=0;a=Error(b.replace(/%s/g,function(){return l[m++]}));a.name="Invariant Violation"}a.framesToPop=1;throw a;}} -function B(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;cP.length&&P.push(a)} -function S(a,b,d,c){var e=typeof a;if("undefined"===e||"boolean"===e)a=null;var g=!1;if(null===a)g=!0;else switch(e){case "string":case "number":g=!0;break;case "object":switch(a.$$typeof){case p:case q:g=!0}}if(g)return d(c,a,""===b?"."+T(a,0):b),1;g=0;b=""===b?".":b+":";if(Array.isArray(a))for(var h=0;h=0.10.0" @@ -67,5 +64,5 @@ "url": "git+https://github.com/facebook/react.git", "directory": "packages/react" }, - "version": "16.8.6" + "version": "16.12.0" } diff --git a/node_modules/react/umd/react.development.js b/node_modules/react/umd/react.development.js index cd2e8c3a3..75d9af668 100644 --- a/node_modules/react/umd/react.development.js +++ b/node_modules/react/umd/react.development.js @@ -1,4 +1,4 @@ -/** @license React v16.8.6 +/** @license React v16.12.0 * react.development.js * * Copyright (c) Facebook, Inc. and its affiliates. @@ -17,37 +17,43 @@ // TODO: this is special because it gets imported during build. -var ReactVersion = '16.8.6'; +var ReactVersion = '16.12.0'; // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. var hasSymbol = typeof Symbol === 'function' && Symbol.for; - var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7; var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca; var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb; var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc; var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd; -var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; +var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary +// (unstable) APIs that have been removed. Can we remove the symbols? + var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf; var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1; +var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4; - +var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5; +var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6; +var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = '@@iterator'; - function getIteratorFn(maybeIterable) { if (maybeIterable === null || typeof maybeIterable !== 'object') { return null; } + var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]; + if (typeof maybeIterator === 'function') { return maybeIterator; } + return null; } @@ -142,6 +148,10 @@ var objectAssign = shouldUseNative() ? Object.assign : function (target, source) return to; }; +// Do not require this module directly! Use normal `invariant` calls with +// template literal strings. The messages will be replaced with error codes +// during build. + /** * Use invariant() to assert state which your program assumes to be true. * @@ -153,40 +163,6 @@ var objectAssign = shouldUseNative() ? Object.assign : function (target, source) * will remain to ensure logic does not differ in production. */ -var validateFormat = function () {}; - -{ - validateFormat = function (format) { - if (format === undefined) { - throw new Error('invariant requires an error message argument'); - } - }; -} - -function invariant(condition, format, a, b, c, d, e, f) { - validateFormat(format); - - if (!condition) { - var error = void 0; - if (format === undefined) { - error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error(format.replace(/%s/g, function () { - return args[argIndex++]; - })); - error.name = 'Invariant Violation'; - } - - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; - } -} - -// Relying on the `invariant()` implementation lets us -// preserve the format and params in the www builds. - /** * Forked from fbjs/warning: * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js @@ -200,12 +176,11 @@ function invariant(condition, format, a, b, c, d, e, f) { * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ - -var lowPriorityWarning = function () {}; +var lowPriorityWarningWithoutStack = function () {}; { var printWarning = function (format) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { args[_key - 1] = arguments[_key]; } @@ -213,9 +188,11 @@ var lowPriorityWarning = function () {}; var message = 'Warning: ' + format.replace(/%s/g, function () { return args[argIndex++]; }); + if (typeof console !== 'undefined') { console.warn(message); } + try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack @@ -224,21 +201,22 @@ var lowPriorityWarning = function () {}; } catch (x) {} }; - lowPriorityWarning = function (condition, format) { + lowPriorityWarningWithoutStack = function (condition, format) { if (format === undefined) { - throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument'); + throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument'); } + if (!condition) { - for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { args[_key2 - 2] = arguments[_key2]; } - printWarning.apply(undefined, [format].concat(args)); + printWarning.apply(void 0, [format].concat(args)); } }; } -var lowPriorityWarning$1 = lowPriorityWarning; +var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack; /** * Similar to invariant but only logs a warning if the condition is not met. @@ -246,35 +224,37 @@ var lowPriorityWarning$1 = lowPriorityWarning; * paths. Removing the logging code for production environments will keep the * same logic and follow the same code paths. */ - var warningWithoutStack = function () {}; { warningWithoutStack = function (condition, format) { - for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { args[_key - 2] = arguments[_key]; } if (format === undefined) { throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument'); } + if (args.length > 8) { // Check before the condition to catch violations early. throw new Error('warningWithoutStack() currently supports at most 8 arguments.'); } + if (condition) { return; } + if (typeof console !== 'undefined') { var argsWithFormat = args.map(function (item) { return '' + item; }); - argsWithFormat.unshift('Warning: ' + format); - - // We intentionally don't use spread (or .apply) directly because it + argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it // breaks IE9: https://github.com/facebook/react/issues/13610 + Function.prototype.apply.call(console.error, console, argsWithFormat); } + try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack @@ -296,18 +276,21 @@ function warnNoop(publicInstance, callerName) { { var _constructor = publicInstance.constructor; var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass'; - var warningKey = componentName + '.' + callerName; + var warningKey = componentName + "." + callerName; + if (didWarnStateUpdateForUnmountedComponent[warningKey]) { return; } + warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName); didWarnStateUpdateForUnmountedComponent[warningKey] = true; } } - /** * This is the abstract API for an update queue. */ + + var ReactNoopUpdateQueue = { /** * Checks whether or not this composite component is mounted. @@ -374,25 +357,26 @@ var ReactNoopUpdateQueue = { }; var emptyObject = {}; + { Object.freeze(emptyObject); } - /** * Base class helpers for the updating state of a component. */ + + function Component(props, context, updater) { this.props = props; - this.context = context; - // If a component has string refs, we will assign a different object later. - this.refs = emptyObject; - // We initialize the default updater but the real one gets injected by the + this.context = context; // If a component has string refs, we will assign a different object later. + + this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the // renderer. + this.updater = updater || ReactNoopUpdateQueue; } Component.prototype.isReactComponent = {}; - /** * Sets a subset of the state. Always use this to mutate * state. You should treat `this.state` as immutable. @@ -418,11 +402,16 @@ Component.prototype.isReactComponent = {}; * @final * @protected */ + Component.prototype.setState = function (partialState, callback) { - !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0; + if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) { + { + throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables."); + } + } + this.updater.enqueueSetState(this, partialState, callback, 'setState'); }; - /** * Forces an update. This should only be invoked when it is known with * certainty that we are **not** in a DOM transaction. @@ -437,28 +426,33 @@ Component.prototype.setState = function (partialState, callback) { * @final * @protected */ + + Component.prototype.forceUpdate = function (callback) { this.updater.enqueueForceUpdate(this, callback, 'forceUpdate'); }; - /** * Deprecated APIs. These APIs used to exist on classic React classes but since * we would like to deprecate them, we're not going to move them over to this * modern base class. Instead, we define a getter that warns if it's accessed. */ + + { var deprecatedAPIs = { isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'], replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'] }; + var defineDeprecationWarning = function (methodName, info) { Object.defineProperty(Component.prototype, methodName, { get: function () { - lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); + lowPriorityWarningWithoutStack$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]); return undefined; } }); }; + for (var fnName in deprecatedAPIs) { if (deprecatedAPIs.hasOwnProperty(fnName)) { defineDeprecationWarning(fnName, deprecatedAPIs[fnName]); @@ -467,23 +461,25 @@ Component.prototype.forceUpdate = function (callback) { } function ComponentDummy() {} -ComponentDummy.prototype = Component.prototype; +ComponentDummy.prototype = Component.prototype; /** * Convenience component with default shallow equality check for sCU. */ + function PureComponent(props, context, updater) { this.props = props; - this.context = context; - // If a component has string refs, we will assign a different object later. + this.context = context; // If a component has string refs, we will assign a different object later. + this.refs = emptyObject; this.updater = updater || ReactNoopUpdateQueue; } var pureComponentPrototype = PureComponent.prototype = new ComponentDummy(); -pureComponentPrototype.constructor = PureComponent; -// Avoid an extra prototype jump for these methods. +pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods. + objectAssign(pureComponentPrototype, Component.prototype); + pureComponentPrototype.isPureReactComponent = true; // an immutable object with a single mutable value @@ -491,2593 +487,3222 @@ function createRef() { var refObject = { current: null }; + { Object.seal(refObject); } + return refObject; } -var enableSchedulerDebugging = false; +/** + * Keeps track of the current dispatcher. + */ +var ReactCurrentDispatcher = { + /** + * @internal + * @type {ReactComponent} + */ + current: null +}; -/* eslint-disable no-var */ +/** + * Keeps track of the current batch's configuration such as how long an update + * should suspend for if it needs to. + */ +var ReactCurrentBatchConfig = { + suspense: null +}; -// TODO: Use symbols? -var ImmediatePriority = 1; -var UserBlockingPriority = 2; -var NormalPriority = 3; -var LowPriority = 4; -var IdlePriority = 5; +/** + * Keeps track of the current owner. + * + * The current owner is the component who should own any components that are + * currently being constructed. + */ +var ReactCurrentOwner = { + /** + * @internal + * @type {ReactComponent} + */ + current: null +}; -// Max 31 bit integer. The max integer size in V8 for 32-bit systems. -// Math.pow(2, 30) - 1 -// 0b111111111111111111111111111111 -var maxSigned31BitInt = 1073741823; +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +var describeComponentFrame = function (name, source, ownerName) { + var sourceInfo = ''; -// Times out immediately -var IMMEDIATE_PRIORITY_TIMEOUT = -1; -// Eventually times out -var USER_BLOCKING_PRIORITY = 250; -var NORMAL_PRIORITY_TIMEOUT = 5000; -var LOW_PRIORITY_TIMEOUT = 10000; -// Never times out -var IDLE_PRIORITY = maxSigned31BitInt; + if (source) { + var path = source.fileName; + var fileName = path.replace(BEFORE_SLASH_RE, ''); -// Callbacks are stored as a circular, doubly linked list. -var firstCallbackNode = null; + { + // In DEV, include code for a common special case: + // prefer "folder/index.js" instead of just "index.js". + if (/^index\./.test(fileName)) { + var match = path.match(BEFORE_SLASH_RE); -var currentDidTimeout = false; -// Pausing the scheduler is useful for debugging. -var isSchedulerPaused = false; + if (match) { + var pathBeforeSlash = match[1]; -var currentPriorityLevel = NormalPriority; -var currentEventStartTime = -1; -var currentExpirationTime = -1; + if (pathBeforeSlash) { + var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); + fileName = folderName + '/' + fileName; + } + } + } + } -// This is set when a callback is being executed, to prevent re-entrancy. -var isExecutingCallback = false; + sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; + } else if (ownerName) { + sourceInfo = ' (created by ' + ownerName + ')'; + } -var isHostCallbackScheduled = false; + return '\n in ' + (name || 'Unknown') + sourceInfo; +}; -var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; +var Resolved = 1; -function ensureHostCallbackIsScheduled() { - if (isExecutingCallback) { - // Don't schedule work yet; wait until the next time we yield. - return; - } - // Schedule the host callback using the earliest expiration in the list. - var expirationTime = firstCallbackNode.expirationTime; - if (!isHostCallbackScheduled) { - isHostCallbackScheduled = true; - } else { - // Cancel the existing host callback. - cancelHostCallback(); - } - requestHostCallback(flushWork, expirationTime); +function refineResolvedLazyComponent(lazyComponent) { + return lazyComponent._status === Resolved ? lazyComponent._result : null; } -function flushFirstCallback() { - var flushedNode = firstCallbackNode; +function getWrappedName(outerType, innerType, wrapperName) { + var functionName = innerType.displayName || innerType.name || ''; + return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName); +} - // Remove the node from the list before calling the callback. That way the - // list is in a consistent state even if the callback throws. - var next = firstCallbackNode.next; - if (firstCallbackNode === next) { - // This is the last callback in the list. - firstCallbackNode = null; - next = null; - } else { - var lastCallbackNode = firstCallbackNode.previous; - firstCallbackNode = lastCallbackNode.next = next; - next.previous = lastCallbackNode; +function getComponentName(type) { + if (type == null) { + // Host root, text node or just invalid type. + return null; } - flushedNode.next = flushedNode.previous = null; - - // Now it's safe to call the callback. - var callback = flushedNode.callback; - var expirationTime = flushedNode.expirationTime; - var priorityLevel = flushedNode.priorityLevel; - var previousPriorityLevel = currentPriorityLevel; - var previousExpirationTime = currentExpirationTime; - currentPriorityLevel = priorityLevel; - currentExpirationTime = expirationTime; - var continuationCallback; - try { - continuationCallback = callback(); - } finally { - currentPriorityLevel = previousPriorityLevel; - currentExpirationTime = previousExpirationTime; - } - - // A callback may return a continuation. The continuation should be scheduled - // with the same priority and expiration as the just-finished callback. - if (typeof continuationCallback === 'function') { - var continuationNode = { - callback: continuationCallback, - priorityLevel: priorityLevel, - expirationTime: expirationTime, - next: null, - previous: null - }; - - // Insert the new callback into the list, sorted by its expiration. This is - // almost the same as the code in `scheduleCallback`, except the callback - // is inserted into the list *before* callbacks of equal expiration instead - // of after. - if (firstCallbackNode === null) { - // This is the first callback in the list. - firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode; - } else { - var nextAfterContinuation = null; - var node = firstCallbackNode; - do { - if (node.expirationTime >= expirationTime) { - // This callback expires at or after the continuation. We will insert - // the continuation *before* this callback. - nextAfterContinuation = node; - break; - } - node = node.next; - } while (node !== firstCallbackNode); - - if (nextAfterContinuation === null) { - // No equal or lower priority callback was found, which means the new - // callback is the lowest priority callback in the list. - nextAfterContinuation = firstCallbackNode; - } else if (nextAfterContinuation === firstCallbackNode) { - // The new callback is the highest priority callback in the list. - firstCallbackNode = continuationNode; - ensureHostCallbackIsScheduled(); - } - - var previous = nextAfterContinuation.previous; - previous.next = nextAfterContinuation.previous = continuationNode; - continuationNode.next = nextAfterContinuation; - continuationNode.previous = previous; + { + if (typeof type.tag === 'number') { + warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); } } -} -function flushImmediateWork() { - if ( - // Confirm we've exited the outer most event handler - currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) { - isExecutingCallback = true; - try { - do { - flushFirstCallback(); - } while ( - // Keep flushing until there are no more immediate callbacks - firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority); - } finally { - isExecutingCallback = false; - if (firstCallbackNode !== null) { - // There's still work remaining. Request another callback. - ensureHostCallbackIsScheduled(); - } else { - isHostCallbackScheduled = false; - } - } + if (typeof type === 'function') { + return type.displayName || type.name || null; } -} - -function flushWork(didTimeout) { - // Exit right away if we're currently paused - if (enableSchedulerDebugging && isSchedulerPaused) { - return; + if (typeof type === 'string') { + return type; } - isExecutingCallback = true; - var previousDidTimeout = currentDidTimeout; - currentDidTimeout = didTimeout; - try { - if (didTimeout) { - // Flush all the expired callbacks without yielding. - while (firstCallbackNode !== null && !(enableSchedulerDebugging && isSchedulerPaused)) { - // TODO Wrap in feature flag - // Read the current time. Flush all the callbacks that expire at or - // earlier than that time. Then read the current time again and repeat. - // This optimizes for as few performance.now calls as possible. - var currentTime = getCurrentTime(); - if (firstCallbackNode.expirationTime <= currentTime) { - do { - flushFirstCallback(); - } while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused)); - continue; - } - break; - } - } else { - // Keep flushing callbacks until we run out of time in the frame. - if (firstCallbackNode !== null) { - do { - if (enableSchedulerDebugging && isSchedulerPaused) { - break; - } - flushFirstCallback(); - } while (firstCallbackNode !== null && !shouldYieldToHost()); - } - } - } finally { - isExecutingCallback = false; - currentDidTimeout = previousDidTimeout; - if (firstCallbackNode !== null) { - // There's still work remaining. Request another callback. - ensureHostCallbackIsScheduled(); - } else { - isHostCallbackScheduled = false; - } - // Before exiting, flush all the immediate work that was scheduled. - flushImmediateWork(); - } -} + switch (type) { + case REACT_FRAGMENT_TYPE: + return 'Fragment'; -function unstable_runWithPriority(priorityLevel, eventHandler) { - switch (priorityLevel) { - case ImmediatePriority: - case UserBlockingPriority: - case NormalPriority: - case LowPriority: - case IdlePriority: - break; - default: - priorityLevel = NormalPriority; - } + case REACT_PORTAL_TYPE: + return 'Portal'; - var previousPriorityLevel = currentPriorityLevel; - var previousEventStartTime = currentEventStartTime; - currentPriorityLevel = priorityLevel; - currentEventStartTime = getCurrentTime(); + case REACT_PROFILER_TYPE: + return "Profiler"; - try { - return eventHandler(); - } finally { - currentPriorityLevel = previousPriorityLevel; - currentEventStartTime = previousEventStartTime; + case REACT_STRICT_MODE_TYPE: + return 'StrictMode'; - // Before exiting, flush all the immediate work that was scheduled. - flushImmediateWork(); - } -} + case REACT_SUSPENSE_TYPE: + return 'Suspense'; -function unstable_next(eventHandler) { - var priorityLevel = void 0; - switch (currentPriorityLevel) { - case ImmediatePriority: - case UserBlockingPriority: - case NormalPriority: - // Shift down to normal priority - priorityLevel = NormalPriority; - break; - default: - // Anything lower than normal priority should remain at the current level. - priorityLevel = currentPriorityLevel; - break; + case REACT_SUSPENSE_LIST_TYPE: + return 'SuspenseList'; } - var previousPriorityLevel = currentPriorityLevel; - var previousEventStartTime = currentEventStartTime; - currentPriorityLevel = priorityLevel; - currentEventStartTime = getCurrentTime(); + if (typeof type === 'object') { + switch (type.$$typeof) { + case REACT_CONTEXT_TYPE: + return 'Context.Consumer'; - try { - return eventHandler(); - } finally { - currentPriorityLevel = previousPriorityLevel; - currentEventStartTime = previousEventStartTime; + case REACT_PROVIDER_TYPE: + return 'Context.Provider'; - // Before exiting, flush all the immediate work that was scheduled. - flushImmediateWork(); - } -} + case REACT_FORWARD_REF_TYPE: + return getWrappedName(type, type.render, 'ForwardRef'); -function unstable_wrapCallback(callback) { - var parentPriorityLevel = currentPriorityLevel; - return function () { - // This is a fork of runWithPriority, inlined for performance. - var previousPriorityLevel = currentPriorityLevel; - var previousEventStartTime = currentEventStartTime; - currentPriorityLevel = parentPriorityLevel; - currentEventStartTime = getCurrentTime(); + case REACT_MEMO_TYPE: + return getComponentName(type.type); - try { - return callback.apply(this, arguments); - } finally { - currentPriorityLevel = previousPriorityLevel; - currentEventStartTime = previousEventStartTime; - flushImmediateWork(); - } - }; -} + case REACT_LAZY_TYPE: + { + var thenable = type; + var resolvedThenable = refineResolvedLazyComponent(thenable); -function unstable_scheduleCallback(callback, deprecated_options) { - var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime(); + if (resolvedThenable) { + return getComponentName(resolvedThenable); + } - var expirationTime; - if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') { - // FIXME: Remove this branch once we lift expiration times out of React. - expirationTime = startTime + deprecated_options.timeout; - } else { - switch (currentPriorityLevel) { - case ImmediatePriority: - expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT; - break; - case UserBlockingPriority: - expirationTime = startTime + USER_BLOCKING_PRIORITY; - break; - case IdlePriority: - expirationTime = startTime + IDLE_PRIORITY; - break; - case LowPriority: - expirationTime = startTime + LOW_PRIORITY_TIMEOUT; - break; - case NormalPriority: - default: - expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT; + break; + } } } - var newNode = { - callback: callback, - priorityLevel: currentPriorityLevel, - expirationTime: expirationTime, - next: null, - previous: null - }; - - // Insert the new callback into the list, ordered first by expiration, then - // by insertion. So the new callback is inserted any other callback with - // equal expiration. - if (firstCallbackNode === null) { - // This is the first callback in the list. - firstCallbackNode = newNode.next = newNode.previous = newNode; - ensureHostCallbackIsScheduled(); - } else { - var next = null; - var node = firstCallbackNode; - do { - if (node.expirationTime > expirationTime) { - // The new callback expires before this one. - next = node; - break; - } - node = node.next; - } while (node !== firstCallbackNode); - - if (next === null) { - // No callback with a later expiration was found, which means the new - // callback has the latest expiration in the list. - next = firstCallbackNode; - } else if (next === firstCallbackNode) { - // The new callback has the earliest expiration in the entire list. - firstCallbackNode = newNode; - ensureHostCallbackIsScheduled(); - } + return null; +} - var previous = next.previous; - previous.next = next.previous = newNode; - newNode.next = next; - newNode.previous = previous; +var ReactDebugCurrentFrame = {}; +var currentlyValidatingElement = null; +function setCurrentlyValidatingElement(element) { + { + currentlyValidatingElement = element; } - - return newNode; } -function unstable_pauseExecution() { - isSchedulerPaused = true; -} +{ + // Stack implementation injected by the current renderer. + ReactDebugCurrentFrame.getCurrentStack = null; -function unstable_continueExecution() { - isSchedulerPaused = false; - if (firstCallbackNode !== null) { - ensureHostCallbackIsScheduled(); - } -} + ReactDebugCurrentFrame.getStackAddendum = function () { + var stack = ''; // Add an extra top frame while an element is being validated -function unstable_getFirstCallbackNode() { - return firstCallbackNode; -} + if (currentlyValidatingElement) { + var name = getComponentName(currentlyValidatingElement.type); + var owner = currentlyValidatingElement._owner; + stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type)); + } // Delegate to the injected renderer-specific implementation -function unstable_cancelCallback(callbackNode) { - var next = callbackNode.next; - if (next === null) { - // Already cancelled. - return; - } - if (next === callbackNode) { - // This is the only scheduled callback. Clear the list. - firstCallbackNode = null; - } else { - // Remove the callback from its position in the list. - if (callbackNode === firstCallbackNode) { - firstCallbackNode = next; - } - var previous = callbackNode.previous; - previous.next = next; - next.previous = previous; - } + var impl = ReactDebugCurrentFrame.getCurrentStack; - callbackNode.next = callbackNode.previous = null; -} + if (impl) { + stack += impl() || ''; + } -function unstable_getCurrentPriorityLevel() { - return currentPriorityLevel; + return stack; + }; } -function unstable_shouldYield() { - return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost()); -} - -// The remaining code is essentially a polyfill for requestIdleCallback. It -// works by scheduling a requestAnimationFrame, storing the time for the start -// of the frame, then scheduling a postMessage which gets scheduled after paint. -// Within the postMessage handler do as much work as possible until time + frame -// rate. By separating the idle call into a separate event tick we ensure that -// layout, paint and other browser work is counted against the available time. -// The frame rate is dynamically adjusted. - -// We capture a local reference to any global, in case it gets polyfilled after -// this module is initially evaluated. We want to be using a -// consistent implementation. -var localDate = Date; - -// This initialization code may run even on server environments if a component -// just imports ReactDOM (e.g. for findDOMNode). Some environments might not -// have setTimeout or clearTimeout. However, we always expect them to be defined -// on the client. https://github.com/facebook/react/pull/13088 -var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined; -var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined; - -// We don't expect either of these to necessarily be defined, but we will error -// later if they are missing on the client. -var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined; -var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined; - -var getCurrentTime; +/** + * Used by act() to track whether you're inside an act() scope. + */ +var IsSomeRendererActing = { + current: false +}; -// requestAnimationFrame does not run when the tab is in the background. If -// we're backgrounded we prefer for that work to happen so that the page -// continues to load in the background. So we also schedule a 'setTimeout' as -// a fallback. -// TODO: Need a better heuristic for backgrounded work. -var ANIMATION_FRAME_TIMEOUT = 100; -var rAFID; -var rAFTimeoutID; -var requestAnimationFrameWithTimeout = function (callback) { - // schedule rAF and also a setTimeout - rAFID = localRequestAnimationFrame(function (timestamp) { - // cancel the setTimeout - localClearTimeout(rAFTimeoutID); - callback(timestamp); - }); - rAFTimeoutID = localSetTimeout(function () { - // cancel the requestAnimationFrame - localCancelAnimationFrame(rAFID); - callback(getCurrentTime()); - }, ANIMATION_FRAME_TIMEOUT); +var ReactSharedInternals = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentBatchConfig: ReactCurrentBatchConfig, + ReactCurrentOwner: ReactCurrentOwner, + IsSomeRendererActing: IsSomeRendererActing, + // Used by renderers to avoid bundling object-assign twice in UMD bundles: + assign: objectAssign }; -if (hasNativePerformanceNow) { - var Performance = performance; - getCurrentTime = function () { - return Performance.now(); - }; -} else { - getCurrentTime = function () { - return localDate.now(); - }; +{ + objectAssign(ReactSharedInternals, { + // These should not be included in production. + ReactDebugCurrentFrame: ReactDebugCurrentFrame, + // Shim for React DOM 16.0.0 which still destructured (but not used) this. + // TODO: remove in React 17.0. + ReactComponentTreeHook: {} + }); } -var requestHostCallback; -var cancelHostCallback; -var shouldYieldToHost; +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ -var globalValue = null; -if (typeof window !== 'undefined') { - globalValue = window; -} else if (typeof global !== 'undefined') { - globalValue = global; -} - -if (globalValue && globalValue._schedMock) { - // Dynamic injection, only for testing purposes. - var globalImpl = globalValue._schedMock; - requestHostCallback = globalImpl[0]; - cancelHostCallback = globalImpl[1]; - shouldYieldToHost = globalImpl[2]; - getCurrentTime = globalImpl[3]; -} else if ( -// If Scheduler runs in a non-DOM environment, it falls back to a naive -// implementation using setTimeout. -typeof window === 'undefined' || -// Check if MessageChannel is supported, too. -typeof MessageChannel !== 'function') { - // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore, - // fallback to a naive implementation. - var _callback = null; - var _flushCallback = function (didTimeout) { - if (_callback !== null) { - try { - _callback(didTimeout); - } finally { - _callback = null; - } - } - }; - requestHostCallback = function (cb, ms) { - if (_callback !== null) { - // Protect against re-entrancy. - setTimeout(requestHostCallback, 0, cb); - } else { - _callback = cb; - setTimeout(_flushCallback, 0, false); - } - }; - cancelHostCallback = function () { - _callback = null; - }; - shouldYieldToHost = function () { - return false; - }; -} else { - if (typeof console !== 'undefined') { - // TODO: Remove fb.me link - if (typeof localRequestAnimationFrame !== 'function') { - console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); - } - if (typeof localCancelAnimationFrame !== 'function') { - console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); +var warning = warningWithoutStack$1; + +{ + warning = function (condition, format) { + if (condition) { + return; } - } - var scheduledHostCallback = null; - var isMessageEventScheduled = false; - var timeoutTime = -1; + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args - var isAnimationFrameScheduled = false; + for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { + args[_key - 2] = arguments[_key]; + } - var isFlushingHostCallback = false; + warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack])); + }; +} - var frameDeadline = 0; - // We start out assuming that we run at 30fps but then the heuristic tracking - // will adjust this value to a faster fps if we get more frequent animation - // frames. - var previousFrameTime = 33; - var activeFrameTime = 33; +var warning$1 = warning; - shouldYieldToHost = function () { - return frameDeadline <= getCurrentTime(); - }; +var hasOwnProperty$1 = Object.prototype.hasOwnProperty; +var RESERVED_PROPS = { + key: true, + ref: true, + __self: true, + __source: true +}; +var specialPropKeyWarningShown; +var specialPropRefWarningShown; - // We use the postMessage trick to defer idle work until after the repaint. - var channel = new MessageChannel(); - var port = channel.port2; - channel.port1.onmessage = function (event) { - isMessageEventScheduled = false; - - var prevScheduledCallback = scheduledHostCallback; - var prevTimeoutTime = timeoutTime; - scheduledHostCallback = null; - timeoutTime = -1; - - var currentTime = getCurrentTime(); - - var didTimeout = false; - if (frameDeadline - currentTime <= 0) { - // There's no time left in this idle period. Check if the callback has - // a timeout and whether it's been exceeded. - if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) { - // Exceeded the timeout. Invoke the callback even though there's no - // time left. - didTimeout = true; - } else { - // No timeout. - if (!isAnimationFrameScheduled) { - // Schedule another animation callback so we retry later. - isAnimationFrameScheduled = true; - requestAnimationFrameWithTimeout(animationTick); - } - // Exit without invoking the callback. - scheduledHostCallback = prevScheduledCallback; - timeoutTime = prevTimeoutTime; - return; - } - } +function hasValidRef(config) { + { + if (hasOwnProperty$1.call(config, 'ref')) { + var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; - if (prevScheduledCallback !== null) { - isFlushingHostCallback = true; - try { - prevScheduledCallback(didTimeout); - } finally { - isFlushingHostCallback = false; + if (getter && getter.isReactWarning) { + return false; } } - }; + } - var animationTick = function (rafTime) { - if (scheduledHostCallback !== null) { - // Eagerly schedule the next animation callback at the beginning of the - // frame. If the scheduler queue is not empty at the end of the frame, it - // will continue flushing inside that callback. If the queue *is* empty, - // then it will exit immediately. Posting the callback at the start of the - // frame ensures it's fired within the earliest possible frame. If we - // waited until the end of the frame to post the callback, we risk the - // browser skipping a frame and not firing the callback until the frame - // after that. - requestAnimationFrameWithTimeout(animationTick); - } else { - // No pending work. Exit. - isAnimationFrameScheduled = false; - return; - } + return config.ref !== undefined; +} + +function hasValidKey(config) { + { + if (hasOwnProperty$1.call(config, 'key')) { + var getter = Object.getOwnPropertyDescriptor(config, 'key').get; - var nextFrameTime = rafTime - frameDeadline + activeFrameTime; - if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) { - if (nextFrameTime < 8) { - // Defensive coding. We don't support higher frame rates than 120hz. - // If the calculated frame time gets lower than 8, it is probably a bug. - nextFrameTime = 8; + if (getter && getter.isReactWarning) { + return false; } - // If one frame goes long, then the next one can be short to catch up. - // If two frames are short in a row, then that's an indication that we - // actually have a higher frame rate than what we're currently optimizing. - // We adjust our heuristic dynamically accordingly. For example, if we're - // running on 120hz display or 90hz VR display. - // Take the max of the two in case one of them was an anomaly due to - // missed frame deadlines. - activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime; - } else { - previousFrameTime = nextFrameTime; } - frameDeadline = rafTime + activeFrameTime; - if (!isMessageEventScheduled) { - isMessageEventScheduled = true; - port.postMessage(undefined); - } - }; + } - requestHostCallback = function (callback, absoluteTimeout) { - scheduledHostCallback = callback; - timeoutTime = absoluteTimeout; - if (isFlushingHostCallback || absoluteTimeout < 0) { - // Don't wait for the next frame. Continue working ASAP, in a new event. - port.postMessage(undefined); - } else if (!isAnimationFrameScheduled) { - // If rAF didn't already schedule one, we need to schedule a frame. - // TODO: If this rAF doesn't materialize because the browser throttles, we - // might want to still have setTimeout trigger rIC as a backup to ensure - // that we keep performing work. - isAnimationFrameScheduled = true; - requestAnimationFrameWithTimeout(animationTick); + return config.key !== undefined; +} + +function defineKeyPropWarningGetter(props, displayName) { + var warnAboutAccessingKey = function () { + if (!specialPropKeyWarningShown) { + specialPropKeyWarningShown = true; + warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); } }; - cancelHostCallback = function () { - scheduledHostCallback = null; - isMessageEventScheduled = false; - timeoutTime = -1; - }; + warnAboutAccessingKey.isReactWarning = true; + Object.defineProperty(props, 'key', { + get: warnAboutAccessingKey, + configurable: true + }); } -// Helps identify side effects in begin-phase lifecycle hooks and setState reducers: - - -// In some cases, StrictMode should also double-render lifecycles. -// This can be confusing for tests though, -// And it can be bad for performance in production. -// This feature flag can be used to control the behavior: - - -// To preserve the "Pause on caught exceptions" behavior of the debugger, we -// replay the begin phase of a failed component inside invokeGuardedCallback. +function defineRefPropWarningGetter(props, displayName) { + var warnAboutAccessingRef = function () { + if (!specialPropRefWarningShown) { + specialPropRefWarningShown = true; + warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); + } + }; + warnAboutAccessingRef.isReactWarning = true; + Object.defineProperty(props, 'ref', { + get: warnAboutAccessingRef, + configurable: true + }); +} +/** + * Factory method to create a new React element. This no longer adheres to + * the class pattern, so do not use new to call it. Also, instanceof check + * will not work. Instead test $$typeof field against Symbol.for('react.element') to check + * if something is a React Element. + * + * @param {*} type + * @param {*} props + * @param {*} key + * @param {string|object} ref + * @param {*} owner + * @param {*} self A *temporary* helper to detect places where `this` is + * different from the `owner` when React.createElement is called, so that we + * can warn. We want to get rid of owner and replace string `ref`s with arrow + * functions, and as long as `this` and owner are the same, there will be no + * change in behavior. + * @param {*} source An annotation object (added by a transpiler or otherwise) + * indicating filename, line number, and/or other information. + * @internal + */ -// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: +var ReactElement = function (type, key, ref, self, source, owner, props) { + var element = { + // This tag allows us to uniquely identify this as a React Element + $$typeof: REACT_ELEMENT_TYPE, + // Built-in properties that belong on the element + type: type, + key: key, + ref: ref, + props: props, + // Record the component responsible for creating this element. + _owner: owner + }; -// Gather advanced timing metrics for Profiler subtrees. - - -// Trace which interactions trigger each commit. -var enableSchedulerTracing = true; - -// Only used in www builds. - // TODO: true? Here it might just be false. - -// Only used in www builds. - - -// Only used in www builds. - + { + // The validation flag is currently mutative. We put it on + // an external backing store so that we can freeze the whole object. + // This can be replaced with a WeakMap once they are implemented in + // commonly used development environments. + element._store = {}; // To make comparing ReactElements easier for testing purposes, we make + // the validation flag non-enumerable (where possible, which should + // include every environment we run tests in), so the test framework + // ignores it. -// React Fire: prevent the value and checked attributes from syncing -// with their related DOM properties + Object.defineProperty(element._store, 'validated', { + configurable: false, + enumerable: false, + writable: true, + value: false + }); // self and source are DEV only properties. + Object.defineProperty(element, '_self', { + configurable: false, + enumerable: false, + writable: false, + value: self + }); // Two elements created in two different places should be considered + // equal for testing purposes and therefore we hide it from enumeration. -// These APIs will no longer be "unstable" in the upcoming 16.7 release, -// Control this behavior with a flag to support 16.6 minor releases in the meanwhile. -var enableStableConcurrentModeAPIs = false; + Object.defineProperty(element, '_source', { + configurable: false, + enumerable: false, + writable: false, + value: source + }); -var DEFAULT_THREAD_ID = 0; + if (Object.freeze) { + Object.freeze(element.props); + Object.freeze(element); + } + } -// Counters used to generate unique IDs. -var interactionIDCounter = 0; -var threadIDCounter = 0; + return element; +}; +/** + * https://github.com/reactjs/rfcs/pull/107 + * @param {*} type + * @param {object} props + * @param {string} key + */ -// Set of currently traced interactions. -// Interactions "stack"– -// Meaning that newly traced interactions are appended to the previously active set. -// When an interaction goes out of scope, the previous set (if any) is restored. -var interactionsRef = null; -// Listener(s) to notify when interactions begin and end. -var subscriberRef = null; -if (enableSchedulerTracing) { - interactionsRef = { - current: new Set() - }; - subscriberRef = { - current: null - }; -} +/** + * https://github.com/reactjs/rfcs/pull/107 + * @param {*} type + * @param {object} props + * @param {string} key + */ -function unstable_clear(callback) { - if (!enableSchedulerTracing) { - return callback(); - } +function jsxDEV(type, config, maybeKey, source, self) { + var propName; // Reserved names are extracted - var prevInteractions = interactionsRef.current; - interactionsRef.current = new Set(); + var props = {}; + var key = null; + var ref = null; // Currently, key can be spread in as a prop. This causes a potential + // issue if key is also explicitly declared (ie.
+ // or
). We want to deprecate key spread, + // but as an intermediary step, we will use jsxDEV for everything except + //
, because we aren't currently able to tell if + // key is explicitly declared to be undefined or not. - try { - return callback(); - } finally { - interactionsRef.current = prevInteractions; + if (maybeKey !== undefined) { + key = '' + maybeKey; } -} -function unstable_getCurrent() { - if (!enableSchedulerTracing) { - return null; - } else { - return interactionsRef.current; + if (hasValidKey(config)) { + key = '' + config.key; } -} -function unstable_getThreadID() { - return ++threadIDCounter; -} + if (hasValidRef(config)) { + ref = config.ref; + } // Remaining properties are added to a new props object -function unstable_trace(name, timestamp, callback) { - var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; - if (!enableSchedulerTracing) { - return callback(); - } + for (propName in config) { + if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { + props[propName] = config[propName]; + } + } // Resolve default props - var interaction = { - __count: 1, - id: interactionIDCounter++, - name: name, - timestamp: timestamp - }; - var prevInteractions = interactionsRef.current; + if (type && type.defaultProps) { + var defaultProps = type.defaultProps; - // Traced interactions should stack/accumulate. - // To do that, clone the current interactions. - // The previous set will be restored upon completion. - var interactions = new Set(prevInteractions); - interactions.add(interaction); - interactionsRef.current = interactions; + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } + } + } - var subscriber = subscriberRef.current; - var returnValue = void 0; + if (key || ref) { + var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; - try { - if (subscriber !== null) { - subscriber.onInteractionTraced(interaction); + if (key) { + defineKeyPropWarningGetter(props, displayName); } - } finally { - try { - if (subscriber !== null) { - subscriber.onWorkStarted(interactions, threadID); - } - } finally { - try { - returnValue = callback(); - } finally { - interactionsRef.current = prevInteractions; - - try { - if (subscriber !== null) { - subscriber.onWorkStopped(interactions, threadID); - } - } finally { - interaction.__count--; - // If no async work was scheduled for this interaction, - // Notify subscribers that it's completed. - if (subscriber !== null && interaction.__count === 0) { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } - } - } + if (ref) { + defineRefPropWarningGetter(props, displayName); } } - return returnValue; + return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); } +/** + * Create and return a new ReactElement of the given type. + * See https://reactjs.org/docs/react-api.html#createelement + */ -function unstable_wrap(callback) { - var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; +function createElement(type, config, children) { + var propName; // Reserved names are extracted - if (!enableSchedulerTracing) { - return callback; - } + var props = {}; + var key = null; + var ref = null; + var self = null; + var source = null; - var wrappedInteractions = interactionsRef.current; + if (config != null) { + if (hasValidRef(config)) { + ref = config.ref; + } - var subscriber = subscriberRef.current; - if (subscriber !== null) { - subscriber.onWorkScheduled(wrappedInteractions, threadID); - } + if (hasValidKey(config)) { + key = '' + config.key; + } - // Update the pending async work count for the current interactions. - // Update after calling subscribers in case of error. - wrappedInteractions.forEach(function (interaction) { - interaction.__count++; - }); + self = config.__self === undefined ? null : config.__self; + source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object - var hasRun = false; + for (propName in config) { + if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { + props[propName] = config[propName]; + } + } + } // Children can be more than one argument, and those are transferred onto + // the newly allocated props object. - function wrapped() { - var prevInteractions = interactionsRef.current; - interactionsRef.current = wrappedInteractions; - subscriber = subscriberRef.current; + var childrenLength = arguments.length - 2; - try { - var returnValue = void 0; + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = Array(childrenLength); - try { - if (subscriber !== null) { - subscriber.onWorkStarted(wrappedInteractions, threadID); - } - } finally { - try { - returnValue = callback.apply(undefined, arguments); - } finally { - interactionsRef.current = prevInteractions; + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 2]; + } - if (subscriber !== null) { - subscriber.onWorkStopped(wrappedInteractions, threadID); - } - } + { + if (Object.freeze) { + Object.freeze(childArray); } + } - return returnValue; - } finally { - if (!hasRun) { - // We only expect a wrapped function to be executed once, - // But in the event that it's executed more than once– - // Only decrement the outstanding interaction counts once. - hasRun = true; + props.children = childArray; + } // Resolve default props - // Update pending async counts for all wrapped interactions. - // If this was the last scheduled async work for any of them, - // Mark them as completed. - wrappedInteractions.forEach(function (interaction) { - interaction.__count--; - if (subscriber !== null && interaction.__count === 0) { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } - }); + if (type && type.defaultProps) { + var defaultProps = type.defaultProps; + + for (propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; } } } - wrapped.cancel = function cancel() { - subscriber = subscriberRef.current; + { + if (key || ref) { + var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; - try { - if (subscriber !== null) { - subscriber.onWorkCanceled(wrappedInteractions, threadID); + if (key) { + defineKeyPropWarningGetter(props, displayName); } - } finally { - // Update pending async counts for all wrapped interactions. - // If this was the last scheduled async work for any of them, - // Mark them as completed. - wrappedInteractions.forEach(function (interaction) { - interaction.__count--; - if (subscriber && interaction.__count === 0) { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } - }); + if (ref) { + defineRefPropWarningGetter(props, displayName); + } } - }; + } - return wrapped; -} - -var subscribers = null; -if (enableSchedulerTracing) { - subscribers = new Set(); + return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); } +/** + * Return a function that produces ReactElements of a given type. + * See https://reactjs.org/docs/react-api.html#createfactory + */ -function unstable_subscribe(subscriber) { - if (enableSchedulerTracing) { - subscribers.add(subscriber); - if (subscribers.size === 1) { - subscriberRef.current = { - onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, - onInteractionTraced: onInteractionTraced, - onWorkCanceled: onWorkCanceled, - onWorkScheduled: onWorkScheduled, - onWorkStarted: onWorkStarted, - onWorkStopped: onWorkStopped - }; - } - } +function cloneAndReplaceKey(oldElement, newKey) { + var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); + return newElement; } +/** + * Clone and return a new ReactElement using element as the starting point. + * See https://reactjs.org/docs/react-api.html#cloneelement + */ -function unstable_unsubscribe(subscriber) { - if (enableSchedulerTracing) { - subscribers.delete(subscriber); - - if (subscribers.size === 0) { - subscriberRef.current = null; +function cloneElement(element, config, children) { + if (!!(element === null || element === undefined)) { + { + throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + "."); } } -} -function onInteractionTraced(interaction) { - var didCatchError = false; - var caughtError = null; + var propName; // Original props are copied - subscribers.forEach(function (subscriber) { - try { - subscriber.onInteractionTraced(interaction); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } - } - }); + var props = objectAssign({}, element.props); // Reserved names are extracted - if (didCatchError) { - throw caughtError; - } -} -function onInteractionScheduledWorkCompleted(interaction) { - var didCatchError = false; - var caughtError = null; + var key = element.key; + var ref = element.ref; // Self is preserved since the owner is preserved. - subscribers.forEach(function (subscriber) { - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } - } - }); + var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a + // transpiler, and the original source is probably a better indicator of the + // true owner. - if (didCatchError) { - throw caughtError; - } -} + var source = element._source; // Owner will be preserved, unless ref is overridden -function onWorkScheduled(interactions, threadID) { - var didCatchError = false; - var caughtError = null; + var owner = element._owner; - subscribers.forEach(function (subscriber) { - try { - subscriber.onWorkScheduled(interactions, threadID); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } + if (config != null) { + if (hasValidRef(config)) { + // Silently steal the ref from the parent. + ref = config.ref; + owner = ReactCurrentOwner.current; } - }); - - if (didCatchError) { - throw caughtError; - } -} -function onWorkStarted(interactions, threadID) { - var didCatchError = false; - var caughtError = null; + if (hasValidKey(config)) { + key = '' + config.key; + } // Remaining properties override existing props - subscribers.forEach(function (subscriber) { - try { - subscriber.onWorkStarted(interactions, threadID); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } - } - }); - if (didCatchError) { - throw caughtError; - } -} + var defaultProps; -function onWorkStopped(interactions, threadID) { - var didCatchError = false; - var caughtError = null; + if (element.type && element.type.defaultProps) { + defaultProps = element.type.defaultProps; + } - subscribers.forEach(function (subscriber) { - try { - subscriber.onWorkStopped(interactions, threadID); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; + for (propName in config) { + if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { + if (config[propName] === undefined && defaultProps !== undefined) { + // Resolve default props + props[propName] = defaultProps[propName]; + } else { + props[propName] = config[propName]; + } } } - }); + } // Children can be more than one argument, and those are transferred onto + // the newly allocated props object. - if (didCatchError) { - throw caughtError; - } -} -function onWorkCanceled(interactions, threadID) { - var didCatchError = false; - var caughtError = null; + var childrenLength = arguments.length - 2; - subscribers.forEach(function (subscriber) { - try { - subscriber.onWorkCanceled(interactions, threadID); - } catch (error) { - if (!didCatchError) { - didCatchError = true; - caughtError = error; - } + if (childrenLength === 1) { + props.children = children; + } else if (childrenLength > 1) { + var childArray = Array(childrenLength); + + for (var i = 0; i < childrenLength; i++) { + childArray[i] = arguments[i + 2]; } - }); - if (didCatchError) { - throw caughtError; + props.children = childArray; } -} + return ReactElement(element.type, key, ref, self, source, owner, props); +} /** - * Keeps track of the current dispatcher. + * Verifies the object is a ReactElement. + * See https://reactjs.org/docs/react-api.html#isvalidelement + * @param {?object} object + * @return {boolean} True if `object` is a ReactElement. + * @final */ -var ReactCurrentDispatcher = { - /** - * @internal - * @type {ReactComponent} - */ - current: null -}; +function isValidElement(object) { + return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; +} + +var SEPARATOR = '.'; +var SUBSEPARATOR = ':'; /** - * Keeps track of the current owner. + * Escape and wrap key so it is safe to use as a reactid * - * The current owner is the component who should own any components that are - * currently being constructed. + * @param {string} key to be escaped. + * @return {string} the escaped key. */ -var ReactCurrentOwner = { - /** - * @internal - * @type {ReactComponent} - */ - current: null -}; - -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; -var describeComponentFrame = function (name, source, ownerName) { - var sourceInfo = ''; - if (source) { - var path = source.fileName; - var fileName = path.replace(BEFORE_SLASH_RE, ''); - { - // In DEV, include code for a common special case: - // prefer "folder/index.js" instead of just "index.js". - if (/^index\./.test(fileName)) { - var match = path.match(BEFORE_SLASH_RE); - if (match) { - var pathBeforeSlash = match[1]; - if (pathBeforeSlash) { - var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ''); - fileName = folderName + '/' + fileName; - } - } - } - } - sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')'; - } else if (ownerName) { - sourceInfo = ' (created by ' + ownerName + ')'; - } - return '\n in ' + (name || 'Unknown') + sourceInfo; -}; +function escape(key) { + var escapeRegex = /[=:]/g; + var escaperLookup = { + '=': '=0', + ':': '=2' + }; + var escapedString = ('' + key).replace(escapeRegex, function (match) { + return escaperLookup[match]; + }); + return '$' + escapedString; +} +/** + * TODO: Test that a single child and an array with one item have the same key + * pattern. + */ -var Resolved = 1; +var didWarnAboutMaps = false; +var userProvidedKeyEscapeRegex = /\/+/g; -function refineResolvedLazyComponent(lazyComponent) { - return lazyComponent._status === Resolved ? lazyComponent._result : null; +function escapeUserProvidedKey(text) { + return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); } -function getWrappedName(outerType, innerType, wrapperName) { - var functionName = innerType.displayName || innerType.name || ''; - return outerType.displayName || (functionName !== '' ? wrapperName + '(' + functionName + ')' : wrapperName); -} +var POOL_SIZE = 10; +var traverseContextPool = []; -function getComponentName(type) { - if (type == null) { - // Host root, text node or just invalid type. - return null; - } - { - if (typeof type.tag === 'number') { - warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.'); - } - } - if (typeof type === 'function') { - return type.displayName || type.name || null; - } - if (typeof type === 'string') { - return type; - } - switch (type) { - case REACT_CONCURRENT_MODE_TYPE: - return 'ConcurrentMode'; - case REACT_FRAGMENT_TYPE: - return 'Fragment'; - case REACT_PORTAL_TYPE: - return 'Portal'; - case REACT_PROFILER_TYPE: - return 'Profiler'; - case REACT_STRICT_MODE_TYPE: - return 'StrictMode'; - case REACT_SUSPENSE_TYPE: - return 'Suspense'; - } - if (typeof type === 'object') { - switch (type.$$typeof) { - case REACT_CONTEXT_TYPE: - return 'Context.Consumer'; - case REACT_PROVIDER_TYPE: - return 'Context.Provider'; - case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, 'ForwardRef'); - case REACT_MEMO_TYPE: - return getComponentName(type.type); - case REACT_LAZY_TYPE: - { - var thenable = type; - var resolvedThenable = refineResolvedLazyComponent(thenable); - if (resolvedThenable) { - return getComponentName(resolvedThenable); - } - } - } +function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) { + if (traverseContextPool.length) { + var traverseContext = traverseContextPool.pop(); + traverseContext.result = mapResult; + traverseContext.keyPrefix = keyPrefix; + traverseContext.func = mapFunction; + traverseContext.context = mapContext; + traverseContext.count = 0; + return traverseContext; + } else { + return { + result: mapResult, + keyPrefix: keyPrefix, + func: mapFunction, + context: mapContext, + count: 0 + }; } - return null; } -var ReactDebugCurrentFrame = {}; - -var currentlyValidatingElement = null; +function releaseTraverseContext(traverseContext) { + traverseContext.result = null; + traverseContext.keyPrefix = null; + traverseContext.func = null; + traverseContext.context = null; + traverseContext.count = 0; -function setCurrentlyValidatingElement(element) { - { - currentlyValidatingElement = element; + if (traverseContextPool.length < POOL_SIZE) { + traverseContextPool.push(traverseContext); } } +/** + * @param {?*} children Children tree container. + * @param {!string} nameSoFar Name of the key path so far. + * @param {!function} callback Callback to invoke with each child found. + * @param {?*} traverseContext Used to pass information throughout the traversal + * process. + * @return {!number} The number of children in this subtree. + */ -{ - // Stack implementation injected by the current renderer. - ReactDebugCurrentFrame.getCurrentStack = null; - ReactDebugCurrentFrame.getStackAddendum = function () { - var stack = ''; +function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { + var type = typeof children; - // Add an extra top frame while an element is being validated - if (currentlyValidatingElement) { - var name = getComponentName(currentlyValidatingElement.type); - var owner = currentlyValidatingElement._owner; - stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type)); - } + if (type === 'undefined' || type === 'boolean') { + // All of the above are perceived as null. + children = null; + } - // Delegate to the injected renderer-specific implementation - var impl = ReactDebugCurrentFrame.getCurrentStack; - if (impl) { - stack += impl() || ''; - } + var invokeCallback = false; - return stack; - }; -} + if (children === null) { + invokeCallback = true; + } else { + switch (type) { + case 'string': + case 'number': + invokeCallback = true; + break; -var ReactSharedInternals = { - ReactCurrentDispatcher: ReactCurrentDispatcher, - ReactCurrentOwner: ReactCurrentOwner, - // Used by renderers to avoid bundling object-assign twice in UMD bundles: - assign: objectAssign -}; + case 'object': + switch (children.$$typeof) { + case REACT_ELEMENT_TYPE: + case REACT_PORTAL_TYPE: + invokeCallback = true; + } -{ - // Re-export the schedule API(s) for UMD bundles. - // This avoids introducing a dependency on a new UMD global in a minor update, - // Since that would be a breaking change (e.g. for all existing CodeSandboxes). - // This re-export is only required for UMD bundles; - // CJS bundles use the shared NPM package. - objectAssign(ReactSharedInternals, { - Scheduler: { - unstable_cancelCallback: unstable_cancelCallback, - unstable_shouldYield: unstable_shouldYield, - unstable_now: getCurrentTime, - unstable_scheduleCallback: unstable_scheduleCallback, - unstable_runWithPriority: unstable_runWithPriority, - unstable_next: unstable_next, - unstable_wrapCallback: unstable_wrapCallback, - unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, - unstable_pauseExecution: unstable_pauseExecution, - unstable_continueExecution: unstable_continueExecution, - unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel, - unstable_IdlePriority: IdlePriority, - unstable_ImmediatePriority: ImmediatePriority, - unstable_LowPriority: LowPriority, - unstable_NormalPriority: NormalPriority, - unstable_UserBlockingPriority: UserBlockingPriority - }, - SchedulerTracing: { - __interactionsRef: interactionsRef, - __subscriberRef: subscriberRef, - unstable_clear: unstable_clear, - unstable_getCurrent: unstable_getCurrent, - unstable_getThreadID: unstable_getThreadID, - unstable_subscribe: unstable_subscribe, - unstable_trace: unstable_trace, - unstable_unsubscribe: unstable_unsubscribe, - unstable_wrap: unstable_wrap } - }); -} - -{ - objectAssign(ReactSharedInternals, { - // These should not be included in production. - ReactDebugCurrentFrame: ReactDebugCurrentFrame, - // Shim for React DOM 16.0.0 which still destructured (but not used) this. - // TODO: remove in React 17.0. - ReactComponentTreeHook: {} - }); -} + } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ + if (invokeCallback) { + callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array + // so that it's consistent if the number of children grows. + nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); + return 1; + } -var warning = warningWithoutStack$1; + var child; + var nextName; + var subtreeCount = 0; // Count of children found in the current subtree. -{ - warning = function (condition, format) { - if (condition) { - return; - } - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - // eslint-disable-next-line react-internal/warning-and-invariant-args + var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; - for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { - args[_key - 2] = arguments[_key]; + if (Array.isArray(children)) { + for (var i = 0; i < children.length; i++) { + child = children[i]; + nextName = nextNamePrefix + getComponentKey(child, i); + subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); } + } else { + var iteratorFn = getIteratorFn(children); - warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack])); - }; -} + if (typeof iteratorFn === 'function') { + { + // Warn about using Maps as children + if (iteratorFn === children.entries) { + !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0; + didWarnAboutMaps = true; + } + } -var warning$1 = warning; + var iterator = iteratorFn.call(children); + var step; + var ii = 0; -var hasOwnProperty$1 = Object.prototype.hasOwnProperty; + while (!(step = iterator.next()).done) { + child = step.value; + nextName = nextNamePrefix + getComponentKey(child, ii++); + subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); + } + } else if (type === 'object') { + var addendum = ''; -var RESERVED_PROPS = { - key: true, - ref: true, - __self: true, - __source: true -}; + { + addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum(); + } -var specialPropKeyWarningShown = void 0; -var specialPropRefWarningShown = void 0; + var childrenString = '' + children; -function hasValidRef(config) { - { - if (hasOwnProperty$1.call(config, 'ref')) { - var getter = Object.getOwnPropertyDescriptor(config, 'ref').get; - if (getter && getter.isReactWarning) { - return false; + { + { + throw Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum); + } } } } - return config.ref !== undefined; + + return subtreeCount; } +/** + * Traverses children that are typically specified as `props.children`, but + * might also be specified through attributes: + * + * - `traverseAllChildren(this.props.children, ...)` + * - `traverseAllChildren(this.props.leftPanelChildren, ...)` + * + * The `traverseContext` is an optional argument that is passed through the + * entire traversal. It can be used to store accumulations or anything else that + * the callback might find relevant. + * + * @param {?*} children Children tree object. + * @param {!function} callback To invoke upon traversing each child. + * @param {?*} traverseContext Context for traversal. + * @return {!number} The number of children in this subtree. + */ -function hasValidKey(config) { - { - if (hasOwnProperty$1.call(config, 'key')) { - var getter = Object.getOwnPropertyDescriptor(config, 'key').get; - if (getter && getter.isReactWarning) { - return false; - } - } + +function traverseAllChildren(children, callback, traverseContext) { + if (children == null) { + return 0; } - return config.key !== undefined; + + return traverseAllChildrenImpl(children, '', callback, traverseContext); } +/** + * Generate a key string that identifies a component within a set. + * + * @param {*} component A component that could contain a manual key. + * @param {number} index Index that is used if a manual key is not provided. + * @return {string} + */ -function defineKeyPropWarningGetter(props, displayName) { - var warnAboutAccessingKey = function () { - if (!specialPropKeyWarningShown) { - specialPropKeyWarningShown = true; - warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); - } - }; - warnAboutAccessingKey.isReactWarning = true; - Object.defineProperty(props, 'key', { - get: warnAboutAccessingKey, - configurable: true - }); -} -function defineRefPropWarningGetter(props, displayName) { - var warnAboutAccessingRef = function () { - if (!specialPropRefWarningShown) { - specialPropRefWarningShown = true; - warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName); - } - }; - warnAboutAccessingRef.isReactWarning = true; - Object.defineProperty(props, 'ref', { - get: warnAboutAccessingRef, - configurable: true - }); +function getComponentKey(component, index) { + // Do some typechecking here since we call this blindly. We want to ensure + // that we don't block potential future ES APIs. + if (typeof component === 'object' && component !== null && component.key != null) { + // Explicit key + return escape(component.key); + } // Implicit key determined by the index in the set + + + return index.toString(36); } +function forEachSingleChild(bookKeeping, child, name) { + var func = bookKeeping.func, + context = bookKeeping.context; + func.call(context, child, bookKeeping.count++); +} /** - * Factory method to create a new React element. This no longer adheres to - * the class pattern, so do not use new to call it. Also, no instanceof check - * will work. Instead test $$typeof field against Symbol.for('react.element') to check - * if something is a React Element. + * Iterates through children that are typically specified as `props.children`. * - * @param {*} type - * @param {*} key - * @param {string|object} ref - * @param {*} self A *temporary* helper to detect places where `this` is - * different from the `owner` when React.createElement is called, so that we - * can warn. We want to get rid of owner and replace string `ref`s with arrow - * functions, and as long as `this` and owner are the same, there will be no - * change in behavior. - * @param {*} source An annotation object (added by a transpiler or otherwise) - * indicating filename, line number, and/or other information. - * @param {*} owner - * @param {*} props - * @internal + * See https://reactjs.org/docs/react-api.html#reactchildrenforeach + * + * The provided forEachFunc(child, index) will be called for each + * leaf child. + * + * @param {?*} children Children tree container. + * @param {function(*, int)} forEachFunc + * @param {*} forEachContext Context for forEachContext. */ -var ReactElement = function (type, key, ref, self, source, owner, props) { - var element = { - // This tag allows us to uniquely identify this as a React Element - $$typeof: REACT_ELEMENT_TYPE, - - // Built-in properties that belong on the element - type: type, - key: key, - ref: ref, - props: props, - - // Record the component responsible for creating this element. - _owner: owner - }; - { - // The validation flag is currently mutative. We put it on - // an external backing store so that we can freeze the whole object. - // This can be replaced with a WeakMap once they are implemented in - // commonly used development environments. - element._store = {}; - // To make comparing ReactElements easier for testing purposes, we make - // the validation flag non-enumerable (where possible, which should - // include every environment we run tests in), so the test framework - // ignores it. - Object.defineProperty(element._store, 'validated', { - configurable: false, - enumerable: false, - writable: true, - value: false - }); - // self and source are DEV only properties. - Object.defineProperty(element, '_self', { - configurable: false, - enumerable: false, - writable: false, - value: self - }); - // Two elements created in two different places should be considered - // equal for testing purposes and therefore we hide it from enumeration. - Object.defineProperty(element, '_source', { - configurable: false, - enumerable: false, - writable: false, - value: source - }); - if (Object.freeze) { - Object.freeze(element.props); - Object.freeze(element); - } +function forEachChildren(children, forEachFunc, forEachContext) { + if (children == null) { + return children; } - return element; -}; - -/** - * Create and return a new ReactElement of the given type. - * See https://reactjs.org/docs/react-api.html#createelement - */ -function createElement(type, config, children) { - var propName = void 0; - - // Reserved names are extracted - var props = {}; + var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext); + traverseAllChildren(children, forEachSingleChild, traverseContext); + releaseTraverseContext(traverseContext); +} - var key = null; - var ref = null; - var self = null; - var source = null; +function mapSingleChildIntoContext(bookKeeping, child, childKey) { + var result = bookKeeping.result, + keyPrefix = bookKeeping.keyPrefix, + func = bookKeeping.func, + context = bookKeeping.context; + var mappedChild = func.call(context, child, bookKeeping.count++); - if (config != null) { - if (hasValidRef(config)) { - ref = config.ref; - } - if (hasValidKey(config)) { - key = '' + config.key; + if (Array.isArray(mappedChild)) { + mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) { + return c; + }); + } else if (mappedChild != null) { + if (isValidElement(mappedChild)) { + mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as + // traverseAllChildren used to do for objects as children + keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); } - self = config.__self === undefined ? null : config.__self; - source = config.__source === undefined ? null : config.__source; - // Remaining properties are added to a new props object - for (propName in config) { - if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { - props[propName] = config[propName]; - } - } + result.push(mappedChild); } +} - // Children can be more than one argument, and those are transferred onto - // the newly allocated props object. - var childrenLength = arguments.length - 2; - if (childrenLength === 1) { - props.children = children; - } else if (childrenLength > 1) { - var childArray = Array(childrenLength); - for (var i = 0; i < childrenLength; i++) { - childArray[i] = arguments[i + 2]; - } - { - if (Object.freeze) { - Object.freeze(childArray); - } - } - props.children = childArray; - } +function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { + var escapedPrefix = ''; - // Resolve default props - if (type && type.defaultProps) { - var defaultProps = type.defaultProps; - for (propName in defaultProps) { - if (props[propName] === undefined) { - props[propName] = defaultProps[propName]; - } - } - } - { - if (key || ref) { - var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type; - if (key) { - defineKeyPropWarningGetter(props, displayName); - } - if (ref) { - defineRefPropWarningGetter(props, displayName); - } - } + if (prefix != null) { + escapedPrefix = escapeUserProvidedKey(prefix) + '/'; } - return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props); -} + var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context); + traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); + releaseTraverseContext(traverseContext); +} /** - * Return a function that produces ReactElements of a given type. - * See https://reactjs.org/docs/react-api.html#createfactory + * Maps children that are typically specified as `props.children`. + * + * See https://reactjs.org/docs/react-api.html#reactchildrenmap + * + * The provided mapFunction(child, key, index) will be called for each + * leaf child. + * + * @param {?*} children Children tree container. + * @param {function(*, int)} func The map function. + * @param {*} context Context for mapFunction. + * @return {object} Object containing the ordered map of results. */ -function cloneAndReplaceKey(oldElement, newKey) { - var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props); +function mapChildren(children, func, context) { + if (children == null) { + return children; + } - return newElement; + var result = []; + mapIntoWithKeyPrefixInternal(children, result, null, func, context); + return result; } - /** - * Clone and return a new ReactElement using element as the starting point. - * See https://reactjs.org/docs/react-api.html#cloneelement + * Count the number of children that are typically specified as + * `props.children`. + * + * See https://reactjs.org/docs/react-api.html#reactchildrencount + * + * @param {?*} children Children tree container. + * @return {number} The number of children. */ -function cloneElement(element, config, children) { - !!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0; - - var propName = void 0; - // Original props are copied - var props = objectAssign({}, element.props); - // Reserved names are extracted - var key = element.key; - var ref = element.ref; - // Self is preserved since the owner is preserved. - var self = element._self; - // Source is preserved since cloneElement is unlikely to be targeted by a - // transpiler, and the original source is probably a better indicator of the - // true owner. - var source = element._source; +function countChildren(children) { + return traverseAllChildren(children, function () { + return null; + }, null); +} +/** + * Flatten a children object (typically specified as `props.children`) and + * return an array with appropriately re-keyed children. + * + * See https://reactjs.org/docs/react-api.html#reactchildrentoarray + */ - // Owner will be preserved, unless ref is overridden - var owner = element._owner; - if (config != null) { - if (hasValidRef(config)) { - // Silently steal the ref from the parent. - ref = config.ref; - owner = ReactCurrentOwner.current; - } - if (hasValidKey(config)) { - key = '' + config.key; - } +function toArray(children) { + var result = []; + mapIntoWithKeyPrefixInternal(children, result, null, function (child) { + return child; + }); + return result; +} +/** + * Returns the first child in a collection of children and verifies that there + * is only one child in the collection. + * + * See https://reactjs.org/docs/react-api.html#reactchildrenonly + * + * The current implementation of this function assumes that a single child gets + * passed without a wrapper, but the purpose of this helper function is to + * abstract away the particular structure of children. + * + * @param {?object} children Child collection structure. + * @return {ReactElement} The first and only `ReactElement` contained in the + * structure. + */ + + +function onlyChild(children) { + if (!isValidElement(children)) { + { + throw Error("React.Children.only expected to receive a single React element child."); + } + } + + return children; +} + +function createContext(defaultValue, calculateChangedBits) { + if (calculateChangedBits === undefined) { + calculateChangedBits = null; + } else { + { + !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0; + } + } + + var context = { + $$typeof: REACT_CONTEXT_TYPE, + _calculateChangedBits: calculateChangedBits, + // As a workaround to support multiple concurrent renderers, we categorize + // some renderers as primary and others as secondary. We only expect + // there to be two concurrent renderers at most: React Native (primary) and + // Fabric (secondary); React DOM (primary) and React ART (secondary). + // Secondary renderers store their context values on separate fields. + _currentValue: defaultValue, + _currentValue2: defaultValue, + // Used to track how many concurrent renderers this context currently + // supports within in a single renderer. Such as parallel server rendering. + _threadCount: 0, + // These are circular + Provider: null, + Consumer: null + }; + context.Provider = { + $$typeof: REACT_PROVIDER_TYPE, + _context: context + }; + var hasWarnedAboutUsingNestedContextConsumers = false; + var hasWarnedAboutUsingConsumerProvider = false; + + { + // A separate object, but proxies back to the original context object for + // backwards compatibility. It has a different $$typeof, so we can properly + // warn for the incorrect usage of Context as a Consumer. + var Consumer = { + $$typeof: REACT_CONTEXT_TYPE, + _context: context, + _calculateChangedBits: context._calculateChangedBits + }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here + + Object.defineProperties(Consumer, { + Provider: { + get: function () { + if (!hasWarnedAboutUsingConsumerProvider) { + hasWarnedAboutUsingConsumerProvider = true; + warning$1(false, 'Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?'); + } + + return context.Provider; + }, + set: function (_Provider) { + context.Provider = _Provider; + } + }, + _currentValue: { + get: function () { + return context._currentValue; + }, + set: function (_currentValue) { + context._currentValue = _currentValue; + } + }, + _currentValue2: { + get: function () { + return context._currentValue2; + }, + set: function (_currentValue2) { + context._currentValue2 = _currentValue2; + } + }, + _threadCount: { + get: function () { + return context._threadCount; + }, + set: function (_threadCount) { + context._threadCount = _threadCount; + } + }, + Consumer: { + get: function () { + if (!hasWarnedAboutUsingNestedContextConsumers) { + hasWarnedAboutUsingNestedContextConsumers = true; + warning$1(false, 'Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?'); + } + + return context.Consumer; + } + } + }); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty + + context.Consumer = Consumer; + } + + { + context._currentRenderer = null; + context._currentRenderer2 = null; + } + + return context; +} + +function lazy(ctor) { + var lazyType = { + $$typeof: REACT_LAZY_TYPE, + _ctor: ctor, + // React uses these fields to store the result. + _status: -1, + _result: null + }; + + { + // In production, this would just set it on the object. + var defaultProps; + var propTypes; + Object.defineProperties(lazyType, { + defaultProps: { + configurable: true, + get: function () { + return defaultProps; + }, + set: function (newDefaultProps) { + warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); + defaultProps = newDefaultProps; // Match production behavior more closely: + + Object.defineProperty(lazyType, 'defaultProps', { + enumerable: true + }); + } + }, + propTypes: { + configurable: true, + get: function () { + return propTypes; + }, + set: function (newPropTypes) { + warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); + propTypes = newPropTypes; // Match production behavior more closely: + + Object.defineProperty(lazyType, 'propTypes', { + enumerable: true + }); + } + } + }); + } + + return lazyType; +} + +function forwardRef(render) { + { + if (render != null && render.$$typeof === REACT_MEMO_TYPE) { + warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); + } else if (typeof render !== 'function') { + warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); + } else { + !( // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object + render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0; + } + + if (render != null) { + !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0; + } + } + + return { + $$typeof: REACT_FORWARD_REF_TYPE, + render: render + }; +} + +function isValidElementType(type) { + return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. + type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE); +} + +function memo(type, compare) { + { + if (!isValidElementType(type)) { + warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); + } + } + + return { + $$typeof: REACT_MEMO_TYPE, + type: type, + compare: compare === undefined ? null : compare + }; +} + +function resolveDispatcher() { + var dispatcher = ReactCurrentDispatcher.current; + + if (!(dispatcher !== null)) { + { + throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem."); + } + } + + return dispatcher; +} + +function useContext(Context, unstable_observedBits) { + var dispatcher = resolveDispatcher(); + + { + !(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0; // TODO: add a more generic warning for invalid values. + + if (Context._context !== undefined) { + var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs + // and nobody should be using this in existing code. + + if (realContext.Consumer === Context) { + warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?'); + } else if (realContext.Provider === Context) { + warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); + } + } + } + + return dispatcher.useContext(Context, unstable_observedBits); +} +function useState(initialState) { + var dispatcher = resolveDispatcher(); + return dispatcher.useState(initialState); +} +function useReducer(reducer, initialArg, init) { + var dispatcher = resolveDispatcher(); + return dispatcher.useReducer(reducer, initialArg, init); +} +function useRef(initialValue) { + var dispatcher = resolveDispatcher(); + return dispatcher.useRef(initialValue); +} +function useEffect(create, inputs) { + var dispatcher = resolveDispatcher(); + return dispatcher.useEffect(create, inputs); +} +function useLayoutEffect(create, inputs) { + var dispatcher = resolveDispatcher(); + return dispatcher.useLayoutEffect(create, inputs); +} +function useCallback(callback, inputs) { + var dispatcher = resolveDispatcher(); + return dispatcher.useCallback(callback, inputs); +} +function useMemo(create, inputs) { + var dispatcher = resolveDispatcher(); + return dispatcher.useMemo(create, inputs); +} +function useImperativeHandle(ref, create, inputs) { + var dispatcher = resolveDispatcher(); + return dispatcher.useImperativeHandle(ref, create, inputs); +} +function useDebugValue(value, formatterFn) { + { + var dispatcher = resolveDispatcher(); + return dispatcher.useDebugValue(value, formatterFn); + } +} +var emptyObject$1 = {}; +function useResponder(responder, listenerProps) { + var dispatcher = resolveDispatcher(); + + { + if (responder == null || responder.$$typeof !== REACT_RESPONDER_TYPE) { + warning$1(false, 'useResponder: invalid first argument. Expected an event responder, but instead got %s', responder); + return; + } + } + + return dispatcher.useResponder(responder, listenerProps || emptyObject$1); +} +function useTransition(config) { + var dispatcher = resolveDispatcher(); + return dispatcher.useTransition(config); +} +function useDeferredValue(value, config) { + var dispatcher = resolveDispatcher(); + return dispatcher.useDeferredValue(value, config); +} + +function withSuspenseConfig(scope, config) { + var previousConfig = ReactCurrentBatchConfig.suspense; + ReactCurrentBatchConfig.suspense = config === undefined ? null : config; + + try { + scope(); + } finally { + ReactCurrentBatchConfig.suspense = previousConfig; + } +} + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; + +var ReactPropTypesSecret_1 = ReactPropTypesSecret$1; + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +var printWarning$1 = function() {}; + +{ + var ReactPropTypesSecret = ReactPropTypesSecret_1; + var loggedTypeFailures = {}; + var has = Function.call.bind(Object.prototype.hasOwnProperty); + + printWarning$1 = function(text) { + var message = 'Warning: ' + text; + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; +} + +/** + * Assert that the values match with the type specs. + * Error messages are memorized and will only be shown once. + * + * @param {object} typeSpecs Map of name to a ReactPropType + * @param {object} values Runtime values that need to be type-checked + * @param {string} location e.g. "prop", "context", "child context" + * @param {string} componentName Name of the component for error messages. + * @param {?Function} getStack Returns the component stack. + * @private + */ +function checkPropTypes(typeSpecs, values, location, componentName, getStack) { + { + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error; + // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== 'function') { + var err = Error( + (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + ); + err.name = 'Invariant Violation'; + throw err; + } + error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); + } catch (ex) { + error = ex; + } + if (error && !(error instanceof Error)) { + printWarning$1( + (componentName || 'React class') + ': type specification of ' + + location + ' `' + typeSpecName + '` is invalid; the type checker ' + + 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + + 'You may have forgotten to pass an argument to the type checker ' + + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + + 'shape all require an argument).' + ); + } + if (error instanceof Error && !(error.message in loggedTypeFailures)) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error.message] = true; + + var stack = getStack ? getStack() : ''; + + printWarning$1( + 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') + ); + } + } + } + } +} + +/** + * Resets warning cache when testing. + * + * @private + */ +checkPropTypes.resetWarningCache = function() { + { + loggedTypeFailures = {}; + } +}; + +var checkPropTypes_1 = checkPropTypes; + +/** + * ReactElementValidator provides a wrapper around a element factory + * which validates the props passed to the element. This is intended to be + * used only in DEV and could be replaced by a static type checker for languages + * that support it. + */ +var propTypesMisspellWarningShown; + +{ + propTypesMisspellWarningShown = false; +} + +var hasOwnProperty$2 = Object.prototype.hasOwnProperty; + +function getDeclarationErrorAddendum() { + if (ReactCurrentOwner.current) { + var name = getComponentName(ReactCurrentOwner.current.type); + + if (name) { + return '\n\nCheck the render method of `' + name + '`.'; + } + } + + return ''; +} + +function getSourceInfoErrorAddendum(source) { + if (source !== undefined) { + var fileName = source.fileName.replace(/^.*[\\\/]/, ''); + var lineNumber = source.lineNumber; + return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; + } + + return ''; +} + +function getSourceInfoErrorAddendumForProps(elementProps) { + if (elementProps !== null && elementProps !== undefined) { + return getSourceInfoErrorAddendum(elementProps.__source); + } + + return ''; +} +/** + * Warn if there's no key explicitly set on dynamic arrays of children or + * object keys are not valid. This allows us to keep track of children between + * updates. + */ + + +var ownerHasKeyUseWarning = {}; + +function getCurrentComponentErrorInfo(parentType) { + var info = getDeclarationErrorAddendum(); + + if (!info) { + var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; + + if (parentName) { + info = "\n\nCheck the top-level render call using <" + parentName + ">."; + } + } + + return info; +} +/** + * Warn if the element doesn't have an explicit key assigned to it. + * This element is in an array. The array could grow and shrink or be + * reordered. All children that haven't already been validated are required to + * have a "key" property assigned to it. Error statuses are cached so a warning + * will only be shown once. + * + * @internal + * @param {ReactElement} element Element that requires a key. + * @param {*} parentType element's parent's type. + */ + + +function validateExplicitKey(element, parentType) { + if (!element._store || element._store.validated || element.key != null) { + return; + } + + element._store.validated = true; + var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); + + if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { + return; + } + + ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a + // property, it may be the creator of the child that's responsible for + // assigning it a key. + + var childOwner = ''; + + if (element && element._owner && element._owner !== ReactCurrentOwner.current) { + // Give the component that originally created this child. + childOwner = " It was passed a child from " + getComponentName(element._owner.type) + "."; + } + + setCurrentlyValidatingElement(element); + + { + warning$1(false, 'Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner); + } + + setCurrentlyValidatingElement(null); +} +/** + * Ensure that every element either is passed in a static location, in an + * array with an explicit keys property defined, or in an object literal + * with valid key property. + * + * @internal + * @param {ReactNode} node Statically passed child of any type. + * @param {*} parentType node's parent's type. + */ + + +function validateChildKeys(node, parentType) { + if (typeof node !== 'object') { + return; + } + + if (Array.isArray(node)) { + for (var i = 0; i < node.length; i++) { + var child = node[i]; + + if (isValidElement(child)) { + validateExplicitKey(child, parentType); + } + } + } else if (isValidElement(node)) { + // This element was passed in a valid location. + if (node._store) { + node._store.validated = true; + } + } else if (node) { + var iteratorFn = getIteratorFn(node); + + if (typeof iteratorFn === 'function') { + // Entry iterators used to provide implicit keys, + // but now we print a separate warning for them later. + if (iteratorFn !== node.entries) { + var iterator = iteratorFn.call(node); + var step; + + while (!(step = iterator.next()).done) { + if (isValidElement(step.value)) { + validateExplicitKey(step.value, parentType); + } + } + } + } + } +} +/** + * Given an element, validate that its props follow the propTypes definition, + * provided by the type. + * + * @param {ReactElement} element + */ + + +function validatePropTypes(element) { + var type = element.type; + + if (type === null || type === undefined || typeof type === 'string') { + return; + } + + var name = getComponentName(type); + var propTypes; + + if (typeof type === 'function') { + propTypes = type.propTypes; + } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here. + // Inner props are checked in the reconciler. + type.$$typeof === REACT_MEMO_TYPE)) { + propTypes = type.propTypes; + } else { + return; + } + + if (propTypes) { + setCurrentlyValidatingElement(element); + checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum); + setCurrentlyValidatingElement(null); + } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { + propTypesMisspellWarningShown = true; + warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown'); + } + + if (typeof type.getDefaultProps === 'function') { + !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0; + } +} +/** + * Given a fragment, validate that it can only be provided with fragment props + * @param {ReactElement} fragment + */ + + +function validateFragmentProps(fragment) { + setCurrentlyValidatingElement(fragment); + var keys = Object.keys(fragment.props); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + + if (key !== 'children' && key !== 'key') { + warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); + break; + } + } + + if (fragment.ref !== null) { + warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.'); + } + + setCurrentlyValidatingElement(null); +} + +function jsxWithValidation(type, props, key, isStaticChildren, source, self) { + var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to + // succeed and there will likely be errors in render. + + if (!validType) { + var info = ''; + + if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { + info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; + } + + var sourceInfo = getSourceInfoErrorAddendum(source); + + if (sourceInfo) { + info += sourceInfo; + } else { + info += getDeclarationErrorAddendum(); + } + + var typeString; + + if (type === null) { + typeString = 'null'; + } else if (Array.isArray(type)) { + typeString = 'array'; + } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { + typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; + info = ' Did you accidentally export a JSX literal instead of a component?'; + } else { + typeString = typeof type; + } - // Remaining properties override existing props - var defaultProps = void 0; - if (element.type && element.type.defaultProps) { - defaultProps = element.type.defaultProps; + warning$1(false, 'React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); + } + + var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used. + // TODO: Drop this when these are no longer allowed as the type argument. + + if (element == null) { + return element; + } // Skip key warning if the type isn't valid since our key validation logic + // doesn't expect a non-string/function type and can throw confusing errors. + // We don't want exception behavior to differ between dev and prod. + // (Rendering will throw with a helpful message and as soon as the type is + // fixed, the key warnings will appear.) + + + if (validType) { + var children = props.children; + + if (children !== undefined) { + if (isStaticChildren) { + if (Array.isArray(children)) { + for (var i = 0; i < children.length; i++) { + validateChildKeys(children[i], type); + } + + if (Object.freeze) { + Object.freeze(children); + } + } else { + warning$1(false, 'React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.'); + } + } else { + validateChildKeys(children, type); + } } - for (propName in config) { - if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) { - if (config[propName] === undefined && defaultProps !== undefined) { - // Resolve default props - props[propName] = defaultProps[propName]; + } + + if (hasOwnProperty$2.call(props, 'key')) { + warning$1(false, 'React.jsx: Spreading a key to JSX is a deprecated pattern. ' + 'Explicitly pass a key after spreading props in your JSX call. ' + 'E.g. '); + } + + if (type === REACT_FRAGMENT_TYPE) { + validateFragmentProps(element); + } else { + validatePropTypes(element); + } + + return element; +} // These two functions exist to still get child warnings in dev +// even with the prod transform. This means that jsxDEV is purely +// opt-in behavior for better messages but that we won't stop +// giving you warnings if you use production apis. + +function jsxWithValidationStatic(type, props, key) { + return jsxWithValidation(type, props, key, true); +} +function jsxWithValidationDynamic(type, props, key) { + return jsxWithValidation(type, props, key, false); +} +function createElementWithValidation(type, props, children) { + var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to + // succeed and there will likely be errors in render. + + if (!validType) { + var info = ''; + + if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { + info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; + } + + var sourceInfo = getSourceInfoErrorAddendumForProps(props); + + if (sourceInfo) { + info += sourceInfo; + } else { + info += getDeclarationErrorAddendum(); + } + + var typeString; + + if (type === null) { + typeString = 'null'; + } else if (Array.isArray(type)) { + typeString = 'array'; + } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { + typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />"; + info = ' Did you accidentally export a JSX literal instead of a component?'; + } else { + typeString = typeof type; + } + + warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); + } + + var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used. + // TODO: Drop this when these are no longer allowed as the type argument. + + if (element == null) { + return element; + } // Skip key warning if the type isn't valid since our key validation logic + // doesn't expect a non-string/function type and can throw confusing errors. + // We don't want exception behavior to differ between dev and prod. + // (Rendering will throw with a helpful message and as soon as the type is + // fixed, the key warnings will appear.) + + + if (validType) { + for (var i = 2; i < arguments.length; i++) { + validateChildKeys(arguments[i], type); + } + } + + if (type === REACT_FRAGMENT_TYPE) { + validateFragmentProps(element); + } else { + validatePropTypes(element); + } + + return element; +} +function createFactoryWithValidation(type) { + var validatedFactory = createElementWithValidation.bind(null, type); + validatedFactory.type = type; // Legacy hook: remove it + + { + Object.defineProperty(validatedFactory, 'type', { + enumerable: false, + get: function () { + lowPriorityWarningWithoutStack$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); + Object.defineProperty(this, 'type', { + value: type + }); + return type; + } + }); + } + + return validatedFactory; +} +function cloneElementWithValidation(element, props, children) { + var newElement = cloneElement.apply(this, arguments); + + for (var i = 2; i < arguments.length; i++) { + validateChildKeys(arguments[i], newElement.type); + } + + validatePropTypes(newElement); + return newElement; +} + +var enableSchedulerDebugging = false; +var enableIsInputPending = false; +var enableProfiling = true; + +var requestHostCallback; + +var requestHostTimeout; +var cancelHostTimeout; +var shouldYieldToHost; +var requestPaint; +var getCurrentTime; +var forceFrameRate; + +if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive +// implementation using setTimeout. +typeof window === 'undefined' || // Check if MessageChannel is supported, too. +typeof MessageChannel !== 'function') { + // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore, + // fallback to a naive implementation. + var _callback = null; + var _timeoutID = null; + + var _flushCallback = function () { + if (_callback !== null) { + try { + var currentTime = getCurrentTime(); + var hasRemainingTime = true; + + _callback(hasRemainingTime, currentTime); + + _callback = null; + } catch (e) { + setTimeout(_flushCallback, 0); + throw e; + } + } + }; + + var initialTime = Date.now(); + + getCurrentTime = function () { + return Date.now() - initialTime; + }; + + requestHostCallback = function (cb) { + if (_callback !== null) { + // Protect against re-entrancy. + setTimeout(requestHostCallback, 0, cb); + } else { + _callback = cb; + setTimeout(_flushCallback, 0); + } + }; + + requestHostTimeout = function (cb, ms) { + _timeoutID = setTimeout(cb, ms); + }; + + cancelHostTimeout = function () { + clearTimeout(_timeoutID); + }; + + shouldYieldToHost = function () { + return false; + }; + + requestPaint = forceFrameRate = function () {}; +} else { + // Capture local references to native APIs, in case a polyfill overrides them. + var performance = window.performance; + var _Date = window.Date; + var _setTimeout = window.setTimeout; + var _clearTimeout = window.clearTimeout; + + if (typeof console !== 'undefined') { + // TODO: Scheduler no longer requires these methods to be polyfilled. But + // maybe we want to continue warning if they don't exist, to preserve the + // option to rely on it in the future? + var requestAnimationFrame = window.requestAnimationFrame; + var cancelAnimationFrame = window.cancelAnimationFrame; // TODO: Remove fb.me link + + if (typeof requestAnimationFrame !== 'function') { + console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); + } + + if (typeof cancelAnimationFrame !== 'function') { + console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); + } + } + + if (typeof performance === 'object' && typeof performance.now === 'function') { + getCurrentTime = function () { + return performance.now(); + }; + } else { + var _initialTime = _Date.now(); + + getCurrentTime = function () { + return _Date.now() - _initialTime; + }; + } + + var isMessageLoopRunning = false; + var scheduledHostCallback = null; + var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main + // thread, like user events. By default, it yields multiple times per frame. + // It does not attempt to align with frame boundaries, since most tasks don't + // need to be frame aligned; for those that do, use requestAnimationFrame. + + var yieldInterval = 5; + var deadline = 0; // TODO: Make this configurable + // TODO: Adjust this based on priority? + + var maxYieldInterval = 300; + var needsPaint = false; + + if (enableIsInputPending && navigator !== undefined && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined) { + var scheduling = navigator.scheduling; + + shouldYieldToHost = function () { + var currentTime = getCurrentTime(); + + if (currentTime >= deadline) { + // There's no time left. We may want to yield control of the main + // thread, so the browser can perform high priority tasks. The main ones + // are painting and user input. If there's a pending paint or a pending + // input, then we should yield. But if there's neither, then we can + // yield less often while remaining responsive. We'll eventually yield + // regardless, since there could be a pending paint that wasn't + // accompanied by a call to `requestPaint`, or other main thread tasks + // like network events. + if (needsPaint || scheduling.isInputPending()) { + // There is either a pending paint or a pending input. + return true; + } // There's no pending input. Only yield if we've reached the max + // yield interval. + + + return currentTime >= maxYieldInterval; + } else { + // There's still time left in the frame. + return false; + } + }; + + requestPaint = function () { + needsPaint = true; + }; + } else { + // `isInputPending` is not available. Since we have no way of knowing if + // there's pending input, always yield at the end of the frame. + shouldYieldToHost = function () { + return getCurrentTime() >= deadline; + }; // Since we yield every frame regardless, `requestPaint` has no effect. + + + requestPaint = function () {}; + } + + forceFrameRate = function (fps) { + if (fps < 0 || fps > 125) { + console.error('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported'); + return; + } + + if (fps > 0) { + yieldInterval = Math.floor(1000 / fps); + } else { + // reset the framerate + yieldInterval = 5; + } + }; + + var performWorkUntilDeadline = function () { + if (scheduledHostCallback !== null) { + var currentTime = getCurrentTime(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync + // cycle. This means there's always time remaining at the beginning of + // the message event. + + deadline = currentTime + yieldInterval; + var hasTimeRemaining = true; + + try { + var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); + + if (!hasMoreWork) { + isMessageLoopRunning = false; + scheduledHostCallback = null; } else { - props[propName] = config[propName]; + // If there's more work, schedule the next message event at the end + // of the preceding one. + port.postMessage(null); } + } catch (error) { + // If a scheduler task throws, exit the current browser task so the + // error can be observed. + port.postMessage(null); + throw error; + } + } else { + isMessageLoopRunning = false; + } // Yielding to the browser will give it a chance to paint, so we can + // reset this. + + + needsPaint = false; + }; + + var channel = new MessageChannel(); + var port = channel.port2; + channel.port1.onmessage = performWorkUntilDeadline; + + requestHostCallback = function (callback) { + scheduledHostCallback = callback; + + if (!isMessageLoopRunning) { + isMessageLoopRunning = true; + port.postMessage(null); + } + }; + + requestHostTimeout = function (callback, ms) { + taskTimeoutID = _setTimeout(function () { + callback(getCurrentTime()); + }, ms); + }; + + cancelHostTimeout = function () { + _clearTimeout(taskTimeoutID); + + taskTimeoutID = -1; + }; +} + +function push(heap, node) { + var index = heap.length; + heap.push(node); + siftUp(heap, node, index); +} +function peek(heap) { + var first = heap[0]; + return first === undefined ? null : first; +} +function pop(heap) { + var first = heap[0]; + + if (first !== undefined) { + var last = heap.pop(); + + if (last !== first) { + heap[0] = last; + siftDown(heap, last, 0); + } + + return first; + } else { + return null; + } +} + +function siftUp(heap, node, i) { + var index = i; + + while (true) { + var parentIndex = Math.floor((index - 1) / 2); + var parent = heap[parentIndex]; + + if (parent !== undefined && compare(parent, node) > 0) { + // The parent is larger. Swap positions. + heap[parentIndex] = node; + heap[index] = parent; + index = parentIndex; + } else { + // The parent is smaller. Exit. + return; + } + } +} + +function siftDown(heap, node, i) { + var index = i; + var length = heap.length; + + while (index < length) { + var leftIndex = (index + 1) * 2 - 1; + var left = heap[leftIndex]; + var rightIndex = leftIndex + 1; + var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those. + + if (left !== undefined && compare(left, node) < 0) { + if (right !== undefined && compare(right, left) < 0) { + heap[index] = right; + heap[rightIndex] = node; + index = rightIndex; + } else { + heap[index] = left; + heap[leftIndex] = node; + index = leftIndex; } + } else if (right !== undefined && compare(right, node) < 0) { + heap[index] = right; + heap[rightIndex] = node; + index = rightIndex; + } else { + // Neither child is smaller. Exit. + return; } } +} - // Children can be more than one argument, and those are transferred onto - // the newly allocated props object. - var childrenLength = arguments.length - 2; - if (childrenLength === 1) { - props.children = children; - } else if (childrenLength > 1) { - var childArray = Array(childrenLength); - for (var i = 0; i < childrenLength; i++) { - childArray[i] = arguments[i + 2]; +function compare(a, b) { + // Compare sort index first, then task id. + var diff = a.sortIndex - b.sortIndex; + return diff !== 0 ? diff : a.id - b.id; +} + +// TODO: Use symbols? +var NoPriority = 0; +var ImmediatePriority = 1; +var UserBlockingPriority = 2; +var NormalPriority = 3; +var LowPriority = 4; +var IdlePriority = 5; + +var runIdCounter = 0; +var mainThreadIdCounter = 0; +var profilingStateSize = 4; +var sharedProfilingBuffer = enableProfiling ? // $FlowFixMe Flow doesn't know about SharedArrayBuffer +typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer +typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9 +: null; +var profilingState = enableProfiling && sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks + +var PRIORITY = 0; +var CURRENT_TASK_ID = 1; +var CURRENT_RUN_ID = 2; +var QUEUE_SIZE = 3; + +if (enableProfiling) { + profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue + // array might include canceled tasks. + + profilingState[QUEUE_SIZE] = 0; + profilingState[CURRENT_TASK_ID] = 0; +} // Bytes per element is 4 + + +var INITIAL_EVENT_LOG_SIZE = 131072; +var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes + +var eventLogSize = 0; +var eventLogBuffer = null; +var eventLog = null; +var eventLogIndex = 0; +var TaskStartEvent = 1; +var TaskCompleteEvent = 2; +var TaskErrorEvent = 3; +var TaskCancelEvent = 4; +var TaskRunEvent = 5; +var TaskYieldEvent = 6; +var SchedulerSuspendEvent = 7; +var SchedulerResumeEvent = 8; + +function logEvent(entries) { + if (eventLog !== null) { + var offset = eventLogIndex; + eventLogIndex += entries.length; + + if (eventLogIndex + 1 > eventLogSize) { + eventLogSize *= 2; + + if (eventLogSize > MAX_EVENT_LOG_SIZE) { + console.error("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.'); + stopLoggingProfilingEvents(); + return; + } + + var newEventLog = new Int32Array(eventLogSize * 4); + newEventLog.set(eventLog); + eventLogBuffer = newEventLog.buffer; + eventLog = newEventLog; } - props.children = childArray; - } - return ReactElement(element.type, key, ref, self, source, owner, props); + eventLog.set(entries, offset); + } } -/** - * Verifies the object is a ReactElement. - * See https://reactjs.org/docs/react-api.html#isvalidelement - * @param {?object} object - * @return {boolean} True if `object` is a ReactElement. - * @final - */ -function isValidElement(object) { - return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; +function startLoggingProfilingEvents() { + eventLogSize = INITIAL_EVENT_LOG_SIZE; + eventLogBuffer = new ArrayBuffer(eventLogSize * 4); + eventLog = new Int32Array(eventLogBuffer); + eventLogIndex = 0; } +function stopLoggingProfilingEvents() { + var buffer = eventLogBuffer; + eventLogSize = 0; + eventLogBuffer = null; + eventLog = null; + eventLogIndex = 0; + return buffer; +} +function markTaskStart(task, ms) { + if (enableProfiling) { + profilingState[QUEUE_SIZE]++; -var SEPARATOR = '.'; -var SUBSEPARATOR = ':'; - -/** - * Escape and wrap key so it is safe to use as a reactid - * - * @param {string} key to be escaped. - * @return {string} the escaped key. - */ -function escape(key) { - var escapeRegex = /[=:]/g; - var escaperLookup = { - '=': '=0', - ':': '=2' - }; - var escapedString = ('' + key).replace(escapeRegex, function (match) { - return escaperLookup[match]; - }); + if (eventLog !== null) { + // performance.now returns a float, representing milliseconds. When the + // event is logged, it's coerced to an int. Convert to microseconds to + // maintain extra degrees of precision. + logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]); + } + } +} +function markTaskCompleted(task, ms) { + if (enableProfiling) { + profilingState[PRIORITY] = NoPriority; + profilingState[CURRENT_TASK_ID] = 0; + profilingState[QUEUE_SIZE]--; - return '$' + escapedString; + if (eventLog !== null) { + logEvent([TaskCompleteEvent, ms * 1000, task.id]); + } + } } +function markTaskCanceled(task, ms) { + if (enableProfiling) { + profilingState[QUEUE_SIZE]--; -/** - * TODO: Test that a single child and an array with one item have the same key - * pattern. - */ + if (eventLog !== null) { + logEvent([TaskCancelEvent, ms * 1000, task.id]); + } + } +} +function markTaskErrored(task, ms) { + if (enableProfiling) { + profilingState[PRIORITY] = NoPriority; + profilingState[CURRENT_TASK_ID] = 0; + profilingState[QUEUE_SIZE]--; -var didWarnAboutMaps = false; + if (eventLog !== null) { + logEvent([TaskErrorEvent, ms * 1000, task.id]); + } + } +} +function markTaskRun(task, ms) { + if (enableProfiling) { + runIdCounter++; + profilingState[PRIORITY] = task.priorityLevel; + profilingState[CURRENT_TASK_ID] = task.id; + profilingState[CURRENT_RUN_ID] = runIdCounter; -var userProvidedKeyEscapeRegex = /\/+/g; -function escapeUserProvidedKey(text) { - return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/'); + if (eventLog !== null) { + logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]); + } + } } +function markTaskYield(task, ms) { + if (enableProfiling) { + profilingState[PRIORITY] = NoPriority; + profilingState[CURRENT_TASK_ID] = 0; + profilingState[CURRENT_RUN_ID] = 0; -var POOL_SIZE = 10; -var traverseContextPool = []; -function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) { - if (traverseContextPool.length) { - var traverseContext = traverseContextPool.pop(); - traverseContext.result = mapResult; - traverseContext.keyPrefix = keyPrefix; - traverseContext.func = mapFunction; - traverseContext.context = mapContext; - traverseContext.count = 0; - return traverseContext; - } else { - return { - result: mapResult, - keyPrefix: keyPrefix, - func: mapFunction, - context: mapContext, - count: 0 - }; + if (eventLog !== null) { + logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]); + } } } +function markSchedulerSuspended(ms) { + if (enableProfiling) { + mainThreadIdCounter++; -function releaseTraverseContext(traverseContext) { - traverseContext.result = null; - traverseContext.keyPrefix = null; - traverseContext.func = null; - traverseContext.context = null; - traverseContext.count = 0; - if (traverseContextPool.length < POOL_SIZE) { - traverseContextPool.push(traverseContext); + if (eventLog !== null) { + logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]); + } + } +} +function markSchedulerUnsuspended(ms) { + if (enableProfiling) { + if (eventLog !== null) { + logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]); + } } } -/** - * @param {?*} children Children tree container. - * @param {!string} nameSoFar Name of the key path so far. - * @param {!function} callback Callback to invoke with each child found. - * @param {?*} traverseContext Used to pass information throughout the traversal - * process. - * @return {!number} The number of children in this subtree. - */ -function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) { - var type = typeof children; +/* eslint-disable no-var */ +// Math.pow(2, 30) - 1 +// 0b111111111111111111111111111111 - if (type === 'undefined' || type === 'boolean') { - // All of the above are perceived as null. - children = null; - } +var maxSigned31BitInt = 1073741823; // Times out immediately - var invokeCallback = false; +var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out - if (children === null) { - invokeCallback = true; - } else { - switch (type) { - case 'string': - case 'number': - invokeCallback = true; - break; - case 'object': - switch (children.$$typeof) { - case REACT_ELEMENT_TYPE: - case REACT_PORTAL_TYPE: - invokeCallback = true; - } +var USER_BLOCKING_PRIORITY = 250; +var NORMAL_PRIORITY_TIMEOUT = 5000; +var LOW_PRIORITY_TIMEOUT = 10000; // Never times out + +var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap + +var taskQueue = []; +var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. + +var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. + +var isSchedulerPaused = false; +var currentTask = null; +var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. + +var isPerformingWork = false; +var isHostCallbackScheduled = false; +var isHostTimeoutScheduled = false; + +function advanceTimers(currentTime) { + // Check for tasks that are no longer delayed and add them to the queue. + var timer = peek(timerQueue); + + while (timer !== null) { + if (timer.callback === null) { + // Timer was cancelled. + pop(timerQueue); + } else if (timer.startTime <= currentTime) { + // Timer fired. Transfer to the task queue. + pop(timerQueue); + timer.sortIndex = timer.expirationTime; + push(taskQueue, timer); + + if (enableProfiling) { + markTaskStart(timer, currentTime); + timer.isQueued = true; + } + } else { + // Remaining timers are pending. + return; } - } - if (invokeCallback) { - callback(traverseContext, children, - // If it's the only child, treat the name as if it was wrapped in an array - // so that it's consistent if the number of children grows. - nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar); - return 1; + timer = peek(timerQueue); } +} - var child = void 0; - var nextName = void 0; - var subtreeCount = 0; // Count of children found in the current subtree. - var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR; +function handleTimeout(currentTime) { + isHostTimeoutScheduled = false; + advanceTimers(currentTime); - if (Array.isArray(children)) { - for (var i = 0; i < children.length; i++) { - child = children[i]; - nextName = nextNamePrefix + getComponentKey(child, i); - subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); - } - } else { - var iteratorFn = getIteratorFn(children); - if (typeof iteratorFn === 'function') { - { - // Warn about using Maps as children - if (iteratorFn === children.entries) { - !didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0; - didWarnAboutMaps = true; - } - } + if (!isHostCallbackScheduled) { + if (peek(taskQueue) !== null) { + isHostCallbackScheduled = true; + requestHostCallback(flushWork); + } else { + var firstTimer = peek(timerQueue); - var iterator = iteratorFn.call(children); - var step = void 0; - var ii = 0; - while (!(step = iterator.next()).done) { - child = step.value; - nextName = nextNamePrefix + getComponentKey(child, ii++); - subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext); - } - } else if (type === 'object') { - var addendum = ''; - { - addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum(); + if (firstTimer !== null) { + requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); } - var childrenString = '' + children; - invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum); } } - - return subtreeCount; } -/** - * Traverses children that are typically specified as `props.children`, but - * might also be specified through attributes: - * - * - `traverseAllChildren(this.props.children, ...)` - * - `traverseAllChildren(this.props.leftPanelChildren, ...)` - * - * The `traverseContext` is an optional argument that is passed through the - * entire traversal. It can be used to store accumulations or anything else that - * the callback might find relevant. - * - * @param {?*} children Children tree object. - * @param {!function} callback To invoke upon traversing each child. - * @param {?*} traverseContext Context for traversal. - * @return {!number} The number of children in this subtree. - */ -function traverseAllChildren(children, callback, traverseContext) { - if (children == null) { - return 0; - } +function flushWork(hasTimeRemaining, initialTime) { + if (enableProfiling) { + markSchedulerUnsuspended(initialTime); + } // We'll need a host callback the next time work is scheduled. - return traverseAllChildrenImpl(children, '', callback, traverseContext); -} -/** - * Generate a key string that identifies a component within a set. - * - * @param {*} component A component that could contain a manual key. - * @param {number} index Index that is used if a manual key is not provided. - * @return {string} - */ -function getComponentKey(component, index) { - // Do some typechecking here since we call this blindly. We want to ensure - // that we don't block potential future ES APIs. - if (typeof component === 'object' && component !== null && component.key != null) { - // Explicit key - return escape(component.key); + isHostCallbackScheduled = false; + + if (isHostTimeoutScheduled) { + // We scheduled a timeout but it's no longer needed. Cancel it. + isHostTimeoutScheduled = false; + cancelHostTimeout(); } - // Implicit key determined by the index in the set - return index.toString(36); -} -function forEachSingleChild(bookKeeping, child, name) { - var func = bookKeeping.func, - context = bookKeeping.context; + isPerformingWork = true; + var previousPriorityLevel = currentPriorityLevel; - func.call(context, child, bookKeeping.count++); -} + try { + if (enableProfiling) { + try { + return workLoop(hasTimeRemaining, initialTime); + } catch (error) { + if (currentTask !== null) { + var currentTime = getCurrentTime(); + markTaskErrored(currentTask, currentTime); + currentTask.isQueued = false; + } -/** - * Iterates through children that are typically specified as `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenforeach - * - * The provided forEachFunc(child, index) will be called for each - * leaf child. - * - * @param {?*} children Children tree container. - * @param {function(*, int)} forEachFunc - * @param {*} forEachContext Context for forEachContext. - */ -function forEachChildren(children, forEachFunc, forEachContext) { - if (children == null) { - return children; + throw error; + } + } else { + // No catch in prod codepath. + return workLoop(hasTimeRemaining, initialTime); + } + } finally { + currentTask = null; + currentPriorityLevel = previousPriorityLevel; + isPerformingWork = false; + + if (enableProfiling) { + var _currentTime = getCurrentTime(); + + markSchedulerSuspended(_currentTime); + } } - var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext); - traverseAllChildren(children, forEachSingleChild, traverseContext); - releaseTraverseContext(traverseContext); } -function mapSingleChildIntoContext(bookKeeping, child, childKey) { - var result = bookKeeping.result, - keyPrefix = bookKeeping.keyPrefix, - func = bookKeeping.func, - context = bookKeeping.context; +function workLoop(hasTimeRemaining, initialTime) { + var currentTime = initialTime; + advanceTimers(currentTime); + currentTask = peek(taskQueue); + + while (currentTask !== null && !(enableSchedulerDebugging && isSchedulerPaused)) { + if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { + // This currentTask hasn't expired, and we've reached the deadline. + break; + } + var callback = currentTask.callback; - var mappedChild = func.call(context, child, bookKeeping.count++); - if (Array.isArray(mappedChild)) { - mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) { - return c; - }); - } else if (mappedChild != null) { - if (isValidElement(mappedChild)) { - mappedChild = cloneAndReplaceKey(mappedChild, - // Keep both the (mapped) and old keys if they differ, just as - // traverseAllChildren used to do for objects as children - keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey); + if (callback !== null) { + currentTask.callback = null; + currentPriorityLevel = currentTask.priorityLevel; + var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; + markTaskRun(currentTask, currentTime); + var continuationCallback = callback(didUserCallbackTimeout); + currentTime = getCurrentTime(); + + if (typeof continuationCallback === 'function') { + currentTask.callback = continuationCallback; + markTaskYield(currentTask, currentTime); + } else { + if (enableProfiling) { + markTaskCompleted(currentTask, currentTime); + currentTask.isQueued = false; + } + + if (currentTask === peek(taskQueue)) { + pop(taskQueue); + } + } + + advanceTimers(currentTime); + } else { + pop(taskQueue); } - result.push(mappedChild); + + currentTask = peek(taskQueue); + } // Return whether there's additional work + + + if (currentTask !== null) { + return true; + } else { + var firstTimer = peek(timerQueue); + + if (firstTimer !== null) { + requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); + } + + return false; } } -function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) { - var escapedPrefix = ''; - if (prefix != null) { - escapedPrefix = escapeUserProvidedKey(prefix) + '/'; +function unstable_runWithPriority(priorityLevel, eventHandler) { + switch (priorityLevel) { + case ImmediatePriority: + case UserBlockingPriority: + case NormalPriority: + case LowPriority: + case IdlePriority: + break; + + default: + priorityLevel = NormalPriority; } - var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context); - traverseAllChildren(children, mapSingleChildIntoContext, traverseContext); - releaseTraverseContext(traverseContext); -} -/** - * Maps children that are typically specified as `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenmap - * - * The provided mapFunction(child, key, index) will be called for each - * leaf child. - * - * @param {?*} children Children tree container. - * @param {function(*, int)} func The map function. - * @param {*} context Context for mapFunction. - * @return {object} Object containing the ordered map of results. - */ -function mapChildren(children, func, context) { - if (children == null) { - return children; + var previousPriorityLevel = currentPriorityLevel; + currentPriorityLevel = priorityLevel; + + try { + return eventHandler(); + } finally { + currentPriorityLevel = previousPriorityLevel; } - var result = []; - mapIntoWithKeyPrefixInternal(children, result, null, func, context); - return result; } -/** - * Count the number of children that are typically specified as - * `props.children`. - * - * See https://reactjs.org/docs/react-api.html#reactchildrencount - * - * @param {?*} children Children tree container. - * @return {number} The number of children. - */ -function countChildren(children) { - return traverseAllChildren(children, function () { - return null; - }, null); -} +function unstable_next(eventHandler) { + var priorityLevel; -/** - * Flatten a children object (typically specified as `props.children`) and - * return an array with appropriately re-keyed children. - * - * See https://reactjs.org/docs/react-api.html#reactchildrentoarray - */ -function toArray(children) { - var result = []; - mapIntoWithKeyPrefixInternal(children, result, null, function (child) { - return child; - }); - return result; -} + switch (currentPriorityLevel) { + case ImmediatePriority: + case UserBlockingPriority: + case NormalPriority: + // Shift down to normal priority + priorityLevel = NormalPriority; + break; -/** - * Returns the first child in a collection of children and verifies that there - * is only one child in the collection. - * - * See https://reactjs.org/docs/react-api.html#reactchildrenonly - * - * The current implementation of this function assumes that a single child gets - * passed without a wrapper, but the purpose of this helper function is to - * abstract away the particular structure of children. - * - * @param {?object} children Child collection structure. - * @return {ReactElement} The first and only `ReactElement` contained in the - * structure. - */ -function onlyChild(children) { - !isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0; - return children; -} + default: + // Anything lower than normal priority should remain at the current level. + priorityLevel = currentPriorityLevel; + break; + } -function createContext(defaultValue, calculateChangedBits) { - if (calculateChangedBits === undefined) { - calculateChangedBits = null; - } else { - { - !(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0; - } + var previousPriorityLevel = currentPriorityLevel; + currentPriorityLevel = priorityLevel; + + try { + return eventHandler(); + } finally { + currentPriorityLevel = previousPriorityLevel; } +} - var context = { - $$typeof: REACT_CONTEXT_TYPE, - _calculateChangedBits: calculateChangedBits, - // As a workaround to support multiple concurrent renderers, we categorize - // some renderers as primary and others as secondary. We only expect - // there to be two concurrent renderers at most: React Native (primary) and - // Fabric (secondary); React DOM (primary) and React ART (secondary). - // Secondary renderers store their context values on separate fields. - _currentValue: defaultValue, - _currentValue2: defaultValue, - // Used to track how many concurrent renderers this context currently - // supports within in a single renderer. Such as parallel server rendering. - _threadCount: 0, - // These are circular - Provider: null, - Consumer: null - }; +function unstable_wrapCallback(callback) { + var parentPriorityLevel = currentPriorityLevel; + return function () { + // This is a fork of runWithPriority, inlined for performance. + var previousPriorityLevel = currentPriorityLevel; + currentPriorityLevel = parentPriorityLevel; - context.Provider = { - $$typeof: REACT_PROVIDER_TYPE, - _context: context + try { + return callback.apply(this, arguments); + } finally { + currentPriorityLevel = previousPriorityLevel; + } }; +} - var hasWarnedAboutUsingNestedContextConsumers = false; - var hasWarnedAboutUsingConsumerProvider = false; - - { - // A separate object, but proxies back to the original context object for - // backwards compatibility. It has a different $$typeof, so we can properly - // warn for the incorrect usage of Context as a Consumer. - var Consumer = { - $$typeof: REACT_CONTEXT_TYPE, - _context: context, - _calculateChangedBits: context._calculateChangedBits - }; - // $FlowFixMe: Flow complains about not setting a value, which is intentional here - Object.defineProperties(Consumer, { - Provider: { - get: function () { - if (!hasWarnedAboutUsingConsumerProvider) { - hasWarnedAboutUsingConsumerProvider = true; - warning$1(false, 'Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?'); - } - return context.Provider; - }, - set: function (_Provider) { - context.Provider = _Provider; - } - }, - _currentValue: { - get: function () { - return context._currentValue; - }, - set: function (_currentValue) { - context._currentValue = _currentValue; - } - }, - _currentValue2: { - get: function () { - return context._currentValue2; - }, - set: function (_currentValue2) { - context._currentValue2 = _currentValue2; - } - }, - _threadCount: { - get: function () { - return context._threadCount; - }, - set: function (_threadCount) { - context._threadCount = _threadCount; - } - }, - Consumer: { - get: function () { - if (!hasWarnedAboutUsingNestedContextConsumers) { - hasWarnedAboutUsingNestedContextConsumers = true; - warning$1(false, 'Rendering is not supported and will be removed in ' + 'a future major release. Did you mean to render instead?'); - } - return context.Consumer; - } - } - }); - // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty - context.Consumer = Consumer; - } +function timeoutForPriorityLevel(priorityLevel) { + switch (priorityLevel) { + case ImmediatePriority: + return IMMEDIATE_PRIORITY_TIMEOUT; - { - context._currentRenderer = null; - context._currentRenderer2 = null; - } + case UserBlockingPriority: + return USER_BLOCKING_PRIORITY; - return context; -} + case IdlePriority: + return IDLE_PRIORITY; -function lazy(ctor) { - var lazyType = { - $$typeof: REACT_LAZY_TYPE, - _ctor: ctor, - // React uses these fields to store the result. - _status: -1, - _result: null - }; + case LowPriority: + return LOW_PRIORITY_TIMEOUT; - { - // In production, this would just set it on the object. - var defaultProps = void 0; - var propTypes = void 0; - Object.defineProperties(lazyType, { - defaultProps: { - configurable: true, - get: function () { - return defaultProps; - }, - set: function (newDefaultProps) { - warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); - defaultProps = newDefaultProps; - // Match production behavior more closely: - Object.defineProperty(lazyType, 'defaultProps', { - enumerable: true - }); - } - }, - propTypes: { - configurable: true, - get: function () { - return propTypes; - }, - set: function (newPropTypes) { - warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.'); - propTypes = newPropTypes; - // Match production behavior more closely: - Object.defineProperty(lazyType, 'propTypes', { - enumerable: true - }); - } - } - }); + case NormalPriority: + default: + return NORMAL_PRIORITY_TIMEOUT; } - - return lazyType; } -function forwardRef(render) { - { - if (render != null && render.$$typeof === REACT_MEMO_TYPE) { - warningWithoutStack$1(false, 'forwardRef requires a render function but received a `memo` ' + 'component. Instead of forwardRef(memo(...)), use ' + 'memo(forwardRef(...)).'); - } else if (typeof render !== 'function') { - warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render); +function unstable_scheduleCallback(priorityLevel, callback, options) { + var currentTime = getCurrentTime(); + var startTime; + var timeout; + + if (typeof options === 'object' && options !== null) { + var delay = options.delay; + + if (typeof delay === 'number' && delay > 0) { + startTime = currentTime + delay; } else { - !( - // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object - render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0; + startTime = currentTime; } - if (render != null) { - !(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0; - } + timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel); + } else { + timeout = timeoutForPriorityLevel(priorityLevel); + startTime = currentTime; } - return { - $$typeof: REACT_FORWARD_REF_TYPE, - render: render + var expirationTime = startTime + timeout; + var newTask = { + id: taskIdCounter++, + callback: callback, + priorityLevel: priorityLevel, + startTime: startTime, + expirationTime: expirationTime, + sortIndex: -1 }; -} -function isValidElementType(type) { - return typeof type === 'string' || typeof type === 'function' || - // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. - type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE); -} + if (enableProfiling) { + newTask.isQueued = false; + } -function memo(type, compare) { - { - if (!isValidElementType(type)) { - warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type); + if (startTime > currentTime) { + // This is a delayed task. + newTask.sortIndex = startTime; + push(timerQueue, newTask); + + if (peek(taskQueue) === null && newTask === peek(timerQueue)) { + // All tasks are delayed, and this is the task with the earliest delay. + if (isHostTimeoutScheduled) { + // Cancel an existing timeout. + cancelHostTimeout(); + } else { + isHostTimeoutScheduled = true; + } // Schedule a timeout. + + + requestHostTimeout(handleTimeout, startTime - currentTime); } - } - return { - $$typeof: REACT_MEMO_TYPE, - type: type, - compare: compare === undefined ? null : compare - }; -} + } else { + newTask.sortIndex = expirationTime; + push(taskQueue, newTask); -function resolveDispatcher() { - var dispatcher = ReactCurrentDispatcher.current; - !(dispatcher !== null) ? invariant(false, 'Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.') : void 0; - return dispatcher; -} + if (enableProfiling) { + markTaskStart(newTask, currentTime); + newTask.isQueued = true; + } // Schedule a host callback, if needed. If we're already performing work, + // wait until the next time we yield. -function useContext(Context, unstable_observedBits) { - var dispatcher = resolveDispatcher(); - { - !(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0; - // TODO: add a more generic warning for invalid values. - if (Context._context !== undefined) { - var realContext = Context._context; - // Don't deduplicate because this legitimately causes bugs - // and nobody should be using this in existing code. - if (realContext.Consumer === Context) { - warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?'); - } else if (realContext.Provider === Context) { - warning$1(false, 'Calling useContext(Context.Provider) is not supported. ' + 'Did you mean to call useContext(Context) instead?'); - } + if (!isHostCallbackScheduled && !isPerformingWork) { + isHostCallbackScheduled = true; + requestHostCallback(flushWork); } } - return dispatcher.useContext(Context, unstable_observedBits); -} -function useState(initialState) { - var dispatcher = resolveDispatcher(); - return dispatcher.useState(initialState); + return newTask; } -function useReducer(reducer, initialArg, init) { - var dispatcher = resolveDispatcher(); - return dispatcher.useReducer(reducer, initialArg, init); +function unstable_pauseExecution() { + isSchedulerPaused = true; } -function useRef(initialValue) { - var dispatcher = resolveDispatcher(); - return dispatcher.useRef(initialValue); -} +function unstable_continueExecution() { + isSchedulerPaused = false; -function useEffect(create, inputs) { - var dispatcher = resolveDispatcher(); - return dispatcher.useEffect(create, inputs); + if (!isHostCallbackScheduled && !isPerformingWork) { + isHostCallbackScheduled = true; + requestHostCallback(flushWork); + } } -function useLayoutEffect(create, inputs) { - var dispatcher = resolveDispatcher(); - return dispatcher.useLayoutEffect(create, inputs); +function unstable_getFirstCallbackNode() { + return peek(taskQueue); } -function useCallback(callback, inputs) { - var dispatcher = resolveDispatcher(); - return dispatcher.useCallback(callback, inputs); +function unstable_cancelCallback(task) { + if (enableProfiling) { + if (task.isQueued) { + var currentTime = getCurrentTime(); + markTaskCanceled(task, currentTime); + task.isQueued = false; + } + } // Null out the callback to indicate the task has been canceled. (Can't + // remove from the queue because you can't remove arbitrary nodes from an + // array based heap, only the first one.) + + + task.callback = null; } -function useMemo(create, inputs) { - var dispatcher = resolveDispatcher(); - return dispatcher.useMemo(create, inputs); +function unstable_getCurrentPriorityLevel() { + return currentPriorityLevel; } -function useImperativeHandle(ref, create, inputs) { - var dispatcher = resolveDispatcher(); - return dispatcher.useImperativeHandle(ref, create, inputs); +function unstable_shouldYield() { + var currentTime = getCurrentTime(); + advanceTimers(currentTime); + var firstTask = peek(taskQueue); + return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost(); +} + +var unstable_requestPaint = requestPaint; +var unstable_Profiling = enableProfiling ? { + startLoggingProfilingEvents: startLoggingProfilingEvents, + stopLoggingProfilingEvents: stopLoggingProfilingEvents, + sharedProfilingBuffer: sharedProfilingBuffer +} : null; + + + +var Scheduler = Object.freeze({ + unstable_ImmediatePriority: ImmediatePriority, + unstable_UserBlockingPriority: UserBlockingPriority, + unstable_NormalPriority: NormalPriority, + unstable_IdlePriority: IdlePriority, + unstable_LowPriority: LowPriority, + unstable_runWithPriority: unstable_runWithPriority, + unstable_next: unstable_next, + unstable_scheduleCallback: unstable_scheduleCallback, + unstable_cancelCallback: unstable_cancelCallback, + unstable_wrapCallback: unstable_wrapCallback, + unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel, + unstable_shouldYield: unstable_shouldYield, + unstable_requestPaint: unstable_requestPaint, + unstable_continueExecution: unstable_continueExecution, + unstable_pauseExecution: unstable_pauseExecution, + unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, + get unstable_now () { return getCurrentTime; }, + get unstable_forceFrameRate () { return forceFrameRate; }, + unstable_Profiling: unstable_Profiling +}); + +// Helps identify side effects in render-phase lifecycle hooks and setState +// reducers by double invoking them in Strict Mode. + + // To preserve the "Pause on caught exceptions" behavior of the debugger, we +// replay the begin phase of a failed component inside invokeGuardedCallback. + + // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: + + // Gather advanced timing metrics for Profiler subtrees. + + // Trace which interactions trigger each commit. + +var enableSchedulerTracing = true; // SSR experiments + + + // Only used in www builds. + + // Only used in www builds. + + // Disable javascript: URL strings in href for XSS protection. + + // React Fire: prevent the value and checked attributes from syncing +// with their related DOM properties + + // These APIs will no longer be "unstable" in the upcoming 16.7 release, +// Control this behavior with a flag to support 16.6 minor releases in the meanwhile. + +var exposeConcurrentModeAPIs = false; + // Experimental React Flare event system and event components support. + +var enableFlareAPI = false; // Experimental Host Component support. + +var enableFundamentalAPI = false; // Experimental Scope support. + +var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107 + +var enableJSXTransformAPI = false; // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?) +// Till then, we warn about the missing mock, but still fallback to a legacy mode compatible version + + // For tests, we flush suspense fallbacks in an act scope; +// *except* in some of our own tests, where we test incremental loading states. + + // Add a callback property to suspense to notify which promises are currently +// in the update queue. This allows reporting and tracing of what is causing +// the user to see a loading state. +// Also allows hydration callbacks to fire when a dehydrated boundary gets +// hydrated or deleted. + + // Part of the simplification of React.createElement so we can eventually move +// from React.createElement to React.jsx +// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md + + + + + + // Flag to turn event.target and event.currentTarget in ReactNative from a reactTag to a component instance + +var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs. + +var interactionIDCounter = 0; +var threadIDCounter = 0; // Set of currently traced interactions. +// Interactions "stack"– +// Meaning that newly traced interactions are appended to the previously active set. +// When an interaction goes out of scope, the previous set (if any) is restored. + +var interactionsRef = null; // Listener(s) to notify when interactions begin and end. + +var subscriberRef = null; + +if (enableSchedulerTracing) { + interactionsRef = { + current: new Set() + }; + subscriberRef = { + current: null + }; } -function useDebugValue(value, formatterFn) { - { - var dispatcher = resolveDispatcher(); - return dispatcher.useDebugValue(value, formatterFn); +function unstable_clear(callback) { + if (!enableSchedulerTracing) { + return callback(); + } + + var prevInteractions = interactionsRef.current; + interactionsRef.current = new Set(); + + try { + return callback(); + } finally { + interactionsRef.current = prevInteractions; + } +} +function unstable_getCurrent() { + if (!enableSchedulerTracing) { + return null; + } else { + return interactionsRef.current; } } +function unstable_getThreadID() { + return ++threadIDCounter; +} +function unstable_trace(name, timestamp, callback) { + var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ + if (!enableSchedulerTracing) { + return callback(); + } + var interaction = { + __count: 1, + id: interactionIDCounter++, + name: name, + timestamp: timestamp + }; + var prevInteractions = interactionsRef.current; // Traced interactions should stack/accumulate. + // To do that, clone the current interactions. + // The previous set will be restored upon completion. + + var interactions = new Set(prevInteractions); + interactions.add(interaction); + interactionsRef.current = interactions; + var subscriber = subscriberRef.current; + var returnValue; + + try { + if (subscriber !== null) { + subscriber.onInteractionTraced(interaction); + } + } finally { + try { + if (subscriber !== null) { + subscriber.onWorkStarted(interactions, threadID); + } + } finally { + try { + returnValue = callback(); + } finally { + interactionsRef.current = prevInteractions; + + try { + if (subscriber !== null) { + subscriber.onWorkStopped(interactions, threadID); + } + } finally { + interaction.__count--; // If no async work was scheduled for this interaction, + // Notify subscribers that it's completed. + if (subscriber !== null && interaction.__count === 0) { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } + } + } + } + } -var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; + return returnValue; +} +function unstable_wrap(callback) { + var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; -var ReactPropTypesSecret_1 = ReactPropTypesSecret$1; + if (!enableSchedulerTracing) { + return callback; + } -/** - * Copyright (c) 2013-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ + var wrappedInteractions = interactionsRef.current; + var subscriber = subscriberRef.current; + if (subscriber !== null) { + subscriber.onWorkScheduled(wrappedInteractions, threadID); + } // Update the pending async work count for the current interactions. + // Update after calling subscribers in case of error. -var printWarning$1 = function() {}; + wrappedInteractions.forEach(function (interaction) { + interaction.__count++; + }); + var hasRun = false; -{ - var ReactPropTypesSecret = ReactPropTypesSecret_1; - var loggedTypeFailures = {}; + function wrapped() { + var prevInteractions = interactionsRef.current; + interactionsRef.current = wrappedInteractions; + subscriber = subscriberRef.current; - printWarning$1 = function(text) { - var message = 'Warning: ' + text; - if (typeof console !== 'undefined') { - console.error(message); - } try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch (x) {} - }; -} + var returnValue; -/** - * Assert that the values match with the type specs. - * Error messages are memorized and will only be shown once. - * - * @param {object} typeSpecs Map of name to a ReactPropType - * @param {object} values Runtime values that need to be type-checked - * @param {string} location e.g. "prop", "context", "child context" - * @param {string} componentName Name of the component for error messages. - * @param {?Function} getStack Returns the component stack. - * @private - */ -function checkPropTypes(typeSpecs, values, location, componentName, getStack) { - { - for (var typeSpecName in typeSpecs) { - if (typeSpecs.hasOwnProperty(typeSpecName)) { - var error; - // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. + try { + if (subscriber !== null) { + subscriber.onWorkStarted(wrappedInteractions, threadID); + } + } finally { try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - if (typeof typeSpecs[typeSpecName] !== 'function') { - var err = Error( - (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + - 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' - ); - err.name = 'Invariant Violation'; - throw err; + returnValue = callback.apply(undefined, arguments); + } finally { + interactionsRef.current = prevInteractions; + + if (subscriber !== null) { + subscriber.onWorkStopped(wrappedInteractions, threadID); } - error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); - } catch (ex) { - error = ex; } - if (error && !(error instanceof Error)) { - printWarning$1( - (componentName || 'React class') + ': type specification of ' + - location + ' `' + typeSpecName + '` is invalid; the type checker ' + - 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + - 'You may have forgotten to pass an argument to the type checker ' + - 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + - 'shape all require an argument).' - ); + } - } - if (error instanceof Error && !(error.message in loggedTypeFailures)) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error.message] = true; + return returnValue; + } finally { + if (!hasRun) { + // We only expect a wrapped function to be executed once, + // But in the event that it's executed more than once– + // Only decrement the outstanding interaction counts once. + hasRun = true; // Update pending async counts for all wrapped interactions. + // If this was the last scheduled async work for any of them, + // Mark them as completed. - var stack = getStack ? getStack() : ''; + wrappedInteractions.forEach(function (interaction) { + interaction.__count--; - printWarning$1( - 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') - ); - } + if (subscriber !== null && interaction.__count === 0) { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } + }); } } } -} -var checkPropTypes_1 = checkPropTypes; + wrapped.cancel = function cancel() { + subscriber = subscriberRef.current; -/** - * ReactElementValidator provides a wrapper around a element factory - * which validates the props passed to the element. This is intended to be - * used only in DEV and could be replaced by a static type checker for languages - * that support it. - */ + try { + if (subscriber !== null) { + subscriber.onWorkCanceled(wrappedInteractions, threadID); + } + } finally { + // Update pending async counts for all wrapped interactions. + // If this was the last scheduled async work for any of them, + // Mark them as completed. + wrappedInteractions.forEach(function (interaction) { + interaction.__count--; -var propTypesMisspellWarningShown = void 0; + if (subscriber && interaction.__count === 0) { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } + }); + } + }; -{ - propTypesMisspellWarningShown = false; + return wrapped; } -function getDeclarationErrorAddendum() { - if (ReactCurrentOwner.current) { - var name = getComponentName(ReactCurrentOwner.current.type); - if (name) { - return '\n\nCheck the render method of `' + name + '`.'; +var subscribers = null; + +if (enableSchedulerTracing) { + subscribers = new Set(); +} + +function unstable_subscribe(subscriber) { + if (enableSchedulerTracing) { + subscribers.add(subscriber); + + if (subscribers.size === 1) { + subscriberRef.current = { + onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted, + onInteractionTraced: onInteractionTraced, + onWorkCanceled: onWorkCanceled, + onWorkScheduled: onWorkScheduled, + onWorkStarted: onWorkStarted, + onWorkStopped: onWorkStopped + }; } } - return ''; } +function unstable_unsubscribe(subscriber) { + if (enableSchedulerTracing) { + subscribers.delete(subscriber); -function getSourceInfoErrorAddendum(elementProps) { - if (elementProps !== null && elementProps !== undefined && elementProps.__source !== undefined) { - var source = elementProps.__source; - var fileName = source.fileName.replace(/^.*[\\\/]/, ''); - var lineNumber = source.lineNumber; - return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.'; + if (subscribers.size === 0) { + subscriberRef.current = null; + } } - return ''; } -/** - * Warn if there's no key explicitly set on dynamic arrays of children or - * object keys are not valid. This allows us to keep track of children between - * updates. - */ -var ownerHasKeyUseWarning = {}; - -function getCurrentComponentErrorInfo(parentType) { - var info = getDeclarationErrorAddendum(); - - if (!info) { - var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name; - if (parentName) { - info = '\n\nCheck the top-level render call using <' + parentName + '>.'; +function onInteractionTraced(interaction) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onInteractionTraced(interaction); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } } + }); + + if (didCatchError) { + throw caughtError; } - return info; } -/** - * Warn if the element doesn't have an explicit key assigned to it. - * This element is in an array. The array could grow and shrink or be - * reordered. All children that haven't already been validated are required to - * have a "key" property assigned to it. Error statuses are cached so a warning - * will only be shown once. - * - * @internal - * @param {ReactElement} element Element that requires a key. - * @param {*} parentType element's parent's type. - */ -function validateExplicitKey(element, parentType) { - if (!element._store || element._store.validated || element.key != null) { - return; - } - element._store.validated = true; +function onInteractionScheduledWorkCompleted(interaction) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } + } + }); - var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType); - if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { - return; + if (didCatchError) { + throw caughtError; } - ownerHasKeyUseWarning[currentComponentErrorInfo] = true; +} - // Usually the current owner is the offender, but if it accepts children as a - // property, it may be the creator of the child that's responsible for - // assigning it a key. - var childOwner = ''; - if (element && element._owner && element._owner !== ReactCurrentOwner.current) { - // Give the component that originally created this child. - childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.'; - } +function onWorkScheduled(interactions, threadID) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onWorkScheduled(interactions, threadID); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } + } + }); - setCurrentlyValidatingElement(element); - { - warning$1(false, 'Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner); + if (didCatchError) { + throw caughtError; } - setCurrentlyValidatingElement(null); } -/** - * Ensure that every element either is passed in a static location, in an - * array with an explicit keys property defined, or in an object literal - * with valid key property. - * - * @internal - * @param {ReactNode} node Statically passed child of any type. - * @param {*} parentType node's parent's type. - */ -function validateChildKeys(node, parentType) { - if (typeof node !== 'object') { - return; - } - if (Array.isArray(node)) { - for (var i = 0; i < node.length; i++) { - var child = node[i]; - if (isValidElement(child)) { - validateExplicitKey(child, parentType); +function onWorkStarted(interactions, threadID) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; } } - } else if (isValidElement(node)) { - // This element was passed in a valid location. - if (node._store) { - node._store.validated = true; - } - } else if (node) { - var iteratorFn = getIteratorFn(node); - if (typeof iteratorFn === 'function') { - // Entry iterators used to provide implicit keys, - // but now we print a separate warning for them later. - if (iteratorFn !== node.entries) { - var iterator = iteratorFn.call(node); - var step = void 0; - while (!(step = iterator.next()).done) { - if (isValidElement(step.value)) { - validateExplicitKey(step.value, parentType); - } - } + }); + + if (didCatchError) { + throw caughtError; + } +} + +function onWorkStopped(interactions, threadID) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onWorkStopped(interactions, threadID); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; } } + }); + + if (didCatchError) { + throw caughtError; } } -/** - * Given an element, validate that its props follow the propTypes definition, - * provided by the type. - * - * @param {ReactElement} element - */ -function validatePropTypes(element) { - var type = element.type; - if (type === null || type === undefined || typeof type === 'string') { - return; - } - var name = getComponentName(type); - var propTypes = void 0; - if (typeof type === 'function') { - propTypes = type.propTypes; - } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || - // Note: Memo only checks outer props here. - // Inner props are checked in the reconciler. - type.$$typeof === REACT_MEMO_TYPE)) { - propTypes = type.propTypes; - } else { - return; - } - if (propTypes) { - setCurrentlyValidatingElement(element); - checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum); - setCurrentlyValidatingElement(null); - } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) { - propTypesMisspellWarningShown = true; - warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown'); - } - if (typeof type.getDefaultProps === 'function') { - !type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0; +function onWorkCanceled(interactions, threadID) { + var didCatchError = false; + var caughtError = null; + subscribers.forEach(function (subscriber) { + try { + subscriber.onWorkCanceled(interactions, threadID); + } catch (error) { + if (!didCatchError) { + didCatchError = true; + caughtError = error; + } + } + }); + + if (didCatchError) { + throw caughtError; } } -/** - * Given a fragment, validate that it can only be provided with fragment props - * @param {ReactElement} fragment - */ -function validateFragmentProps(fragment) { - setCurrentlyValidatingElement(fragment); - var keys = Object.keys(fragment.props); - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (key !== 'children' && key !== 'key') { - warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key); - break; - } - } - if (fragment.ref !== null) { - warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.'); - } +var SchedulerTracing = Object.freeze({ + get __interactionsRef () { return interactionsRef; }, + get __subscriberRef () { return subscriberRef; }, + unstable_clear: unstable_clear, + unstable_getCurrent: unstable_getCurrent, + unstable_getThreadID: unstable_getThreadID, + unstable_trace: unstable_trace, + unstable_wrap: unstable_wrap, + unstable_subscribe: unstable_subscribe, + unstable_unsubscribe: unstable_unsubscribe +}); - setCurrentlyValidatingElement(null); -} +var ReactSharedInternals$2 = { + ReactCurrentDispatcher: ReactCurrentDispatcher, + ReactCurrentOwner: ReactCurrentOwner, + IsSomeRendererActing: IsSomeRendererActing, + // Used by renderers to avoid bundling object-assign twice in UMD bundles: + assign: objectAssign +}; -function createElementWithValidation(type, props, children) { - var validType = isValidElementType(type); +{ + objectAssign(ReactSharedInternals$2, { + // These should not be included in production. + ReactDebugCurrentFrame: ReactDebugCurrentFrame, + // Shim for React DOM 16.0.0 which still destructured (but not used) this. + // TODO: remove in React 17.0. + ReactComponentTreeHook: {} + }); +} // Re-export the schedule API(s) for UMD bundles. +// This avoids introducing a dependency on a new UMD global in a minor update, +// Since that would be a breaking change (e.g. for all existing CodeSandboxes). +// This re-export is only required for UMD bundles; +// CJS bundles use the shared NPM package. - // We warn in this case but don't throw. We expect the element creation to - // succeed and there will likely be errors in render. - if (!validType) { - var info = ''; - if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) { - info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports."; - } - var sourceInfo = getSourceInfoErrorAddendum(props); - if (sourceInfo) { - info += sourceInfo; - } else { - info += getDeclarationErrorAddendum(); - } +objectAssign(ReactSharedInternals$2, { + Scheduler: Scheduler, + SchedulerTracing: SchedulerTracing +}); - var typeString = void 0; - if (type === null) { - typeString = 'null'; - } else if (Array.isArray(type)) { - typeString = 'array'; - } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) { - typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />'; - info = ' Did you accidentally export a JSX literal instead of a component?'; - } else { - typeString = typeof type; - } +var hasBadMapPolyfill; - warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info); - } +{ + hasBadMapPolyfill = false; - var element = createElement.apply(this, arguments); + try { + var frozenObject = Object.freeze({}); + var testMap = new Map([[frozenObject, null]]); + var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused. + // https://github.com/rollup/rollup/issues/1771 + // TODO: we can remove these if Rollup fixes the bug. - // The result can be nullish if a mock or a custom function is used. - // TODO: Drop this when these are no longer allowed as the type argument. - if (element == null) { - return element; + testMap.set(0, 0); + testSet.add(0); + } catch (e) { + // TODO: Consider warning about bad polyfills + hasBadMapPolyfill = true; } +} - // Skip key warning if the type isn't valid since our key validation logic - // doesn't expect a non-string/function type and can throw confusing errors. - // We don't want exception behavior to differ between dev and prod. - // (Rendering will throw with a helpful message and as soon as the type is - // fixed, the key warnings will appear.) - if (validType) { - for (var i = 2; i < arguments.length; i++) { - validateChildKeys(arguments[i], type); - } +function createFundamentalComponent(impl) { + // We use responder as a Map key later on. When we have a bad + // polyfill, then we can't use it as a key as the polyfill tries + // to add a property to the object. + if (true && !hasBadMapPolyfill) { + Object.freeze(impl); } - if (type === REACT_FRAGMENT_TYPE) { - validateFragmentProps(element); - } else { - validatePropTypes(element); - } + var fundamantalComponent = { + $$typeof: REACT_FUNDAMENTAL_TYPE, + impl: impl + }; - return element; -} + { + Object.freeze(fundamantalComponent); + } + + return fundamantalComponent; +} + +function createEventResponder(displayName, responderConfig) { + var getInitialState = responderConfig.getInitialState, + onEvent = responderConfig.onEvent, + onMount = responderConfig.onMount, + onUnmount = responderConfig.onUnmount, + onRootEvent = responderConfig.onRootEvent, + rootEventTypes = responderConfig.rootEventTypes, + targetEventTypes = responderConfig.targetEventTypes, + targetPortalPropagation = responderConfig.targetPortalPropagation; + var eventResponder = { + $$typeof: REACT_RESPONDER_TYPE, + displayName: displayName, + getInitialState: getInitialState || null, + onEvent: onEvent || null, + onMount: onMount || null, + onRootEvent: onRootEvent || null, + onUnmount: onUnmount || null, + rootEventTypes: rootEventTypes || null, + targetEventTypes: targetEventTypes || null, + targetPortalPropagation: targetPortalPropagation || false + }; // We use responder as a Map key later on. When we have a bad + // polyfill, then we can't use it as a key as the polyfill tries + // to add a property to the object. + + if (true && !hasBadMapPolyfill) { + Object.freeze(eventResponder); + } + + return eventResponder; +} + +function createScope() { + var scopeComponent = { + $$typeof: REACT_SCOPE_TYPE + }; -function createFactoryWithValidation(type) { - var validatedFactory = createElementWithValidation.bind(null, type); - validatedFactory.type = type; - // Legacy hook: remove it { - Object.defineProperty(validatedFactory, 'type', { - enumerable: false, - get: function () { - lowPriorityWarning$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.'); - Object.defineProperty(this, 'type', { - value: type - }); - return type; - } - }); + Object.freeze(scopeComponent); } - return validatedFactory; -} - -function cloneElementWithValidation(element, props, children) { - var newElement = cloneElement.apply(this, arguments); - for (var i = 2; i < arguments.length; i++) { - validateChildKeys(arguments[i], newElement.type); - } - validatePropTypes(newElement); - return newElement; + return scopeComponent; } var React = { @@ -3088,16 +3713,13 @@ var React = { toArray: toArray, only: onlyChild }, - createRef: createRef, Component: Component, PureComponent: PureComponent, - createContext: createContext, forwardRef: forwardRef, lazy: lazy, memo: memo, - useCallback: useCallback, useContext: useContext, useEffect: useEffect, @@ -3108,34 +3730,48 @@ var React = { useReducer: useReducer, useRef: useRef, useState: useState, - Fragment: REACT_FRAGMENT_TYPE, + Profiler: REACT_PROFILER_TYPE, StrictMode: REACT_STRICT_MODE_TYPE, Suspense: REACT_SUSPENSE_TYPE, - createElement: createElementWithValidation, cloneElement: cloneElementWithValidation, createFactory: createFactoryWithValidation, isValidElement: isValidElement, - version: ReactVersion, + __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals$2 +}; - unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE, - unstable_Profiler: REACT_PROFILER_TYPE, +if (exposeConcurrentModeAPIs) { + React.useTransition = useTransition; + React.useDeferredValue = useDeferredValue; + React.SuspenseList = REACT_SUSPENSE_LIST_TYPE; + React.unstable_withSuspenseConfig = withSuspenseConfig; +} - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals -}; +if (enableFlareAPI) { + React.unstable_useResponder = useResponder; + React.unstable_createResponder = createEventResponder; +} + +if (enableFundamentalAPI) { + React.unstable_createFundamental = createFundamentalComponent; +} -// Note: some APIs are added with feature flags. +if (enableScopeAPI) { + React.unstable_createScope = createScope; +} // Note: some APIs are added with feature flags. // Make sure that stable builds for open source // don't modify the React object to avoid deopts. // Also let's not expose their names in stable builds. -if (enableStableConcurrentModeAPIs) { - React.ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; - React.Profiler = REACT_PROFILER_TYPE; - React.unstable_ConcurrentMode = undefined; - React.unstable_Profiler = undefined; + +if (enableJSXTransformAPI) { + { + React.jsxDEV = jsxWithValidation; + React.jsx = jsxWithValidationDynamic; + React.jsxs = jsxWithValidationStatic; + } } @@ -3148,6 +3784,8 @@ var React$3 = ( React$2 && React ) || React$2; // TODO: decide on the top-level export form. // This is hacky but makes it work with both Rollup and Jest. + + var react = React$3.default || React$3; return react; diff --git a/node_modules/react/umd/react.production.min.js b/node_modules/react/umd/react.production.min.js index 4dc1c2c03..2d9fb9aa2 100644 --- a/node_modules/react/umd/react.production.min.js +++ b/node_modules/react/umd/react.production.min.js @@ -1,4 +1,4 @@ -/** @license React v16.8.6 +/** @license React v16.12.0 * react.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. @@ -6,28 +6,27 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ -'use strict';(function(N,q){"object"===typeof exports&&"undefined"!==typeof module?module.exports=q():"function"===typeof define&&define.amd?define(q):N.React=q()})(this,function(){function N(a,b,d,g,p,c,e,h){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var n=[d,g,p,c,e,h],f=0;a=Error(b.replace(/%s/g,function(){return n[f++]}));a.name="Invariant Violation"}a.framesToPop=1; -throw a;}}function q(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,g=0;g=b){d=a;break}a=a.next}while(a!==c);null===d?d=c:d=== -c&&(c=n,u());b=d.previous;b.next=d.previous=n;n.next=d;n.previous=b}}function F(){if(-1===k&&null!==c&&1===c.priorityLevel){x=!0;try{do Q();while(null!==c&&1===c.priorityLevel)}finally{x=!1,null!==c?u():C=!1}}}function ta(a){x=!0;var b=G;G=a;try{if(a)for(;null!==c;){var d=l();if(c.expirationTime<=d){do Q();while(null!==c&&c.expirationTime<=d)}else break}else if(null!==c){do Q();while(null!==c&&!H())}}finally{x=!1,G=b,null!==c?u():C=!1,F()}}function ea(a,b,d){var g=void 0,p={},c=null,e=null;if(null!= -b)for(g in void 0!==b.ref&&(e=b.ref),void 0!==b.key&&(c=""+b.key),b)fa.call(b,g)&&!ha.hasOwnProperty(g)&&(p[g]=b[g]);var h=arguments.length-2;if(1===h)p.children=d;else if(1I.length&&I.push(a)}function T(a,b,d,g){var c=typeof a;if("undefined"===c||"boolean"===c)a=null;var e=!1;if(null=== -a)e=!0;else switch(c){case "string":case "number":e=!0;break;case "object":switch(a.$$typeof){case y:case wa:e=!0}}if(e)return d(g,a,""===b?"."+U(a,0):b),1;e=0;b=""===b?".":b+":";if(Array.isArray(a))for(var f=0;fa;a++)b["_"+String.fromCharCode(a)]=a;if("0123456789"!==Object.getOwnPropertyNames(b).map(function(a){return b[a]}).join(""))return!1;var d={};"abcdefghijklmnopqrst".split("").forEach(function(a){d[a]=a});return"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},d)).join("")?!1:!0}catch(g){return!1}}()?Object.assign:function(a,b){if(null===a||void 0===a)throw new TypeError("Object.assign cannot be called with null or undefined");var d=Object(a);for(var c,e=1;e=L-d)if(-1!==b&&b<=d)c=!0;else{A||(A=!0,Y(aa));w=a;z=b;return}if(null!==a){Z=!0;try{a(c)}finally{Z=!1}}};var aa=function(a){if(null!==w){Y(aa);var b=a-L+B;bb&&(b=8),B=bb?sa.postMessage(void 0):A||(A=!0,Y(aa))};P=function(){w=null;K=!1;z=-1}}var Oa= -0,ma={current:null},R={current:null};e={ReactCurrentDispatcher:ma,ReactCurrentOwner:R,assign:J};J(e,{Scheduler:{unstable_cancelCallback:function(a){var b=a.next;if(null!==b){if(b===a)c=null;else{a===c&&(c=b);var d=a.previous;d.next=b;b.previous=d}a.next=a.previous=null}},unstable_shouldYield:function(){return!G&&(null!==c&&c.expirationTimeb){d=g;break}g=g.next}while(g!==c);null===d?d=c:d===c&&(c=a,u());b=d.previous;b.next=d.previous=a;a.next=d;a.previous=b}return a},unstable_runWithPriority:function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a= -3}var d=f,c=k;f=a;k=l();try{return b()}finally{f=d,k=c,F()}},unstable_next:function(a){switch(f){case 1:case 2:case 3:var b=3;break;default:b=f}var d=f,c=k;f=b;k=l();try{return a()}finally{f=d,k=c,F()}},unstable_wrapCallback:function(a){var b=f;return function(){var d=f,c=k;f=b;k=l();try{return a.apply(this,arguments)}finally{f=d,k=c,F()}}},unstable_getFirstCallbackNode:function(){return c},unstable_pauseExecution:function(){},unstable_continueExecution:function(){null!==c&&u()},unstable_getCurrentPriorityLevel:function(){return f}, -unstable_IdlePriority:5,unstable_ImmediatePriority:1,unstable_LowPriority:4,unstable_NormalPriority:3,unstable_UserBlockingPriority:2},SchedulerTracing:{__interactionsRef:null,__subscriberRef:null,unstable_clear:function(a){return a()},unstable_getCurrent:function(){return null},unstable_getThreadID:function(){return++Oa},unstable_subscribe:function(a){},unstable_trace:function(a,b,d){return d()},unstable_unsubscribe:function(a){},unstable_wrap:function(a){return a}}});var fa=Object.prototype.hasOwnProperty, -ha={key:!0,ref:!0,__self:!0,__source:!0},la=/\/+/g,I=[];r={Children:{map:function(a,b,d){if(null==a)return a;var c=[];W(a,c,null,b,d);return c},forEach:function(a,b,d){if(null==a)return a;b=ia(null,null,b,d);V(a,xa,b);ja(b)},count:function(a){return V(a,function(){return null},null)},toArray:function(a){var b=[];W(a,b,null,function(a){return a});return b},only:function(a){S(a)?void 0:q("143");return a}},createRef:function(){return{current:null}},Component:t,PureComponent:O,createContext:function(a, -b){void 0===b&&(b=null);a={$$typeof:Ba,_calculateChangedBits:b,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:Aa,_context:a};return a.Consumer=a},forwardRef:function(a){return{$$typeof:Da,render:a}},lazy:function(a){return{$$typeof:Ga,_ctor:a,_status:-1,_result:null}},memo:function(a,b){return{$$typeof:Fa,type:a,compare:void 0===b?null:b}},useCallback:function(a,b){return m().useCallback(a,b)},useContext:function(a,b){return m().useContext(a,b)}, -useEffect:function(a,b){return m().useEffect(a,b)},useImperativeHandle:function(a,b,d){return m().useImperativeHandle(a,b,d)},useDebugValue:function(a,b){},useLayoutEffect:function(a,b){return m().useLayoutEffect(a,b)},useMemo:function(a,b){return m().useMemo(a,b)},useReducer:function(a,b,d){return m().useReducer(a,b,d)},useRef:function(a){return m().useRef(a)},useState:function(a){return m().useState(a)},Fragment:r,StrictMode:X,Suspense:Ea,createElement:ea,cloneElement:function(a,b,d){null===a|| -void 0===a?q("267",a):void 0;var c=void 0,e=J({},a.props),f=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=R.current);void 0!==b.key&&(f=""+b.key);var l=void 0;a.type&&a.type.defaultProps&&(l=a.type.defaultProps);for(c in b)fa.call(b,c)&&!ha.hasOwnProperty(c)&&(e[c]=void 0===b[c]&&void 0!==l?l[c]:b[c])}c=arguments.length-2;if(1===c)e.children=d;else if(1D.length&&D.push(a)}function P(a,b,c,d){var e=typeof a;if("undefined"===e||"boolean"===e)a=null;var p=!1;if(null===a)p=!0;else switch(e){case "string":case "number":p=!0;break;case "object":switch(a.$$typeof){case y:case ya:p=!0}}if(p)return c(d,a,""===b?"."+Q(a,0):b),1;p=0;b=""===b?".":b+":";if(Array.isArray(a))for(var f=0;fE(h,c))void 0!==k&&0>E(k,h)?(a[d]=k,a[g]=c,d=g):(a[d]=h,a[f]=c,d=f);else if(void 0!==k&&0>E(k,c))a[d]=k,a[g]=c,d=g;else break a}}return b}return null}function E(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}function G(a){for(var b=n(u);null!==b;){if(null=== +b.callback)F(u);else if(b.startTime<=a)F(u),b.sortIndex=b.expirationTime,T(q,b);else break;b=n(u)}}function U(a){z=!1;G(a);if(!w)if(null!==n(q))w=!0,A(V);else{var b=n(u);null!==b&&H(U,b.startTime-a)}}function V(a,b){w=!1;z&&(z=!1,W());I=!0;var c=h;try{G(b);for(l=n(q);null!==l&&(!(l.expirationTime>b)||a&&!X());){var d=l.callback;if(null!==d){l.callback=null;h=l.priorityLevel;var e=d(l.expirationTime<=b);b=r();"function"===typeof e?l.callback=e:l===n(q)&&F(q);G(b)}else F(q);l=n(q)}if(null!==l)var f= +!0;else{var m=n(u);null!==m&&H(U,m.startTime-b);f=!1}return f}finally{l=null,h=c,I=!1}}function pa(a){switch(a){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4;default:return 5E3}}var f="function"===typeof Symbol&&Symbol.for,y=f?Symbol.for("react.element"):60103,ya=f?Symbol.for("react.portal"):60106,x=f?Symbol.for("react.fragment"):60107,Y=f?Symbol.for("react.strict_mode"):60108,Ba=f?Symbol.for("react.profiler"):60114,Ca=f?Symbol.for("react.provider"):60109,Da=f?Symbol.for("react.context"): +60110,Ea=f?Symbol.for("react.forward_ref"):60112,Fa=f?Symbol.for("react.suspense"):60113;f&&Symbol.for("react.suspense_list");var Ga=f?Symbol.for("react.memo"):60115,Ha=f?Symbol.for("react.lazy"):60116;f&&Symbol.for("react.fundamental");f&&Symbol.for("react.responder");f&&Symbol.for("react.scope");var ma="function"===typeof Symbol&&Symbol.iterator,qa=Object.getOwnPropertySymbols,Ia=Object.prototype.hasOwnProperty,Ja=Object.prototype.propertyIsEnumerable,J=function(){try{if(!Object.assign)return!1; +var a=new String("abc");a[5]="de";if("5"===Object.getOwnPropertyNames(a)[0])return!1;var b={};for(a=0;10>a;a++)b["_"+String.fromCharCode(a)]=a;if("0123456789"!==Object.getOwnPropertyNames(b).map(function(a){return b[a]}).join(""))return!1;var c={};"abcdefghijklmnopqrst".split("").forEach(function(a){c[a]=a});return"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},c)).join("")?!1:!0}catch(d){return!1}}()?Object.assign:function(a,b){if(null===a||void 0===a)throw new TypeError("Object.assign cannot be called with null or undefined"); +var c=Object(a);for(var d,e=1;e=va};f=function(){};Z=function(a){0>a||125d?(a.sortIndex=e,T(u,a),null===n(q)&&a===n(u)&&(z?W():z=!0,H(U,e-d))):(a.sortIndex=c,T(q,a),w||I||(w=!0,A(V)));return a},unstable_cancelCallback:function(a){a.callback=null},unstable_wrapCallback:function(a){var b=h;return function(){var c=h;h=b;try{return a.apply(this,arguments)}finally{h=c}}},unstable_getCurrentPriorityLevel:function(){return h}, +unstable_shouldYield:function(){var a=r();G(a);var b=n(q);return b!==l&&null!==l&&null!==b&&null!==b.callback&&b.startTime<=a&&b.expirationTime=b){c=a;break}a=a.next}while(a!==f);null===c?c= -f:c===f&&(f=l,x());b=c.previous;b.next=c.previous=l;l.next=c;l.previous=b}}function I(){if(-1===n&&null!==f&&1===f.priorityLevel){A=!0;try{do T();while(null!==f&&1===f.priorityLevel)}finally{A=!1,null!==f?x():F=!1}}}function xa(a){A=!0;var b=J;J=a;try{if(a)for(;null!==f;){var c=p();if(f.expirationTime<=c){do T();while(null!==f&&f.expirationTime<=c)}else break}else if(null!==f){do T();while(null!==f&&!K())}}finally{A=!1,J=b,null!==f?x():F=!1,I()}}function ya(a){var b=!1,c=null;q.forEach(function(d){try{d.onInteractionTraced(a)}catch(e){b|| -(b=!0,c=e)}});if(b)throw c;}function za(a){var b=!1,c=null;q.forEach(function(d){try{d.onInteractionScheduledWorkCompleted(a)}catch(e){b||(b=!0,c=e)}});if(b)throw c;}function Aa(a,b){var c=!1,d=null;q.forEach(function(e){try{e.onWorkScheduled(a,b)}catch(l){c||(c=!0,d=l)}});if(c)throw d;}function Ba(a,b){var c=!1,d=null;q.forEach(function(e){try{e.onWorkStarted(a,b)}catch(l){c||(c=!0,d=l)}});if(c)throw d;}function Ca(a,b){var c=!1,d=null;q.forEach(function(e){try{e.onWorkStopped(a,b)}catch(l){c||(c= -!0,d=l)}});if(c)throw d;}function Da(a,b){var c=!1,d=null;q.forEach(function(e){try{e.onWorkCanceled(a,b)}catch(l){c||(c=!0,d=l)}});if(c)throw d;}function ia(a,b,c){var d=void 0,e={},l=null,f=null;if(null!=b)for(d in void 0!==b.ref&&(f=b.ref),void 0!==b.key&&(l=""+b.key),b)ja.call(b,d)&&!ka.hasOwnProperty(d)&&(e[d]=b[d]);var h=arguments.length-2;if(1===h)e.children=c;else if(1L.length&&L.push(a)}function W(a,b,c,d){var e=typeof a;if("undefined"===e||"boolean"===e)a=null;var l=!1;if(null===a)l=!0;else switch(e){case "string":case "number":l=!0;break;case "object":switch(a.$$typeof){case B:case Ga:l=!0}}if(l)return c(d,a,""===b?"."+X(a,0):b),1;l=0;b=""===b?".":b+":";if(Array.isArray(a))for(var f=0;fa;a++)b["_"+String.fromCharCode(a)]=a;if("0123456789"!==Object.getOwnPropertyNames(b).map(function(a){return b[a]}).join(""))return!1;var c={};"abcdefghijklmnopqrst".split("").forEach(function(a){c[a]=a});return"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},c)).join("")?!1:!0}catch(d){return!1}}()?Object.assign: -function(a,b){if(null===a||void 0===a)throw new TypeError("Object.assign cannot be called with null or undefined");var c=Object(a);for(var d,e=1;e=O-c)if(-1!==b&&b<=c)d=!0;else{D||(D=!0,ba(da));z=a;C=b;return}if(null!==a){ca=!0;try{a(d)}finally{ca=!1}}};var da=function(a){if(null!== -z){ba(da);var b=a-O+E;bb&&(b=8),E=bb?va.postMessage(void 0):D||(D=!0,ba(da))};S=function(){z=null;N=!1;C=-1}}var Ya=0,Za=0,m=null,u=null;m={current:new Set};u={current:null};var q=null;q=new Set;var pa={current:null},U={current:null};g={ReactCurrentDispatcher:pa,ReactCurrentOwner:U,assign:M};M(g,{Scheduler:{unstable_cancelCallback:function(a){var b=a.next;if(null!==b){if(b===a)f=null;else{a===f&& -(f=b);var c=a.previous;c.next=b;b.previous=c}a.next=a.previous=null}},unstable_shouldYield:function(){return!J&&(null!==f&&f.expirationTimeb){c=d;break}d=d.next}while(d!==f);null===c?c=f:c===f&&(f=a,x());b=c.previous;b.next=c.previous=a;a.next=c;a.previous=b}return a},unstable_runWithPriority:function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=k,d=n;k=a;n=p();try{return b()}finally{k=c,n=d,I()}},unstable_next:function(a){switch(k){case 1:case 2:case 3:var b=3;break;default:b=k}var c=k,d=n;k=b;n=p();try{return a()}finally{k=c,n=d,I()}}, -unstable_wrapCallback:function(a){var b=k;return function(){var c=k,d=n;k=b;n=p();try{return a.apply(this,arguments)}finally{k=c,n=d,I()}}},unstable_getFirstCallbackNode:function(){return f},unstable_pauseExecution:function(){},unstable_continueExecution:function(){null!==f&&x()},unstable_getCurrentPriorityLevel:function(){return k},unstable_IdlePriority:5,unstable_ImmediatePriority:1,unstable_LowPriority:4,unstable_NormalPriority:3,unstable_UserBlockingPriority:2},SchedulerTracing:{__interactionsRef:m, -__subscriberRef:u,unstable_clear:function(a){var b=m.current;m.current=new Set;try{return a()}finally{m.current=b}},unstable_getCurrent:function(){return m.current},unstable_getThreadID:function(){return++Za},unstable_subscribe:function(a){q.add(a);1===q.size&&(u.current={onInteractionScheduledWorkCompleted:za,onInteractionTraced:ya,onWorkCanceled:Da,onWorkScheduled:Aa,onWorkStarted:Ba,onWorkStopped:Ca})},unstable_trace:function(a,b,c){var d=3L.length&&L.push(a)}function Y(a,b,c,d){var e=typeof a;if("undefined"===e||"boolean"===e)a=null;var f=!1;if(null===a)f=!0;else switch(e){case "string":case "number":f=!0;break;case "object":switch(a.$$typeof){case F:case Ra:f=!0}}if(f)return c(d,a,""===b?"."+Z(a,0):b),1;f=0;b=""===b?".":b+":";if(Array.isArray(a))for(var k=0;kM(k,c))void 0!==q&&0>M(q,k)?(a[d]=q,a[g]=c,d=g):(a[d]=k,a[f]=c,d=f);else if(void 0!==q&&0>M(q,c))a[d]=q,a[g]=c,d=g;else break a}}return b}return null}function M(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}function z(a){if(null!==r){var b=G;G+=a.length; +if(G+1>D){D*=2;if(524288b)||a&&!ia());){var d=h.callback;if(null!==d){h.callback=null;n=h.priorityLevel;var e=h.expirationTime<=b,f=h,k=b;R++;m[0]=f.priorityLevel;m[1]=f.id;m[2]=R;null!==r&&z([5,1E3*k,f.id,R]);var g=d(e);b=t();"function"===typeof g?(h.callback=g,f=h,k=b,m[0]=0,m[1]= +0,m[2]=0,null!==r&&z([6,1E3*k,f.id,R])):(f=h,k=b,m[0]=0,m[1]=0,m[3]--,null!==r&&z([2,1E3*k,f.id]),h.isQueued=!1,h===u(v)&&N(v));O(b)}else N(v);h=u(v)}if(null!==h)var q=!0;else{var l=u(A);null!==l&&P(da,l.startTime-b);q=!1}return q}catch(Ua){if(null!==h){var p=t();a=h;m[0]=0;m[1]=0;m[3]--;null!==r&&z([3,1E3*p,a.id]);h.isQueued=!1}throw Ua;}}finally{h=null,n=c,Q=!1,c=t(),fa++,null!==r&&z([7,1E3*c,fa])}}function Ca(a){switch(a){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4; +default:return 5E3}}function Va(a){var b=!1,c=null;w.forEach(function(d){try{d.onInteractionTraced(a)}catch(e){b||(b=!0,c=e)}});if(b)throw c;}function Wa(a){var b=!1,c=null;w.forEach(function(d){try{d.onInteractionScheduledWorkCompleted(a)}catch(e){b||(b=!0,c=e)}});if(b)throw c;}function Xa(a,b){var c=!1,d=null;w.forEach(function(e){try{e.onWorkScheduled(a,b)}catch(f){c||(c=!0,d=f)}});if(c)throw d;}function Ya(a,b){var c=!1,d=null;w.forEach(function(e){try{e.onWorkStarted(a,b)}catch(f){c||(c=!0,d= +f)}});if(c)throw d;}function Za(a,b){var c=!1,d=null;w.forEach(function(e){try{e.onWorkStopped(a,b)}catch(f){c||(c=!0,d=f)}});if(c)throw d;}function $a(a,b){var c=!1,d=null;w.forEach(function(e){try{e.onWorkCanceled(a,b)}catch(f){c||(c=!0,d=f)}});if(c)throw d;}var l="function"===typeof Symbol&&Symbol.for,F=l?Symbol.for("react.element"):60103,Ra=l?Symbol.for("react.portal"):60106,ab=l?Symbol.for("react.fragment"):60107,bb=l?Symbol.for("react.strict_mode"):60108,cb=l?Symbol.for("react.profiler"):60114, +db=l?Symbol.for("react.provider"):60109,eb=l?Symbol.for("react.context"):60110,fb=l?Symbol.for("react.forward_ref"):60112,gb=l?Symbol.for("react.suspense"):60113;l&&Symbol.for("react.suspense_list");var hb=l?Symbol.for("react.memo"):60115,ib=l?Symbol.for("react.lazy"):60116;l&&Symbol.for("react.fundamental");l&&Symbol.for("react.responder");l&&Symbol.for("react.scope");var xa="function"===typeof Symbol&&Symbol.iterator,Da=Object.getOwnPropertySymbols,jb=Object.prototype.hasOwnProperty,kb=Object.prototype.propertyIsEnumerable, +S=function(){try{if(!Object.assign)return!1;var a=new String("abc");a[5]="de";if("5"===Object.getOwnPropertyNames(a)[0])return!1;var b={};for(a=0;10>a;a++)b["_"+String.fromCharCode(a)]=a;if("0123456789"!==Object.getOwnPropertyNames(b).map(function(a){return b[a]}).join(""))return!1;var c={};"abcdefghijklmnopqrst".split("").forEach(function(a){c[a]=a});return"abcdefghijklmnopqrst"!==Object.keys(Object.assign({},c)).join("")?!1:!0}catch(d){return!1}}()?Object.assign:function(a,b){if(null===a||void 0=== +a)throw new TypeError("Object.assign cannot be called with null or undefined");var c=Object(a);for(var d,e=1;e=Ja};Ga=function(){};ka=function(a){0>a||125d?(a.sortIndex=e,ca(A,a),null===u(v)&&a===u(A)&&(I?ha():I=!0,P(da,e-d))):(a.sortIndex=c,ca(v,a),Ba(a,d),a.isQueued=!0,E||Q||(E=!0,J(ea)));return a},unstable_cancelCallback:function(a){if(a.isQueued){var b=t();m[3]--;null!==r&&z([4,1E3*b,a.id]);a.isQueued=!1}a.callback=null},unstable_wrapCallback:function(a){var b=n;return function(){var c=n;n=b;try{return a.apply(this, +arguments)}finally{n=c}}},unstable_getCurrentPriorityLevel:function(){return n},unstable_shouldYield:function(){var a=t();O(a);var b=u(v);return b!==h&&null!==h&&null!==b&&null!==b.callback&&b.startTime<=a&&b.expirationTime or --tests=. -gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests. -gulp lint # Runs tslint on the TypeScript source. -gulp help # List the above commands. +gulp local # Build the compiler into built/local. +gulp clean # Delete the built compiler. +gulp LKG # Replace the last known good with the built one. + # Bootstrapping step to be executed when the built compiler reaches a stable state. +gulp tests # Build the test infrastructure using the built compiler. +gulp runtests # Run tests using the built compiler and test infrastructure. + # Some low-value tests are skipped when not on a CI machine - you can use the + # --skipPercent=0 command to override this behavior and run all tests locally. + # You can override the specific suite runner used or specify a test for this command. + # Use --tests= for a specific test and/or --runner= for a specific suite. + # Valid runners include conformance, compiler, fourslash, project, user, and docker + # The user and docker runners are extended test suite runners - the user runner + # works on disk in the tests/cases/user directory, while the docker runner works in containers. + # You'll need to have the docker executable in your system path for the docker runner to work. +gulp runtests-parallel # Like runtests, but split across multiple threads. Uses a number of threads equal to the system + # core count by default. Use --workers= to adjust this. +gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests. +gulp lint # Runs eslint on the TypeScript source. +gulp help # List the above commands. ``` @@ -96,4 +104,4 @@ node built/local/tsc.js hello.ts ## Roadmap -For details on our planned features and future direction please refer to our [roadmap](https://github.com/Microsoft/TypeScript/wiki/Roadmap). +For details on our planned features and future direction please refer to our [roadmap](https://github.com/microsoft/TypeScript/wiki/Roadmap). diff --git a/node_modules/typescript/lib/cs/diagnosticMessages.generated.json b/node_modules/typescript/lib/cs/diagnosticMessages.generated.json index 32a067f4f..fabd59da8 100644 --- a/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/cs/diagnosticMessages.generated.json @@ -441,7 +441,7 @@ "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391": "Implementace funkce chybí nebo nenásleduje hned po deklaraci.", "Function_implementation_name_must_be_0_2389": "Název implementace funkce musí být {0}.", "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024": "Funkce implicitně obsahuje návratový typ any, protože neobsahuje anotaci návratového typu a odkazuje se na ni přímo nebo nepřímo v jednom z jejích návratových výrazů.", - "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "Ve funkci chybí koncový návratový příkaz a návratový typ neobsahuje undefined.", + "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "Ve funkci chybí koncový příkaz return a návratový typ neobsahuje undefined.", "Function_overload_must_be_static_2387": "Přetížení funkce musí být statické.", "Function_overload_must_not_be_static_2388": "Přetížení funkce nesmí být statické.", "Generate_get_and_set_accessors_95046": "Generovat přístupové objekty get a set", diff --git a/node_modules/typescript/lib/de/diagnosticMessages.generated.json b/node_modules/typescript/lib/de/diagnosticMessages.generated.json index f7bf53b67..d010e9503 100644 --- a/node_modules/typescript/lib/de/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/de/diagnosticMessages.generated.json @@ -1032,7 +1032,7 @@ "await_expression_is_only_allowed_within_an_async_function_1308": "Der Ausdruck \"await\" ist nur in einer asynchronen Funktion zulässig.", "await_expressions_cannot_be_used_in_a_parameter_initializer_2524": "await-Ausdrücke dürfen nicht in einem Parameterinitialisierer verwendet werden.", "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106": "Die Option \"baseUrl\" ist auf \"{0}\" festgelegt. Dieser Wert wird verwendet, um den nicht relativen Modulnamen \"{1}\" aufzulösen.", - "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312": "\"=\" kann nur in einer Objektliteraleigenschaft innerhalb eines Destrukturierungsauftrags verwendet werden.", + "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312": "\"=\" kann nur in einer Objektliteraleigenschaft innerhalb eines Destrukturierungszuweisung verwendet werden.", "case_or_default_expected_1130": "\"case\" oder \"default\" wurde erwartet.", "class_expressions_are_not_currently_supported_9003": "class-Ausdrücke werden zurzeit nicht unterstützt.", "const_declarations_can_only_be_declared_inside_a_block_1156": "const-Deklarationen können nur innerhalb eines Blocks deklariert werden.", diff --git a/node_modules/typescript/lib/es/diagnosticMessages.generated.json b/node_modules/typescript/lib/es/diagnosticMessages.generated.json index 52840b120..c0ce6ef5b 100644 --- a/node_modules/typescript/lib/es/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/es/diagnosticMessages.generated.json @@ -441,7 +441,7 @@ "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391": "Falta la implementación de función o no sigue inmediatamente a la declaración.", "Function_implementation_name_must_be_0_2389": "El nombre de la implementación de función debe ser '{0}'.", "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024": "La función tiene el tipo de valor devuelto \"any\" implícitamente porque no tiene una anotación de tipo de valor devuelto y se hace referencia a ella directa o indirectamente en una de sus expresiones return.", - "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "Falta la instrucción return final en la función y el tipo de valor devuelto no incluye 'undefined'.", + "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "Falta la instrucción \"return\" final en la función y el tipo de valor devuelto no incluye 'undefined'.", "Function_overload_must_be_static_2387": "La sobrecarga de función debe ser estática.", "Function_overload_must_not_be_static_2388": "La sobrecarga de función no debe ser estática.", "Generate_get_and_set_accessors_95046": "Generar los descriptores de acceso \"get\" y \"set\"", @@ -453,7 +453,7 @@ "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220": "Los generadores solo están disponibles cuando el destino es ECMAScript 2015 o una versión posterior.", "Generic_type_0_requires_1_type_argument_s_2314": "El tipo genérico '{0}' requiere los siguientes argumentos de tipo: {1}.", "Generic_type_0_requires_between_1_and_2_type_arguments_2707": "El tipo genérico \"{0}\" requiere entre {1} y {2} argumentos de tipo.", - "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550": "La creación de instancias de tipo genérico es excesivamente profunda y posiblemente infinita.", + "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550": "La creación de una instancia de tipo genérico es excesivamente profunda y posiblemente infinita.", "Getter_and_setter_accessors_do_not_agree_in_visibility_2379": "Los descriptores de acceso de captador y establecedor no se corresponden respecto a la visibilidad.", "Global_module_exports_may_only_appear_at_top_level_1316": "Las exportaciones de módulos globales solo pueden aparecer en el nivel superior.", "Global_module_exports_may_only_appear_in_declaration_files_1315": "Las exportaciones de módulos globales solo pueden aparecer en archivos de declaración.", diff --git a/node_modules/typescript/lib/fr/diagnosticMessages.generated.json b/node_modules/typescript/lib/fr/diagnosticMessages.generated.json index 1699b44df..7a84aae49 100644 --- a/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/fr/diagnosticMessages.generated.json @@ -142,7 +142,7 @@ "An_async_iterator_must_have_a_next_method_2519": "Un itérateur asynchrone doit comporter une méthode 'next()'.", "An_element_access_expression_should_take_an_argument_1011": "Une expression d'accès à un élément doit accepter un argument.", "An_enum_member_cannot_have_a_numeric_name_2452": "Un membre enum ne peut pas avoir un nom numérique.", - "An_export_assignment_can_only_be_used_in_a_module_1231": "Une attribution d'exportation peut uniquement être utilisée dans un module.", + "An_export_assignment_can_only_be_used_in_a_module_1231": "Une affectation d'exportation peut uniquement être utilisée dans un module.", "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309": "Impossible d'utiliser une assignation d'exportation dans un module comportant d'autres éléments exportés.", "An_export_assignment_cannot_be_used_in_a_namespace_1063": "Une affectation d'exportation ne peut pas être utilisée dans un espace de noms.", "An_export_assignment_cannot_have_modifiers_1120": "Une assignation d'exportation ne peut pas avoir de modificateurs.", @@ -594,7 +594,7 @@ "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003": "Aucune entrée dans le fichier config '{0}'. Les chemins 'include' spécifiés étaient '{1}' et les chemins 'exclude' étaient '{2}'.", "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515": "La classe non abstraite '{0}' n'implémente pas le membre abstrait '{1}' hérité de la classe '{2}'.", "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653": "L'expression de classe non abstraite '{0}' n'implémente pas le membre abstrait hérité '{0}' de la classe '{1}'.", - "Not_all_code_paths_return_a_value_7030": "Les chemins de code ne retournent pas tous une valeur.", + "Not_all_code_paths_return_a_value_7030": "Les chemins du code ne retournent pas tous une valeur.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "Impossible d'assigner le type d'index numérique '{0}' au type d'index de chaîne '{1}'.", "Numeric_separators_are_not_allowed_here_6188": "Les séparateurs numériques ne sont pas autorisés ici.", "Object_is_of_type_unknown_2571": "L'objet est de type 'unknown'.", @@ -745,7 +745,7 @@ "Remove_unused_label_95053": "Supprimer l'étiquette inutilisée", "Remove_variable_statement_90010": "Supprimer l'instruction de variable", "Replace_import_with_0_95015": "Remplacez l'importation par '{0}'.", - "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Signalez une erreur quand les chemins de code de la fonction ne retournent pas tous une valeur.", + "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Signalez une erreur quand les chemins du code de la fonction ne retournent pas tous une valeur.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Signalez les erreurs pour les case avec fallthrough dans une instruction switch.", "Report_errors_in_js_files_8019": "Signalez les erreurs dans les fichiers .js.", "Report_errors_on_unused_locals_6134": "Signaler les erreurs sur les variables locales inutilisées.", diff --git a/node_modules/typescript/lib/ja/diagnosticMessages.generated.json b/node_modules/typescript/lib/ja/diagnosticMessages.generated.json index d3029982c..751357dbc 100644 --- a/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/ja/diagnosticMessages.generated.json @@ -130,7 +130,7 @@ "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "'--isolatedModules' フラグが指定されている場合、アンビエント const 列挙型は使用できません。", "Ambient_module_declaration_cannot_specify_relative_module_name_2436": "アンビエント モジュール宣言では、相対モジュール名を指定できません。", "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435": "アンビエント モジュールを、他のモジュールまたは名前空間内の入れ子にすることはできません。", - "An_AMD_module_cannot_have_multiple_name_assignments_2458": "AMD モジュールに複数の名前を割り当てることはできません。", + "An_AMD_module_cannot_have_multiple_name_assignments_2458": "AMD モジュールに複数の名前を代入することはできません。", "An_abstract_accessor_cannot_have_an_implementation_1318": "抽象アクセサーに実装を含めることはできません。", "An_accessor_cannot_be_declared_in_an_ambient_context_1086": "環境コンテキストではアクセサーは宣言できません。", "An_accessor_cannot_have_type_parameters_1094": "アクセサーに型パラメーターを指定することはできません。", @@ -142,10 +142,10 @@ "An_async_iterator_must_have_a_next_method_2519": "非同期反復子には 'next()' メソッドが必要です。", "An_element_access_expression_should_take_an_argument_1011": "要素アクセス式では、引数を取る必要があります。", "An_enum_member_cannot_have_a_numeric_name_2452": "列挙型メンバーに数値名を含めることはできません。", - "An_export_assignment_can_only_be_used_in_a_module_1231": "エクスポートの割り当てはモジュールでのみ使用可能です。", - "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309": "エクスポートの割り当ては、エクスポートされた他の要素を含むモジュールでは使用できません。", - "An_export_assignment_cannot_be_used_in_a_namespace_1063": "エクスポートの割り当ては、名前空間では使用できません。", - "An_export_assignment_cannot_have_modifiers_1120": "エクスポートの割り当てに修飾子を指定することはできません。", + "An_export_assignment_can_only_be_used_in_a_module_1231": "エクスポートの代入はモジュールでのみ使用可能です。", + "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309": "エクスポートの代入は、エクスポートされた他の要素を含むモジュールでは使用できません。", + "An_export_assignment_cannot_be_used_in_a_namespace_1063": "エクスポートの代入は、名前空間では使用できません。", + "An_export_assignment_cannot_have_modifiers_1120": "エクスポートの代入に修飾子を指定することはできません。", "An_export_declaration_can_only_be_used_in_a_module_1233": "エクスポート宣言はモジュールでのみ使用可能です。", "An_export_declaration_cannot_have_modifiers_1193": "エクスポート宣言に修飾子を指定することはできません。", "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198": "拡張された Unicode エスケープ値は 0x0 と 0x10FFFF の間 (両端を含む) でなければなりません。", @@ -389,8 +389,8 @@ "Experimental_Options_6177": "試験的なオプション", "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219": "デコレーターの実験的なサポートは将来のリリースで変更になる可能性がある機能です。'experimentalDecorators' オプションを設定してこの警告を削除します。", "Explicitly_specified_module_resolution_kind_Colon_0_6087": "明示的に指定されたモジュール解決の種類 '{0}'。", - "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203": "ECMAScript モジュールを対象にする場合は、エクスポート割り当てを使用できません。代わりに 'export default' または別のモジュール書式の使用をご検討ください。", - "Export_assignment_is_not_supported_when_module_flag_is_system_1218": "割り当てのエクスポートは、'--module' フラグが 'system' の場合にはサポートされません。", + "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203": "ECMAScript モジュールを対象にする場合は、エクスポート代入を使用できません。代わりに 'export default' または別のモジュール書式の使用をご検討ください。", + "Export_assignment_is_not_supported_when_module_flag_is_system_1218": "代入のエクスポートは、'--module' フラグが 'system' の場合にはサポートされません。", "Export_declaration_conflicts_with_exported_declaration_of_0_2484": "エクスポート宣言が、'{0}' のエクスポートされた宣言と競合しています。", "Export_declarations_are_not_permitted_in_a_namespace_1194": "エクスポート宣言は名前空間でサポートされません。", "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656": "エクスポートされた外部パッケージの型指定のファイル '{0}' はモジュールではありません。パッケージ定義を更新する場合は、パッケージの作成者にお問い合わせください。", @@ -399,7 +399,7 @@ "Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4023": "エクスポートされた変数 '{0}' が外部モジュール {2} の名前 '{1}' を持っているか使用していますが、名前を指定することはできません。", "Exported_variable_0_has_or_is_using_name_1_from_private_module_2_4024": "エクスポートされた変数 '{0}' がプライベート モジュール '{2}' の名前 '{1}' を持っているか、使用しています。", "Exported_variable_0_has_or_is_using_private_name_1_4025": "エクスポートされた変数 '{0}' がプライベート名 '{1}' を持っているか、使用しています。", - "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666": "エクスポートとエクスポートの割り当てはモジュールの拡張では許可されていません。", + "Exports_and_export_assignments_are_not_permitted_in_module_augmentations_2666": "エクスポートとエクスポートの代入はモジュールの拡張では許可されていません。", "Expression_expected_1109": "式が必要です。", "Expression_or_comma_expected_1137": "式またはコンマが必要です。", "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402": "式は、コンパイラが基底クラスの参照をキャプチャするために使用する '_super' に解決されます。", @@ -473,7 +473,7 @@ "Implement_interface_0_90006": "インターフェイス '{0}' を実装する", "Implements_clause_of_exported_class_0_has_or_is_using_private_name_1_4019": "エクスポートされたクラス '{0}' の Implements 句がプライベート名 '{1}' を持っているか、使用しています。", "Import_0_from_module_1_90013": "モジュール \"{1}\" から '{0}' をインポートする", - "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202": "ECMAScript モジュールを対象にする場合は、インポート割り当てを使用できません。代わりに 'import * as ns from \"mod\"'、'import {a} from \"mod\"'、'import d from \"mod\"' などのモジュール書式の使用をご検討ください。", + "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202": "ECMAScript モジュールを対象にする場合は、インポート代入を使用できません。代わりに 'import * as ns from \"mod\"'、'import {a} from \"mod\"'、'import d from \"mod\"' などのモジュール書式の使用をご検討ください。", "Import_declaration_0_is_using_private_name_1_4000": "インポート宣言 '{0}' がプライベート名 '{1}' を使用しています。", "Import_declaration_conflicts_with_local_declaration_of_0_2440": "インポート宣言が、'{0}' のローカル宣言と競合しています。", "Import_declarations_in_a_namespace_cannot_reference_a_module_1147": "名前空間内のインポート宣言は、モジュールを参照できません。", @@ -536,7 +536,7 @@ "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001": "JSX 要素に同じ名前の複数の属性を指定することはできません。", "JSX_expressions_must_have_one_parent_element_2657": "JSX 式には 1 つの親要素が必要です。", "JSX_fragment_has_no_corresponding_closing_tag_17014": "JSX フラグメントには対応する終了タグがありません。", - "JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma_17017": "JSX フラグメントはインライン JSX ファクトリ プラグマの使用時にサポートされていません", + "JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma_17017": "JSX フラグメントはインライン JSX ファクトリ pragma の使用時にサポートされていません", "JSX_fragment_is_not_supported_when_using_jsxFactory_17016": "--jsxFactory を使う場合、JSX フラグメントはサポートされません", "JSX_spread_child_must_be_an_array_type_2609": "JSX スプレッドの子は、配列型でなければなりません。", "Jump_target_cannot_cross_function_boundary_1107": "ジャンプ先は関数の境界を越えることはできません。", @@ -714,7 +714,7 @@ "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033": "エクスポートされたインターフェイスのプロパティ '{0}' が、プライベート名 '{1}' を持っているか、使用しています。", "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412": "型 '{1}' のプロパティ '{0}' を数値インデックス型 '{2}' に割り当てることはできません。", "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411": "型 '{1}' のプロパティ '{0}' を文字列インデックス型 '{2}' に割り当てることはできません。", - "Property_assignment_expected_1136": "プロパティの割り当てが必要です。", + "Property_assignment_expected_1136": "プロパティの代入が必要です。", "Property_destructuring_pattern_expected_1180": "プロパティの非構造化パターンが必要です。", "Property_or_signature_expected_1131": "プロパティまたはシグネチャが必要です。", "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328": "プロパティ値には、文字列リテラル、数値リテラル、'true'、'false'、'null'、オブジェクト リテラルまたは配列リテラルのみ使用できます。", @@ -850,7 +850,7 @@ "The_character_set_of_the_input_files_6163": "入力ファイルの文字セット。", "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563": "含まれている関数またはモジュールの本体は、制御フロー解析には大きすぎます。", "The_current_host_does_not_support_the_0_option_5001": "現在のホストは '{0}' オプションをサポートしていません。", - "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714": "エクスポートの割り当ての式は、環境コンテキストの識別子または修飾名にする必要があります。", + "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714": "エクスポートの代入の式は、環境コンテキストの識別子または修飾名にする必要があります。", "The_files_list_in_config_file_0_is_empty_18002": "構成ファイル '{0}' の 'files' リストが空です。", "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "Promise では、'then' メソッドの最初のパラメーターはコールバックでなければなりません。", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "グローバル型 'JSX.{0}' には複数のプロパティが含まれていない可能性があります。", @@ -882,7 +882,7 @@ "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359": "instanceof' 式の右辺には、'any' 型、または 'Function' インターフェイス型に割り当てることができる型を指定してください。", "The_specified_path_does_not_exist_Colon_0_5058": "指定されたパスがありません: '{0}'。", "The_target_of_an_assignment_must_be_a_variable_or_a_property_access_2541": "代入式のターゲットは、変数またはプロパティ アクセスである必要があります。", - "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701": "オブジェクトの残り部分の割り当ての対象は、変数またはプロパティ アクセスである必要があります。", + "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701": "オブジェクトの残り部分の代入の対象は、変数またはプロパティ アクセスである必要があります。", "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684": "型 '{0}' の 'this' コンテキストを型 '{1}' のメソッドの 'this' に割り当てることはできません。", "The_this_types_of_each_signature_are_incompatible_2685": "各シグネチャの 'this' 型に互換性がありません。", "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453": "型パラメーター '{0}' の型引数を使用法から推論することはできません。型引数を明示的に指定してください。", @@ -1032,14 +1032,14 @@ "await_expression_is_only_allowed_within_an_async_function_1308": "'await' 式は、非同期関数内でのみ使用できます。", "await_expressions_cannot_be_used_in_a_parameter_initializer_2524": "'await' 式は、パラメーター初期化子では使用できません。", "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106": "'baseUrl' オプションは '{0}' に設定され、この値を使用して非相対モジュール名 '{1}' を解決します。", - "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312": "'=' は、非構造化割り当て内のオブジェクト リテラル プロパティでのみ使用できます。", + "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312": "'=' は、非構造化代入内のオブジェクト リテラル プロパティでのみ使用できます。", "case_or_default_expected_1130": "'case' または 'default' が必要です。", "class_expressions_are_not_currently_supported_9003": "'class' 式は現在サポートされていません。", "const_declarations_can_only_be_declared_inside_a_block_1156": "'const' 宣言は、ブロック内でのみ宣言できます。", "const_declarations_must_be_initialized_1155": "'const' 宣言は初期化する必要があります。", "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477": "'const' 列挙型メンバーの初期化子が、無限値に評価されました。", "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478": "'const' 列挙型メンバーの初期化子が、許可されない値 'NaN' に評価されました。", - "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475": "'const' 列挙型は、プロパティまたはインデックスのアクセス式、インポート宣言またはエクスポートの割り当ての右辺、型のクエリにのみ使用できます。", + "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475": "'const' 列挙型は、プロパティまたはインデックスのアクセス式、インポート宣言またはエクスポートの代入の右辺、型のクエリにのみ使用できます。", "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102": "厳格モードでは 'delete' を識別子で呼び出すことはできません。", "delete_this_Project_0_is_up_to_date_because_it_was_previously_built_6360": "これを削除します - プロジェクト '{0}' は、以前にビルドされているため、最新の状態です", "enum_declarations_can_only_be_used_in_a_ts_file_8015": "'列挙型宣言' を使用できるのは .ts ファイル内のみです。", diff --git a/node_modules/typescript/lib/ko/diagnosticMessages.generated.json b/node_modules/typescript/lib/ko/diagnosticMessages.generated.json index abda4ace9..fb77b68ac 100644 --- a/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/ko/diagnosticMessages.generated.json @@ -885,7 +885,7 @@ "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701": "개체 rest 할당의 대상은 변수 또는 속성 액세스여야 합니다.", "The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1_2684": "'{0}' 형식의 'this' 컨텍스트를 메서드의 '{1}' 형식 'this'에 할당할 수 없습니다.", "The_this_types_of_each_signature_are_incompatible_2685": "각 시그니처의 'this' 형식이 호환되지 않습니다.", - "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453": "형식 매개 변수 '{0}'의 형식 인수를 유추할 수 없습니다. 형식 인수를 명시적으로 지정하세요.", + "The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_typ_2453": "사용량에서 형식 매개 변수 '{0}'의 형식 인수를 유추할 수 없습니다. 형식 인수를 명시적으로 지정하세요.", "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547": "비동기 반복기의 'next()' 메서드에서 반환하는 형식은 'value' 속성이 있는 형식에 대한 프라미스여야 합니다.", "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490": "반복기의 'next()' 메서드에 의해 반환되는 형식에는 'value' 속성이 있어야 합니다.", "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189": "'for...in' 문의 변수 선언에 이니셜라이저가 포함될 수 없습니다.", @@ -1067,7 +1067,7 @@ "or_expected_1144": "'{' 또는 ';'이(가) 필요합니다.", "package_json_does_not_have_a_0_field_6100": "'package.json'에는 '{0}' 필드가 없습니다.", "package_json_has_0_field_1_that_references_2_6101": "'package.json'에 '{2}'을(를) 참조하는 '{0}' 필드 '{1}'이(가) 있습니다.", - "parameter_modifiers_can_only_be_used_in_a_ts_file_8012": "'parameter modifiers'는 .ts 파일에서만 사용할 수 있습니다.", + "parameter_modifiers_can_only_be_used_in_a_ts_file_8012": "'매개 변수 한정자'는 .ts 파일에서만 사용할 수 있습니다.", "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091": "'paths' 옵션이 지정되었습니다. 모듈 이름 '{0}'과(와) 일치하는 패턴을 찾는 중입니다.", "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024": "'readonly' 한정자는 속성 선언 또는 인덱스 시그니처에만 나타날 수 있습니다.", "require_call_may_be_converted_to_an_import_80005": "'require' 호출이 가져오기로 변환될 수 있습니다.", diff --git a/node_modules/typescript/lib/lib.dom.d.ts b/node_modules/typescript/lib/lib.dom.d.ts index ffb28f244..124a08590 100644 --- a/node_modules/typescript/lib/lib.dom.d.ts +++ b/node_modules/typescript/lib/lib.dom.d.ts @@ -2750,7 +2750,7 @@ interface CSSStyleDeclaration { alignContent: string; alignItems: string; alignSelf: string; - alignmentBaseline: string | null; + alignmentBaseline: string; animation: string; animationDelay: string; animationDirection: string; @@ -2760,65 +2760,83 @@ interface CSSStyleDeclaration { animationName: string; animationPlayState: string; animationTimingFunction: string; - backfaceVisibility: string | null; - background: string | null; - backgroundAttachment: string | null; - backgroundClip: string | null; - backgroundColor: string | null; - backgroundImage: string | null; - backgroundOrigin: string | null; - backgroundPosition: string | null; - backgroundPositionX: string | null; - backgroundPositionY: string | null; - backgroundRepeat: string | null; - backgroundSize: string | null; - baselineShift: string | null; - border: string | null; - borderBottom: string | null; - borderBottomColor: string | null; - borderBottomLeftRadius: string | null; - borderBottomRightRadius: string | null; - borderBottomStyle: string | null; - borderBottomWidth: string | null; - borderCollapse: string | null; - borderColor: string | null; - borderImage: string | null; - borderImageOutset: string | null; - borderImageRepeat: string | null; - borderImageSlice: string | null; - borderImageSource: string | null; - borderImageWidth: string | null; - borderLeft: string | null; - borderLeftColor: string | null; - borderLeftStyle: string | null; - borderLeftWidth: string | null; - borderRadius: string | null; - borderRight: string | null; - borderRightColor: string | null; - borderRightStyle: string | null; - borderRightWidth: string | null; - borderSpacing: string | null; - borderStyle: string | null; - borderTop: string | null; - borderTopColor: string | null; - borderTopLeftRadius: string | null; - borderTopRightRadius: string | null; - borderTopStyle: string | null; - borderTopWidth: string | null; - borderWidth: string | null; - bottom: string | null; - boxShadow: string | null; + backfaceVisibility: string; + background: string; + backgroundAttachment: string; + backgroundClip: string; + backgroundColor: string; + backgroundImage: string; + backgroundOrigin: string; + backgroundPosition: string; + backgroundPositionX: string; + backgroundPositionY: string; + backgroundRepeat: string; + backgroundSize: string; + baselineShift: string; + blockSize: string; + border: string; + borderBlockEnd: string; + borderBlockEndColor: string; + borderBlockEndStyle: string; + borderBlockEndWidth: string; + borderBlockStart: string; + borderBlockStartColor: string; + borderBlockStartStyle: string; + borderBlockStartWidth: string; + borderBottom: string; + borderBottomColor: string; + borderBottomLeftRadius: string; + borderBottomRightRadius: string; + borderBottomStyle: string; + borderBottomWidth: string; + borderCollapse: string; + borderColor: string; + borderImage: string; + borderImageOutset: string; + borderImageRepeat: string; + borderImageSlice: string; + borderImageSource: string; + borderImageWidth: string; + borderInlineEnd: string; + borderInlineEndColor: string; + borderInlineEndStyle: string; + borderInlineEndWidth: string; + borderInlineStart: string; + borderInlineStartColor: string; + borderInlineStartStyle: string; + borderInlineStartWidth: string; + borderLeft: string; + borderLeftColor: string; + borderLeftStyle: string; + borderLeftWidth: string; + borderRadius: string; + borderRight: string; + borderRightColor: string; + borderRightStyle: string; + borderRightWidth: string; + borderSpacing: string; + borderStyle: string; + borderTop: string; + borderTopColor: string; + borderTopLeftRadius: string; + borderTopRightRadius: string; + borderTopStyle: string; + borderTopWidth: string; + borderWidth: string; + bottom: string; + boxShadow: string; boxSizing: string; - breakAfter: string | null; - breakBefore: string | null; - breakInside: string | null; - captionSide: string | null; + breakAfter: string; + breakBefore: string; + breakInside: string; + captionSide: string; caretColor: string; - clear: string | null; + clear: string; clip: string; clipPath: string; clipRule: string; color: string | null; + colorInterpolation: string; colorInterpolationFilters: string; columnCount: string; columnFill: string; @@ -2830,28 +2848,29 @@ interface CSSStyleDeclaration { columnSpan: string; columnWidth: string; columns: string; - content: string | null; - counterIncrement: string | null; - counterReset: string | null; + content: string; + counterIncrement: string; + counterReset: string; cssFloat: string | null; cssText: string; cursor: string; direction: string; - display: string | null; - dominantBaseline: string | null; - emptyCells: string | null; + display: string; + dominantBaseline: string; + emptyCells: string; enableBackground: string | null; - fill: string | null; - fillOpacity: string | null; - fillRule: string | null; + fill: string; + fillOpacity: string; + fillRule: string; filter: string; - flex: string | null; - flexBasis: string | null; - flexDirection: string | null; - flexFlow: string | null; - flexGrow: string | null; - flexShrink: string | null; - flexWrap: string | null; + flex: string; + flexBasis: string; + flexDirection: string; + flexFlow: string; + flexGrow: string; + flexShrink: string; + flexWrap: string; + float: string; floodColor: string; floodOpacity: string; font: string; @@ -2873,29 +2892,30 @@ interface CSSStyleDeclaration { gap: string; glyphOrientationHorizontal: string | null; glyphOrientationVertical: string; - grid: string | null; - gridArea: string | null; - gridAutoColumns: string | null; - gridAutoFlow: string | null; - gridAutoRows: string | null; - gridColumn: string | null; - gridColumnEnd: string | null; + grid: string; + gridArea: string; + gridAutoColumns: string; + gridAutoFlow: string; + gridAutoRows: string; + gridColumn: string; + gridColumnEnd: string; gridColumnGap: string; - gridColumnStart: string | null; + gridColumnStart: string; gridGap: string; - gridRow: string | null; - gridRowEnd: string | null; + gridRow: string; + gridRowEnd: string; gridRowGap: string; - gridRowStart: string | null; - gridTemplate: string | null; - gridTemplateAreas: string | null; - gridTemplateColumns: string | null; - gridTemplateRows: string | null; - height: string | null; + gridRowStart: string; + gridTemplate: string; + gridTemplateAreas: string; + gridTemplateColumns: string; + gridTemplateRows: string; + height: string; hyphens: string; imageOrientation: string; imageRendering: string; imeMode: string | null; + inlineSize: string; justifyContent: string; justifyItems: string; justifySelf: string; @@ -2905,25 +2925,29 @@ interface CSSStyleDeclaration { layoutGridLine: string | null; layoutGridMode: string | null; layoutGridType: string | null; - left: string | null; + left: string; readonly length: number; letterSpacing: string; lightingColor: string; lineBreak: string; - lineHeight: string | null; - listStyle: string | null; - listStyleImage: string | null; - listStylePosition: string | null; - listStyleType: string | null; - margin: string | null; - marginBottom: string | null; - marginLeft: string | null; - marginRight: string | null; - marginTop: string | null; - marker: string | null; - markerEnd: string | null; - markerMid: string | null; - markerStart: string | null; + lineHeight: string; + listStyle: string; + listStyleImage: string; + listStylePosition: string; + listStyleType: string; + margin: string; + marginBlockEnd: string; + marginBlockStart: string; + marginBottom: string; + marginInlineEnd: string; + marginInlineStart: string; + marginLeft: string; + marginRight: string; + marginTop: string; + marker: string; + markerEnd: string; + markerMid: string; + markerStart: string; mask: string; maskComposite: string; maskImage: string; @@ -2931,10 +2955,14 @@ interface CSSStyleDeclaration { maskRepeat: string; maskSize: string; maskType: string; - maxHeight: string | null; - maxWidth: string | null; - minHeight: string | null; - minWidth: string | null; + maxBlockSize: string; + maxHeight: string; + maxInlineSize: string; + maxWidth: string; + minBlockSize: string; + minHeight: string; + minInlineSize: string; + minWidth: string; msContentZoomChaining: string | null; msContentZoomLimit: string | null; msContentZoomLimitMax: any; @@ -2985,8 +3013,8 @@ interface CSSStyleDeclaration { objectFit: string; objectPosition: string; opacity: string | null; - order: string | null; - orphans: string | null; + order: string; + orphans: string; outline: string; outlineColor: string; outlineOffset: string; @@ -2997,45 +3025,51 @@ interface CSSStyleDeclaration { overflowWrap: string; overflowX: string; overflowY: string; - padding: string | null; - paddingBottom: string | null; - paddingLeft: string | null; - paddingRight: string | null; - paddingTop: string | null; - pageBreakAfter: string | null; - pageBreakBefore: string | null; - pageBreakInside: string | null; + padding: string; + paddingBlockEnd: string; + paddingBlockStart: string; + paddingBottom: string; + paddingInlineEnd: string; + paddingInlineStart: string; + paddingLeft: string; + paddingRight: string; + paddingTop: string; + pageBreakAfter: string; + pageBreakBefore: string; + pageBreakInside: string; + paintOrder: string; readonly parentRule: CSSRule; penAction: string | null; - perspective: string | null; - perspectiveOrigin: string | null; + perspective: string; + perspectiveOrigin: string; placeContent: string; placeItems: string; placeSelf: string; pointerEvents: string | null; - position: string | null; - quotes: string | null; + position: string; + quotes: string; resize: string; - right: string | null; - rotate: string | null; + right: string; + rotate: string; rowGap: string; rubyAlign: string | null; rubyOverhang: string | null; rubyPosition: string | null; - scale: string | null; + scale: string; scrollBehavior: string; + shapeRendering: string; stopColor: string | null; stopOpacity: string | null; - stroke: string | null; - strokeDasharray: string | null; - strokeDashoffset: string | null; - strokeLinecap: string | null; - strokeLinejoin: string | null; - strokeMiterlimit: string | null; - strokeOpacity: string | null; - strokeWidth: string | null; + stroke: string; + strokeDasharray: string; + strokeDashoffset: string; + strokeLinecap: string; + strokeLinejoin: string; + strokeMiterlimit: string; + strokeOpacity: string; + strokeWidth: string; tabSize: string; - tableLayout: string | null; + tableLayout: string; textAlign: string; textAlignLast: string; textAnchor: string | null; @@ -3054,25 +3088,26 @@ interface CSSStyleDeclaration { textKashidaSpace: string | null; textOrientation: string; textOverflow: string; + textRendering: string; textShadow: string; textTransform: string; textUnderlinePosition: string; - top: string | null; + top: string; touchAction: string; transform: string; transformBox: string; transformOrigin: string; - transformStyle: string | null; + transformStyle: string; transition: string; transitionDelay: string; transitionDuration: string; transitionProperty: string; transitionTimingFunction: string; - translate: string | null; + translate: string; unicodeBidi: string; userSelect: string; - verticalAlign: string | null; - visibility: string | null; + verticalAlign: string; + visibility: string; /** @deprecated */ webkitAlignContent: string; /** @deprecated */ @@ -3228,14 +3263,14 @@ interface CSSStyleDeclaration { webkitUserSelect: string | null; webkitWritingMode: string | null; whiteSpace: string; - widows: string | null; - width: string | null; + widows: string; + width: string; willChange: string; wordBreak: string; wordSpacing: string; wordWrap: string; writingMode: string; - zIndex: string | null; + zIndex: string; zoom: string | null; getPropertyPriority(propertyName: string): string; getPropertyValue(propertyName: string): string; @@ -3445,7 +3480,7 @@ interface CanvasRect { } /** The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a element. It is used for drawing shapes, text, images, and other objects. */ -interface CanvasRenderingContext2D extends CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasUserInterface, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath { +interface CanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface { readonly canvas: HTMLCanvasElement; } @@ -3527,7 +3562,7 @@ declare var ChannelSplitterNode: { }; /** The CharacterData abstract interface represents a Node object that contains characters. This is an abstract interface, meaning there aren't any object of type CharacterData: it is implemented by other interfaces, like Text, Comment, or ProcessingInstruction which aren't abstract. */ -interface CharacterData extends Node, NonDocumentTypeChildNode, ChildNode { +interface CharacterData extends Node, ChildNode, NonDocumentTypeChildNode { data: string; readonly length: number; appendData(data: string): void; @@ -4469,7 +4504,7 @@ interface DocumentEventMap extends GlobalEventHandlersEventMap, DocumentAndEleme } /** Any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree. */ -interface Document extends Node, NonElementParentNode, DocumentOrShadowRoot, ParentNode, XPathEvaluatorBase, GlobalEventHandlers, DocumentAndElementEventHandlers { +interface Document extends Node, DocumentAndElementEventHandlers, DocumentOrShadowRoot, GlobalEventHandlers, NonElementParentNode, ParentNode, XPathEvaluatorBase { /** * Sets or gets the URL for the current document. */ @@ -5160,7 +5195,7 @@ interface ElementEventMap { } /** Element is the most general base class from which all objects in a Document inherit. It only has methods and properties common to all kinds of elements. More specific classes inherit from Element. */ -interface Element extends Node, ParentNode, NonDocumentTypeChildNode, ChildNode, Slotable, InnerHTML, Animatable { +interface Element extends Node, Animatable, ChildNode, InnerHTML, NonDocumentTypeChildNode, ParentNode, Slotable { readonly assignedSlot: HTMLSlotElement | null; readonly attributes: NamedNodeMap; /** @@ -5234,8 +5269,8 @@ interface Element extends Node, ParentNode, NonDocumentTypeChildNode, ChildNode, getAttributeNames(): string[]; getAttributeNode(name: string): Attr | null; getAttributeNodeNS(namespaceURI: string, localName: string): Attr | null; - getBoundingClientRect(): ClientRect | DOMRect; - getClientRects(): ClientRectList | DOMRectList; + getBoundingClientRect(): DOMRect; + getClientRects(): DOMRectList; /** * Returns a HTMLCollection of the elements in the object on which the method was invoked (a document or an element) that have all the classes given by classNames. The classNames argument is interpreted as a space-separated list of classes. */ @@ -6655,7 +6690,7 @@ interface HTMLElementEventMap extends ElementEventMap, GlobalEventHandlersEventM } /** Any HTML element. Some elements directly implement this interface, while others implement it via an interface that inherits it. */ -interface HTMLElement extends Element, GlobalEventHandlers, DocumentAndElementEventHandlers, ElementContentEditable, HTMLOrSVGElement, ElementCSSInlineStyle { +interface HTMLElement extends Element, DocumentAndElementEventHandlers, ElementCSSInlineStyle, ElementContentEditable, GlobalEventHandlers, HTMLOrSVGElement { accessKey: string; readonly accessKeyLabel: string; autocapitalize: string; @@ -9747,7 +9782,7 @@ interface ImageData { declare var ImageData: { prototype: ImageData; new(width: number, height: number): ImageData; - new(array: Uint8ClampedArray, width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height?: number): ImageData; }; interface InnerHTML { @@ -9792,11 +9827,11 @@ declare var IntersectionObserver: { /** This Intersection Observer API interface describes the intersection between the target element and its root container at a specific moment of transition. */ interface IntersectionObserverEntry { - readonly boundingClientRect: ClientRect | DOMRect; + readonly boundingClientRect: DOMRectReadOnly; readonly intersectionRatio: number; - readonly intersectionRect: ClientRect | DOMRect; + readonly intersectionRect: DOMRectReadOnly; readonly isIntersecting: boolean; - readonly rootBounds: ClientRect | DOMRect | null; + readonly rootBounds: DOMRectReadOnly | null; readonly target: Element; readonly time: number; } @@ -10837,7 +10872,7 @@ declare var NavigationPreloadManager: { }; /** The state and the identity of the user agent. It allows scripts to query it and to register themselves to carry on some activities. */ -interface Navigator extends NavigatorID, NavigatorLanguage, NavigatorOnLine, NavigatorContentUtils, NavigatorCookies, NavigatorPlugins, NavigatorConcurrentHardware, NavigatorStorage, NavigatorAutomationInformation, MSFileSaver, MSNavigatorDoNotTrack, NavigatorBeacon { +interface Navigator extends MSFileSaver, MSNavigatorDoNotTrack, NavigatorAutomationInformation, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorContentUtils, NavigatorCookies, NavigatorID, NavigatorLanguage, NavigatorOnLine, NavigatorPlugins, NavigatorStorage { readonly activeVRDisplays: ReadonlyArray; readonly clipboard: Clipboard; readonly credentials: CredentialsContainer; @@ -11376,7 +11411,7 @@ declare var OffscreenCanvas: { new(width: number, height: number): OffscreenCanvas; }; -interface OffscreenCanvasRenderingContext2D extends CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath { +interface OffscreenCanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform { readonly canvas: OffscreenCanvas; commit(): void; } @@ -12608,8 +12643,8 @@ interface Range extends AbstractRange { deleteContents(): void; detach(): void; extractContents(): DocumentFragment; - getBoundingClientRect(): ClientRect | DOMRect; - getClientRects(): ClientRectList | DOMRectList; + getBoundingClientRect(): DOMRect; + getClientRects(): DOMRectList; insertNode(node: Node): void; /** * Returns whether range intersects node. @@ -13133,7 +13168,7 @@ interface SVGElementEventMap extends ElementEventMap, GlobalEventHandlersEventMa } /** All of the SVG DOM interfaces that correspond directly to elements in the SVG language derive from the SVGElement interface. */ -interface SVGElement extends Element, GlobalEventHandlers, DocumentAndElementEventHandlers, SVGElementInstance, HTMLOrSVGElement, ElementCSSInlineStyle { +interface SVGElement extends Element, DocumentAndElementEventHandlers, ElementCSSInlineStyle, GlobalEventHandlers, HTMLOrSVGElement, SVGElementInstance { /** @deprecated */ readonly className: any; readonly ownerSVGElement: SVGSVGElement | null; @@ -14343,7 +14378,7 @@ declare var SVGPathSegMovetoRel: { }; /** Corresponds to the element. */ -interface SVGPatternElement extends SVGElement, SVGTests, SVGFitToViewBox, SVGURIReference { +interface SVGPatternElement extends SVGElement, SVGFitToViewBox, SVGTests, SVGURIReference { readonly height: SVGAnimatedLength; readonly patternContentUnits: SVGAnimatedEnumeration; readonly patternTransform: SVGAnimatedTransformList; @@ -15644,7 +15679,7 @@ interface TextDecoderCommon { readonly ignoreBOM: boolean; } -interface TextDecoderStream extends TextDecoderCommon, GenericTransformStream { +interface TextDecoderStream extends GenericTransformStream, TextDecoderCommon { } declare var TextDecoderStream: { @@ -15676,7 +15711,7 @@ interface TextEncoderCommon { readonly encoding: string; } -interface TextEncoderStream extends TextEncoderCommon, GenericTransformStream { +interface TextEncoderStream extends GenericTransformStream, TextEncoderCommon { } declare var TextEncoderStream: { @@ -16444,7 +16479,7 @@ declare var WebAuthnAssertion: { new(): WebAuthnAssertion; }; -interface WebGL2RenderingContext extends WebGLRenderingContextBase, WebGL2RenderingContextBase, WebGL2RenderingContextOverloads { +interface WebGL2RenderingContext extends WebGL2RenderingContextBase, WebGL2RenderingContextOverloads, WebGLRenderingContextBase { } declare var WebGL2RenderingContext: { @@ -18497,7 +18532,7 @@ interface WindowEventMap extends GlobalEventHandlersEventMap, WindowEventHandler } /** A window containing a DOM document; the document property points to the DOM document loaded in that window. */ -interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, AnimationFrameProvider, WindowOrWorkerGlobalScope, WindowEventHandlers { +interface Window extends EventTarget, AnimationFrameProvider, GlobalEventHandlers, IDBEnvironment, WindowBase64, WindowConsole, WindowEventHandlers, WindowLocalStorage, WindowOrWorkerGlobalScope, WindowSessionStorage, WindowTimers { readonly applicationCache: ApplicationCache; readonly caches: CacheStorage; readonly clientInformation: Navigator; @@ -19059,16 +19094,16 @@ declare namespace WebAssembly { var Global: { prototype: Global; - new(descriptor: GlobalDescriptor, value?: any): Global; + new(descriptor: GlobalDescriptor, v?: any): Global; }; interface Instance { - readonly exports: any; + readonly exports: Exports; } var Instance: { prototype: Instance; - new(module: Module, importObject?: any): Instance; + new(module: Module, importObject?: Imports): Instance; }; interface LinkError { @@ -19095,9 +19130,9 @@ declare namespace WebAssembly { var Module: { prototype: Module; new(bytes: BufferSource): Module; - customSections(module: Module, sectionName: string): ArrayBuffer[]; - exports(module: Module): ModuleExportDescriptor[]; - imports(module: Module): ModuleImportDescriptor[]; + customSections(moduleObject: Module, sectionName: string): ArrayBuffer[]; + exports(moduleObject: Module): ModuleExportDescriptor[]; + imports(moduleObject: Module): ModuleImportDescriptor[]; }; interface RuntimeError { @@ -19122,7 +19157,7 @@ declare namespace WebAssembly { interface GlobalDescriptor { mutable?: boolean; - value: string; + value: ValueType; } interface MemoryDescriptor { @@ -19154,9 +19189,17 @@ declare namespace WebAssembly { type ImportExportKind = "function" | "table" | "memory" | "global"; type TableKind = "anyfunc"; + type ValueType = "i32" | "i64" | "f32" | "f64"; + type ExportValue = Function | Global | Memory | Table; + type Exports = Record; + type ImportValue = ExportValue | number; + type ModuleImports = Record; + type Imports = Record; function compile(bytes: BufferSource): Promise; - function instantiate(bytes: BufferSource, importObject?: any): Promise; - function instantiate(moduleObject: Module, importObject?: any): Promise; + function compileStreaming(source: Response | Promise): Promise; + function instantiate(bytes: BufferSource, importObject?: Imports): Promise; + function instantiate(moduleObject: Module, importObject?: Imports): Promise; + function instantiateStreaming(response: Response | PromiseLike, importObject?: Imports): Promise; function validate(bytes: BufferSource): boolean; } @@ -20116,7 +20159,7 @@ type Transport = "usb" | "nfc" | "ble"; type UserVerificationRequirement = "required" | "preferred" | "discouraged"; type VRDisplayEventReason = "mounted" | "navigation" | "requested" | "unmounted"; type VideoFacingModeEnum = "user" | "environment" | "left" | "right"; -type VisibilityState = "hidden" | "visible" | "prerender"; +type VisibilityState = "hidden" | "visible"; type WebGLPowerPreference = "default" | "low-power" | "high-performance"; type WorkerType = "classic" | "module"; type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; diff --git a/node_modules/typescript/lib/lib.dom.iterable.d.ts b/node_modules/typescript/lib/lib.dom.iterable.d.ts index b89ba2d5a..bbda4ba2d 100644 --- a/node_modules/typescript/lib/lib.dom.iterable.d.ts +++ b/node_modules/typescript/lib/lib.dom.iterable.d.ts @@ -293,37 +293,37 @@ interface WebAuthentication { } interface WebGL2RenderingContextBase { + clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; + clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; + clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; + drawBuffers(buffers: Iterable): void; + getActiveUniforms(program: WebGLProgram, uniformIndices: Iterable, pname: GLenum): any; + getUniformIndices(program: WebGLProgram, uniformNames: Iterable): Iterable | null; invalidateFramebuffer(target: GLenum, attachments: Iterable): void; invalidateSubFramebuffer(target: GLenum, attachments: Iterable, x: GLint, y: GLint, width: GLsizei, height: GLsizei): void; + transformFeedbackVaryings(program: WebGLProgram, varyings: Iterable, bufferMode: GLenum): void; uniform1uiv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform2uiv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform3uiv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform4uiv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix3x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix4x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix2x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniformMatrix4x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix2x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniformMatrix3x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix3x4fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniformMatrix4x2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniformMatrix4x3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; vertexAttribI4iv(index: GLuint, values: Iterable): void; vertexAttribI4uiv(index: GLuint, values: Iterable): void; - drawBuffers(buffers: Iterable): void; - clearBufferfv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; - clearBufferiv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; - clearBufferuiv(buffer: GLenum, drawbuffer: GLint, values: Iterable, srcOffset?: GLuint): void; - transformFeedbackVaryings(program: WebGLProgram, varyings: Iterable, bufferMode: GLenum): void; - getUniformIndices(program: WebGLProgram, uniformNames: Iterable): Iterable | null; - getActiveUniforms(program: WebGLProgram, uniformIndices: Iterable, pname: GLenum): any; } interface WebGL2RenderingContextOverloads { uniform1fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform2fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform3fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; - uniform4fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform1iv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniform2fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform2iv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniform3fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform3iv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; + uniform4fv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniform4iv(location: WebGLUniformLocation | null, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, data: Iterable, srcOffset?: GLuint, srcLength?: GLuint): void; @@ -339,12 +339,12 @@ interface WebGLRenderingContextBase { interface WebGLRenderingContextOverloads { uniform1fv(location: WebGLUniformLocation | null, v: Iterable): void; - uniform2fv(location: WebGLUniformLocation | null, v: Iterable): void; - uniform3fv(location: WebGLUniformLocation | null, v: Iterable): void; - uniform4fv(location: WebGLUniformLocation | null, v: Iterable): void; uniform1iv(location: WebGLUniformLocation | null, v: Iterable): void; + uniform2fv(location: WebGLUniformLocation | null, v: Iterable): void; uniform2iv(location: WebGLUniformLocation | null, v: Iterable): void; + uniform3fv(location: WebGLUniformLocation | null, v: Iterable): void; uniform3iv(location: WebGLUniformLocation | null, v: Iterable): void; + uniform4fv(location: WebGLUniformLocation | null, v: Iterable): void; uniform4iv(location: WebGLUniformLocation | null, v: Iterable): void; uniformMatrix2fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable): void; uniformMatrix3fv(location: WebGLUniformLocation | null, transpose: GLboolean, value: Iterable): void; diff --git a/node_modules/typescript/lib/lib.es2015.collection.d.ts b/node_modules/typescript/lib/lib.es2015.collection.d.ts index 036723b15..d1f1f6213 100644 --- a/node_modules/typescript/lib/lib.es2015.collection.d.ts +++ b/node_modules/typescript/lib/lib.es2015.collection.d.ts @@ -30,7 +30,7 @@ interface Map { interface MapConstructor { new(): Map; - new(entries?: ReadonlyArray | null): Map; + new(entries?: readonly (readonly [K, V])[] | null): Map; readonly prototype: Map; } declare var Map: MapConstructor; @@ -50,7 +50,7 @@ interface WeakMap { } interface WeakMapConstructor { - new (entries?: ReadonlyArray<[K, V]> | null): WeakMap; + new (entries?: readonly [K, V][] | null): WeakMap; readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -65,7 +65,7 @@ interface Set { } interface SetConstructor { - new (values?: ReadonlyArray | null): Set; + new (values?: readonly T[] | null): Set; readonly prototype: Set; } declare var Set: SetConstructor; @@ -83,7 +83,7 @@ interface WeakSet { } interface WeakSetConstructor { - new (values?: ReadonlyArray | null): WeakSet; + new (values?: readonly T[] | null): WeakSet; readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; diff --git a/node_modules/typescript/lib/lib.es2015.core.d.ts b/node_modules/typescript/lib/lib.es2015.core.d.ts index 11abcb962..913db853f 100644 --- a/node_modules/typescript/lib/lib.es2015.core.d.ts +++ b/node_modules/typescript/lib/lib.es2015.core.d.ts @@ -319,9 +319,9 @@ interface ObjectConstructor { getOwnPropertySymbols(o: any): symbol[]; /** - * Returns the names of the enumerable string properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ + * Returns the names of the enumerable string properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ keys(o: {}): string[]; /** @@ -332,7 +332,7 @@ interface ObjectConstructor { is(value1: any, value2: any): boolean; /** - * Sets the prototype of a specified object o to object proto or null. Returns the object o. + * Sets the prototype of a specified object o to object proto or null. Returns the object o. * @param o The object to change its prototype. * @param proto The value of the new prototype or null. */ @@ -349,8 +349,8 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => value is S, thisArg?: any): S | undefined; - find(predicate: (value: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: readonly T[]) => value is S, thisArg?: any): S | undefined; + find(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -361,7 +361,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => unknown, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: readonly T[]) => unknown, thisArg?: any): number; } interface RegExp { diff --git a/node_modules/typescript/lib/lib.es2015.promise.d.ts b/node_modules/typescript/lib/lib.es2015.promise.d.ts index 2ea966273..b20efaed8 100644 --- a/node_modules/typescript/lib/lib.es2015.promise.d.ts +++ b/node_modules/typescript/lib/lib.es2015.promise.d.ts @@ -38,7 +38,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -46,7 +46,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -54,7 +54,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -62,7 +62,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -70,7 +70,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -78,7 +78,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike , T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -86,7 +86,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike ]): Promise<[T1, T2, T3, T4]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -94,7 +94,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -102,7 +102,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; + all(values: readonly [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; /** * Creates a Promise that is resolved with an array of results when all of the provided Promises @@ -110,7 +110,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - all(values: (T | PromiseLike)[]): Promise; + all(values: readonly (T | PromiseLike)[]): Promise; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved @@ -118,7 +118,7 @@ interface PromiseConstructor { * @param values An array of Promises. * @returns A new Promise. */ - race(values: T[]): Promise ? U : T>; + race(values: readonly T[]): Promise ? U : T>; /** * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved diff --git a/node_modules/typescript/lib/lib.es2017.object.d.ts b/node_modules/typescript/lib/lib.es2017.object.d.ts index c5db0f41d..7e34fe1d9 100644 --- a/node_modules/typescript/lib/lib.es2017.object.d.ts +++ b/node_modules/typescript/lib/lib.es2017.object.d.ts @@ -23,7 +23,7 @@ interface ObjectConstructor { * Returns an array of values of the enumerable properties of an object * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ - values(o: { [s: string]: T } | ArrayLike): T[]; + values(o: { [s: string]: T } | ArrayLike): T[]; /** * Returns an array of values of the enumerable properties of an object diff --git a/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts b/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts index 282c99691..041f24a29 100644 --- a/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +++ b/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts @@ -22,7 +22,7 @@ and limitations under the License. interface AsyncGenerator extends AsyncIterator { // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. - next(...args: [] | [TNext | PromiseLike]): Promise>; + next(...args: [] | [TNext]): Promise>; return(value: TReturn | PromiseLike): Promise>; throw(e: any): Promise>; [Symbol.asyncIterator](): AsyncGenerator; diff --git a/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts b/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts index 3f0ae5584..8016a8a6b 100644 --- a/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +++ b/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts @@ -31,7 +31,7 @@ interface SymbolConstructor { interface AsyncIterator { // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places. - next(...args: [] | [TNext | PromiseLike]): Promise>; + next(...args: [] | [TNext]): Promise>; return?(value?: TReturn | PromiseLike): Promise>; throw?(e?: any): Promise>; } diff --git a/node_modules/typescript/lib/lib.es2018.intl.d.ts b/node_modules/typescript/lib/lib.es2018.intl.d.ts index a88331e0b..462b3a956 100644 --- a/node_modules/typescript/lib/lib.es2018.intl.d.ts +++ b/node_modules/typescript/lib/lib.es2018.intl.d.ts @@ -20,14 +20,14 @@ and limitations under the License. declare namespace Intl { interface PluralRulesOptions { - localeMatcher?: 'lookup' | 'best fit'; - type?: 'cardinal' | 'ordinal'; + localeMatcher?: "lookup" | "best fit"; + type?: "cardinal" | "ordinal"; } interface ResolvedPluralRulesOptions { locale: string; pluralCategories: string[]; - type: 'cardinal' | 'ordinal'; + type: "cardinal" | "ordinal"; minimumIntegerDigits: number; minimumFractionDigits: number; maximumFractionDigits: number; diff --git a/node_modules/typescript/lib/lib.es2019.array.d.ts b/node_modules/typescript/lib/lib.es2019.array.d.ts index 398d9df8d..ca375ffdb 100644 --- a/node_modules/typescript/lib/lib.es2019.array.d.ts +++ b/node_modules/typescript/lib/lib.es2019.array.d.ts @@ -31,7 +31,7 @@ interface ReadonlyArray { * thisArg is omitted, undefined is used as the this value. */ flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, + callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This ): U[] @@ -130,7 +130,7 @@ interface ReadonlyArray { * @param depth The maximum recursion depth */ flat(depth?: number): any[]; - } +} interface Array { @@ -145,7 +145,7 @@ interface Array { * thisArg is omitted, undefined is used as the this value. */ flatMap ( - callback: (this: This, value: T, index: number, array: T[]) => U|ReadonlyArray, + callback: (this: This, value: T, index: number, array: T[]) => U | ReadonlyArray, thisArg?: This ): U[] diff --git a/node_modules/typescript/lib/lib.es2019.string.d.ts b/node_modules/typescript/lib/lib.es2019.string.d.ts index 6515d087d..6208074c2 100644 --- a/node_modules/typescript/lib/lib.es2019.string.d.ts +++ b/node_modules/typescript/lib/lib.es2019.string.d.ts @@ -19,15 +19,15 @@ and limitations under the License. interface String { - /** Removes the trailing white space and line terminator characters from a string. */ - trimEnd(): string; + /** Removes the trailing white space and line terminator characters from a string. */ + trimEnd(): string; - /** Removes the leading white space and line terminator characters from a string. */ - trimStart(): string; + /** Removes the leading white space and line terminator characters from a string. */ + trimStart(): string; - /** Removes the leading white space and line terminator characters from a string. */ - trimLeft(): string; + /** Removes the leading white space and line terminator characters from a string. */ + trimLeft(): string; - /** Removes the trailing white space and line terminator characters from a string. */ - trimRight(): string; + /** Removes the trailing white space and line terminator characters from a string. */ + trimRight(): string; } diff --git a/node_modules/typescript/lib/lib.es2019.symbol.d.ts b/node_modules/typescript/lib/lib.es2019.symbol.d.ts index b956cf0d3..05bd9ba12 100644 --- a/node_modules/typescript/lib/lib.es2019.symbol.d.ts +++ b/node_modules/typescript/lib/lib.es2019.symbol.d.ts @@ -18,9 +18,9 @@ and limitations under the License. /// -interface Symbol { - /** - * expose the [[Description]] internal slot of a symbol directly - */ - readonly description: string; -} +interface Symbol { + /** + * expose the [[Description]] internal slot of a symbol directly + */ + readonly description: string; +} diff --git a/node_modules/typescript/lib/lib.es2020.string.d.ts b/node_modules/typescript/lib/lib.es2020.string.d.ts index ce3aeba3d..b6a2576b5 100644 --- a/node_modules/typescript/lib/lib.es2020.string.d.ts +++ b/node_modules/typescript/lib/lib.es2020.string.d.ts @@ -21,10 +21,10 @@ and limitations under the License. /// interface String { - /** - * Matches a string with a regular expression, and returns an iterable of matches - * containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ - matchAll(regexp: RegExp): IterableIterator; + /** + * Matches a string with a regular expression, and returns an iterable of matches + * containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ + matchAll(regexp: RegExp): IterableIterator; } diff --git a/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts b/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts index 06bc1dfb1..2cd1e7279 100644 --- a/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +++ b/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts @@ -22,18 +22,18 @@ and limitations under the License. /// interface SymbolConstructor { - /** - * A regular expression method that matches the regular expression against a string. Called - * by the String.prototype.matchAll method. - */ - readonly matchAll: symbol; + /** + * A regular expression method that matches the regular expression against a string. Called + * by the String.prototype.matchAll method. + */ + readonly matchAll: symbol; } interface RegExp { - /** - * Matches a string with this regular expression, and returns an iterable of matches - * containing the results of that search. - * @param string A string to search within. - */ - [Symbol.matchAll](str: string): IterableIterator; + /** + * Matches a string with this regular expression, and returns an iterable of matches + * containing the results of that search. + * @param string A string to search within. + */ + [Symbol.matchAll](str: string): IterableIterator; } diff --git a/node_modules/typescript/lib/lib.es5.d.ts b/node_modules/typescript/lib/lib.es5.d.ts index 8216c5a3a..541fcf0bf 100644 --- a/node_modules/typescript/lib/lib.es5.d.ts +++ b/node_modules/typescript/lib/lib.es5.d.ts @@ -26,80 +26,80 @@ declare var NaN: number; declare var Infinity: number; /** - * Evaluates JavaScript code and executes it. - * @param x A String value that contains valid JavaScript code. - */ + * Evaluates JavaScript code and executes it. + * @param x A String value that contains valid JavaScript code. + */ declare function eval(x: string): any; /** - * Converts a string to an integer. - * @param s A string to convert into a number. - * @param radix A value between 2 and 36 that specifies the base of the number in numString. - * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. - * All other strings are considered decimal. - */ + * Converts a string to an integer. + * @param s A string to convert into a number. + * @param radix A value between 2 and 36 that specifies the base of the number in numString. + * If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. + * All other strings are considered decimal. + */ declare function parseInt(s: string, radix?: number): number; /** - * Converts a string to a floating-point number. - * @param string A string that contains a floating-point number. - */ + * Converts a string to a floating-point number. + * @param string A string that contains a floating-point number. + */ declare function parseFloat(string: string): number; /** - * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). - * @param number A numeric value. - */ + * Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). + * @param number A numeric value. + */ declare function isNaN(number: number): boolean; /** - * Determines whether a supplied number is finite. - * @param number Any numeric value. - */ + * Determines whether a supplied number is finite. + * @param number Any numeric value. + */ declare function isFinite(number: number): boolean; /** - * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). - * @param encodedURI A value representing an encoded URI. - */ + * Gets the unencoded version of an encoded Uniform Resource Identifier (URI). + * @param encodedURI A value representing an encoded URI. + */ declare function decodeURI(encodedURI: string): string; /** - * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). - * @param encodedURIComponent A value representing an encoded URI component. - */ + * Gets the unencoded version of an encoded component of a Uniform Resource Identifier (URI). + * @param encodedURIComponent A value representing an encoded URI component. + */ declare function decodeURIComponent(encodedURIComponent: string): string; /** - * Encodes a text string as a valid Uniform Resource Identifier (URI) - * @param uri A value representing an encoded URI. - */ + * Encodes a text string as a valid Uniform Resource Identifier (URI) + * @param uri A value representing an encoded URI. + */ declare function encodeURI(uri: string): string; /** - * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). - * @param uriComponent A value representing an encoded URI component. - */ + * Encodes a text string as a valid component of a Uniform Resource Identifier (URI). + * @param uriComponent A value representing an encoded URI component. + */ declare function encodeURIComponent(uriComponent: string | number | boolean): string; /** - * Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. - * @param string A string value - */ + * Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. + * @param string A string value + */ declare function escape(string: string): string; /** - * Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. - * @param string A string value - */ + * Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. + * @param string A string value + */ declare function unescape(string: string): string; interface Symbol { - /** Returns a string representation of an object. */ - toString(): string; + /** Returns a string representation of an object. */ + toString(): string; - /** Returns the primitive value of the specified object. */ - valueOf(): symbol; + /** Returns the primitive value of the specified object. */ + valueOf(): symbol; } declare type PropertyKey = string | number | symbol; @@ -131,21 +131,21 @@ interface Object { valueOf(): Object; /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ + * Determines whether an object has a property with the specified name. + * @param v A property name. + */ hasOwnProperty(v: PropertyKey): boolean; /** - * Determines whether an object exists in another object's prototype chain. - * @param v Another object whose prototype chain is to be checked. - */ + * Determines whether an object exists in another object's prototype chain. + * @param v Another object whose prototype chain is to be checked. + */ isPrototypeOf(v: Object): boolean; /** - * Determines whether a specified property is enumerable. - * @param v A property name. - */ + * Determines whether a specified property is enumerable. + * @param v A property name. + */ propertyIsEnumerable(v: PropertyKey): boolean; } @@ -158,138 +158,138 @@ interface ObjectConstructor { readonly prototype: Object; /** - * Returns the prototype of an object. - * @param o The object that references the prototype. - */ + * Returns the prototype of an object. + * @param o The object that references the prototype. + */ getPrototypeOf(o: any): any; /** - * Gets the own property descriptor of the specified object. - * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. - * @param o Object that contains the property. - * @param p Name of the property. - */ + * Gets the own property descriptor of the specified object. + * An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype. + * @param o Object that contains the property. + * @param p Name of the property. + */ getOwnPropertyDescriptor(o: any, p: PropertyKey): PropertyDescriptor | undefined; /** - * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly - * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. - * @param o Object that contains the own properties. - */ + * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly + * on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions. + * @param o Object that contains the own properties. + */ getOwnPropertyNames(o: any): string[]; /** - * Creates an object that has the specified prototype or that has null prototype. - * @param o Object to use as a prototype. May be null. - */ + * Creates an object that has the specified prototype or that has null prototype. + * @param o Object to use as a prototype. May be null. + */ create(o: object | null): any; /** - * Creates an object that has the specified prototype, and that optionally contains specified properties. - * @param o Object to use as a prototype. May be null - * @param properties JavaScript object that contains one or more property descriptors. - */ + * Creates an object that has the specified prototype, and that optionally contains specified properties. + * @param o Object to use as a prototype. May be null + * @param properties JavaScript object that contains one or more property descriptors. + */ create(o: object | null, properties: PropertyDescriptorMap & ThisType): any; /** - * Adds a property to an object, or modifies attributes of an existing property. - * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. - * @param p The property name. - * @param attributes Descriptor for the property. It can be for a data property or an accessor property. - */ + * Adds a property to an object, or modifies attributes of an existing property. + * @param o Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. + * @param p The property name. + * @param attributes Descriptor for the property. It can be for a data property or an accessor property. + */ defineProperty(o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType): any; /** - * Adds one or more properties to an object, and/or modifies attributes of existing properties. - * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. - * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. - */ + * Adds one or more properties to an object, and/or modifies attributes of existing properties. + * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object. + * @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property. + */ defineProperties(o: any, properties: PropertyDescriptorMap & ThisType): any; /** - * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ + * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ seal(o: T): T; /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ - freeze(a: T[]): ReadonlyArray; + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ + freeze(a: T[]): readonly T[]; /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ freeze(f: T): T; /** - * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. - * @param o Object on which to lock the attributes. - */ + * Prevents the modification of existing property attributes and values, and prevents the addition of new properties. + * @param o Object on which to lock the attributes. + */ freeze(o: T): Readonly; /** - * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. - */ + * Prevents the addition of new properties to an object. + * @param o Object to make non-extensible. + */ preventExtensions(o: T): T; /** - * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. - */ + * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. + * @param o Object to test. + */ isSealed(o: any): boolean; /** - * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. - */ + * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. + * @param o Object to test. + */ isFrozen(o: any): boolean; /** - * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. - */ + * Returns a value that indicates whether new properties can be added to an object. + * @param o Object to test. + */ isExtensible(o: any): boolean; /** - * Returns the names of the enumerable string properties and methods of an object. - * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. - */ - keys(o: object): string[]; + * Returns the names of the enumerable string properties and methods of an object. + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + keys(o: object): string[]; } /** - * Provides functionality common to all JavaScript objects. - */ + * Provides functionality common to all JavaScript objects. + */ declare var Object: ObjectConstructor; /** - * Creates a new function. - */ + * Creates a new function. + */ interface Function { /** - * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. - * @param thisArg The object to be used as the this object. - * @param argArray A set of arguments to be passed to the function. - */ + * Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function. + * @param thisArg The object to be used as the this object. + * @param argArray A set of arguments to be passed to the function. + */ apply(this: Function, thisArg: any, argArray?: any): any; /** - * Calls a method of an object, substituting another object for the current object. - * @param thisArg The object to be used as the current object. - * @param argArray A list of arguments to be passed to the method. - */ + * Calls a method of an object, substituting another object for the current object. + * @param thisArg The object to be used as the current object. + * @param argArray A list of arguments to be passed to the method. + */ call(this: Function, thisArg: any, ...argArray: any[]): any; /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg An object to which the this keyword can refer inside the new function. - * @param argArray A list of arguments to be passed to the new function. - */ + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg An object to which the this keyword can refer inside the new function. + * @param argArray A list of arguments to be passed to the new function. + */ bind(this: Function, thisArg: any, ...argArray: any[]): any; /** Returns a string representation of a function. */ @@ -305,9 +305,9 @@ interface Function { interface FunctionConstructor { /** - * Creates a new function. - * @param args A list of arguments the function accepts. - */ + * Creates a new function. + * @param args A list of arguments the function accepts. + */ new(...args: string[]): Function; (...args: string[]): Function; readonly prototype: Function; @@ -327,26 +327,26 @@ type OmitThisParameter = unknown extends ThisParameterType ? T : T extends interface CallableFunction extends Function { /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. - * @param args An array of argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the elements of specified array as the arguments. + * @param thisArg The object to be used as the this object. + * @param args An array of argument values to be passed to the function. + */ apply(this: (this: T) => R, thisArg: T): R; apply(this: (this: T, ...args: A) => R, thisArg: T, args: A): R; /** - * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. - * @param thisArg The object to be used as the this object. - * @param args Argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. + * @param thisArg The object to be used as the this object. + * @param args Argument values to be passed to the function. + */ call(this: (this: T, ...args: A) => R, thisArg: T, ...args: A): R; /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg The object to be used as the this object. - * @param args Arguments to bind to the parameters of the function. - */ + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg The object to be used as the this object. + * @param args Arguments to bind to the parameters of the function. + */ bind(this: T, thisArg: ThisParameterType): OmitThisParameter; bind(this: (this: T, arg0: A0, ...args: A) => R, thisArg: T, arg0: A0): (...args: A) => R; bind(this: (this: T, arg0: A0, arg1: A1, ...args: A) => R, thisArg: T, arg0: A0, arg1: A1): (...args: A) => R; @@ -357,26 +357,26 @@ interface CallableFunction extends Function { interface NewableFunction extends Function { /** - * Calls the function with the specified object as the this value and the elements of specified array as the arguments. - * @param thisArg The object to be used as the this object. - * @param args An array of argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the elements of specified array as the arguments. + * @param thisArg The object to be used as the this object. + * @param args An array of argument values to be passed to the function. + */ apply(this: new () => T, thisArg: T): void; apply(this: new (...args: A) => T, thisArg: T, args: A): void; /** - * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. - * @param thisArg The object to be used as the this object. - * @param args Argument values to be passed to the function. - */ + * Calls the function with the specified object as the this value and the specified rest arguments as the arguments. + * @param thisArg The object to be used as the this object. + * @param args Argument values to be passed to the function. + */ call(this: new (...args: A) => T, thisArg: T, ...args: A): void; /** - * For a given function, creates a bound function that has the same body as the original function. - * The this object of the bound function is associated with the specified object, and has the specified initial parameters. - * @param thisArg The object to be used as the this object. - * @param args Arguments to bind to the parameters of the function. - */ + * For a given function, creates a bound function that has the same body as the original function. + * The this object of the bound function is associated with the specified object, and has the specified initial parameters. + * @param thisArg The object to be used as the this object. + * @param args Arguments to bind to the parameters of the function. + */ bind(this: T, thisArg: any): T; bind(this: new (arg0: A0, ...args: A) => R, thisArg: any, arg0: A0): new (...args: A) => R; bind(this: new (arg0: A0, arg1: A1, ...args: A) => R, thisArg: any, arg0: A0, arg1: A1): new (...args: A) => R; @@ -396,103 +396,103 @@ interface String { toString(): string; /** - * Returns the character at the specified index. - * @param pos The zero-based index of the desired character. - */ + * Returns the character at the specified index. + * @param pos The zero-based index of the desired character. + */ charAt(pos: number): string; /** - * Returns the Unicode value of the character at the specified location. - * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. - */ + * Returns the Unicode value of the character at the specified location. + * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. + */ charCodeAt(index: number): number; /** - * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. - */ + * Returns a string that contains the concatenation of two or more strings. + * @param strings The strings to append to the end of the string. + */ concat(...strings: string[]): string; /** - * Returns the position of the first occurrence of a substring. - * @param searchString The substring to search for in the string - * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. - */ + * Returns the position of the first occurrence of a substring. + * @param searchString The substring to search for in the string + * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. + */ indexOf(searchString: string, position?: number): number; /** - * Returns the last occurrence of a substring in the string. - * @param searchString The substring to search for. - * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. - */ + * Returns the last occurrence of a substring in the string. + * @param searchString The substring to search for. + * @param position The index at which to begin searching. If omitted, the search begins at the end of the string. + */ lastIndexOf(searchString: string, position?: number): number; /** - * Determines whether two strings are equivalent in the current locale. - * @param that String to compare to target string - */ + * Determines whether two strings are equivalent in the current locale. + * @param that String to compare to target string + */ localeCompare(that: string): number; /** - * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A variable name or string literal containing the regular expression pattern and flags. - */ + * Matches a string with a regular expression, and returns an array containing the results of that search. + * @param regexp A variable name or string literal containing the regular expression pattern and flags. + */ match(regexp: string | RegExp): RegExpMatchArray | null; /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. - */ + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. + */ replace(searchValue: string | RegExp, replaceValue: string): string; /** - * Replaces text in a string, using a regular expression or search string. - * @param searchValue A string to search for. - * @param replacer A function that returns the replacement text. - */ + * Replaces text in a string, using a regular expression or search string. + * @param searchValue A string to search for. + * @param replacer A function that returns the replacement text. + */ replace(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string; /** - * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. - */ + * Finds the first substring match in a regular expression search. + * @param regexp The regular expression pattern and applicable flags. + */ search(regexp: string | RegExp): number; /** - * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. - * If this value is not specified, the substring continues to the end of stringObj. - */ + * Returns a section of a string. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * If this value is not specified, the substring continues to the end of stringObj. + */ slice(start?: number, end?: number): string; /** - * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. - * @param limit A value used to limit the number of elements returned in the array. - */ + * Split a string into substrings using the specified separator and return them as an array. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param limit A value used to limit the number of elements returned in the array. + */ split(separator: string | RegExp, limit?: number): string[]; /** - * Returns the substring at the specified location within a String object. - * @param start The zero-based index number indicating the beginning of the substring. - * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. - * If end is omitted, the characters from start through the end of the original string are returned. - */ + * Returns the substring at the specified location within a String object. + * @param start The zero-based index number indicating the beginning of the substring. + * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. + * If end is omitted, the characters from start through the end of the original string are returned. + */ substring(start: number, end?: number): string; /** Converts all the alphabetic characters in a string to lowercase. */ toLowerCase(): string; /** Converts all alphabetic characters to lowercase, taking into account the host environment's current locale. */ - toLocaleLowerCase(): string; + toLocaleLowerCase(locales?: string | string[]): string; /** Converts all the alphabetic characters in a string to uppercase. */ toUpperCase(): string; /** Returns a string where all alphabetic characters have been converted to uppercase, taking into account the host environment's current locale. */ - toLocaleUpperCase(): string; + toLocaleUpperCase(locales?: string | string[]): string; /** Removes the leading and trailing white space and line terminator characters from a string. */ trim(): string; @@ -502,10 +502,10 @@ interface String { // IE extensions /** - * Gets a substring beginning at the specified location and having the specified length. - * @param from The starting position of the desired substring. The index of the first character in the string is zero. - * @param length The number of characters to include in the returned substring. - */ + * Gets a substring beginning at the specified location and having the specified length. + * @param from The starting position of the desired substring. The index of the first character in the string is zero. + * @param length The number of characters to include in the returned substring. + */ substr(from: number, length?: number): string; /** Returns the primitive value of the specified object. */ @@ -522,8 +522,8 @@ interface StringConstructor { } /** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. - */ + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. + */ declare var String: StringConstructor; interface Boolean { @@ -541,27 +541,27 @@ declare var Boolean: BooleanConstructor; interface Number { /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. - */ + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. This value is only used for numbers. + */ toString(radix?: number): string; /** - * Returns a string representing a number in fixed-point notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ + * Returns a string representing a number in fixed-point notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ toFixed(fractionDigits?: number): string; /** - * Returns a string containing a number represented in exponential notation. - * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. - */ + * Returns a string containing a number represented in exponential notation. + * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. + */ toExponential(fractionDigits?: number): string; /** - * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. - * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. - */ + * Returns a string containing a number represented either in exponential or fixed-point notation with a specified number of digits. + * @param precision Number of significant digits. Must be in the range 1 - 21, inclusive. + */ toPrecision(precision?: number): string; /** Returns the primitive value of the specified object. */ @@ -580,21 +580,21 @@ interface NumberConstructor { readonly MIN_VALUE: number; /** - * A value that is not a number. - * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. - */ + * A value that is not a number. + * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. + */ readonly NaN: number; /** - * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. - */ + * A value that is less than the largest negative number that can be represented in JavaScript. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. + */ readonly NEGATIVE_INFINITY: number; /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. - */ + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. + */ readonly POSITIVE_INFINITY: number; } @@ -602,7 +602,7 @@ interface NumberConstructor { declare var Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { - readonly raw: ReadonlyArray; + readonly raw: readonly string[]; } /** @@ -632,94 +632,94 @@ interface Math { /** The square root of 2. */ readonly SQRT2: number; /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). - * For example, the absolute value of -5 is the same as the absolute value of 5. - * @param x A numeric expression for which the absolute value is needed. - */ + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * For example, the absolute value of -5 is the same as the absolute value of 5. + * @param x A numeric expression for which the absolute value is needed. + */ abs(x: number): number; /** - * Returns the arc cosine (or inverse cosine) of a number. - * @param x A numeric expression. - */ + * Returns the arc cosine (or inverse cosine) of a number. + * @param x A numeric expression. + */ acos(x: number): number; /** - * Returns the arcsine of a number. - * @param x A numeric expression. - */ + * Returns the arcsine of a number. + * @param x A numeric expression. + */ asin(x: number): number; /** - * Returns the arctangent of a number. - * @param x A numeric expression for which the arctangent is needed. - */ + * Returns the arctangent of a number. + * @param x A numeric expression for which the arctangent is needed. + */ atan(x: number): number; /** - * Returns the angle (in radians) from the X axis to a point. - * @param y A numeric expression representing the cartesian y-coordinate. - * @param x A numeric expression representing the cartesian x-coordinate. - */ + * Returns the angle (in radians) from the X axis to a point. + * @param y A numeric expression representing the cartesian y-coordinate. + * @param x A numeric expression representing the cartesian x-coordinate. + */ atan2(y: number, x: number): number; /** - * Returns the smallest integer greater than or equal to its numeric argument. - * @param x A numeric expression. - */ + * Returns the smallest integer greater than or equal to its numeric argument. + * @param x A numeric expression. + */ ceil(x: number): number; /** - * Returns the cosine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the cosine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ cos(x: number): number; /** - * Returns e (the base of natural logarithms) raised to a power. - * @param x A numeric expression representing the power of e. - */ + * Returns e (the base of natural logarithms) raised to a power. + * @param x A numeric expression representing the power of e. + */ exp(x: number): number; /** - * Returns the greatest integer less than or equal to its numeric argument. - * @param x A numeric expression. - */ + * Returns the greatest integer less than or equal to its numeric argument. + * @param x A numeric expression. + */ floor(x: number): number; /** - * Returns the natural logarithm (base e) of a number. - * @param x A numeric expression. - */ + * Returns the natural logarithm (base e) of a number. + * @param x A numeric expression. + */ log(x: number): number; /** - * Returns the larger of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ + * Returns the larger of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ max(...values: number[]): number; /** - * Returns the smaller of a set of supplied numeric expressions. - * @param values Numeric expressions to be evaluated. - */ + * Returns the smaller of a set of supplied numeric expressions. + * @param values Numeric expressions to be evaluated. + */ min(...values: number[]): number; /** - * Returns the value of a base expression taken to a specified power. - * @param x The base value of the expression. - * @param y The exponent value of the expression. - */ + * Returns the value of a base expression taken to a specified power. + * @param x The base value of the expression. + * @param y The exponent value of the expression. + */ pow(x: number, y: number): number; /** Returns a pseudorandom number between 0 and 1. */ random(): number; /** - * Returns a supplied numeric expression rounded to the nearest number. - * @param x The value to be rounded to the nearest number. - */ + * Returns a supplied numeric expression rounded to the nearest integer. + * @param x The value to be rounded to the nearest integer. + */ round(x: number): number; /** - * Returns the sine of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the sine of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ sin(x: number): number; /** - * Returns the square root of a number. - * @param x A numeric expression. - */ + * Returns the square root of a number. + * @param x A numeric expression. + */ sqrt(x: number): number; /** - * Returns the tangent of a number. - * @param x A numeric expression that contains an angle measured in radians. - */ + * Returns the tangent of a number. + * @param x A numeric expression that contains an angle measured in radians. + */ tan(x: number): number; } /** An intrinsic object that provides basic mathematics functionality and constants. */ @@ -778,98 +778,98 @@ interface Date { /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ getTimezoneOffset(): number; /** - * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. - */ + * Sets the date and time value in the Date object. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + */ setTime(time: number): number; /** - * Sets the milliseconds value in the Date object using local time. - * @param ms A numeric value equal to the millisecond value. - */ + * Sets the milliseconds value in the Date object using local time. + * @param ms A numeric value equal to the millisecond value. + */ setMilliseconds(ms: number): number; /** - * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). - * @param ms A numeric value equal to the millisecond value. - */ + * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). + * @param ms A numeric value equal to the millisecond value. + */ setUTCMilliseconds(ms: number): number; /** - * Sets the seconds value in the Date object using local time. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the seconds value in the Date object using local time. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setSeconds(sec: number, ms?: number): number; /** - * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the seconds value in the Date object using Universal Coordinated Time (UTC). + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setUTCSeconds(sec: number, ms?: number): number; /** - * Sets the minutes value in the Date object using local time. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setMinutes(min: number, sec?: number, ms?: number): number; /** - * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setUTCMinutes(min: number, sec?: number, ms?: number): number; /** - * Sets the hour value in the Date object using local time. - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the hour value in the Date object using local time. + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setHours(hours: number, min?: number, sec?: number, ms?: number): number; /** - * Sets the hours value in the Date object using Universal Coordinated Time (UTC). - * @param hours A numeric value equal to the hours value. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. - * @param ms A numeric value equal to the milliseconds value. - */ + * Sets the hours value in the Date object using Universal Coordinated Time (UTC). + * @param hours A numeric value equal to the hours value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. + * @param ms A numeric value equal to the milliseconds value. + */ setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; /** - * Sets the numeric day-of-the-month value of the Date object using local time. - * @param date A numeric value equal to the day of the month. - */ + * Sets the numeric day-of-the-month value of the Date object using local time. + * @param date A numeric value equal to the day of the month. + */ setDate(date: number): number; /** - * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). - * @param date A numeric value equal to the day of the month. - */ + * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). + * @param date A numeric value equal to the day of the month. + */ setUTCDate(date: number): number; /** - * Sets the month value in the Date object using local time. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. - */ + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. + */ setMonth(month: number, date?: number): number; /** - * Sets the month value in the Date object using Universal Coordinated Time (UTC). - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. - * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. - */ + * Sets the month value in the Date object using Universal Coordinated Time (UTC). + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + * @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used. + */ setUTCMonth(month: number, date?: number): number; /** - * Sets the year of the Date object using local time. - * @param year A numeric value for the year. - * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. - * @param date A numeric value equal for the day of the month. - */ + * Sets the year of the Date object using local time. + * @param year A numeric value for the year. + * @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified. + * @param date A numeric value equal for the day of the month. + */ setFullYear(year: number, month?: number, date?: number): number; /** - * Sets the year value in the Date object using Universal Coordinated Time (UTC). - * @param year A numeric value equal to the year. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. - * @param date A numeric value equal to the day of the month. - */ + * Sets the year value in the Date object using Universal Coordinated Time (UTC). + * @param year A numeric value equal to the year. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied. + * @param date A numeric value equal to the day of the month. + */ setUTCFullYear(year: number, month?: number, date?: number): number; /** Returns a date converted to a string using Universal Coordinated Time (UTC). */ toUTCString(): string; @@ -886,20 +886,20 @@ interface DateConstructor { (): string; readonly prototype: Date; /** - * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. - * @param s A date string - */ + * Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970. + * @param s A date string + */ parse(s: string): number; /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. - * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. - * @param month The month as an number between 0 and 11 (January to December). - * @param date The date as an number between 1 and 31. - * @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour. - * @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes. - * @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds. - * @param ms An number from 0 to 999 that specifies the milliseconds. - */ + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. + * @param month The month as a number between 0 and 11 (January to December). + * @param date The date as a number between 1 and 31. + * @param hours Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour. + * @param minutes Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes. + * @param seconds Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds. + * @param ms A number from 0 to 999 that specifies the milliseconds. + */ UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number; now(): number; } @@ -918,15 +918,15 @@ interface RegExpExecArray extends Array { interface RegExp { /** - * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. - * @param string The String object or string literal on which to perform the search. - */ + * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. + * @param string The String object or string literal on which to perform the search. + */ exec(string: string): RegExpExecArray | null; /** - * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. - * @param string String on which to perform the search. - */ + * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. + * @param string String on which to perform the search. + */ test(string: string): boolean; /** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */ @@ -1051,31 +1051,31 @@ declare var URIError: URIErrorConstructor; interface JSON { /** - * Converts a JavaScript Object Notation (JSON) string into an object. - * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. - */ + * Converts a JavaScript Object Notation (JSON) string into an object. + * @param text A valid JSON string. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. + */ parse(text: string, reviver?: (this: any, key: string, value: any) => any): any; /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer A function that transforms the results. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer A function that transforms the results. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string; /** - * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. - * @param value A JavaScript value, usually an object or array, to be converted. - * @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified. - * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. - */ + * Converts a JavaScript value to a JavaScript Object Notation (JSON) string. + * @param value A JavaScript value, usually an object or array, to be converted. + * @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified. + * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. + */ stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string; } /** - * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. - */ + * An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format. + */ declare var JSON: JSON; @@ -1085,112 +1085,118 @@ declare var JSON: JSON; interface ReadonlyArray { /** - * Gets the length of the array. This is a number one higher than the highest element defined in an array. - */ + * Gets the length of the array. This is a number one higher than the highest element defined in an array. + */ readonly length: number; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. - */ + * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + */ toLocaleString(): string; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: ConcatArray[]): T[]; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: (T | ConcatArray)[]): T[]; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): T[]; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ indexOf(searchElement: T, fromIndex?: number): number; /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ lastIndexOf(searchElement: T, fromIndex?: number): number; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: T, index: number, array: ReadonlyArray) => unknown, thisArg?: any): boolean; - /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: T, index: number, array: ReadonlyArray) => unknown, thisArg?: any): boolean; - /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - forEach(callbackfn: (value: T, index: number, array: ReadonlyArray) => void, thisArg?: any): void; - /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - map(callbackfn: (value: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; + /** + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean; + /** + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void; + /** + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + map(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => value is S, thisArg?: any): S[]; - /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ - filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => unknown, thisArg?: any): T[]; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T): T; - reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue: T): T; - /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T): T; - reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: ReadonlyArray) => T, initialValue: T): T; - /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ - reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: ReadonlyArray) => U, initialValue: U): U; + filter(callbackfn: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[]; + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[]; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; + reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; + /** + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T; + reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T; + /** + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ + reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U; readonly [n: number]: T; } @@ -1204,113 +1210,124 @@ interface ConcatArray { interface Array { /** - * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. - */ + * Gets or sets the length of the array. This is a number one higher than the highest element defined in an array. + */ length: number; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; /** - * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. - */ + * Returns a string representation of an array. The elements are converted to string using their toLocalString methods. + */ toLocaleString(): string; /** - * Removes the last element from an array and returns it. - */ + * Removes the last element from an array and returns it. + */ pop(): T | undefined; /** - * Appends new elements to an array, and returns the new length of the array. - * @param items New elements of the Array. - */ + * Appends new elements to an array, and returns the new length of the array. + * @param items New elements of the Array. + */ push(...items: T[]): number; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: ConcatArray[]): T[]; /** - * Combines two or more arrays. - * @param items Additional items to add to the end of array1. - */ + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ concat(...items: (T | ConcatArray)[]): T[]; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): T[]; /** - * Removes the first element from an array and returns it. - */ + * Removes the first element from an array and returns it. + */ shift(): T | undefined; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): T[]; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: T, b: T) => number): this; /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - */ + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + */ splice(start: number, deleteCount?: number): T[]; /** - * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. - * @param start The zero-based location in the array from which to start removing elements. - * @param deleteCount The number of elements to remove. - * @param items Elements to insert into the array in place of the deleted elements. - */ + * Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements. + * @param start The zero-based location in the array from which to start removing elements. + * @param deleteCount The number of elements to remove. + * @param items Elements to insert into the array in place of the deleted elements. + */ splice(start: number, deleteCount: number, ...items: T[]): T[]; /** - * Inserts new elements at the start of an array. - * @param items Elements to insert at the start of the Array. - */ + * Inserts new elements at the start of an array. + * @param items Elements to insert at the start of the Array. + */ unshift(...items: T[]): number; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. + */ indexOf(searchElement: T, fromIndex?: number): number; /** - * Returns the index of the last occurrence of a specified value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. - */ + * Returns the index of the last occurrence of a specified value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array. + */ lastIndexOf(searchElement: T, fromIndex?: number): number; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; /** - * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; /** * Returns the elements of an array that meet the condition specified in a callback function. @@ -1319,36 +1336,36 @@ interface Array { */ filter(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[]; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[]; /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; /** - * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T; reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; /** - * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; [n: number]: T; @@ -1361,8 +1378,8 @@ interface ArrayConstructor { (arrayLength?: number): any[]; (arrayLength: number): T[]; (...items: T[]): T[]; - isArray(arg: any): arg is Array; - readonly prototype: Array; + isArray(arg: any): arg is any[]; + readonly prototype: any[]; } declare var Array: ArrayConstructor; @@ -1499,20 +1516,20 @@ type InstanceType any> = T extends new (...args: interface ThisType { } /** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. + */ interface ArrayBuffer { /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ + * Read-only. The length of the ArrayBuffer (in bytes). + */ readonly byteLength: number; /** - * Returns a section of an ArrayBuffer. - */ + * Returns a section of an ArrayBuffer. + */ slice(begin: number, end?: number): ArrayBuffer; } @@ -1533,18 +1550,18 @@ declare var ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ byteOffset: number; } @@ -1553,126 +1570,126 @@ interface DataView { readonly byteLength: number; readonly byteOffset: number; /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getFloat32(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Float64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getFloat64(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getInt8(byteOffset: number): number; /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getInt16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getInt32(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getUint8(byteOffset: number): number; /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getUint16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getUint32(byteOffset: number, littleEndian?: boolean): number; /** - * Stores an Float32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Float32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Float64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Float64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ + * Stores an Int8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ setInt8(byteOffset: number, value: number): void; /** - * Stores an Int16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Int16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Int32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint8 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - */ + * Stores an Uint8 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + */ setUint8(byteOffset: number, value: number): void; /** - * Stores an Uint16 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Uint16 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint32 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores an Uint32 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; } @@ -1682,241 +1699,245 @@ interface DataViewConstructor { declare var DataView: DataViewConstructor; /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Int8Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Int8Array) => any, thisArg?: any): Int8Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Int8Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Int8Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int8Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int8Array; + * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Int8Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -1928,28 +1949,28 @@ interface Int8ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int8Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Int8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Int8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int8Array; @@ -1957,241 +1978,245 @@ interface Int8ArrayConstructor { declare var Int8Array: Int8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint8Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Uint8Array) => any, thisArg?: any): Uint8Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint8Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint8Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8Array; + * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Uint8Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -2204,269 +2229,273 @@ interface Uint8ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint8Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8Array; } declare var Uint8Array: Uint8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * If the requested number of bytes could not be allocated an exception is raised. + */ interface Uint8ClampedArray { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => any, thisArg?: any): Uint8ClampedArray; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint8ClampedArray; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint8ClampedArray; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint8ClampedArray; + * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Uint8ClampedArray; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -2479,267 +2508,271 @@ interface Uint8ClampedArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8ClampedArray; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint8ClampedArray; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint8ClampedArray; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint8ClampedArray; } declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Int16Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Int16Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Int16Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int16Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int16Array; + * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Int16Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -2752,28 +2785,28 @@ interface Int16ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int16Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Int16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Int16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int16Array; @@ -2781,241 +2814,245 @@ interface Int16ArrayConstructor { declare var Int16Array: Int16ArrayConstructor; /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint16Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Uint16Array) => any, thisArg?: any): Uint16Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint16Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint16Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint16Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint16Array; + * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Uint16Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3028,269 +3065,273 @@ interface Uint16ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint16Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint16Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint16Array; } declare var Uint16Array: Uint16ArrayConstructor; /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Int32Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Int32Array) => any, thisArg?: any): Int32Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Int32Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Int32Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Int32Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Int32Array; + * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Int32Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3303,268 +3344,272 @@ interface Int32ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int32Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Int32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Int32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Int32Array; } declare var Int32Array: Int32ArrayConstructor; /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated an exception is raised. + */ interface Uint32Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Uint32Array) => any, thisArg?: any): Uint32Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Uint32Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Uint32Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Uint32Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Uint32Array; + * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Uint32Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3577,269 +3622,273 @@ interface Uint32ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint32Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Uint32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Uint32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Uint32Array; } declare var Uint32Array: Uint32ArrayConstructor; /** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ + * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number + * of bytes could not be allocated an exception is raised. + */ interface Float32Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Float32Array) => any, thisArg?: any): Float32Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Float32Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Float32Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float32Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float32Array; + * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Float32Array; /** - * Converts a number to a string by using the current locale. - */ + * Converts a number to a string by using the current locale. + */ toLocaleString(): string; /** - * Returns a string representation of an array. - */ + * Returns a string representation of an array. + */ toString(): string; [index: number]: number; @@ -3852,28 +3901,28 @@ interface Float32ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float32Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Float32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Float32Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float32Array; @@ -3881,241 +3930,236 @@ interface Float32ArrayConstructor { declare var Float32Array: Float32ArrayConstructor; /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * number of bytes could not be allocated an exception is raised. + */ interface Float64Array { /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. - */ + * The ArrayBuffer instance referenced by the array. + */ readonly buffer: ArrayBufferLike; /** - * The length in bytes of the array. - */ + * The length in bytes of the array. + */ readonly byteLength: number; /** - * The offset in bytes of the array. - */ + * The offset in bytes of the array. + */ readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - every(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value false, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + every(callbackfn: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: number, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: number, index: number, array: Float64Array) => any, thisArg?: any): Float64Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: number, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: number, fromIndex?: number): number; /** - * The length of the array. - */ + * The length of the array. + */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number): number; reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue: number): number; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. - */ + * Reverses the elements in an Array. + */ reverse(): Float64Array; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. This is exclusive of the element at the index 'end'. + */ slice(start?: number, end?: number): Float64Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ - some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls + * the callbackfn function for each element in the array until the callbackfn returns a value + * which is coercible to the Boolean value true, or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ + some(callbackfn: (value: number, index: number, array: Float64Array) => unknown, thisArg?: any): boolean; /** - * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If - * omitted, the elements are sorted in ascending, ASCII character order. - */ + * Sorts an array. + * @param compareFn Function used to determine the order of the elements. It is expected to return + * a negative value if first argument is less than second argument, zero if they're equal and a positive + * value otherwise. If omitted, the elements are sorted in ascending, ASCII character order. + * ```ts + * [11,2,22,1].sort((a, b) => a - b) + * ``` + */ sort(compareFn?: (a: number, b: number) => number): this; /** - * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): Float64Array; - - /** - * Converts a number to a string by using the current locale. - */ - toLocaleString(): string; + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): Float64Array; - /** - * Returns a string representation of an array. - */ toString(): string; [index: number]: number; @@ -4128,28 +4172,28 @@ interface Float64ArrayConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float64Array; /** - * The size in bytes of each element in the array. - */ + * The size in bytes of each element in the array. + */ readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: number[]): Float64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + */ from(arrayLike: ArrayLike): Float64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike, mapfn: (v: T, k: number) => number, thisArg?: any): Float64Array; } @@ -4272,41 +4316,41 @@ declare namespace Intl { interface String { /** - * Determines whether two strings are equivalent in the current or specified locale. - * @param that String to compare to target string - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. - * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. - */ + * Determines whether two strings are equivalent in the current or specified locale. + * @param that String to compare to target string + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. This parameter must conform to BCP 47 standards; see the Intl.Collator object for details. + * @param options An object that contains one or more properties that specify comparison options. see the Intl.Collator object for details. + */ localeCompare(that: string, locales?: string | string[], options?: Intl.CollatorOptions): number; } interface Number { /** - * Converts a number to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a number to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions): string; } interface Date { /** - * Converts a date and time to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a date and time to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a date to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a date to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleDateString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a time to a string by using the current or specified locale. - * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. - * @param options An object that contains one or more properties that specify comparison options. - */ + * Converts a time to a string by using the current or specified locale. + * @param locales A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. + * @param options An object that contains one or more properties that specify comparison options. + */ toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): string; } diff --git a/node_modules/typescript/lib/lib.esnext.bigint.d.ts b/node_modules/typescript/lib/lib.esnext.bigint.d.ts index ae6711a4a..748841ae7 100644 --- a/node_modules/typescript/lib/lib.esnext.bigint.d.ts +++ b/node_modules/typescript/lib/lib.esnext.bigint.d.ts @@ -20,9 +20,9 @@ and limitations under the License. interface BigInt { /** - * Returns a string representation of an object. - * @param radix Specifies a radix for converting numeric values to strings. - */ + * Returns a string representation of an object. + * @param radix Specifies a radix for converting numeric values to strings. + */ toString(radix?: number): string; /** Returns a string representation appropriate to the host environment's current locale. */ @@ -39,27 +39,27 @@ interface BigIntConstructor { readonly prototype: BigInt; /** - * Interprets the low bits of a BigInt as a 2's-complement signed integer. - * All higher bits are discarded. - * @param bits The number of low bits to use - * @param int The BigInt whose bits to extract - */ + * Interprets the low bits of a BigInt as a 2's-complement signed integer. + * All higher bits are discarded. + * @param bits The number of low bits to use + * @param int The BigInt whose bits to extract + */ asIntN(bits: number, int: bigint): bigint; /** - * Interprets the low bits of a BigInt as an unsigned integer. - * All higher bits are discarded. - * @param bits The number of low bits to use - * @param int The BigInt whose bits to extract - */ + * Interprets the low bits of a BigInt as an unsigned integer. + * All higher bits are discarded. + * @param bits The number of low bits to use + * @param int The BigInt whose bits to extract + */ asUintN(bits: number, int: bigint): bigint; } declare var BigInt: BigIntConstructor; /** - * A typed array of 64-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated, an exception is raised. - */ + * A typed array of 64-bit signed integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated, an exception is raised. + */ interface BigInt64Array { /** The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -74,213 +74,213 @@ interface BigInt64Array { readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** Yields index, value pairs for every entry in the array. */ entries(): IterableIterator<[number, bigint]>; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in the array until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: bigint, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: bigint, index: number, array: BigInt64Array) => any, thisArg?: any): BigInt64Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): bigint | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: bigint, index: number, array: BigInt64Array) => void, thisArg?: any): void; /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: bigint, fromIndex?: number): boolean; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: bigint, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** Yields each index in the array. */ keys(): IterableIterator; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: bigint, fromIndex?: number): number; /** The length of the array. */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: bigint, index: number, array: BigInt64Array) => bigint, thisArg?: any): BigInt64Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigInt64Array) => bigint): bigint; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigInt64Array) => U, initialValue: U): U; /** Reverses the elements in the array. */ reverse(): this; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ slice(start?: number, end?: number): BigInt64Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in the array until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in the array until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: bigint, index: number, array: BigInt64Array) => boolean, thisArg?: any): boolean; /** - * Sorts the array. - * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. - */ + * Sorts the array. + * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. + */ sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; /** - * Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): BigInt64Array; + * Gets a new BigInt64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): BigInt64Array; /** Converts the array to a string by using the current locale. */ toLocaleString(): string; @@ -308,17 +308,17 @@ interface BigInt64ArrayConstructor { readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: bigint[]): BigInt64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike): BigInt64Array; from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigInt64Array; } @@ -326,9 +326,9 @@ interface BigInt64ArrayConstructor { declare var BigInt64Array: BigInt64ArrayConstructor; /** - * A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated, an exception is raised. - */ + * A typed array of 64-bit unsigned integer values. The contents are initialized to 0. If the + * requested number of bytes could not be allocated, an exception is raised. + */ interface BigUint64Array { /** The size in bytes of each element in the array. */ readonly BYTES_PER_ELEMENT: number; @@ -343,213 +343,213 @@ interface BigUint64Array { readonly byteOffset: number; /** - * Returns the this object after copying a section of the array identified by start and end - * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it - * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. - */ + * Returns the this object after copying a section of the array identified by start and end + * to the same array starting at position target + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it + * is treated as length+end. + * @param end If not specified, length of the this object is used as its default value. + */ copyWithin(target: number, start: number, end?: number): this; /** Yields index, value pairs for every entry in the array. */ entries(): IterableIterator<[number, bigint]>; /** - * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in the array until the callbackfn returns false, - * or until the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether all the members of an array satisfy the specified test. + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in the array until the callbackfn returns false, + * or until the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ every(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; /** - * Returns the this object after filling the section identified by start and end with value - * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as - * length+end. - */ + * Returns the this object after filling the section identified by start and end with value + * @param value value to fill array section with + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as + * length+end. + */ fill(value: bigint, start?: number, end?: number): this; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ filter(callbackfn: (value: bigint, index: number, array: BigUint64Array) => any, thisArg?: any): BigUint64Array; /** - * Returns the value of the first element in the array where predicate is true, and undefined - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find - * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ find(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): bigint | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg If provided, it will be used as the this value for each invocation of - * predicate. If it is not provided, undefined is used instead. - */ + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ findIndex(predicate: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): number; /** - * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Performs the specified action for each element in an array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ forEach(callbackfn: (value: bigint, index: number, array: BigUint64Array) => void, thisArg?: any): void; /** - * Determines whether an array includes a certain element, returning true or false as appropriate. - * @param searchElement The element to search for. - * @param fromIndex The position in this array at which to begin searching for searchElement. - */ + * Determines whether an array includes a certain element, returning true or false as appropriate. + * @param searchElement The element to search for. + * @param fromIndex The position in this array at which to begin searching for searchElement. + */ includes(searchElement: bigint, fromIndex?: number): boolean; /** - * Returns the index of the first occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the first occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ indexOf(searchElement: bigint, fromIndex?: number): number; /** - * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the - * resulting String. If omitted, the array elements are separated with a comma. - */ + * Adds all the elements of an array separated by the specified separator string. + * @param separator A string used to separate one element of an array from the next in the + * resulting String. If omitted, the array elements are separated with a comma. + */ join(separator?: string): string; /** Yields each index in the array. */ keys(): IterableIterator; /** - * Returns the index of the last occurrence of a value in an array. - * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the - * search starts at index 0. - */ + * Returns the index of the last occurrence of a value in an array. + * @param searchElement The value to locate in the array. + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * search starts at index 0. + */ lastIndexOf(searchElement: bigint, fromIndex?: number): number; /** The length of the array. */ readonly length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that - * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Calls a defined callback function on each element of an array, and returns an array that + * contains the results. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ map(callbackfn: (value: bigint, index: number, array: BigUint64Array) => bigint, thisArg?: any): BigUint64Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next - * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the - * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next + * call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduce(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an - * argument instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an + * argument instead of an array value. + */ reduceRight(callbackfn: (previousValue: bigint, currentValue: bigint, currentIndex: number, array: BigUint64Array) => bigint): bigint; /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an - * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument - * instead of an array value. - */ + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an + * argument in the next call to the callback function. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument + * instead of an array value. + */ reduceRight(callbackfn: (previousValue: U, currentValue: bigint, currentIndex: number, array: BigUint64Array) => U, initialValue: U): U; /** Reverses the elements in the array. */ reverse(): this; /** - * Sets a value or an array of values. - * @param array A typed or untyped array of values to set. - * @param offset The index in the current array at which the values are to be written. - */ + * Sets a value or an array of values. + * @param array A typed or untyped array of values to set. + * @param offset The index in the current array at which the values are to be written. + */ set(array: ArrayLike, offset?: number): void; /** - * Returns a section of an array. - * @param start The beginning of the specified portion of the array. - * @param end The end of the specified portion of the array. - */ + * Returns a section of an array. + * @param start The beginning of the specified portion of the array. + * @param end The end of the specified portion of the array. + */ slice(start?: number, end?: number): BigUint64Array; /** - * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in the array until the callbackfn returns true, or until - * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. - * If thisArg is omitted, undefined is used as the this value. - */ + * Determines whether the specified callback function returns true for any element of an array. + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in the array until the callbackfn returns true, or until + * the end of the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * If thisArg is omitted, undefined is used as the this value. + */ some(callbackfn: (value: bigint, index: number, array: BigUint64Array) => boolean, thisArg?: any): boolean; /** - * Sorts the array. - * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. - */ + * Sorts the array. + * @param compareFn The function used to determine the order of the elements. If omitted, the elements are sorted in ascending order. + */ sort(compareFn?: (a: bigint, b: bigint) => number | bigint): this; /** - * Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. - * @param begin The index of the beginning of the array. - * @param end The index of the end of the array. - */ - subarray(begin: number, end?: number): BigUint64Array; + * Gets a new BigUint64Array view of the ArrayBuffer store for this array, referencing the elements + * at begin, inclusive, up to end, exclusive. + * @param begin The index of the beginning of the array. + * @param end The index of the end of the array. + */ + subarray(begin?: number, end?: number): BigUint64Array; /** Converts the array to a string by using the current locale. */ toLocaleString(): string; @@ -577,17 +577,17 @@ interface BigUint64ArrayConstructor { readonly BYTES_PER_ELEMENT: number; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * Returns a new array from a set of elements. + * @param items A set of elements to include in the new array object. + */ of(...items: bigint[]): BigUint64Array; /** - * Creates an array from an array-like or iterable object. - * @param arrayLike An array-like or iterable object to convert to an array. - * @param mapfn A mapping function to call on every element of the array. - * @param thisArg Value of 'this' used to invoke the mapfn. - */ + * Creates an array from an array-like or iterable object. + * @param arrayLike An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of 'this' used to invoke the mapfn. + */ from(arrayLike: ArrayLike): BigUint64Array; from(arrayLike: ArrayLike, mapfn: (v: U, k: number) => bigint, thisArg?: any): BigUint64Array; } @@ -596,34 +596,34 @@ declare var BigUint64Array: BigUint64ArrayConstructor; interface DataView { /** - * Gets the BigInt64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the BigInt64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getBigInt64(byteOffset: number, littleEndian?: boolean): bigint; /** - * Gets the BigUint64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. - * @param byteOffset The place in the buffer at which the value should be retrieved. - */ + * Gets the BigUint64 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. + * @param byteOffset The place in the buffer at which the value should be retrieved. + */ getBigUint64(byteOffset: number, littleEndian?: boolean): bigint; /** - * Stores a BigInt64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores a BigInt64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setBigInt64(byteOffset: number, value: bigint, littleEndian?: boolean): void; /** - * Stores a BigUint64 value at the specified byte offset from the start of the view. - * @param byteOffset The place in the buffer at which the value should be set. - * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, - * otherwise a little-endian value should be written. - */ + * Stores a BigUint64 value at the specified byte offset from the start of the view. + * @param byteOffset The place in the buffer at which the value should be set. + * @param value The value to set. + * @param littleEndian If false or undefined, a big-endian value should be written, + * otherwise a little-endian value should be written. + */ setBigUint64(byteOffset: number, value: bigint, littleEndian?: boolean): void; } diff --git a/node_modules/typescript/lib/lib.esnext.d.ts b/node_modules/typescript/lib/lib.esnext.d.ts index f94447465..a4a0d06ac 100644 --- a/node_modules/typescript/lib/lib.esnext.d.ts +++ b/node_modules/typescript/lib/lib.esnext.d.ts @@ -18,6 +18,6 @@ and limitations under the License. /// -/// +/// /// /// diff --git a/node_modules/typescript/lib/lib.esnext.intl.d.ts b/node_modules/typescript/lib/lib.esnext.intl.d.ts index 72a9bae1e..33988f314 100644 --- a/node_modules/typescript/lib/lib.esnext.intl.d.ts +++ b/node_modules/typescript/lib/lib.esnext.intl.d.ts @@ -29,4 +29,4 @@ declare namespace Intl { interface NumberFormat { formatToParts(number?: number): NumberFormatPart[]; } - } +} diff --git a/node_modules/typescript/lib/lib.webworker.d.ts b/node_modules/typescript/lib/lib.webworker.d.ts index 153ecbd29..3e6773d77 100644 --- a/node_modules/typescript/lib/lib.webworker.d.ts +++ b/node_modules/typescript/lib/lib.webworker.d.ts @@ -2222,7 +2222,7 @@ interface ImageData { declare var ImageData: { prototype: ImageData; new(width: number, height: number): ImageData; - new(array: Uint8ClampedArray, width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height?: number): ImageData; }; /** This Channel Messaging API interface allows us to create a new message channel and send data through it via its two MessagePort properties. */ @@ -2472,7 +2472,7 @@ declare var OffscreenCanvas: { new(width: number, height: number): OffscreenCanvas; }; -interface OffscreenCanvasRenderingContext2D extends CanvasState, CanvasTransform, CanvasCompositing, CanvasImageSmoothing, CanvasFillStrokeStyles, CanvasShadowStyles, CanvasFilters, CanvasRect, CanvasDrawPath, CanvasText, CanvasDrawImage, CanvasImageData, CanvasPathDrawingStyles, CanvasTextDrawingStyles, CanvasPath { +interface OffscreenCanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform { readonly canvas: OffscreenCanvas; commit(): void; } @@ -3102,7 +3102,7 @@ interface TextDecoderCommon { readonly ignoreBOM: boolean; } -interface TextDecoderStream extends TextDecoderCommon, GenericTransformStream { +interface TextDecoderStream extends GenericTransformStream, TextDecoderCommon { } declare var TextDecoderStream: { @@ -3134,7 +3134,7 @@ interface TextEncoderCommon { readonly encoding: string; } -interface TextEncoderStream extends TextEncoderCommon, GenericTransformStream { +interface TextEncoderStream extends GenericTransformStream, TextEncoderCommon { } declare var TextEncoderStream: { @@ -3385,7 +3385,7 @@ interface WEBGL_lose_context { restoreContext(): void; } -interface WebGL2RenderingContext extends WebGLRenderingContextBase, WebGL2RenderingContextBase, WebGL2RenderingContextOverloads { +interface WebGL2RenderingContext extends WebGL2RenderingContextBase, WebGL2RenderingContextOverloads, WebGLRenderingContextBase { } declare var WebGL2RenderingContext: { @@ -5375,7 +5375,7 @@ interface WorkerGlobalScopeEventMap { } /** This Web Workers API interface is an interface representing the scope of any worker. Workers have no browsing context; this scope contains the information usually conveyed by Window objects — in this case event handlers, the console or the associated WorkerNavigator object. Each WorkerGlobalScope has its own event loop. */ -interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, WindowOrWorkerGlobalScope { +interface WorkerGlobalScope extends EventTarget, WindowConsole, WindowOrWorkerGlobalScope, WorkerUtils { readonly caches: CacheStorage; readonly isSecureContext: boolean; readonly location: WorkerLocation; @@ -5414,7 +5414,7 @@ declare var WorkerLocation: { }; /** A subset of the Navigator interface allowed to be accessed from a Worker. Such an object is initialized for each worker and is available via the WorkerGlobalScope.navigator property obtained by calling window.self.navigator. */ -interface WorkerNavigator extends NavigatorID, NavigatorOnLine, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorStorage { +interface WorkerNavigator extends NavigatorBeacon, NavigatorConcurrentHardware, NavigatorID, NavigatorOnLine, NavigatorStorage { readonly permissions: Permissions; readonly serviceWorker: ServiceWorkerContainer; } @@ -5620,16 +5620,16 @@ declare namespace WebAssembly { var Global: { prototype: Global; - new(descriptor: GlobalDescriptor, value?: any): Global; + new(descriptor: GlobalDescriptor, v?: any): Global; }; interface Instance { - readonly exports: any; + readonly exports: Exports; } var Instance: { prototype: Instance; - new(module: Module, importObject?: any): Instance; + new(module: Module, importObject?: Imports): Instance; }; interface Memory { @@ -5648,9 +5648,9 @@ declare namespace WebAssembly { var Module: { prototype: Module; new(bytes: BufferSource): Module; - customSections(module: Module, sectionName: string): ArrayBuffer[]; - exports(module: Module): ModuleExportDescriptor[]; - imports(module: Module): ModuleImportDescriptor[]; + customSections(moduleObject: Module, sectionName: string): ArrayBuffer[]; + exports(moduleObject: Module): ModuleExportDescriptor[]; + imports(moduleObject: Module): ModuleImportDescriptor[]; }; interface Table { @@ -5667,7 +5667,7 @@ declare namespace WebAssembly { interface GlobalDescriptor { mutable?: boolean; - value: string; + value: ValueType; } interface MemoryDescriptor { @@ -5699,9 +5699,17 @@ declare namespace WebAssembly { type ImportExportKind = "function" | "table" | "memory" | "global"; type TableKind = "anyfunc"; + type ValueType = "i32" | "i64" | "f32" | "f64"; + type ExportValue = Function | Global | Memory | Table; + type Exports = Record; + type ImportValue = ExportValue | number; + type ModuleImports = Record; + type Imports = Record; function compile(bytes: BufferSource): Promise; - function instantiate(bytes: BufferSource, importObject?: any): Promise; - function instantiate(moduleObject: Module, importObject?: any): Promise; + function compileStreaming(source: Response | Promise): Promise; + function instantiate(bytes: BufferSource, importObject?: Imports): Promise; + function instantiate(moduleObject: Module, importObject?: Imports): Promise; + function instantiateStreaming(response: Response | PromiseLike, importObject?: Imports): Promise; function validate(bytes: BufferSource): boolean; } @@ -5875,7 +5883,7 @@ type RequestRedirect = "follow" | "error" | "manual"; type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; type ServiceWorkerUpdateViaCache = "imports" | "all" | "none"; -type VisibilityState = "hidden" | "visible" | "prerender"; +type VisibilityState = "hidden" | "visible"; type WebGLPowerPreference = "default" | "low-power" | "high-performance"; type WorkerType = "classic" | "module"; type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; diff --git a/node_modules/typescript/lib/pl/diagnosticMessages.generated.json b/node_modules/typescript/lib/pl/diagnosticMessages.generated.json index 8573d802c..e625476e0 100644 --- a/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/pl/diagnosticMessages.generated.json @@ -30,7 +30,7 @@ "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249": "Dekorator może dekorować jedynie implementację metody, a nie przeciążenie.", "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113": "Klauzula „default” nie może występować więcej niż raz w instrukcji „switch”.", "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319": "Eksport domyślny może być używany tylko w module w stylu języka ECMAScript.", - "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255": "Asercja określonego przydziału „!” nie jest dozwolona w tym kontekście.", + "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255": "Asercja określonego przypisania „!” nie jest dozwolona w tym kontekście.", "A_destructuring_declaration_must_have_an_initializer_1182": "Deklaracja usuwająca strukturę musi mieć inicjator.", "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712": "Wywołanie dynamicznego importowania w wersji ES5/ES3 wymaga konstruktora „Promise”. Upewnij się, że masz deklarację dla konstruktora „Promise”, lub uwzględnij wartość „ES2015” w opcji „--lib”.", "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711": "Wywołanie dynamicznego importowania zwraca element „Promise”. Upewnij się, że masz deklarację elementu „Promise” lub uwzględnij wartość „ES2015” w opcji „--lib”.", @@ -278,7 +278,7 @@ "Computed_property_names_are_not_allowed_in_enums_1164": "Obliczone nazwy właściwości nie są dozwolone w wyliczeniach.", "Computed_values_are_not_permitted_in_an_enum_with_string_valued_members_2553": "Obliczone wartości nie są dozwolone w wyliczeniu ze składowymi o wartości ciągu.", "Concatenate_and_emit_output_to_single_file_6001": "Połącz i wyemituj dane wyjściowe do pojedynczego pliku.", - "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090": "Znaleziono sprzeczne definicje dla „{0}” w „{1}” i „{2}”. Rozważ zainstalowanie konkretnej wersji tej biblioteki, aby rozwiązać problem.", + "Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_librar_4090": "Znaleziono definicje będące w konflikcie dla „{0}” w „{1}” i „{2}”. Rozważ zainstalowanie konkretnej wersji tej biblioteki, aby rozwiązać problem.", "Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type_7013": "Dla sygnatury konstrukcji bez adnotacji zwracanego typu niejawnie określono zwracany typ „any”.", "Constructor_implementation_is_missing_2390": "Brak implementacji konstruktora.", "Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration_2673": "Konstruktor klasy „{0}” jest prywatny i dostępny tylko w ramach deklaracji klasy.", @@ -441,7 +441,7 @@ "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391": "Brak implementacji funkcji lub nie występuje ona bezpośrednio po deklaracji.", "Function_implementation_name_must_be_0_2389": "Implementacja funkcji musi mieć nazwę „{0}”.", "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024": "Dla funkcji niejawnie określono zwracany typ „any”, ponieważ nie zawiera ona adnotacji zwracanego typu i jest przywoływana bezpośrednio lub pośrednio w jednym z jej zwracanych wyrażeń.", - "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "Funkcja nie zawiera końcowej instrukcji „return”, a zwracany typ nie obejmuje wartości „undefined”.", + "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "Funkcja nie zawiera końcowej instrukcji return, a zwracany typ nie obejmuje wartości „undefined”.", "Function_overload_must_be_static_2387": "Przeciążenie funkcji musi być statyczne.", "Function_overload_must_not_be_static_2388": "Przeciążenie funkcji nie może być statyczne.", "Generate_get_and_set_accessors_95046": "Generuj metody dostępu „get” i „set”.", @@ -594,7 +594,7 @@ "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003": "Nie można znaleźć danych wejściowych w pliku konfiguracji „{0}”. Określone ścieżki „include” to „{1}”, a „exclude” to „{2}”.", "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515": "Klasa nieabstrakcyjna „{0}” nie implementuje odziedziczonej abstrakcyjnej składowej „{1}” z klasy „{2}”.", "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653": "Wyrażenie klasy nieabstrakcyjnej nie implementuje odziedziczonej abstrakcyjnej składowej „{0}” z klasy „{1}”.", - "Not_all_code_paths_return_a_value_7030": "Nie wszystkie ścieżki kodu zwracają wartość.", + "Not_all_code_paths_return_a_value_7030": "Nie wszystkie ścieżki w kodzie zwracają wartość.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "Nie można przypisać typu indeksu numerycznego „{0}” do typu indeksu ciągu „{1}”.", "Numeric_separators_are_not_allowed_here_6188": "Separatory liczbowe nie są dozwolone w tym miejscu.", "Object_is_of_type_unknown_2571": "Obiekt jest typu „nieznany”.", @@ -745,7 +745,7 @@ "Remove_unused_label_95053": "Usuń nieużywaną etykietę", "Remove_variable_statement_90010": "Usuń instrukcję zmiennej", "Replace_import_with_0_95015": "Zamień import na element „{0}”.", - "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Zgłoś błąd, gdy nie wszystkie ścieżki kodu zwracają wartość.", + "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Zgłoś błąd, gdy nie wszystkie ścieżki w kodzie zwracają wartość.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Zgłoś błędy dla przepuszczających klauzul case w instrukcji switch.", "Report_errors_in_js_files_8019": "Zgłaszaj błędy w plikach js.", "Report_errors_on_unused_locals_6134": "Raportuj błędy dla nieużywanych elementów lokalnych.", diff --git a/node_modules/typescript/lib/protocol.d.ts b/node_modules/typescript/lib/protocol.d.ts index 5b9154cf4..1747e0f98 100644 --- a/node_modules/typescript/lib/protocol.d.ts +++ b/node_modules/typescript/lib/protocol.d.ts @@ -467,7 +467,7 @@ declare namespace ts.server.protocol { scope: OrganizeImportsScope; } interface OrganizeImportsResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } interface GetEditsForFileRenameRequest extends Request { command: CommandTypes.GetEditsForFileRename; @@ -479,7 +479,7 @@ declare namespace ts.server.protocol { readonly newFilePath: string; } interface GetEditsForFileRenameResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } /** * Request for the available codefixes at a specific position. @@ -526,7 +526,7 @@ declare namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes: ReadonlyArray; + errorCodes: readonly number[]; } interface GetCombinedCodeFixRequestArgs { scope: GetCombinedCodeFixScope; @@ -643,7 +643,7 @@ declare namespace ts.server.protocol { interface FileSpanWithContext extends FileSpan, TextSpanWithContext { } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions: readonly FileSpanWithContext[]; textSpan: TextSpan; } /** @@ -652,9 +652,11 @@ declare namespace ts.server.protocol { interface DefinitionResponse extends Response { body?: FileSpanWithContext[]; } - interface DefinitionInfoAndBoundSpanReponse extends Response { + interface DefinitionInfoAndBoundSpanResponse extends Response { body?: DefinitionInfoAndBoundSpan; } + /** @deprecated Use `DefinitionInfoAndBoundSpanResponse` instead. */ + type DefinitionInfoAndBoundSpanReponse = DefinitionInfoAndBoundSpanResponse; /** * Definition response message. Gives text range for definition. */ @@ -781,7 +783,7 @@ declare namespace ts.server.protocol { /** * The file locations referencing the symbol. */ - refs: ReadonlyArray; + refs: readonly ReferencesResponseItem[]; /** * The name of the symbol. */ @@ -885,7 +887,7 @@ declare namespace ts.server.protocol { /** * An array of span groups (one per file) that refer to the item to be renamed. */ - locs: ReadonlyArray; + locs: readonly SpanGroup[]; } /** * Rename response message. @@ -1364,8 +1366,8 @@ declare namespace ts.server.protocol { commands?: {}[]; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray<{}>; + changes: readonly FileCodeEdits[]; + commands?: readonly {}[]; } interface CodeFixAction extends CodeAction { /** Short name to identify the fix, for use by telemetry. */ @@ -1572,7 +1574,7 @@ declare namespace ts.server.protocol { readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; - readonly entries: ReadonlyArray; + readonly entries: readonly CompletionEntry[]; } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; @@ -2251,7 +2253,7 @@ declare namespace ts.server.protocol { /** * list of packages to install */ - packages: ReadonlyArray; + packages: readonly string[]; } interface BeginInstallTypesEventBody extends InstallTypesEventBody { } @@ -2272,6 +2274,11 @@ declare namespace ts.server.protocol { Block = "Block", Smart = "Smart" } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorSettings { baseIndentSize?: number; indentSize?: number; @@ -2297,6 +2304,7 @@ declare namespace ts.server.protocol { placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; insertSpaceBeforeTypeAnnotation?: boolean; + semicolons?: SemicolonPreference; } interface UserPreferences { readonly disableSuggestions?: boolean; @@ -2311,6 +2319,12 @@ declare namespace ts.server.protocol { * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. */ readonly includeCompletionsWithInsertText?: boolean; + /** + * Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled, + * member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined + * values, with insertion text to replace preceding `.` tokens with `?.`. + */ + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; readonly lazyConfiguredProjectsFromExternalProject?: boolean; @@ -2380,6 +2394,7 @@ declare namespace ts.server.protocol { strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; + useDefineForClassFields?: boolean; target?: ScriptTarget | ts.ScriptTarget; traceResolution?: boolean; resolveJsonModule?: boolean; @@ -2533,6 +2548,10 @@ declare namespace ts.server.protocol { } export interface TypeAcquisition { + /** + * @deprecated typingOptions.enableAutoDiscovery + * Use typeAcquisition.enable instead. + */ enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; diff --git a/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json b/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json index de74fa7bd..a1623b581 100644 --- a/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json @@ -441,7 +441,7 @@ "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391": "A implementação da função está ausente ou não está imediatamente depois da declaração.", "Function_implementation_name_must_be_0_2389": "O nome da implementação de função deve ser '{0}'.", "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024": "A função tem o tipo de retorno 'any', de forma implícita, porque ela não tem uma anotação de tipo de retorno e é referenciada direta ou indiretamente em uma das suas expressões de retorno.", - "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "A função não tem a instrução de retorno final e o tipo de retorno não inclui 'undefined'.", + "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "A função não tem a instrução return final e o tipo de retorno não inclui 'undefined'.", "Function_overload_must_be_static_2387": "A sobrecarga de função deve ser estática.", "Function_overload_must_not_be_static_2388": "A sobrecarga de função não deve ser estática.", "Generate_get_and_set_accessors_95046": "Gerar acessadores 'get' e 'set'", diff --git a/node_modules/typescript/lib/ru/diagnosticMessages.generated.json b/node_modules/typescript/lib/ru/diagnosticMessages.generated.json index 468fd47b8..f66fa953a 100644 --- a/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/ru/diagnosticMessages.generated.json @@ -30,7 +30,7 @@ "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249": "Декоратор может только декорировать реализацию метода, а не перегрузку.", "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113": "Предложение default не может повторяться в операторе switch.", "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319": "Экспорт по умолчанию можно использовать только в модуле в стиле ECMAScript.", - "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255": "Утверждение определенного присваивания \"!\" запрещено в этом контексте.", + "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255": "Утверждение определенного назначения \"!\" запрещено в этом контексте.", "A_destructuring_declaration_must_have_an_initializer_1182": "Объявление деструктурирования должно включать инициализатор.", "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712": "Для вызова динамического импорта в ES5/ES3 требуется конструктор \"Promise\". Объявите конструктор \"Promise\" или включите \"ES2015\" в параметр \"--lib\".", "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711": "Вызов динамического импорта возвращает конструктор \"Promise\". Объявите конструктор \"Promise\" или включите \"ES2015\" в параметр \"--lib\".", @@ -103,8 +103,8 @@ "Add_all_missing_super_calls_95039": "Добавить все отсутствующие вызовы super", "Add_async_modifier_to_containing_function_90029": "Добавьте модификатор async в содержащую функцию", "Add_braces_to_arrow_function_95059": "Добавить скобки в стрелочную функцию", - "Add_definite_assignment_assertion_to_property_0_95020": "Добавить утверждение определенного присваивания к свойству \"{0}\"", - "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "Добавить утверждения определенного присваивания ко всем неинициализированным свойствам", + "Add_definite_assignment_assertion_to_property_0_95020": "Добавить утверждение определенного назначения к свойству \"{0}\"", + "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "Добавить утверждения определенного назначения ко всем неинициализированным свойствам", "Add_index_signature_for_property_0_90017": "Добавьте сигнатуру индекса для свойства \"{0}\"", "Add_initializer_to_property_0_95019": "Добавить инициализатор к свойству \"{0}\"", "Add_initializers_to_all_uninitialized_properties_95027": "Добавить инициализаторы ко всем неинициализированным свойствам", @@ -130,7 +130,7 @@ "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209": "Перечисление внешних констант не разрешено, если задан флаг \"--isolatedModules\".", "Ambient_module_declaration_cannot_specify_relative_module_name_2436": "Объявление окружающего модуля не может содержать относительное имя модуля.", "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435": "Внешний модуль не может быть вложен в другие модули или пространства имен.", - "An_AMD_module_cannot_have_multiple_name_assignments_2458": "Модуль AMD не может иметь несколько присваиваний имен.", + "An_AMD_module_cannot_have_multiple_name_assignments_2458": "Модуль AMD не может иметь несколько назначений имен.", "An_abstract_accessor_cannot_have_an_implementation_1318": "У абстрактного метода доступа не может быть реализации.", "An_accessor_cannot_be_declared_in_an_ambient_context_1086": "Метод доступа нельзя объявить в окружающем контексте.", "An_accessor_cannot_have_type_parameters_1094": "Метод доступа не может иметь параметры типа.", @@ -142,10 +142,10 @@ "An_async_iterator_must_have_a_next_method_2519": "В асинхронном итераторе должен быть метод next().", "An_element_access_expression_should_take_an_argument_1011": "Выражение доступа к элементу должно принимать аргумент.", "An_enum_member_cannot_have_a_numeric_name_2452": "Имя элемента перечисления не может быть числовым.", - "An_export_assignment_can_only_be_used_in_a_module_1231": "Присваивание экспорта может быть использовано только в модуле.", - "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309": "Присваивание экспорта нельзя использовать в модуле с другими экспортированными элементами.", - "An_export_assignment_cannot_be_used_in_a_namespace_1063": "Присваивание экспорта нельзя использовать в пространстве имен.", - "An_export_assignment_cannot_have_modifiers_1120": "Присваивание экспорта не может иметь модификаторы.", + "An_export_assignment_can_only_be_used_in_a_module_1231": "Назначение экспорта может быть использовано только в модуле.", + "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309": "Назначение экспорта нельзя использовать в модуле с другими экспортированными элементами.", + "An_export_assignment_cannot_be_used_in_a_namespace_1063": "Назначение экспорта нельзя использовать в пространстве имен.", + "An_export_assignment_cannot_have_modifiers_1120": "Назначение экспорта не может иметь модификаторы.", "An_export_declaration_can_only_be_used_in_a_module_1233": "Объявление экспорта может быть использовано только в модуле.", "An_export_declaration_cannot_have_modifiers_1193": "Объявление экспорта не может иметь модификаторы.", "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198": "Расширенное escape-значение в Юникоде должно быть в пределах от 0x0 до 0x10FFFF включительно.", @@ -390,7 +390,7 @@ "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219": "Экспериментальная поддержка для декораторов — это функция, которая будет изменена в будущем выпуске. Задайте параметр experimentalDecorators, чтобы удалить это предупреждение.", "Explicitly_specified_module_resolution_kind_Colon_0_6087": "Явно указанный тип разрешения модуля: \"{0}\".", "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203": "Назначение экспорта невозможно использовать при разработке для модулей ECMAScript. Попробуйте использовать \"export default\" или другой формат модуля.", - "Export_assignment_is_not_supported_when_module_flag_is_system_1218": "Присваивание экспорта не поддерживается, если флаг \"--module\" имеет значение \"system\".", + "Export_assignment_is_not_supported_when_module_flag_is_system_1218": "Назначение экспорта не поддерживается, если флаг \"--module\" имеет значение \"system\".", "Export_declaration_conflicts_with_exported_declaration_of_0_2484": "Объявление экспорта конфликтует с экспортированным объявлением \"{0}\".", "Export_declarations_are_not_permitted_in_a_namespace_1194": "Объявления экспорта не разрешены в пространстве имен.", "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656": "Файл экспортированных внешних типизаций пакета \"{0}\" не является модулем. Обратитесь к автору пакета для обновления определения пакета.", @@ -441,7 +441,7 @@ "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391": "Реализация функции отсутствует либо не идет сразу после объявления.", "Function_implementation_name_must_be_0_2389": "Имя реализации функции должно иметь значение \"{0}\".", "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024": "Функция неявно имеет тип возвращаемого значения any, так как у нее нет заметки с типом возвращаемого значения, а также на нее прямо или косвенно указывает ссылка в одном из ее выражений \"return\".", - "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "В функции отсутствует завершающий оператор возвращаемого значения, а тип возвращаемого значения не включает undefined.", + "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "В функции отсутствует завершающий оператор return, а тип возвращаемого значения не включает \"undefined\".", "Function_overload_must_be_static_2387": "Перегрузка функции должна быть статической.", "Function_overload_must_not_be_static_2388": "Перегрузка функции не должна быть статической.", "Generate_get_and_set_accessors_95046": "Создать методы доступа get и set", @@ -594,7 +594,7 @@ "No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2_18003": "Не удалось найти входные данные в файле конфигурации \"{0}\". Указанные пути \"include\": \"{1}\", пути \"exclude\": \"{2}\".", "Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2_2515": "Класс \"{0}\", не являющийся абстрактным, не реализует наследуемый абстрактный элемент \"{1}\" класса \"{2}\".", "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653": "Выражение неабстрактного класса не реализует унаследованный абстрактный элемент \"{0}\" класса \"{1}\".", - "Not_all_code_paths_return_a_value_7030": "Не все пути кода возвращают значение.", + "Not_all_code_paths_return_a_value_7030": "Не все пути к коду возвращают значение.", "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413": "Тип числового индекса \"{0}\" нельзя назначить типу строкового индекса \"{1}\".", "Numeric_separators_are_not_allowed_here_6188": "Числовые разделители здесь запрещены.", "Object_is_of_type_unknown_2571": "Объект имеет тип \"Неизвестный\".", @@ -714,7 +714,7 @@ "Property_0_of_exported_interface_has_or_is_using_private_name_1_4033": "Свойство \"{0}\" экспортированного интерфейса имеет или использует закрытое имя \"{1}\".", "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412": "Свойство \"{0}\" типа \"{1}\" нельзя назначить типу числового индекса \"{2}\".", "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411": "Свойство \"{0}\" типа \"{1}\" нельзя назначить типу строкового индекса \"{2}\".", - "Property_assignment_expected_1136": "Ожидалось присваивание свойства.", + "Property_assignment_expected_1136": "Ожидалось назначение свойства.", "Property_destructuring_pattern_expected_1180": "Ожидался шаблон деструктурирования свойства.", "Property_or_signature_expected_1131": "Ожидалось свойство или сигнатура.", "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328": "Значение свойства может быть только строковым или числовым литералом, True, False, Null, объектным литералом либо литералом массива.", @@ -745,7 +745,7 @@ "Remove_unused_label_95053": "Удалить неиспользуемую метку", "Remove_variable_statement_90010": "Удалить оператор с переменной", "Replace_import_with_0_95015": "Замена импорта на \"{0}\".", - "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Сообщать об ошибке, если не все пути кода в функции возвращают значение.", + "Report_error_when_not_all_code_paths_in_function_return_a_value_6075": "Сообщать об ошибке, если не все пути к коду в функции возвращают значение.", "Report_errors_for_fallthrough_cases_in_switch_statement_6076": "Сообщать об ошибках для случаев передачи управления в операторе switch.", "Report_errors_in_js_files_8019": "Сообщать об ошибках в JS-файлах.", "Report_errors_on_unused_locals_6134": "Сообщать об ошибках в неиспользованных локальных переменных.", @@ -850,7 +850,7 @@ "The_character_set_of_the_input_files_6163": "Кодировка входных файлов.", "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563": "Содержащая функция или текст модуля слишком велики для анализа потока управления.", "The_current_host_does_not_support_the_0_option_5001": "Текущий узел не поддерживает параметр \"{0}\".", - "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714": "Выражение присваивания экспорта должно представлять собой идентификатор или полное имя в окружающем контексте.", + "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714": "Выражение назначения экспорта должно представлять собой идентификатор или полное имя в окружающем контексте.", "The_files_list_in_config_file_0_is_empty_18002": "Список \"files\" в файле конфигурации \"{0}\" пуст.", "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060": "Первым параметром метода then класса promise должен быть обратный вызов.", "The_global_type_JSX_0_may_not_have_more_than_one_property_2608": "Глобальный тип \"JSX.{0}\" не может иметь больше одного свойства.", @@ -1039,7 +1039,7 @@ "const_declarations_must_be_initialized_1155": "Объявления \"const\" должны быть инициализированы.", "const_enum_member_initializer_was_evaluated_to_a_non_finite_value_2477": "Инициализатор элементов перечисления const был вычислен в неконечное значение.", "const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN_2478": "Инициализатор элементов перечисления const был вычислен в запрещенное значение NaN.", - "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475": "Перечисления const можно использовать только в выражениях доступа к свойству или индексу, а также в правой части объявления импорта, присваивания экспорта или запроса типа.", + "const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_im_2475": "Перечисления const можно использовать только в выражениях доступа к свойству или индексу, а также в правой части объявления импорта, назначения экспорта или запроса типа.", "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102": "Невозможно вызвать оператор delete с идентификатором в строгом режиме.", "delete_this_Project_0_is_up_to_date_because_it_was_previously_built_6360": "удалить это — проект \"{0}\" не требует обновления, так как был собран ранее", "enum_declarations_can_only_be_used_in_a_ts_file_8015": "Объявления перечислений можно использовать только в TS-файле.", diff --git a/node_modules/typescript/lib/tr/diagnosticMessages.generated.json b/node_modules/typescript/lib/tr/diagnosticMessages.generated.json index 892fc74d3..dc52ec079 100644 --- a/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/tr/diagnosticMessages.generated.json @@ -453,7 +453,7 @@ "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220": "Oluşturucular yalnızca ECMEAScript 2015 veya üstü hedeflenirken kullanılabilir.", "Generic_type_0_requires_1_type_argument_s_2314": "'{0}' genel türü, {1} tür bağımsız değişkenini gerektiriyor.", "Generic_type_0_requires_between_1_and_2_type_arguments_2707": "'{0}' genel türü {1} ile {2} arasında bağımsız değişken gerektirir.", - "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550": "Genel tür oluşturma işlemi, fazla ayrıntılı ve büyük olasılıkla sınırsız.", + "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550": "Genel tür örneği oluşturma işlemi, fazla ayrıntılı ve büyük olasılıkla sınırsız.", "Getter_and_setter_accessors_do_not_agree_in_visibility_2379": "Alıcı ve ayarlayıcı erişimcileri görünürlükte anlaşamıyor.", "Global_module_exports_may_only_appear_at_top_level_1316": "Genel modül dışarı aktarmaları yalnızca en üst düzeyde görünebilir.", "Global_module_exports_may_only_appear_in_declaration_files_1315": "Genel modül dışarı aktarmaları yalnızca bildirim dosyalarında görünebilir.", diff --git a/node_modules/typescript/lib/tsc.js b/node_modules/typescript/lib/tsc.js index 447e45118..8f42c6874 100644 --- a/node_modules/typescript/lib/tsc.js +++ b/node_modules/typescript/lib/tsc.js @@ -66,19 +66,25 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook }; var ts; (function (ts) { - ts.versionMajorMinor = "3.6"; - ts.version = ts.versionMajorMinor + ".4"; + ts.versionMajorMinor = "3.7"; + ts.version = ts.versionMajorMinor + ".2"; })(ts || (ts = {})); (function (ts) { - ts.emptyArray = []; - function createDictionaryObject() { - var map = Object.create(null); - map.__ = undefined; - delete map.__; - return map; + function tryGetNativeMap() { + return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined; } + ts.tryGetNativeMap = tryGetNativeMap; +})(ts || (ts = {})); +(function (ts) { + ts.emptyArray = []; + ts.Map = ts.tryGetNativeMap() || (function () { + if (typeof ts.createMapShim === "function") { + return ts.createMapShim(); + } + throw new Error("TypeScript requires an environment that provides a compatible native Map implementation."); + })(); function createMap() { - return new ts.MapCtr(); + return new ts.Map(); } ts.createMap = createMap; function createMapFromEntries(entries) { @@ -91,7 +97,7 @@ var ts; } ts.createMapFromEntries = createMapFromEntries; function createMapFromTemplate(template) { - var map = new ts.MapCtr(); + var map = new ts.Map(); for (var key in template) { if (hasOwnProperty.call(template, key)) { map.set(key, template[key]); @@ -100,121 +106,6 @@ var ts; return map; } ts.createMapFromTemplate = createMapFromTemplate; - ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); - function shimMap() { - var MapIterator = (function () { - function MapIterator(currentEntry, selector) { - this.currentEntry = currentEntry; - this.selector = selector; - } - MapIterator.prototype.next = function () { - while (this.currentEntry) { - var skipNext = !!this.currentEntry.skipNext; - this.currentEntry = this.currentEntry.nextEntry; - if (!skipNext) { - break; - } - } - if (this.currentEntry) { - return { value: this.selector(this.currentEntry.key, this.currentEntry.value), done: false }; - } - else { - return { value: undefined, done: true }; - } - }; - return MapIterator; - }()); - return (function () { - function class_1() { - this.data = createDictionaryObject(); - this.size = 0; - this.firstEntry = {}; - this.lastEntry = this.firstEntry; - } - class_1.prototype.get = function (key) { - var entry = this.data[key]; - return entry && entry.value; - }; - class_1.prototype.set = function (key, value) { - if (!this.has(key)) { - this.size++; - var newEntry = { - key: key, - value: value - }; - this.data[key] = newEntry; - var previousLastEntry = this.lastEntry; - previousLastEntry.nextEntry = newEntry; - newEntry.previousEntry = previousLastEntry; - this.lastEntry = newEntry; - } - else { - this.data[key].value = value; - } - return this; - }; - class_1.prototype.has = function (key) { - return key in this.data; - }; - class_1.prototype.delete = function (key) { - if (this.has(key)) { - this.size--; - var entry = this.data[key]; - delete this.data[key]; - var previousEntry = entry.previousEntry; - previousEntry.nextEntry = entry.nextEntry; - if (entry.nextEntry) { - entry.nextEntry.previousEntry = previousEntry; - } - if (this.lastEntry === entry) { - this.lastEntry = previousEntry; - } - entry.previousEntry = undefined; - entry.nextEntry = previousEntry; - entry.skipNext = true; - return true; - } - return false; - }; - class_1.prototype.clear = function () { - this.data = createDictionaryObject(); - this.size = 0; - var firstEntry = this.firstEntry; - var currentEntry = firstEntry.nextEntry; - while (currentEntry) { - var nextEntry = currentEntry.nextEntry; - currentEntry.previousEntry = undefined; - currentEntry.nextEntry = firstEntry; - currentEntry.skipNext = true; - currentEntry = nextEntry; - } - firstEntry.nextEntry = undefined; - this.lastEntry = firstEntry; - }; - class_1.prototype.keys = function () { - return new MapIterator(this.firstEntry, function (key) { return key; }); - }; - class_1.prototype.values = function () { - return new MapIterator(this.firstEntry, function (_key, value) { return value; }); - }; - class_1.prototype.entries = function () { - return new MapIterator(this.firstEntry, function (key, value) { return [key, value]; }); - }; - class_1.prototype.forEach = function (action) { - var iterator = this.entries(); - while (true) { - var iterResult = iterator.next(); - if (iterResult.done) { - break; - } - var _a = iterResult.value, key = _a[0], value = _a[1]; - action(value, key); - } - }; - return class_1; - }()); - } - ts.shimMap = shimMap; function length(array) { return array ? array.length : 0; } @@ -231,6 +122,18 @@ var ts; return undefined; } ts.forEach = forEach; + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; function firstDefined(array, callback) { if (array === undefined) { return undefined; @@ -1198,6 +1101,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1278,7 +1187,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1534,20 +1443,6 @@ var ts; return str.indexOf(substring) !== -1; } ts.stringContains = stringContains; - function fileExtensionIs(path, extension) { - return path.length > extension.length && endsWith(path, extension); - } - ts.fileExtensionIs = fileExtensionIs; - function fileExtensionIsOneOf(path, extensions) { - for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { - var extension = extensions_1[_i]; - if (fileExtensionIs(path, extension)) { - return true; - } - } - return false; - } - ts.fileExtensionIsOneOf = fileExtensionIsOneOf; function removeMinAndVersionNumbers(fileName) { var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/; return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, ""); @@ -1639,10 +1534,32 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { @@ -1784,7 +1701,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -1889,6 +1806,9 @@ var ts; Debug.assertNode = shouldAssert(1) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -1899,6 +1819,33 @@ var ts; ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); } : ts.noop; var isDebugInfoEnabled = false; + var extendedDebugModule; + function extendedDebug() { + enableDebugInfo(); + if (!extendedDebugModule) { + throw new Error("Debugging helpers could not be loaded."); + } + return extendedDebugModule; + } + function printControlFlowGraph(flowNode) { + return console.log(formatControlFlowGraph(flowNode)); + } + Debug.printControlFlowGraph = printControlFlowGraph; + function formatControlFlowGraph(flowNode) { + return extendedDebug().formatControlFlowGraph(flowNode); + } + Debug.formatControlFlowGraph = formatControlFlowGraph; + function attachFlowNodeDebugInfo(flowNode) { + if (isDebugInfoEnabled) { + if (!("__debugFlowFlags" in flowNode)) { + Object.defineProperties(flowNode, { + __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, true); } }, + __debugToString: { value: function () { return formatControlFlowGraph(this); } } + }); + } + } + } + Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo; function enableDebugInfo() { if (isDebugInfoEnabled) return; @@ -1938,6 +1885,18 @@ var ts; }); } } + try { + if (ts.sys && ts.sys.require) { + var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath())); + var result = ts.sys.require(basePath, "./compiler-debug"); + if (!result.error) { + result.module.init(ts); + extendedDebugModule = result.module; + } + } + } + catch (_a) { + } isDebugInfoEnabled = true; } Debug.enableDebugInfo = enableDebugInfo; @@ -2059,8 +2018,6 @@ var ts; etwModule = undefined; } ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; - var args = typeof process === "undefined" ? [] : process.argv; - ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); })(ts || (ts = {})); var ts; (function (ts) { @@ -2351,12 +2308,20 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); var ExitStatus; (function (ExitStatus) { ExitStatus[ExitStatus["Success"] = 0] = "Success"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped"; + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { @@ -2782,6 +2747,27 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + function patchWriteFileEnsuringDirectory(sys) { + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -2800,6 +2786,7 @@ var ts; ts.sys = (function () { var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -2810,6 +2797,8 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; @@ -2883,8 +2872,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -2907,8 +2898,90 @@ var ts; bufferFrom: bufferFrom, base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); }, base64encode: function (input) { return bufferFrom(input).toString("base64"); }, + require: function (baseDir, moduleName) { + try { + var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem); + return { module: require(modulePath), modulePath: modulePath, error: undefined }; + } + catch (error) { + return { module: undefined, modulePath: undefined, error: error }; + } + } }; return nodeSystem; + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { return Buffer.from && Buffer.from !== Int8Array.from ? Buffer.from(input, encoding) @@ -3314,16 +3387,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -3332,14 +3395,7 @@ var ts; sys = getNodeSystem(); } if (sys) { - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -3355,401 +3411,870 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + ts.directorySeparator = "/"; + var altDirectorySeparator = "\\"; + var urlSchemeSeparator = "://"; + var backslashRegExp = /\\/g; + function isAnyDirectorySeparator(charCode) { + return charCode === 47 || charCode === 92; } - ts.Diagnostics = { - Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), - Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), - _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), - A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), - Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), - An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), - Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), - A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), - A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), - Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), - A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), - An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), - An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), - An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), - An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), - An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), - An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), - An_index_signature_parameter_type_must_be_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_or_number_1023", "An index signature parameter type must be 'string' or 'number'."), - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), - Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), - _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), - _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), - _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), - super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), - Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), - Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), - Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), - _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), - _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), - _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), - _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), - _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), - A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), - Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), - A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), - A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), - A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), - A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), - A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), - A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), - A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), - An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), - The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), - A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), - The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), - Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), - Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), - An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), - Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), - _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), - _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), - A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), - Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), - _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), - Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), - Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), - An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), - A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), - An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), - _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), - Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), - Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), - Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), - with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), - delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), - Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), - A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), - Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), - Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), - Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), - An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), - Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), - Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), - Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), - Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), - Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), - Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), - Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), - case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), - Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), - Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), - Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), - Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), - Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), - Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), - Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), - Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), - Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), - String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), - Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), - or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), - Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), - Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), - File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), - const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), - const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), - let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), - Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), - Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), - An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), - A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), - Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), - A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), - extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), - extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), - Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), - implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), - Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), - Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), - Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), - Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), - Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), - Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), - A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), - An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), - Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), - Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), - A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), - A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), - An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), - Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), - An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), - Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), - Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), - Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), - Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), - Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), - Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), - Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), - All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), - A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), - Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), - Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), - Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), - An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), - _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), - Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), - Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), - Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), - Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), - A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), - An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), - An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), - _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), - Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), - An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), - A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), - A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), - A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), - A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), - A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), - Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), - Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), - Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), - with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), - await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), - The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), - Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), - Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), - Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), - A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), - An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), - A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), - Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), - Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), - Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323", "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'."), - Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), - Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), - String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), - Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), - _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), - A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), - A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), - A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), - unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), - unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), - unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), - An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), - An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), - infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), - Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), - Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), - A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), - An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), - This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), - use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), - Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), - use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), - Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), - An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), - A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), - A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), - readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), - A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), - Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), - Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), - Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), - Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), - Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), - Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), - File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), - Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), - Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), - A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), - An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), - Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), - Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), - Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), - Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), - Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), - Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), - Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), - Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), - Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), - Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), - Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), - Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), - Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), - Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), - Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), - Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), - Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), - Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), - this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), - this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), - this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), - this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), - super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), - super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: diag(2338, ts.DiagnosticCategory.Error, "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class."), - Property_0_does_not_exist_on_type_1: diag(2339, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."), - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), - Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), - Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), - Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), - Untyped_function_calls_may_not_accept_type_arguments: diag(2347, ts.DiagnosticCategory.Error, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."), - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, ts.DiagnosticCategory.Error, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"), - This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."), - Only_a_void_function_can_be_called_with_the_new_keyword: diag(2350, ts.DiagnosticCategory.Error, "Only_a_void_function_can_be_called_with_the_new_keyword_2350", "Only a void function can be called with the 'new' keyword."), - This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."), - Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, ts.DiagnosticCategory.Error, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."), - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), - This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), - An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), - Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), - Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), - This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), - Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), - A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), - A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."), - Parameter_0_cannot_be_referenced_in_its_initializer: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_be_referenced_in_its_initializer_2372", "Parameter '{0}' cannot be referenced in its initializer."), - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it."), - Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."), - Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."), - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties."), - Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), - A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), - A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), - Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), - Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."), - Overload_signatures_must_all_be_public_private_or_protected: diag(2385, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."), - Overload_signatures_must_all_be_optional_or_required: diag(2386, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_optional_or_required_2386", "Overload signatures must all be optional or required."), - Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."), - Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."), - Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."), - Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."), - Function_implementation_is_missing_or_not_immediately_following_the_declaration: diag(2391, ts.DiagnosticCategory.Error, "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", "Function implementation is missing or not immediately following the declaration."), - Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."), - Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."), - This_overload_signature_is_not_compatible_with_its_implementation_signature: diag(2394, ts.DiagnosticCategory.Error, "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394", "This overload signature is not compatible with its implementation signature."), - Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: diag(2395, ts.DiagnosticCategory.Error, "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", "Individual declarations in merged declaration '{0}' must be all exported or all local."), - Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: diag(2396, ts.DiagnosticCategory.Error, "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters."), - Declaration_name_conflicts_with_built_in_global_identifier_0: diag(2397, ts.DiagnosticCategory.Error, "Declaration_name_conflicts_with_built_in_global_identifier_0_2397", "Declaration name conflicts with built-in global identifier '{0}'."), - Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."), - Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."), - Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: diag(2401, ts.DiagnosticCategory.Error, "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference."), - Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."), - Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."), - The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."), - The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: diag(2405, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'."), - The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: diag(2406, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", "The left-hand side of a 'for...in' statement must be a variable or a property access."), - The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0: diag(2407, ts.DiagnosticCategory.Error, "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_2407", "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '{0}'."), - Setters_cannot_return_a_value: diag(2408, ts.DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."), - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: diag(2409, ts.DiagnosticCategory.Error, "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", "Return type of constructor signature must be assignable to the instance type of the class."), - The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: diag(2410, ts.DiagnosticCategory.Error, "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'."), - Property_0_of_type_1_is_not_assignable_to_string_index_type_2: diag(2411, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", "Property '{0}' of type '{1}' is not assignable to string index type '{2}'."), - Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: diag(2412, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'."), - Numeric_index_type_0_is_not_assignable_to_string_index_type_1: diag(2413, ts.DiagnosticCategory.Error, "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", "Numeric index type '{0}' is not assignable to string index type '{1}'."), - Class_name_cannot_be_0: diag(2414, ts.DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."), - Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), - Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), - Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), - Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), - Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), - A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."), - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2424, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property."), - Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."), - Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."), - Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."), - All_declarations_of_0_must_have_identical_type_parameters: diag(2428, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_type_parameters_2428", "All declarations of '{0}' must have identical type parameters."), - Interface_0_incorrectly_extends_interface_1: diag(2430, ts.DiagnosticCategory.Error, "Interface_0_incorrectly_extends_interface_1_2430", "Interface '{0}' incorrectly extends interface '{1}'."), - Enum_name_cannot_be_0: diag(2431, ts.DiagnosticCategory.Error, "Enum_name_cannot_be_0_2431", "Enum name cannot be '{0}'."), - In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: diag(2432, ts.DiagnosticCategory.Error, "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element."), - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: diag(2433, ts.DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", "A namespace declaration cannot be in a different file from a class or function with which it is merged."), - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: diag(2434, ts.DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", "A namespace declaration cannot be located prior to a class or function with which it is merged."), + ts.isAnyDirectorySeparator = isAnyDirectorySeparator; + function isUrl(path) { + return getEncodedRootLength(path) < 0; + } + ts.isUrl = isUrl; + function isRootedDiskPath(path) { + return getEncodedRootLength(path) > 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + function isDiskPathRoot(path) { + var rootLength = getEncodedRootLength(path); + return rootLength > 0 && rootLength === path.length; + } + ts.isDiskPathRoot = isDiskPathRoot; + function pathIsAbsolute(path) { + return getEncodedRootLength(path) !== 0; + } + ts.pathIsAbsolute = pathIsAbsolute; + function pathIsRelative(path) { + return /^\.\.?($|[\\/])/.test(path); + } + ts.pathIsRelative = pathIsRelative; + function hasExtension(fileName) { + return ts.stringContains(getBaseFileName(fileName), "."); + } + ts.hasExtension = hasExtension; + function fileExtensionIs(path, extension) { + return path.length > extension.length && ts.endsWith(path, extension); + } + ts.fileExtensionIs = fileExtensionIs; + function fileExtensionIsOneOf(path, extensions) { + for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { + var extension = extensions_1[_i]; + if (fileExtensionIs(path, extension)) { + return true; + } + } + return false; + } + ts.fileExtensionIsOneOf = fileExtensionIsOneOf; + function hasTrailingDirectorySeparator(path) { + return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); + } + ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; + function isVolumeCharacter(charCode) { + return (charCode >= 97 && charCode <= 122) || + (charCode >= 65 && charCode <= 90); + } + function getFileUrlVolumeSeparatorEnd(url, start) { + var ch0 = url.charCodeAt(start); + if (ch0 === 58) + return start + 1; + if (ch0 === 37 && url.charCodeAt(start + 1) === 51) { + var ch2 = url.charCodeAt(start + 2); + if (ch2 === 97 || ch2 === 65) + return start + 3; + } + return -1; + } + function getEncodedRootLength(path) { + if (!path) + return 0; + var ch0 = path.charCodeAt(0); + if (ch0 === 47 || ch0 === 92) { + if (path.charCodeAt(1) !== ch0) + return 1; + var p1 = path.indexOf(ch0 === 47 ? ts.directorySeparator : altDirectorySeparator, 2); + if (p1 < 0) + return path.length; + return p1 + 1; + } + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58) { + var ch2 = path.charCodeAt(2); + if (ch2 === 47 || ch2 === 92) + return 3; + if (path.length === 2) + return 2; + } + var schemeEnd = path.indexOf(urlSchemeSeparator); + if (schemeEnd !== -1) { + var authorityStart = schemeEnd + urlSchemeSeparator.length; + var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); + if (authorityEnd !== -1) { + var scheme = path.slice(0, schemeEnd); + var authority = path.slice(authorityStart, authorityEnd); + if (scheme === "file" && (authority === "" || authority === "localhost") && + isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { + var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); + if (volumeSeparatorEnd !== -1) { + if (path.charCodeAt(volumeSeparatorEnd) === 47) { + return ~(volumeSeparatorEnd + 1); + } + if (volumeSeparatorEnd === path.length) { + return ~volumeSeparatorEnd; + } + } + } + return ~(authorityEnd + 1); + } + return ~path.length; + } + return 0; + } + function getRootLength(path) { + var rootLength = getEncodedRootLength(path); + return rootLength < 0 ? ~rootLength : rootLength; + } + ts.getRootLength = getRootLength; + function getDirectoryPath(path) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + if (rootLength === path.length) + return path; + path = removeTrailingDirectorySeparator(path); + return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function getBaseFileName(path, extensions, ignoreCase) { + path = normalizeSlashes(path); + var rootLength = getRootLength(path); + if (rootLength === path.length) + return ""; + path = removeTrailingDirectorySeparator(path); + var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); + var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; + return extension ? name.slice(0, name.length - extension.length) : name; + } + ts.getBaseFileName = getBaseFileName; + function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { + if (!ts.startsWith(extension, ".")) + extension = "." + extension; + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46) { + var pathExtension = path.slice(path.length - extension.length); + if (stringEqualityComparer(pathExtension, extension)) { + return pathExtension; + } + } + } + function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { + if (typeof extensions === "string") { + return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || ""; + } + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer); + if (result) + return result; + } + return ""; + } + function getAnyExtensionFromPath(path, extensions, ignoreCase) { + if (extensions) { + return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); + } + var baseFileName = getBaseFileName(path); + var extensionIndex = baseFileName.lastIndexOf("."); + if (extensionIndex >= 0) { + return baseFileName.substring(extensionIndex); + } + return ""; + } + ts.getAnyExtensionFromPath = getAnyExtensionFromPath; + function pathComponents(path, rootLength) { + var root = path.substring(0, rootLength); + var rest = path.substring(rootLength).split(ts.directorySeparator); + if (rest.length && !ts.lastOrUndefined(rest)) + rest.pop(); + return __spreadArrays([root], rest); + } + function getPathComponents(path, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } + path = combinePaths(currentDirectory, path); + return pathComponents(path, getRootLength(path)); + } + ts.getPathComponents = getPathComponents; + function getPathFromPathComponents(pathComponents) { + if (pathComponents.length === 0) + return ""; + var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]); + return root + pathComponents.slice(1).join(ts.directorySeparator); + } + ts.getPathFromPathComponents = getPathFromPathComponents; + function normalizeSlashes(path) { + return path.replace(backslashRegExp, ts.directorySeparator); + } + ts.normalizeSlashes = normalizeSlashes; + function reducePathComponents(components) { + if (!ts.some(components)) + return []; + var reduced = [components[0]]; + for (var i = 1; i < components.length; i++) { + var component = components[i]; + if (!component) + continue; + if (component === ".") + continue; + if (component === "..") { + if (reduced.length > 1) { + if (reduced[reduced.length - 1] !== "..") { + reduced.pop(); + continue; + } + } + else if (reduced[0]) + continue; + } + reduced.push(component); + } + return reduced; + } + ts.reducePathComponents = reducePathComponents; + function combinePaths(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + if (path) + path = normalizeSlashes(path); + for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { + var relativePath = paths_1[_a]; + if (!relativePath) + continue; + relativePath = normalizeSlashes(relativePath); + if (!path || getRootLength(relativePath) !== 0) { + path = relativePath; + } + else { + path = ensureTrailingDirectorySeparator(path) + relativePath; + } + } + return path; + } + ts.combinePaths = combinePaths; + function resolvePath(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path)); + } + ts.resolvePath = resolvePath; + function getNormalizedPathComponents(path, currentDirectory) { + return reducePathComponents(getPathComponents(path, currentDirectory)); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function normalizePath(path) { + path = normalizeSlashes(path); + var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); + return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; + } + ts.normalizePath = normalizePath; + function getPathWithoutRoot(pathComponents) { + if (pathComponents.length === 0) + return ""; + return pathComponents.slice(1).join(ts.directorySeparator); + } + function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { + return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; + function normalizePathAndParts(path) { + path = normalizeSlashes(path); + var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; + } + else { + return { path: root, parts: parts }; + } + } + ts.normalizePathAndParts = normalizePathAndParts; + function removeTrailingDirectorySeparator(path) { + if (hasTrailingDirectorySeparator(path)) { + return path.substr(0, path.length - 1); + } + return path; + } + ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; + function ensureTrailingDirectorySeparator(path) { + if (!hasTrailingDirectorySeparator(path)) { + return path + ts.directorySeparator; + } + return path; + } + ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; + function ensurePathIsNonModuleName(path) { + return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path; + } + ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; + function changeAnyExtension(path, ext, extensions, ignoreCase) { + var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); + return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; + } + ts.changeAnyExtension = changeAnyExtension; + var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + function comparePathsWorker(a, b, componentComparer) { + if (a === b) + return 0; + if (a === undefined) + return -1; + if (b === undefined) + return 1; + var aRoot = a.substring(0, getRootLength(a)); + var bRoot = b.substring(0, getRootLength(b)); + var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); + if (result !== 0) { + return result; + } + var aRest = a.substring(aRoot.length); + var bRest = b.substring(bRoot.length); + if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { + return componentComparer(aRest, bRest); + } + var aComponents = reducePathComponents(getPathComponents(a)); + var bComponents = reducePathComponents(getPathComponents(b)); + var sharedLength = Math.min(aComponents.length, bComponents.length); + for (var i = 1; i < sharedLength; i++) { + var result_1 = componentComparer(aComponents[i], bComponents[i]); + if (result_1 !== 0) { + return result_1; + } + } + return ts.compareValues(aComponents.length, bComponents.length); + } + function comparePathsCaseSensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + } + ts.comparePathsCaseSensitive = comparePathsCaseSensitive; + function comparePathsCaseInsensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + } + ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; + function comparePaths(a, b, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + a = combinePaths(currentDirectory, a); + b = combinePaths(currentDirectory, b); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + } + ts.comparePaths = comparePaths; + function containsPath(parent, child, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + parent = combinePaths(currentDirectory, parent); + child = combinePaths(currentDirectory, child); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + if (parent === undefined || child === undefined) + return false; + if (parent === child) + return true; + var parentComponents = reducePathComponents(getPathComponents(parent)); + var childComponents = reducePathComponents(getPathComponents(child)); + if (childComponents.length < parentComponents.length) { + return false; + } + var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; + for (var i = 0; i < parentComponents.length; i++) { + var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; + if (!equalityComparer(parentComponents[i], childComponents[i])) { + return false; + } + } + return true; + } + ts.containsPath = containsPath; + function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { + var canonicalFileName = getCanonicalFileName(fileName); + var canonicalDirectoryName = getCanonicalFileName(directoryName); + return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); + } + ts.startsWithDirectory = startsWithDirectory; + function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { + var fromComponents = reducePathComponents(getPathComponents(from)); + var toComponents = reducePathComponents(getPathComponents(to)); + var start; + for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { + var fromComponent = getCanonicalFileName(fromComponents[start]); + var toComponent = getCanonicalFileName(toComponents[start]); + var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; + if (!comparer(fromComponent, toComponent)) + break; + } + if (start === 0) { + return toComponents; + } + var components = toComponents.slice(start); + var relative = []; + for (; start < fromComponents.length; start++) { + relative.push(".."); + } + return __spreadArrays([""], relative, components); + } + ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; + function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { + ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); + var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; + var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; + var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathFromDirectory = getRelativePathFromDirectory; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); + } + ts.convertToRelativePath = convertToRelativePath; + function getRelativePathFromFile(from, to, getCanonicalFileName) { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); + } + ts.getRelativePathFromFile = getRelativePathFromFile; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); + var firstComponent = pathComponents[0]; + if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) { + var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; + pathComponents[0] = prefix + firstComponent; + } + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } + ts.forEachAncestorDirectory = forEachAncestorDirectory; +})(ts || (ts = {})); +var ts; +(function (ts) { + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; + } + ts.Diagnostics = { + Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), + Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), + _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), + A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), + Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), + Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), + An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), + Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), + A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), + A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), + Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), + A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), + An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), + An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), + An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), + An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), + An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), + An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), + An_index_signature_parameter_type_must_be_either_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_either_string_or_number_1023", "An index signature parameter type must be either 'string' or 'number'."), + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), + Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), + _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), + _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), + _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), + super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), + Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), + Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), + Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), + _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), + _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), + _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), + _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), + _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), + A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), + Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), + A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), + A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), + A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), + A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), + A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), + A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), + A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), + An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), + A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), + Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), + An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), + _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), + _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), + A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), + Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), + _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), + _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), + Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), + Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), + An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), + A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), + An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), + _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), + Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), + Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), + Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), + with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), + delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), + A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), + Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), + Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), + Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), + An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), + Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), + Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), + Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), + Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), + Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), + Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), + Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), + Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), + case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), + Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), + Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), + Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), + Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), + Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), + Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), + Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), + Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), + Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), + String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), + Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), + or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), + Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), + Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), + Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), + File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), + const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), + const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), + let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), + Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), + Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), + An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), + A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), + Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), + A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), + extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), + extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), + Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), + implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), + Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), + Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), + Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), + Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), + Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), + Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), + A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), + An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), + Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), + Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), + A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), + A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), + An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), + Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), + An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), + Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), + Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), + Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), + Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), + Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), + Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), + Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), + All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), + A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), + Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), + Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), + Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), + An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), + _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), + Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), + Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), + Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), + Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), + A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), + An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), + An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), + _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), + Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), + An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), + A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), + A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), + A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), + _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), + A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), + A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), + Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), + with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), + await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), + The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), + Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), + Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), + Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), + A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), + An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd_1323", "Dynamic imports are only supported when the '--module' flag is set to 'esnext', 'commonjs', 'amd', 'system', or 'umd'."), + Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), + Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), + Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), + String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), + Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), + _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), + A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), + A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), + A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), + unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), + unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), + unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), + An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), + An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), + infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), + Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), + Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), + A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), + An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), + This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), + use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), + Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), + use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), + An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), + A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), + A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), + readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), + A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), + Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", undefined, true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", undefined, true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", undefined, true), + Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), + Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), + Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), + Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), + Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), + File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), + Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), + Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), + Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), + A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), + An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), + Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), + Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), + Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), + Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), + Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), + Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), + Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), + Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), + Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), + Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), + Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), + Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), + Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), + Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), + Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), + Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), + Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), + Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), + this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), + this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), + this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), + this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), + super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), + super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: diag(2338, ts.DiagnosticCategory.Error, "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class."), + Property_0_does_not_exist_on_type_1: diag(2339, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."), + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), + Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), + Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), + Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), + Untyped_function_calls_may_not_accept_type_arguments: diag(2347, ts.DiagnosticCategory.Error, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."), + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, ts.DiagnosticCategory.Error, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"), + This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."), + Only_a_void_function_can_be_called_with_the_new_keyword: diag(2350, ts.DiagnosticCategory.Error, "Only_a_void_function_can_be_called_with_the_new_keyword_2350", "Only a void function can be called with the 'new' keyword."), + This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."), + Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, ts.DiagnosticCategory.Error, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."), + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), + Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), + Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), + Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), + A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), + A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."), + Parameter_0_cannot_be_referenced_in_its_initializer: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_be_referenced_in_its_initializer_2372", "Parameter '{0}' cannot be referenced in its initializer."), + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it."), + Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."), + Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."), + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties."), + Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), + A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), + Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), + get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), + Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), + Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."), + Overload_signatures_must_all_be_public_private_or_protected: diag(2385, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."), + Overload_signatures_must_all_be_optional_or_required: diag(2386, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_optional_or_required_2386", "Overload signatures must all be optional or required."), + Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."), + Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."), + Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."), + Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."), + Function_implementation_is_missing_or_not_immediately_following_the_declaration: diag(2391, ts.DiagnosticCategory.Error, "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", "Function implementation is missing or not immediately following the declaration."), + Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."), + Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."), + This_overload_signature_is_not_compatible_with_its_implementation_signature: diag(2394, ts.DiagnosticCategory.Error, "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394", "This overload signature is not compatible with its implementation signature."), + Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: diag(2395, ts.DiagnosticCategory.Error, "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", "Individual declarations in merged declaration '{0}' must be all exported or all local."), + Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: diag(2396, ts.DiagnosticCategory.Error, "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters."), + Declaration_name_conflicts_with_built_in_global_identifier_0: diag(2397, ts.DiagnosticCategory.Error, "Declaration_name_conflicts_with_built_in_global_identifier_0_2397", "Declaration name conflicts with built-in global identifier '{0}'."), + Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."), + Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."), + Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference: diag(2401, ts.DiagnosticCategory.Error, "Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference_2401", "Duplicate identifier '_super'. Compiler uses '_super' to capture base class reference."), + Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."), + Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."), + The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."), + The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any: diag(2405, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any_2405", "The left-hand side of a 'for...in' statement must be of type 'string' or 'any'."), + The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: diag(2406, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", "The left-hand side of a 'for...in' statement must be a variable or a property access."), + The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_here_has_type_0: diag(2407, ts.DiagnosticCategory.Error, "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_but_2407", "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter, but here has type '{0}'."), + Setters_cannot_return_a_value: diag(2408, ts.DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."), + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: diag(2409, ts.DiagnosticCategory.Error, "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", "Return type of constructor signature must be assignable to the instance type of the class."), + The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: diag(2410, ts.DiagnosticCategory.Error, "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'."), + Property_0_of_type_1_is_not_assignable_to_string_index_type_2: diag(2411, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", "Property '{0}' of type '{1}' is not assignable to string index type '{2}'."), + Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: diag(2412, ts.DiagnosticCategory.Error, "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'."), + Numeric_index_type_0_is_not_assignable_to_string_index_type_1: diag(2413, ts.DiagnosticCategory.Error, "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", "Numeric index type '{0}' is not assignable to string index type '{1}'."), + Class_name_cannot_be_0: diag(2414, ts.DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."), + Class_0_incorrectly_extends_base_class_1: diag(2415, ts.DiagnosticCategory.Error, "Class_0_incorrectly_extends_base_class_1_2415", "Class '{0}' incorrectly extends base class '{1}'."), + Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2: diag(2416, ts.DiagnosticCategory.Error, "Property_0_in_type_1_is_not_assignable_to_the_same_property_in_base_type_2_2416", "Property '{0}' in type '{1}' is not assignable to the same property in base type '{2}'."), + Class_static_side_0_incorrectly_extends_base_class_static_side_1: diag(2417, ts.DiagnosticCategory.Error, "Class_static_side_0_incorrectly_extends_base_class_static_side_1_2417", "Class static side '{0}' incorrectly extends base class static side '{1}'."), + Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1: diag(2418, ts.DiagnosticCategory.Error, "Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418", "Type of computed property's value is '{0}', which is not assignable to type '{1}'."), + Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), + A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."), + Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."), + Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."), + All_declarations_of_0_must_have_identical_type_parameters: diag(2428, ts.DiagnosticCategory.Error, "All_declarations_of_0_must_have_identical_type_parameters_2428", "All declarations of '{0}' must have identical type parameters."), + Interface_0_incorrectly_extends_interface_1: diag(2430, ts.DiagnosticCategory.Error, "Interface_0_incorrectly_extends_interface_1_2430", "Interface '{0}' incorrectly extends interface '{1}'."), + Enum_name_cannot_be_0: diag(2431, ts.DiagnosticCategory.Error, "Enum_name_cannot_be_0_2431", "Enum name cannot be '{0}'."), + In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element: diag(2432, ts.DiagnosticCategory.Error, "In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enu_2432", "In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element."), + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: diag(2433, ts.DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", "A namespace declaration cannot be in a different file from a class or function with which it is merged."), + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: diag(2434, ts.DiagnosticCategory.Error, "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", "A namespace declaration cannot be located prior to a class or function with which it is merged."), Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: diag(2435, ts.DiagnosticCategory.Error, "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", "Ambient modules cannot be nested in other modules or namespaces."), Ambient_module_declaration_cannot_specify_relative_module_name: diag(2436, ts.DiagnosticCategory.Error, "Ambient_module_declaration_cannot_specify_relative_module_name_2436", "Ambient module declaration cannot specify relative module name."), Module_0_is_hidden_by_a_local_declaration_with_the_same_name: diag(2437, ts.DiagnosticCategory.Error, "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", "Module '{0}' is hidden by a local declaration with the same name."), @@ -3910,6 +4435,11 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(2613, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(2614, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -4032,6 +4562,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -4118,6 +4656,11 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), + Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), + Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -4128,6 +4671,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -4153,6 +4697,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -4340,6 +4885,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -4358,9 +4904,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), - Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -4399,9 +4947,12 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), + Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -4485,6 +5036,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -4514,6 +5067,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -4631,6 +5185,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -4640,93 +5202,94 @@ var ts; (function (ts) { var _a; function tokenIsIdentifierOrKeyword(token) { - return token >= 73; + return token >= 75; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 || tokenIsIdentifierOrKeyword(token); + return token === 31 || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119, - any: 121, - as: 120, - bigint: 147, - boolean: 124, - break: 74, - case: 75, - catch: 76, - class: 77, - continue: 79, - const: 78 + abstract: 121, + any: 124, + as: 122, + asserts: 123, + bigint: 150, + boolean: 127, + break: 76, + case: 77, + catch: 78, + class: 79, + continue: 81, + const: 80 }, - _a["" + "constructor"] = 125, - _a.debugger = 80, - _a.declare = 126, - _a.default = 81, - _a.delete = 82, - _a.do = 83, - _a.else = 84, - _a.enum = 85, - _a.export = 86, - _a.extends = 87, - _a.false = 88, - _a.finally = 89, - _a.for = 90, - _a.from = 145, - _a.function = 91, - _a.get = 127, - _a.if = 92, - _a.implements = 110, - _a.import = 93, - _a.in = 94, - _a.infer = 128, - _a.instanceof = 95, - _a.interface = 111, - _a.is = 129, - _a.keyof = 130, - _a.let = 112, - _a.module = 131, - _a.namespace = 132, - _a.never = 133, - _a.new = 96, - _a.null = 97, - _a.number = 136, - _a.object = 137, - _a.package = 113, - _a.private = 114, - _a.protected = 115, - _a.public = 116, - _a.readonly = 134, - _a.require = 135, - _a.global = 146, - _a.return = 98, - _a.set = 138, - _a.static = 117, - _a.string = 139, - _a.super = 99, - _a.switch = 100, - _a.symbol = 140, - _a.this = 101, - _a.throw = 102, - _a.true = 103, - _a.try = 104, - _a.type = 141, - _a.typeof = 105, - _a.undefined = 142, - _a.unique = 143, - _a.unknown = 144, - _a.var = 106, - _a.void = 107, - _a.while = 108, - _a.with = 109, - _a.yield = 118, - _a.async = 122, - _a.await = 123, - _a.of = 148, + _a["" + "constructor"] = 128, + _a.debugger = 82, + _a.declare = 129, + _a.default = 83, + _a.delete = 84, + _a.do = 85, + _a.else = 86, + _a.enum = 87, + _a.export = 88, + _a.extends = 89, + _a.false = 90, + _a.finally = 91, + _a.for = 92, + _a.from = 148, + _a.function = 93, + _a.get = 130, + _a.if = 94, + _a.implements = 112, + _a.import = 95, + _a.in = 96, + _a.infer = 131, + _a.instanceof = 97, + _a.interface = 113, + _a.is = 132, + _a.keyof = 133, + _a.let = 114, + _a.module = 134, + _a.namespace = 135, + _a.never = 136, + _a.new = 98, + _a.null = 99, + _a.number = 139, + _a.object = 140, + _a.package = 115, + _a.private = 116, + _a.protected = 117, + _a.public = 118, + _a.readonly = 137, + _a.require = 138, + _a.global = 149, + _a.return = 100, + _a.set = 141, + _a.static = 119, + _a.string = 142, + _a.super = 101, + _a.switch = 102, + _a.symbol = 143, + _a.this = 103, + _a.throw = 104, + _a.true = 105, + _a.try = 106, + _a.type = 144, + _a.typeof = 107, + _a.undefined = 145, + _a.unique = 146, + _a.unknown = 147, + _a.var = 108, + _a.void = 109, + _a.while = 110, + _a.with = 111, + _a.yield = 120, + _a.async = 125, + _a.await = 126, + _a.of = 151, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18, "}": 19, "(": 20, ")": 21, "[": 22, "]": 23, ".": 24, "...": 25, ";": 26, ",": 27, "<": 28, ">": 30, "<=": 31, ">=": 32, "==": 33, "!=": 34, "===": 35, "!==": 36, "=>": 37, "+": 38, "-": 39, "**": 41, "*": 40, "/": 42, "%": 43, "++": 44, "--": 45, "<<": 46, ">": 47, ">>>": 48, "&": 49, "|": 50, "^": 51, "!": 52, "~": 53, "&&": 54, "||": 55, "?": 56, ":": 57, "=": 60, "+=": 61, "-=": 62, "*=": 63, "**=": 64, "/=": 65, "%=": 66, "<<=": 67, ">>=": 68, ">>>=": 69, "&=": 70, "|=": 71, "^=": 72, "@": 58, "`": 59 })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18, "}": 19, "(": 20, ")": 21, "[": 22, "]": 23, ".": 24, "...": 25, ";": 26, ",": 27, "<": 29, ">": 31, "<=": 32, ">=": 33, "==": 34, "!=": 35, "===": 36, "!==": 37, "=>": 38, "+": 39, "-": 40, "**": 42, "*": 41, "/": 43, "%": 44, "++": 45, "--": 46, "<<": 47, ">": 48, ">>>": 49, "&": 50, "|": 51, "^": 52, "!": 53, "~": 54, "&&": 55, "||": 56, "?": 57, "??": 60, "?.": 28, ":": 58, "=": 62, "+=": 63, "-=": 64, "*=": 65, "**=": 66, "/=": 67, "%=": 68, "<<=": 69, ">>=": 70, ">>>=": 71, "&=": 72, "|=": 73, "^=": 74, "@": 59, "`": 61 })); 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,]; @@ -5213,7 +5776,7 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, @@ -5223,8 +5786,8 @@ var ts; hasUnicodeEscape: function () { return (tokenFlags & 1024) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; }, - isIdentifier: function () { return token === 73 || token > 109; }, - isReservedWord: function () { return token >= 74 && token <= 109; }, + isIdentifier: function () { return token === 75 || token > 111; }, + isReservedWord: function () { return token >= 76 && token <= 111; }, isUnterminated: function () { return (tokenFlags & 4) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -5234,6 +5797,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -5248,6 +5812,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -5666,7 +6239,7 @@ var ts; } } } - return token = 73; + return token = 75; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -5793,12 +6366,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 36; + return pos += 3, token = 37; } - return pos += 2, token = 34; + return pos += 2, token = 35; } pos++; - return token = 52; + return token = 53; case 34: case 39: tokenValue = scanString(); @@ -5807,19 +6380,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 66; + return pos += 2, token = 68; } pos++; - return token = 43; + return token = 44; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 54; + return pos += 2, token = 55; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 70; + return pos += 2, token = 72; } pos++; - return token = 49; + return token = 50; case 40: pos++; return token = 20; @@ -5828,41 +6401,41 @@ var ts; return token = 21; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 65; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 64; + return pos += 3, token = 66; } - return pos += 2, token = 41; + return pos += 2, token = 42; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1)) { asteriskSeen = true; continue; } - return token = 40; + return token = 41; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 61; + return pos += 2, token = 63; } pos++; - return token = 38; + return token = 39; case 44: pos++; return token = 27; case 45: if (text.charCodeAt(pos + 1) === 45) { - return pos += 2, token = 45; + return pos += 2, token = 46; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 64; } pos++; - return token = 39; + return token = 40; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -5921,10 +6494,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 67; } pos++; - return token = 42; + return token = 43; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -5977,7 +6550,7 @@ var ts; return token; case 58: pos++; - return token = 57; + return token = 58; case 59: pos++; return token = 26; @@ -5993,20 +6566,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 67; + return pos += 3, token = 69; } - return pos += 2, token = 46; + return pos += 2, token = 47; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 31; + return pos += 2, token = 32; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 29; + return pos += 2, token = 30; } pos++; - return token = 28; + return token = 29; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -6019,15 +6592,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 35; + return pos += 3, token = 36; } - return pos += 2, token = 33; + return pos += 2, token = 34; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 37; + return pos += 2, token = 38; } pos++; - return token = 60; + return token = 62; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -6039,10 +6612,18 @@ var ts; } } pos++; - return token = 30; + return token = 31; case 63: pos++; - return token = 56; + if (text.charCodeAt(pos) === 46 && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28; + } + if (text.charCodeAt(pos) === 63) { + pos++; + return token = 60; + } + return token = 57; case 91: pos++; return token = 22; @@ -6051,10 +6632,10 @@ var ts; return token = 23; case 94: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 72; + return pos += 2, token = 74; } pos++; - return token = 51; + return token = 52; case 123: pos++; return token = 18; @@ -6069,22 +6650,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 55; + return pos += 2, token = 56; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 71; + return pos += 2, token = 73; } pos++; - return token = 50; + return token = 51; case 125: pos++; return token = 19; case 126: pos++; - return token = 53; + return token = 54; case 64: pos++; - return token = 58; + return token = 59; case 92: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { @@ -6130,29 +6711,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 30) { + if (token === 31) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 69; + return pos += 3, token = 71; } - return pos += 2, token = 48; + return pos += 2, token = 49; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; + return pos += 2, token = 70; } pos++; - return token = 47; + return token = 48; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 32; + return token = 33; } } return token; } function reScanSlashToken() { - if (token === 42 || token === 65) { + if (token === 43 || token === 67) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -6205,12 +6786,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46) { + if (token === 47) { pos = tokenPos + 1; - return token = 28; + return token = 29; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -6220,10 +6806,10 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 29; + return token = 30; } pos++; - return token = 28; + return token = 29; } if (char === 123) { pos++; @@ -6300,13 +6886,13 @@ var ts; } return token = 5; case 64: - return token = 58; + return token = 59; case 10: case 13: tokenFlags |= 1; return token = 4; case 42: - return token = 40; + return token = 41; case 123: return token = 18; case 125: @@ -6316,17 +6902,17 @@ var ts; case 93: return token = 23; case 60: - return token = 28; + return token = 29; case 62: - return token = 30; + return token = 31; case 61: - return token = 60; + return token = 62; case 44: return token = 27; case 46: return token = 24; case 96: - return token = 59; + return token = 61; case 92: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -6348,7 +6934,7 @@ var ts; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion)) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); if (char === 92) { @@ -6486,7 +7072,7 @@ var ts; } ts.getDeclarationOfKind = getDeclarationOfKind; function createUnderscoreEscapedMap() { - return new ts.MapCtr(); + return new ts.Map(); } ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap; function hasEntries(map) { @@ -6528,6 +7114,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, writeLine: function () { return str += " "; }, increaseIndent: ts.noop, decreaseIndent: ts.noop, @@ -6538,13 +7126,6 @@ var ts; reportPrivateInBaseOfClassExpression: ts.noop, }; } - function toPath(fileName, basePath, getCanonicalFileName) { - var nonCanonicalizedPath = ts.isRootedDiskPath(fileName) - ? ts.normalizePath(fileName) - : ts.getNormalizedAbsolutePath(fileName, basePath); - return getCanonicalFileName(nonCanonicalizedPath); - } - ts.toPath = toPath; function changesAffectModuleResolution(oldOptions, newOptions) { return oldOptions.configFilePath !== newOptions.configFilePath || optionsHaveModuleResolutionChanges(oldOptions, newOptions); @@ -6613,7 +7194,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -6700,21 +7281,21 @@ var ts; ts.hasChangesInResolutions = hasChangesInResolutions; function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072) !== 0; + return (node.flags & 262144) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144)) { - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768) !== 0) || + if (!(node.flags & 524288)) { + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536) !== 0) || ts.forEachChild(node, containsParseError); if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072; + node.flags |= 262144; } - node.flags |= 262144; + node.flags |= 524288; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285) { + while (node && node.kind !== 288) { node = node.parent; } return node; @@ -6722,11 +7303,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219: - case 247: - case 226: - case 227: - case 228: + case 222: + case 250: + case 229: + case 230: + case 231: return true; } return false; @@ -6849,7 +7430,7 @@ var ts; if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 314 && node._children.length > 0) { + if (node.kind === 317 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -6868,7 +7449,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -6952,7 +7533,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 && node.parent.kind === 275; + return node.kind === 241 && node.parent.kind === 278; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -6976,16 +7557,16 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 245 && (!node.body); + return node && node.kind === 248 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 || - node.kind === 245 || + return node.kind === 288 || + node.kind === 248 || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512); + return !!(module.flags & 1024); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -6994,9 +7575,9 @@ var ts; ts.isExternalModuleAugmentation = isExternalModuleAugmentation; function isModuleAugmentationExternal(node) { switch (node.parent.kind) { - case 285: + case 288: return ts.isExternalModule(node.parent); - case 246: + case 249: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -7040,22 +7621,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285: - case 247: - case 275: - case 245: - case 226: - case 227: - case 228: - case 158: - case 157: - case 159: + case 288: + case 250: + case 278: + case 248: + case 229: + case 230: + case 231: + case 161: case 160: - case 240: - case 197: - case 198: + case 162: + case 163: + case 243: + case 200: + case 201: return true; - case 219: + case 222: return !ts.isFunctionLike(parentNode); } return false; @@ -7063,9 +7644,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 305: - case 312: - case 300: + case 308: + case 315: + case 303: return true; default: ts.assertType(node); @@ -7075,25 +7656,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161: - case 162: - case 156: - case 163: + case 164: + case 165: + case 159: case 166: - case 167: - case 295: - case 241: - case 210: - case 242: + case 169: + case 170: + case 298: + case 244: + case 213: + case 245: + case 246: + case 314: case 243: - case 311: - case 240: - case 157: - case 158: - case 159: case 160: - case 197: - case 198: + case 161: + case 162: + case 163: + case 200: + case 201: return true; default: ts.assertType(node); @@ -7103,8 +7684,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250: - case 249: + case 253: + case 252: return true; default: return false; @@ -7113,15 +7694,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250: - case 249: - case 220: - case 241: - case 240: - case 245: - case 243: - case 242: + case 253: + case 252: + case 224: case 244: + case 243: + case 248: + case 246: + case 245: + case 247: return true; default: return false; @@ -7146,13 +7727,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73: + case 75: return name.escapedText; case 10: case 8: case 14: return ts.escapeLeadingUnderscores(name.text); - case 150: + case 153: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -7163,11 +7744,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73: + case 75: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149: + case 152: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190: + case 193: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -7212,7 +7793,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219) { + if (node.body && node.body.kind === 222) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7224,36 +7805,42 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285: + case 288: var pos_1 = ts.skipTrivia(sourceFile.text, 0, false); if (pos_1 === sourceFile.text.length) { return ts.createTextSpan(0, 0); } return getSpanOfTokenAtPosition(sourceFile, pos_1); - case 238: - case 187: case 241: - case 210: - case 242: - case 245: + case 190: case 244: - case 279: - case 240: - case 197: - case 157: - case 159: - case 160: + case 213: + case 245: + case 248: + case 247: + case 282: case 243: - case 155: - case 154: + case 200: + case 160: + case 162: + case 163: + case 246: + case 158: + case 157: errorNode = node.name; break; - case 198: + case 201: return getErrorSpanForArrowFunction(sourceFile, node); + case 275: + case 276: + var start = ts.skipTrivia(sourceFile.text, node.pos); + var end = node.statements.length > 0 ? node.statements[0].pos : node.end; + return ts.createTextSpanFromBounds(start, end); } if (errorNode === undefined) { return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -7294,16 +7881,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 && n.expression.kind === 99; + return n.kind === 195 && n.expression.kind === 101; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 && n.expression.kind === 93; + return n.kind === 195 && n.expression.kind === 95; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 93 + && n.keywordToken === 95 && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -7312,7 +7899,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 + return node.kind === 225 && node.expression.kind === 10; } ts.isPrologueDirective = isPrologueDirective; @@ -7321,11 +7908,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 || - node.kind === 151 || - node.kind === 197 || - node.kind === 198 || - node.kind === 196) ? + var commentRanges = (node.kind === 155 || + node.kind === 154 || + node.kind === 200 || + node.kind === 201 || + node.kind === 199) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); return ts.filter(commentRanges, function (comment) { @@ -7340,79 +7927,79 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 <= node.kind && node.kind <= 184) { + if (167 <= node.kind && node.kind <= 187) { return true; } switch (node.kind) { - case 121: - case 144: - case 136: + case 124: case 147: case 139: - case 124: - case 140: - case 137: + case 150: case 142: - case 133: + case 127: + case 143: + case 140: + case 145: + case 136: return true; - case 107: - return node.parent.kind !== 201; - case 212: + case 109: + return node.parent.kind !== 204; + case 215: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151: - return node.parent.kind === 182 || node.parent.kind === 177; - case 73: - if (node.parent.kind === 149 && node.parent.right === node) { + case 154: + return node.parent.kind === 185 || node.parent.kind === 180; + case 75: + if (node.parent.kind === 152 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 && node.parent.name === node) { + else if (node.parent.kind === 193 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 73 || node.kind === 149 || node.kind === 190, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 149: - case 190: - case 101: { + ts.Debug.assert(node.kind === 75 || node.kind === 152 || node.kind === 193, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 152: + case 193: + case 103: { var parent = node.parent; - if (parent.kind === 168) { + if (parent.kind === 171) { return false; } - if (parent.kind === 184) { + if (parent.kind === 187) { return !parent.isTypeOf; } - if (164 <= parent.kind && parent.kind <= 184) { + if (167 <= parent.kind && parent.kind <= 187) { return true; } switch (parent.kind) { - case 212: + case 215: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151: + case 154: return node === parent.constraint; - case 311: + case 314: return node === parent.constraint; - case 155: - case 154: - case 152: - case 238: - return node === parent.type; - case 240: - case 197: - case 198: case 158: case 157: - case 156: - case 159: - case 160: + case 155: + case 241: return node === parent.type; + case 243: + case 200: + case 201: case 161: + case 160: + case 159: case 162: case 163: return node === parent.type; - case 195: + case 164: + case 165: + case 166: return node === parent.type; - case 192: - case 193: + case 198: + return node === parent.type; + case 195: + case 196: return ts.contains(parent.typeArguments, node); - case 194: + case 197: return false; } } @@ -7434,23 +8021,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231: + case 234: return visitor(node); - case 247: - case 219: - case 223: - case 224: - case 225: + case 250: + case 222: case 226: case 227: case 228: - case 232: - case 233: - case 272: - case 273: - case 234: + case 229: + case 230: + case 231: + case 235: case 236: case 275: + case 276: + case 237: + case 239: + case 278: return ts.forEachChild(node, traverse); } } @@ -7460,23 +8047,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208: + case 211: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244: - case 242: + case 247: case 245: - case 243: - case 241: - case 210: + case 248: + case 246: + case 244: + case 213: return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150) { + if (node.name && node.name.kind === 153) { traverse(node.name.expression); return; } @@ -7489,10 +8076,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 170) { + if (node && node.kind === 173) { return node.elementType; } - else if (node && node.kind === 165) { + else if (node && node.kind === 168) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7502,12 +8089,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242: - case 241: - case 210: - case 169: + case 245: + case 244: + case 213: + case 172: return node.members; - case 189: + case 192: return node.properties; } } @@ -7515,14 +8102,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187: - case 279: - case 152: - case 276: + case 190: + case 282: case 155: - case 154: - case 277: - case 238: + case 279: + case 158: + case 157: + case 280: + case 241: return true; } } @@ -7534,8 +8121,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 - && node.parent.parent.kind === 220; + return node.parent.kind === 242 + && node.parent.parent.kind === 224; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -7546,13 +8133,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157: - case 156: - case 158: - case 159: case 160: - case 240: - case 197: + case 159: + case 161: + case 162: + case 163: + case 243: + case 200: return true; } return false; @@ -7563,7 +8150,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234) { + if (node.statement.kind !== 237) { return node.statement; } node = node.statement; @@ -7571,17 +8158,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 && ts.isFunctionLike(node.parent); + return node && node.kind === 222 && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 && node.parent.kind === 189; + return node && node.kind === 160 && node.parent.kind === 192; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 && - (node.parent.kind === 189 || - node.parent.kind === 210); + return node.kind === 160 && + (node.parent.kind === 192 || + node.parent.kind === 213); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7594,7 +8181,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276) { + if (property.kind === 279) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -7635,46 +8222,46 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285); + ts.Debug.assert(node.kind !== 288); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); } switch (node.kind) { - case 150: + case 153: if (ts.isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 153: - if (node.parent.kind === 152 && ts.isClassElement(node.parent.parent)) { + case 156: + if (node.parent.kind === 155 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { node = node.parent; } break; - case 198: + case 201: if (!includeArrowFunctions) { continue; } - case 240: - case 197: - case 245: - case 155: - case 154: - case 157: - case 156: + case 243: + case 200: + case 248: case 158: - case 159: + case 157: case 160: + case 159: case 161: case 162: case 163: - case 244: - case 285: + case 164: + case 165: + case 166: + case 247: + case 288: return node; } } @@ -7684,9 +8271,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 158: - case 240: - case 197: + case 161: + case 243: + case 200: return container; } } @@ -7700,25 +8287,25 @@ var ts; return node; } switch (node.kind) { - case 150: + case 153: node = node.parent; break; - case 240: - case 197: - case 198: + case 243: + case 200: + case 201: if (!stopOnFunctions) { continue; } - case 155: - case 154: - case 157: - case 156: case 158: - case 159: + case 157: case 160: + case 159: + case 161: + case 162: + case 163: return node; - case 153: - if (node.parent.kind === 152 && ts.isClassElement(node.parent.parent)) { + case 156: + if (node.parent.kind === 155 && ts.isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (ts.isClassElement(node.parent)) { @@ -7730,46 +8317,46 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 || func.kind === 198) { + if (func.kind === 200 || func.kind === 201) { var prev = func; var parent = func.parent; - while (parent.kind === 196) { + while (parent.kind === 199) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 && parent.expression === prev) { + if (parent.kind === 195 && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 + return node.kind === 101 || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 || kind === 191) - && node.expression.kind === 99; + return (kind === 193 || kind === 194) + && node.expression.kind === 101; } ts.isSuperProperty = isSuperProperty; function isThisProperty(node) { var kind = node.kind; - return (kind === 190 || kind === 191) - && node.expression.kind === 101; + return (kind === 193 || kind === 194) + && node.expression.kind === 103; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165: + case 168: return node.typeName; - case 212: + case 215: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73: - case 149: + case 75: + case 152: return node; } return undefined; @@ -7777,10 +8364,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194: + case 197: return node.tag; - case 263: - case 262: + case 266: + case 265: return node.tagName; default: return node.expression; @@ -7789,21 +8376,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241: + case 244: return true; - case 155: - return parent.kind === 241; - case 159: + case 158: + return parent.kind === 244; + case 162: + case 163: case 160: - case 157: return node.body !== undefined - && parent.kind === 241; - case 152: + && parent.kind === 244; + case 155: return parent.body !== undefined - && (parent.kind === 158 - || parent.kind === 157 - || parent.kind === 160) - && grandparent.kind === 241; + && (parent.kind === 161 + || parent.kind === 160 + || parent.kind === 163) + && grandparent.kind === 244; } return false; } @@ -7819,10 +8406,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241: + case 244: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); - case 157: case 160: + case 163: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); default: return false; @@ -7831,9 +8418,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 || - parent.kind === 262 || - parent.kind === 264) { + if (parent.kind === 266 || + parent.kind === 265 || + parent.kind === 267) { return parent.tagName === node; } return false; @@ -7841,56 +8428,56 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { + case 101: case 99: - case 97: - case 103: - case 88: + case 105: + case 90: case 13: - case 188: - case 189: - case 190: case 191: case 192: case 193: case 194: - case 213: case 195: - case 214: case 196: case 197: - case 210: + case 216: case 198: - case 201: + case 217: case 199: case 200: - case 203: + case 213: + case 201: case 204: - case 205: + case 202: + case 203: case 206: - case 209: case 207: - case 14: - case 211: - case 261: - case 262: - case 265: case 208: - case 202: - case 215: + case 209: + case 212: + case 210: + case 214: + case 264: + case 265: + case 268: + case 211: + case 205: + case 218: return true; - case 149: - while (node.parent.kind === 149) { + case 152: + while (node.parent.kind === 152) { node = node.parent; } - return node.parent.kind === 168 || isJSXTagName(node); - case 73: - if (node.parent.kind === 168 || isJSXTagName(node)) { + return node.parent.kind === 171 || isJSXTagName(node); + case 75: + if (node.parent.kind === 171 || isJSXTagName(node)) { return true; } case 8: case 9: case 10: - case 101: + case 14: + case 103: return isInExpressionContext(node); default: return false; @@ -7900,49 +8487,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238: - case 152: + case 241: case 155: - case 154: + case 158: + case 157: + case 282: case 279: - case 276: - case 187: + case 190: return parent.initializer === node; - case 222: - case 223: - case 224: case 225: - case 231: - case 232: - case 233: - case 272: + case 226: + case 227: + case 228: + case 234: case 235: + case 236: + case 275: + case 238: return parent.expression === node; - case 226: + case 229: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242) || forStatement.condition === node || forStatement.incrementor === node; - case 227: - case 228: + case 230: + case 231: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242) || forInStatement.expression === node; - case 195: - case 213: - return node === parent.expression; - case 217: + case 198: + case 216: return node === parent.expression; - case 150: + case 220: return node === parent.expression; case 153: - case 271: - case 270: - case 278: + return node === parent.expression; + case 156: + case 274: + case 273: + case 281: return true; - case 212: + case 215: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277: + case 280: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -7950,7 +8537,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 && node.moduleReference.kind === 260; + return node.kind === 252 && node.moduleReference.kind === 263; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7959,7 +8546,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 && node.moduleReference.kind !== 260; + return node.kind === 252 && node.moduleReference.kind !== 263; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -7971,15 +8558,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536); + return !!node && !!(node.flags & 131072); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216); + return !!node && !!(node.flags & 33554432); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152); + return !!node && !!(node.flags & 4194304); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -7987,22 +8574,22 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 || node.typeArguments[0].kind === 136); + (node.typeArguments[0].kind === 142 || node.typeArguments[0].kind === 139); } ts.isJSDocIndexSignature = isJSDocIndexSignature; - function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192) { + function isRequireCall(callExpression, requireStringLiteralLikeArgument) { + if (callExpression.kind !== 195) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 || expression.escapedText !== "require") { + if (expression.kind !== 75 || expression.escapedText !== "require") { return false; } if (args.length !== 1) { return false; } var arg = args[0]; - return !checkArgumentIsStringLiteralLike || ts.isStringLiteralLike(arg); + return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { @@ -8026,21 +8613,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55) { - if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { - name = node.parent.parent.name; - decl = node.parent.parent; - } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 60 && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 || parentNodeOperator === 60) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -8050,12 +8641,13 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 || node.initializer.operatorToken.kind === 60) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -8068,10 +8660,16 @@ var ts; } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; function hasExpandoValueProperty(node, isPrototypeAssignment) { - return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + return ts.forEach(node.properties, function (p) { + return ts.isPropertyAssignment(p) && + ts.isIdentifier(p.name) && + p.name.escapedText === "value" && + p.initializer && + getExpandoInitializer(p.initializer, isPrototypeAssignment); + }); } function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -8087,11 +8685,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 || e.kind === 198 ? initializer : undefined; + return e.kind === 200 || e.kind === 201 ? initializer : undefined; } - if (initializer.kind === 197 || - initializer.kind === 210 || - initializer.kind === 198) { + if (initializer.kind === 200 || + initializer.kind === 213 || + initializer.kind === 201) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -8100,22 +8698,24 @@ var ts; } ts.getExpandoInitializer = getExpandoInitializer; function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 || initializer.operatorToken.kind === 60) + && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } ts.isDefaultedExpandoInitializer = isDefaultedExpandoInitializer; function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = (node.parent.operatorToken.kind === 55 && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 || node.parent.operatorToken.kind === 60) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -8125,19 +8725,20 @@ var ts; } ts.getNameOfExpando = getNameOfExpando; function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -8152,10 +8753,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; function getAssignmentDeclarationKind(expr) { var special = getAssignmentDeclarationKindWorker(expr); return special === 5 || isInJSFile(expr) ? special : 0; @@ -8168,55 +8772,114 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0], true); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 || isBindableStaticNameExpression(node.expression, true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103) || + isEntityNameExpression(node.expression) || + isBindableStaticAccessExpression(node.expression, true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9; } return 7; } - if (expr.operatorToken.kind !== 60 || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 || !isAccessExpression(expr.left)) { return 0; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression, true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { return 6; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); + } + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101) { + if (lhs.expression.kind === 103) { return 4; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { return 2; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, true)) { if (isPrototypeAccess(lhs.expression)) { return 3; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; - if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { + if ((id.escapedText === "exports" || + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") && + isBindableStaticAccessExpression(lhs)) { return 1; } - return 5; + if (isBindableStaticNameExpression(lhs, true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs) && lhs.expression.kind !== 103)) { + return 5; + } } return 0; } @@ -8234,7 +8897,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 && + expr.parent && expr.parent.kind === 225 && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -8243,7 +8907,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -8252,14 +8916,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250: - case 256: + case 253: + case 259: return node.parent; - case 260: + case 263: return node.parent.parent; - case 192: + case 195: return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined; - case 183: + case 186: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -8269,12 +8933,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250: - case 256: + case 253: + case 259: return node.moduleSpecifier; - case 249: - return node.moduleReference.kind === 260 ? node.moduleReference.expression : undefined; - case 184: + case 252: + return node.moduleReference.kind === 263 ? node.moduleReference.expression : undefined; + case 187: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -8283,11 +8947,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250: + case 253: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249: + case 252: return node; - case 256: + case 259: return undefined; default: return ts.Debug.assertNever(node); @@ -8295,19 +8959,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 && !!node.importClause && !!node.importClause.name; + return node.kind === 253 && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152: - case 157: - case 156: - case 277: - case 276: case 155: - case 154: + case 160: + case 159: + case 280: + case 279: + case 158: + case 157: return node.questionToken !== undefined; } } @@ -8321,7 +8985,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 312 || node.kind === 305 || node.kind === 306; + return node.kind === 315 || node.kind === 308 || node.kind === 309; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -8331,7 +8995,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 + node.expression.operatorToken.kind === 62 ? node.expression.right : undefined; } @@ -8340,18 +9004,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 + (node.expression.right.operatorToken.kind === 56 || node.expression.right.operatorToken.kind === 60) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220: + case 224: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155: + case 158: return node.initializer; - case 276: + case 279: return node.initializer; } } @@ -8362,7 +9026,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 + node.body.kind === 248 ? node.body : undefined; } @@ -8376,11 +9040,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152) { + if (node.kind === 155) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151) { + if (node.kind === 154) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -8391,17 +9055,17 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 || - parent.kind === 255 || - parent.kind === 155 || - parent.kind === 222 && node.kind === 190 || + if (parent.kind === 279 || + parent.kind === 258 || + parent.kind === 158 || + parent.kind === 225 && node.kind === 193 || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62) { return parent; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -8423,7 +9087,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -8448,7 +9112,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -8458,38 +9122,38 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 296; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299; } ts.isRestParameter = isRestParameter; function getAssignmentTargetKind(node) { var parent = node.parent; while (true) { switch (parent.kind) { - case 205: + case 208: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 ? 1 : 2 : + binaryOperator === 62 ? 1 : 2 : 0; - case 203: - case 204: + case 206: + case 207: var unaryOperator = parent.operator; - return unaryOperator === 44 || unaryOperator === 45 ? 2 : 0; - case 227: - case 228: + return unaryOperator === 45 || unaryOperator === 46 ? 2 : 0; + case 230: + case 231: return parent.initializer === node ? 1 : 0; - case 196: - case 188: - case 209: - case 214: + case 199: + case 191: + case 212: + case 217: node = parent; break; - case 277: + case 280: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 276: + case 279: if (parent.name === node) { return 0; } @@ -8508,22 +9172,22 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219: - case 220: - case 232: - case 223: - case 233: - case 247: - case 272: - case 273: - case 234: - case 226: - case 227: - case 228: + case 222: case 224: - case 225: + case 235: + case 226: case 236: + case 250: case 275: + case 276: + case 237: + case 229: + case 230: + case 231: + case 227: + case 228: + case 239: + case 278: return true; } return false; @@ -8540,32 +9204,32 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178); + return walkUp(node, 181); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196); + return walkUp(node, 199); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196) { + while (node.kind === 199) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196) { + while (node.kind === 199) { node = node.parent; } return node; } function isDeleteTarget(node) { - if (node.kind !== 190 && node.kind !== 191) { + if (node.kind !== 193 && node.kind !== 194) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199; + return node && node.kind === 202; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -8585,10 +9249,11 @@ var ts; var parent = name.parent; switch (name.kind) { case 10: + case 14: case 8: if (ts.isComputedPropertyName(parent)) return parent.parent; - case 73: + case 75: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -8611,58 +9276,73 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 || node.kind === 8) && - node.parent.kind === 150 && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155: - case 154: + case 158: case 157: - case 156: - case 159: case 160: + case 159: + case 162: + case 163: + case 282: case 279: - case 276: - case 190: + case 193: return parent.name === node; - case 149: + case 152: if (parent.right === node) { - while (parent.kind === 149) { + while (parent.kind === 152) { parent = parent.parent; } - return parent.kind === 168 || parent.kind === 165; + return parent.kind === 171 || parent.kind === 168; } return false; - case 187: - case 254: + case 190: + case 257: return parent.propertyName === node; - case 258: - case 268: + case 261: + case 271: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 249 || - node.kind === 248 || - node.kind === 251 && !!node.name || - node.kind === 252 || - node.kind === 254 || - node.kind === 258 || - node.kind === 255 && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node); + return node.kind === 252 || + node.kind === 251 || + node.kind === 254 && !!node.name || + node.kind === 255 || + node.kind === 257 || + node.kind === 261 || + node.kind === 258 && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 && isAliasableExpression(node.parent.right) || + node.kind === 280 || + node.kind === 279 && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 ? node.name : node.kind === 279 ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -8675,23 +9355,23 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87); + var heritageClause = getHeritageClause(node.heritageClauses, 89); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110); + var heritageClause = getHeritageClause(node.heritageClauses, 112); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87); + var heritageClause = getHeritageClause(node.heritageClauses, 89); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -8718,11 +9398,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 <= token && token <= 148; + return 76 <= token && token <= 151; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 <= token && token <= 148; + return 121 <= token && token <= 151; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -8730,7 +9410,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 110 <= token && token <= 118; + return 112 <= token && token <= 120; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -8738,6 +9418,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -8753,13 +9438,13 @@ var ts; } var flags = 0; switch (node.kind) { - case 240: - case 197: - case 157: + case 243: + case 200: + case 160: if (node.asteriskToken) { flags |= 1; } - case 198: + case 201: if (hasModifier(node, 256)) { flags |= 2; } @@ -8773,10 +9458,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240: - case 197: - case 198: - case 157: + case 243: + case 200: + case 201: + case 160: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256); @@ -8789,7 +9474,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 || node.operator === 39) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 || node.operator === 40) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; function hasDynamicName(declaration) { @@ -8798,10 +9483,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 || name.kind === 194)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; function isWellKnownSymbolSyntactically(node) { @@ -8810,12 +9498,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73: + case 75: return name.escapedText; case 10: case 8: return ts.escapeLeadingUnderscores(name.text); - case 150: + case 153: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -8831,7 +9519,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73: + case 75: case 10: case 14: case 8: @@ -8842,11 +9530,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 ? ts.idText(node) : node.text; + return node.kind === 75 ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -8858,7 +9546,7 @@ var ts; } ts.isKnownSymbol = isKnownSymbol; function isESSymbolIdentifier(node) { - return node.kind === 73 && node.escapedText === "Symbol"; + return node.kind === 75 && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -8867,11 +9555,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152; + return root.kind === 155; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187) { + while (node.kind === 190) { node = node.parent.parent; } return node; @@ -8879,15 +9567,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 - || kind === 197 - || kind === 240 - || kind === 198 - || kind === 157 - || kind === 159 + return kind === 161 + || kind === 200 + || kind === 243 + || kind === 201 || kind === 160 - || kind === 245 - || kind === 285; + || kind === 162 + || kind === 163 + || kind === 248 + || kind === 288; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -8901,38 +9589,38 @@ var ts; ts.getOriginalSourceFile = getOriginalSourceFile; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193: + case 196: return hasArguments ? 0 : 1; + case 206: case 203: - case 200: - case 201: - case 199: + case 204: case 202: - case 206: - case 208: - return 1; case 205: + case 209: + case 211: + return 1; + case 208: switch (operator) { - case 41: - case 60: - case 61: + case 42: case 62: - case 64: case 63: - case 65: + case 64: case 66: + case 65: case 67: case 68: case 69: case 70: - case 72: case 71: + case 72: + case 74: + case 73: return 1; } } @@ -8941,15 +9629,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205) { + if (expression.kind === 208) { return expression.operatorToken.kind; } - else if (expression.kind === 203 || expression.kind === 204) { + else if (expression.kind === 206 || expression.kind === 207) { return expression.operator; } else { @@ -8959,73 +9647,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 317: + case 320: return 0; - case 209: + case 212: return 1; - case 208: + case 211: return 2; - case 206: + case 209: return 4; - case 205: + case 208: switch (operatorKind) { case 27: return 0; - case 60: - case 61: case 62: - case 64: case 63: - case 65: + case 64: case 66: + case 65: case 67: case 68: case 69: case 70: - case 72: case 71: + case 72: + case 74: + case 73: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } + case 206: case 203: - case 200: - case 201: - case 199: + case 204: case 202: + case 205: return 16; - case 204: + case 207: return 17; - case 192: + case 195: return 18; - case 193: + case 196: return hasArguments ? 19 : 18; + case 197: + case 193: case 194: - case 190: - case 191: return 19; + case 103: case 101: + case 75: case 99: - case 73: - case 97: - case 103: - case 88: + case 105: + case 90: case 8: case 9: case 10: - case 188: - case 189: - case 197: - case 198: - case 210: - case 261: - case 262: + case 191: + case 192: + case 200: + case 201: + case 213: + case 264: case 265: + case 268: case 13: case 14: - case 207: - case 196: - case 211: + case 210: + case 199: + case 214: return 20; default: return -1; @@ -9034,41 +9722,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55: + case 60: + return 4; + case 56: return 5; - case 54: + case 55: return 6; - case 50: - return 7; case 51: + return 7; + case 52: return 8; - case 49: + case 50: return 9; - case 33: case 34: case 35: case 36: + case 37: return 10; - case 28: - case 30: + case 29: case 31: case 32: - case 95: - case 94: - case 120: + case 33: + case 97: + case 96: + case 122: return 11; - case 46: case 47: case 48: + case 49: return 12; - case 38: case 39: - return 13; case 40: - case 42: + return 13; + case 41: case 43: + case 44: return 14; - case 41: + case 42: return 15; } return -1; @@ -9173,16 +9863,17 @@ var ts; ts.escapeString = escapeString; function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 || + charCode === 34 || + charCode === 96; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0) { var lookAhead = input.charCodeAt(offset + c.length); @@ -9229,6 +9920,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -9240,7 +9932,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -9250,17 +9942,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -9274,6 +9978,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -9293,6 +9998,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -9307,12 +10014,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -9376,7 +10083,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -9391,7 +10098,7 @@ var ts; ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration; function getExternalModuleNameFromPath(host, fileName, referencePath) { var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false); var extensionless = ts.removeFileExtension(relativePath); @@ -9501,11 +10208,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 && identifierIsThisKeyword(node); + return !!node && node.kind === 75 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101; + return id.originalKeywordKind === 103; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -9515,10 +10222,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159) { + if (accessor.kind === 162) { getAccessor = accessor; } - else if (accessor.kind === 160) { + else if (accessor.kind === 163) { setAccessor = accessor; } else { @@ -9538,10 +10245,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 && !getAccessor) { + if (member.kind === 162 && !getAccessor) { getAccessor = member; } - if (member.kind === 160 && !setAccessor) { + if (member.kind === 163 && !setAccessor) { setAccessor = member; } } @@ -9578,7 +10285,7 @@ var ts; } ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 298 && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 && tag.parent.tags.some(isJSDocTypeAlias)); } function getEffectiveSetAccessorTypeAnnotationNode(node) { var parameter = getSetAccessorValueParameter(node); @@ -9770,7 +10477,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 || (node.kind === 73 && node.isInJSDocNamespace)) { + if (node.flags & 4 || (node.kind === 75 && node.isInJSDocNamespace)) { flags |= 1; } return flags; @@ -9778,29 +10485,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117: return 32; - case 116: return 4; - case 115: return 16; - case 114: return 8; - case 119: return 128; - case 86: return 1; - case 126: return 2; - case 78: return 2048; - case 81: return 512; - case 122: return 256; - case 134: return 64; + case 119: return 32; + case 118: return 4; + case 117: return 16; + case 116: return 8; + case 121: return 128; + case 88: return 1; + case 129: return 2; + case 80: return 2048; + case 83: return 512; + case 125: return 256; + case 137: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 - || token === 54 - || token === 52; + return token === 56 + || token === 55 + || token === 53; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 && token <= 72; + return token >= 62 && token <= 74; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { @@ -9812,14 +10519,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 + ? node.operatorToken.kind === 62 : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -9827,8 +10534,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 189 - || kind === 188; + return kind === 192 + || kind === 191; } return false; } @@ -9838,9 +10545,32 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function getFirstIdentifier(node) { + switch (node.kind) { + case 75: + return node; + case 152: + do { + node = node.left; + } while (node.kind !== 75); + return node; + case 193: + do { + node = node.expression; + } while (node.kind !== 75); + return node; + } + } + ts.getFirstIdentifier = getFirstIdentifier; + function isDottedName(node) { + return node.kind === 75 || node.kind === 103 || + node.kind === 193 && isDottedName(node.expression) || + node.kind === 199 && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -9856,21 +10586,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 && node.parent.right === node) || - (node.parent.kind === 190 && node.parent.name === node); + return (node.parent.kind === 152 && node.parent.right === node) || + (node.parent.kind === 193 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 && + return expression.kind === 192 && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 && + return expression.kind === 191 && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -10108,8 +10838,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244: - case 245: + case 247: + case 248: return parseNode === parseNode.parent.name; } } @@ -10175,32 +10905,32 @@ var ts; if (!parent) return 0; switch (parent.kind) { - case 196: + case 199: return accessKind(parent); - case 204: - case 203: + case 207: + case 206: var operator = parent.operator; - return operator === 44 || operator === 45 ? writeOrReadWrite() : 0; - case 205: + return operator === 45 || operator === 46 ? writeOrReadWrite() : 0; + case 208: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 ? 1 : writeOrReadWrite() + operatorToken.kind === 62 ? 1 : writeOrReadWrite() : 0; - case 190: + case 193: return parent.name !== node ? 0 : accessKind(parent); - case 276: { + case 279: { var parentAccess = accessKind(parent.parent); return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 277: + case 280: return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent); - case 188: + case 191: return accessKind(parent); default: return 0; } function writeOrReadWrite() { - return parent.parent && skipParenthesesUp(parent.parent).kind === 222 ? 1 : 2; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 ? 1 : 2; } } function reverseAccessKind(a) { @@ -10263,20 +10993,6 @@ var ts; }); } ts.mutateMap = mutateMap; - function forEachAncestorDirectory(directory, callback) { - while (true) { - var result = callback(directory); - if (result !== undefined) { - return result; - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - return undefined; - } - directory = parentPath; - } - } - ts.forEachAncestorDirectory = forEachAncestorDirectory; function isAbstractConstructorType(type) { return !!(getObjectFlags(type) & 16) && !!type.symbol && isAbstractConstructorSymbol(type.symbol); } @@ -10302,7 +11018,7 @@ var ts; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { - return !!forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); + return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { @@ -10345,32 +11061,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 && kind <= 184) - || kind === 121 - || kind === 144 - || kind === 136 - || kind === 147 - || kind === 137 + return (kind >= 167 && kind <= 187) || kind === 124 + || kind === 147 || kind === 139 + || kind === 150 || kind === 140 - || kind === 101 - || kind === 107 + || kind === 127 || kind === 142 - || kind === 97 - || kind === 133 - || kind === 212 - || kind === 290 - || kind === 291 - || kind === 292 + || kind === 143 + || kind === 103 + || kind === 109 + || kind === 145 + || kind === 99 + || kind === 136 + || kind === 215 || kind === 293 || kind === 294 || kind === 295 - || kind === 296; + || kind === 296 + || kind === 297 + || kind === 298 + || kind === 299; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 || node.kind === 191; + return node.kind === 193 || node.kind === 194; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -10383,6 +11099,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -10516,9 +11236,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151) { + if (d && d.kind === 154) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245) { return current; } } @@ -10526,7 +11246,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasModifier(node, 92) && parent.kind === 158; + return ts.hasModifier(node, 92) && parent.kind === 161; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -10556,14 +11276,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238) { + if (node.kind === 241) { node = node.parent; } - if (node && node.kind === 239) { + if (node && node.kind === 242) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220) { + if (node && node.kind === 224) { flags |= getFlags(node); } return flags; @@ -10674,30 +11394,30 @@ var ts; return getDeclarationIdentifier(hostNode); } switch (hostNode.kind) { - case 220: + case 224: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222: + case 225: var expr = hostNode.expression; - if (expr.kind === 205 && expr.operatorToken.kind === 60) { + if (expr.kind === 208 && expr.operatorToken.kind === 62) { expr = expr.left; } switch (expr.kind) { - case 190: + case 193: return expr.name; - case 191: + case 194: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196: { + case 199: { return getDeclarationIdentifier(hostNode.expression); } - case 234: { + case 237: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -10709,6 +11429,16 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -10719,41 +11449,46 @@ var ts; ts.isNamedDeclaration = isNamedDeclaration; function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73: + case 75: return declaration; - case 313: - case 307: { + case 316: + case 310: { var name = declaration.name; - if (name.kind === 149) { + if (name.kind === 152) { return name.right; } break; } - case 192: - case 205: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195: + case 208: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1: case 4: case 5: case 3: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7: case 8: case 9: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 312: + case 315: return getNameOfJSDocTypedef(declaration); - case 306: + case 309: return nameForNamelessJSDocTypedef(declaration); - case 255: { + case 258: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -10776,8 +11511,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -10893,7 +11628,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 298); + ts.Debug.assert(node.parent.kind === 301); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -10913,10 +11648,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -10958,191 +11692,219 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73; + return node.kind === 75; } ts.isIdentifier = isIdentifier; function isQualifiedName(node) { - return node.kind === 149; + return node.kind === 152; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150; + return node.kind === 153; } ts.isComputedPropertyName = isComputedPropertyName; function isTypeParameterDeclaration(node) { - return node.kind === 151; + return node.kind === 154; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152; + return node.kind === 155; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153; + return node.kind === 156; } ts.isDecorator = isDecorator; function isPropertySignature(node) { - return node.kind === 154; + return node.kind === 157; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155; + return node.kind === 158; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156; + return node.kind === 159; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157; + return node.kind === 160; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158; + return node.kind === 161; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159; + return node.kind === 162; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160; + return node.kind === 163; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161; + return node.kind === 164; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162; + return node.kind === 165; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163; + return node.kind === 166; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 || node.kind === 159; + return node.kind === 163 || node.kind === 162; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; function isTypePredicateNode(node) { - return node.kind === 164; + return node.kind === 167; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165; + return node.kind === 168; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166; + return node.kind === 169; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167; + return node.kind === 170; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168; + return node.kind === 171; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169; + return node.kind === 172; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170; + return node.kind === 173; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171; + return node.kind === 174; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174; + return node.kind === 177; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175; + return node.kind === 178; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176; + return node.kind === 179; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177; + return node.kind === 180; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178; + return node.kind === 181; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179; + return node.kind === 182; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180; + return node.kind === 183; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181; + return node.kind === 184; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182; + return node.kind === 185; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183; + return node.kind === 186; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184; + return node.kind === 187; } ts.isImportTypeNode = isImportTypeNode; function isObjectBindingPattern(node) { - return node.kind === 185; + return node.kind === 188; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186; + return node.kind === 189; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187; + return node.kind === 190; } ts.isBindingElement = isBindingElement; function isArrayLiteralExpression(node) { - return node.kind === 188; + return node.kind === 191; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189; + return node.kind === 192; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190; + return node.kind === 193; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191; + return node.kind === 194; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192; + return node.kind === 195; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + var kind = node.kind; + return !!(node.flags & 32) && + (kind === 193 + || kind === 194 + || kind === 195); + } + ts.isOptionalChain = isOptionalChain; + function isExpressionOfOptionalChainRoot(node) { + return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node; + } + ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot; + function isNullishCoalesce(node) { + return node.kind === 208 && node.operatorToken.kind === 60; + } + ts.isNullishCoalesce = isNullishCoalesce; function isNewExpression(node) { - return node.kind === 193; + return node.kind === 196; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194; + return node.kind === 197; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195; + return node.kind === 198; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -11151,368 +11913,368 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196; + return node.kind === 199; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 316) { + while (node.kind === 319) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197; + return node.kind === 200; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198; + return node.kind === 201; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199; + return node.kind === 202; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200; + return node.kind === 203; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201; + return node.kind === 204; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202; + return node.kind === 205; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203; + return node.kind === 206; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204; + return node.kind === 207; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205; + return node.kind === 208; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206; + return node.kind === 209; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207; + return node.kind === 210; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208; + return node.kind === 211; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209; + return node.kind === 212; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210; + return node.kind === 213; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211; + return node.kind === 214; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212; + return node.kind === 215; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213; + return node.kind === 216; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214; + return node.kind === 217; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215; + return node.kind === 218; } ts.isMetaProperty = isMetaProperty; function isTemplateSpan(node) { - return node.kind === 217; + return node.kind === 220; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218; + return node.kind === 221; } ts.isSemicolonClassElement = isSemicolonClassElement; function isBlock(node) { - return node.kind === 219; + return node.kind === 222; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220; + return node.kind === 224; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221; + return node.kind === 223; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222; + return node.kind === 225; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223; + return node.kind === 226; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224; + return node.kind === 227; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225; + return node.kind === 228; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226; + return node.kind === 229; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227; + return node.kind === 230; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228; + return node.kind === 231; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229; + return node.kind === 232; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230; + return node.kind === 233; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 || node.kind === 229; + return node.kind === 233 || node.kind === 232; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231; + return node.kind === 234; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232; + return node.kind === 235; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233; + return node.kind === 236; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234; + return node.kind === 237; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235; + return node.kind === 238; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236; + return node.kind === 239; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237; + return node.kind === 240; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238; + return node.kind === 241; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239; + return node.kind === 242; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240; + return node.kind === 243; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241; + return node.kind === 244; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242; + return node.kind === 245; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243; + return node.kind === 246; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244; + return node.kind === 247; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245; + return node.kind === 248; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246; + return node.kind === 249; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247; + return node.kind === 250; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248; + return node.kind === 251; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249; + return node.kind === 252; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250; + return node.kind === 253; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251; + return node.kind === 254; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252; + return node.kind === 255; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253; + return node.kind === 256; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254; + return node.kind === 257; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255; + return node.kind === 258; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256; + return node.kind === 259; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257; + return node.kind === 260; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258; + return node.kind === 261; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259; + return node.kind === 262; } ts.isMissingDeclaration = isMissingDeclaration; function isExternalModuleReference(node) { - return node.kind === 260; + return node.kind === 263; } ts.isExternalModuleReference = isExternalModuleReference; function isJsxElement(node) { - return node.kind === 261; + return node.kind === 264; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262; + return node.kind === 265; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263; + return node.kind === 266; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264; + return node.kind === 267; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265; + return node.kind === 268; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266; + return node.kind === 269; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267; + return node.kind === 270; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268; + return node.kind === 271; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269; + return node.kind === 272; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270; + return node.kind === 273; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271; + return node.kind === 274; } ts.isJsxExpression = isJsxExpression; function isCaseClause(node) { - return node.kind === 272; + return node.kind === 275; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273; + return node.kind === 276; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274; + return node.kind === 277; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275; + return node.kind === 278; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 276; + return node.kind === 279; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277; + return node.kind === 280; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278; + return node.kind === 281; } ts.isSpreadAssignment = isSpreadAssignment; function isEnumMember(node) { - return node.kind === 279; + return node.kind === 282; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 285; + return node.kind === 288; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286; + return node.kind === 289; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287; + return node.kind === 290; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281; + return node.kind === 284; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282: - case 283: + case 285: + case 286: return true; default: return false; @@ -11521,110 +12283,110 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 || - node.kind === 284; + node.kind === 283 || + node.kind === 287; } ts.isUnparsedNode = isUnparsedNode; function isJSDocTypeExpression(node) { - return node.kind === 289; + return node.kind === 292; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290; + return node.kind === 293; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291; + return node.kind === 294; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292; + return node.kind === 295; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293; + return node.kind === 296; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294; + return node.kind === 297; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295; + return node.kind === 298; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296; + return node.kind === 299; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 298; + return node.kind === 301; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 303; + return node.kind === 306; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 302; + return node.kind === 305; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 304; + return node.kind === 307; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 306; + return node.kind === 309; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 309; + return node.kind === 312; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 307; + return node.kind === 310; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 308; + return node.kind === 311; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 310; + return node.kind === 313; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 311; + return node.kind === 314; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 312; + return node.kind === 315; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 313; + return node.kind === 316; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 313 || node.kind === 307; + return node.kind === 316 || node.kind === 310; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 299; + return node.kind === 302; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 305; + return node.kind === 308; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 300; + return node.kind === 303; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); (function (ts) { function isSyntaxList(n) { - return n.kind === 314; + return n.kind === 317; } ts.isSyntaxList = isSyntaxList; function isNode(node) { @@ -11632,11 +12394,11 @@ var ts; } ts.isNode = isNode; function isNodeKind(kind) { - return kind >= 149; + return kind >= 152; } ts.isNodeKind = isNodeKind; function isToken(n) { - return n.kind >= 0 && n.kind <= 148; + return n.kind >= 0 && n.kind <= 151; } ts.isToken = isToken; function isNodeArray(array) { @@ -11679,17 +12441,17 @@ var ts; ts.isGeneratedIdentifier = isGeneratedIdentifier; function isModifierKind(token) { switch (token) { - case 119: - case 122: - case 78: - case 126: - case 81: - case 86: + case 121: + case 125: + case 80: + case 129: + case 83: + case 88: + case 118: case 116: - case 114: - case 115: - case 134: case 117: + case 137: + case 119: return true; } return false; @@ -11700,7 +12462,7 @@ var ts; } ts.isParameterPropertyModifier = isParameterPropertyModifier; function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117; + return isParameterPropertyModifier(idToken) || idToken === 119; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -11709,23 +12471,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 - || kind === 73; + return kind === 152 + || kind === 75; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 + return kind === 75 || kind === 10 || kind === 8 - || kind === 150; + || kind === 153; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 - || kind === 185 - || kind === 186; + return kind === 75 + || kind === 188 + || kind === 189; } ts.isBindingName = isBindingName; function isFunctionLike(node) { @@ -11738,13 +12500,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240: - case 157: - case 158: - case 159: + case 243: case 160: - case 197: - case 198: + case 161: + case 162: + case 163: + case 200: + case 201: return true; default: return false; @@ -11752,14 +12514,14 @@ var ts; } function isFunctionLikeKind(kind) { switch (kind) { - case 156: - case 161: - case 300: - case 162: - case 163: + case 159: + case 164: + case 303: + case 165: case 166: - case 295: - case 167: + case 169: + case 298: + case 170: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -11772,28 +12534,28 @@ var ts; ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; - return kind === 158 - || kind === 155 - || kind === 157 - || kind === 159 + return kind === 161 + || kind === 158 || kind === 160 + || kind === 162 || kind === 163 - || kind === 218; + || kind === 166 + || kind === 221; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 || node.kind === 210); + return node && (node.kind === 244 || node.kind === 213); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 || node.kind === 160); + return node && (node.kind === 162 || node.kind === 163); } ts.isAccessor = isAccessor; function isMethodOrAccessor(node) { switch (node.kind) { - case 157: - case 159: case 160: + case 162: + case 163: return true; default: return false; @@ -11802,11 +12564,11 @@ var ts; ts.isMethodOrAccessor = isMethodOrAccessor; function isTypeElement(node) { var kind = node.kind; - return kind === 162 - || kind === 161 - || kind === 154 - || kind === 156 - || kind === 163; + return kind === 165 + || kind === 164 + || kind === 157 + || kind === 159 + || kind === 166; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -11815,12 +12577,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 - || kind === 277 - || kind === 278 - || kind === 157 - || kind === 159 - || kind === 160; + return kind === 279 + || kind === 280 + || kind === 281 + || kind === 160 + || kind === 162 + || kind === 163; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNode(node) { @@ -11829,8 +12591,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166: - case 167: + case 169: + case 170: return true; } return false; @@ -11839,29 +12601,29 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 - || kind === 185; + return kind === 189 + || kind === 188; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 - || kind === 189; + return kind === 191 + || kind === 192; } ts.isAssignmentPattern = isAssignmentPattern; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 - || kind === 211; + return kind === 190 + || kind === 214; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238: - case 152: - case 187: + case 241: + case 155: + case 190: return true; } return false; @@ -11874,8 +12636,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185: - case 189: + case 188: + case 192: return true; } return false; @@ -11883,8 +12645,8 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186: - case 188: + case 189: + case 191: return true; } return false; @@ -11892,25 +12654,25 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 - || kind === 149 - || kind === 184; + return kind === 193 + || kind === 152 + || kind === 187; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 - || kind === 149; + return kind === 193 + || kind === 152; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263: - case 262: - case 192: - case 193: - case 194: - case 153: + case 266: + case 265: + case 195: + case 196: + case 197: + case 156: return true; default: return false; @@ -11918,12 +12680,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 || node.kind === 193; + return node.kind === 195 || node.kind === 196; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 + return kind === 210 || kind === 14; } ts.isTemplateLiteral = isTemplateLiteral; @@ -11933,34 +12695,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190: - case 191: case 193: - case 192: - case 261: - case 262: - case 265: case 194: - case 188: case 196: - case 189: - case 210: + case 195: + case 264: + case 265: + case 268: case 197: - case 73: + case 191: + case 199: + case 192: + case 213: + case 200: + case 75: case 13: case 8: case 9: case 10: case 14: - case 207: - case 88: - case 97: - case 101: - case 103: + case 210: + case 90: case 99: - case 214: - case 215: - case 93: + case 103: + case 105: + case 101: + case 217: + case 218: + case 95: return true; default: return false; @@ -11972,13 +12734,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { + case 206: + case 207: + case 202: case 203: case 204: - case 199: - case 200: - case 201: - case 202: - case 195: + case 205: + case 198: return true; default: return isLeftHandSideExpressionKind(kind); @@ -11986,11 +12748,11 @@ var ts; } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204: + case 207: return true; - case 203: - return expr.operator === 44 || - expr.operator === 45; + case 206: + return expr.operator === 45 || + expr.operator === 46; default: return false; } @@ -12002,15 +12764,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206: - case 208: - case 198: - case 205: case 209: - case 213: case 211: - case 317: - case 316: + case 201: + case 208: + case 212: + case 216: + case 214: + case 320: + case 319: return true; default: return isUnaryExpressionKind(kind); @@ -12018,18 +12780,22 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 - || kind === 213; + return kind === 198 + || kind === 216; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 316; + return node.kind === 319; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 315; + return node.kind === 318; } ts.isNotEmittedStatement = isNotEmittedStatement; + function isSyntheticReference(node) { + return node.kind === 323; + } + ts.isSyntheticReference = isSyntheticReference; function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -12037,20 +12803,36 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226: + case 229: + case 230: + case 231: case 227: case 228: - case 224: - case 225: return true; - case 234: + case 237: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + function isExternalModuleIndicator(result) { + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; function isForInOrOfStatement(node) { - return node.kind === 227 || node.kind === 228; + return node.kind === 230 || node.kind === 231; } ts.isForInOrOfStatement = isForInOrOfStatement; function isConciseBody(node) { @@ -12069,108 +12851,108 @@ var ts; ts.isForInitializer = isForInitializer; function isModuleBody(node) { var kind = node.kind; - return kind === 246 - || kind === 245 - || kind === 73; + return kind === 249 + || kind === 248 + || kind === 75; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 - || kind === 245; + return kind === 249 + || kind === 248; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 - || kind === 245; + return kind === 75 + || kind === 248; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 - || kind === 252; + return kind === 256 + || kind === 255; } ts.isNamedImportBindings = isNamedImportBindings; function isModuleOrEnumDeclaration(node) { - return node.kind === 245 || node.kind === 244; + return node.kind === 248 || node.kind === 247; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 - || kind === 187 - || kind === 241 - || kind === 210 - || kind === 158 + return kind === 201 + || kind === 190 || kind === 244 - || kind === 279 - || kind === 258 - || kind === 240 - || kind === 197 - || kind === 159 - || kind === 251 - || kind === 249 + || kind === 213 + || kind === 161 + || kind === 247 + || kind === 282 + || kind === 261 + || kind === 243 + || kind === 200 + || kind === 162 || kind === 254 - || kind === 242 - || kind === 268 - || kind === 157 - || kind === 156 + || kind === 252 + || kind === 257 || kind === 245 + || kind === 271 + || kind === 160 + || kind === 159 || kind === 248 - || kind === 252 - || kind === 152 - || kind === 276 + || kind === 251 + || kind === 255 || kind === 155 + || kind === 279 + || kind === 158 + || kind === 157 + || kind === 163 + || kind === 280 + || kind === 246 || kind === 154 - || kind === 160 - || kind === 277 - || kind === 243 - || kind === 151 - || kind === 238 - || kind === 312 - || kind === 305 - || kind === 313; + || kind === 241 + || kind === 315 + || kind === 308 + || kind === 316; } function isDeclarationStatementKind(kind) { - return kind === 240 - || kind === 259 - || kind === 241 - || kind === 242 - || kind === 243 + return kind === 243 + || kind === 262 || kind === 244 || kind === 245 - || kind === 250 - || kind === 249 - || kind === 256 - || kind === 255 - || kind === 248; + || kind === 246 + || kind === 247 + || kind === 248 + || kind === 253 + || kind === 252 + || kind === 259 + || kind === 258 + || kind === 251; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 + return kind === 233 + || kind === 232 + || kind === 240 + || kind === 227 + || kind === 225 + || kind === 223 + || kind === 230 + || kind === 231 || kind === 229 + || kind === 226 || kind === 237 + || kind === 234 + || kind === 236 + || kind === 238 + || kind === 239 || kind === 224 - || kind === 222 - || kind === 221 - || kind === 227 || kind === 228 - || kind === 226 - || kind === 223 - || kind === 234 - || kind === 231 - || kind === 233 || kind === 235 - || kind === 236 - || kind === 220 - || kind === 225 - || kind === 232 - || kind === 315 - || kind === 319 - || kind === 318; + || kind === 318 + || kind === 322 + || kind === 321; } function isDeclaration(node) { - if (node.kind === 151) { - return (node.parent && node.parent.kind !== 311) || ts.isInJSFile(node); + if (node.kind === 154) { + return (node.parent && node.parent.kind !== 314) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -12191,10 +12973,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219) + if (node.kind !== 222) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 || node.parent.kind === 275) { + if (node.parent.kind === 239 || node.parent.kind === 278) { return false; } } @@ -12202,71 +12984,75 @@ var ts; } function isModuleReference(node) { var kind = node.kind; - return kind === 260 - || kind === 149 - || kind === 73; + return kind === 263 + || kind === 152 + || kind === 75; } ts.isModuleReference = isModuleReference; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 - || kind === 73 - || kind === 190; + return kind === 103 + || kind === 75 + || kind === 193; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 261 - || kind === 271 - || kind === 262 + return kind === 264 + || kind === 274 + || kind === 265 || kind === 11 - || kind === 265; + || kind === 268; } ts.isJsxChild = isJsxChild; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 - || kind === 270; + return kind === 271 + || kind === 273; } ts.isJsxAttributeLike = isJsxAttributeLike; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 - || kind === 271; + || kind === 274; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 - || kind === 262; + return kind === 266 + || kind === 265; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 - || kind === 273; + return kind === 275 + || kind === 276; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isJSDocNode(node) { - return node.kind >= 289 && node.kind <= 313; + return node.kind >= 292 && node.kind <= 316; } ts.isJSDocNode = isJSDocNode; function isJSDocCommentContainingNode(node) { - return node.kind === 298 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; function isJSDocTag(node) { - return node.kind >= 301 && node.kind <= 313; + return node.kind >= 304 && node.kind <= 316; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160; + return node.kind === 163; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159; + return node.kind === 162; } ts.isGetAccessor = isGetAccessor; + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; + } + ts.isOptionalChainRoot = isOptionalChainRoot; function hasJSDocNodes(node) { var jsDoc = node.jsDoc; return !!jsDoc && jsDoc.length > 0; @@ -12285,11 +13071,11 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 || node.kind === 270 || isObjectLiteralElementLike(node); + return node.kind === 271 || node.kind === 273 || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; function isTypeReferenceType(node) { - return node.kind === 165 || node.kind === 212; + return node.kind === 168 || node.kind === 215; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -12323,7 +13109,7 @@ var ts; })(ts || (ts = {})); (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 || node.kind === 257; + return node.kind === 256 || node.kind === 260; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -12341,7 +13127,12 @@ var ts; this.checker = checker; } } - function Signature() { } + function Signature(checker, flags) { + this.flags = flags; + if (ts.Debug.isDebugging) { + this.checker = checker; + } + } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -12614,390 +13405,39 @@ var ts; return true; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - ts.directorySeparator = "/"; - var altDirectorySeparator = "\\"; - var urlSchemeSeparator = "://"; - var backslashRegExp = /\\/g; - function normalizeSlashes(path) { - return path.replace(backslashRegExp, ts.directorySeparator); - } - ts.normalizeSlashes = normalizeSlashes; - function isVolumeCharacter(charCode) { - return (charCode >= 97 && charCode <= 122) || - (charCode >= 65 && charCode <= 90); - } - function getFileUrlVolumeSeparatorEnd(url, start) { - var ch0 = url.charCodeAt(start); - if (ch0 === 58) - return start + 1; - if (ch0 === 37 && url.charCodeAt(start + 1) === 51) { - var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 || ch2 === 65) - return start + 3; - } - return -1; - } - function getEncodedRootLength(path) { - if (!path) - return 0; - var ch0 = path.charCodeAt(0); - if (ch0 === 47 || ch0 === 92) { - if (path.charCodeAt(1) !== ch0) - return 1; - var p1 = path.indexOf(ch0 === 47 ? ts.directorySeparator : altDirectorySeparator, 2); - if (p1 < 0) - return path.length; - return p1 + 1; - } - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58) { - var ch2 = path.charCodeAt(2); - if (ch2 === 47 || ch2 === 92) - return 3; - if (path.length === 2) - return 2; - } - var schemeEnd = path.indexOf(urlSchemeSeparator); - if (schemeEnd !== -1) { - var authorityStart = schemeEnd + urlSchemeSeparator.length; - var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); - if (authorityEnd !== -1) { - var scheme = path.slice(0, schemeEnd); - var authority = path.slice(authorityStart, authorityEnd); - if (scheme === "file" && (authority === "" || authority === "localhost") && - isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { - var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); - if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47) { - return ~(volumeSeparatorEnd + 1); - } - if (volumeSeparatorEnd === path.length) { - return ~volumeSeparatorEnd; - } - } - } - return ~(authorityEnd + 1); - } - return ~path.length; - } - return 0; - } - function getRootLength(path) { - var rootLength = getEncodedRootLength(path); - return rootLength < 0 ? ~rootLength : rootLength; - } - ts.getRootLength = getRootLength; - function normalizePath(path) { - return ts.resolvePath(path); - } - ts.normalizePath = normalizePath; - function normalizePathAndParts(path) { - path = normalizeSlashes(path); - var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); - if (parts.length) { - var joinedParts = root + parts.join(ts.directorySeparator); - return { path: ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; - } - else { - return { path: root, parts: parts }; + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); } + return result; } - ts.normalizePathAndParts = normalizePathAndParts; - function getDirectoryPath(path) { - path = normalizeSlashes(path); - var rootLength = getRootLength(path); - if (rootLength === path.length) - return path; - path = ts.removeTrailingDirectorySeparator(path); - return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { - var canonicalFileName = getCanonicalFileName(fileName); - var canonicalDirectoryName = getCanonicalFileName(directoryName); - return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); - } - ts.startsWithDirectory = startsWithDirectory; - function isUrl(path) { - return getEncodedRootLength(path) < 0; - } - ts.isUrl = isUrl; - function pathIsRelative(path) { - return /^\.\.?($|[\\/])/.test(path); - } - ts.pathIsRelative = pathIsRelative; - function isRootedDiskPath(path) { - return getEncodedRootLength(path) > 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - function isDiskPathRoot(path) { - var rootLength = getEncodedRootLength(path); - return rootLength > 0 && rootLength === path.length; - } - ts.isDiskPathRoot = isDiskPathRoot; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false); - } - ts.convertToRelativePath = convertToRelativePath; - function pathComponents(path, rootLength) { - var root = path.substring(0, rootLength); - var rest = path.substring(rootLength).split(ts.directorySeparator); - if (rest.length && !ts.lastOrUndefined(rest)) - rest.pop(); - return __spreadArrays([root], rest); - } - function getPathComponents(path, currentDirectory) { - if (currentDirectory === void 0) { currentDirectory = ""; } - path = ts.combinePaths(currentDirectory, path); - var rootLength = getRootLength(path); - return pathComponents(path, rootLength); - } - ts.getPathComponents = getPathComponents; - function reducePathComponents(components) { - if (!ts.some(components)) - return []; - var reduced = [components[0]]; - for (var i = 1; i < components.length; i++) { - var component = components[i]; - if (!component) - continue; - if (component === ".") - continue; - if (component === "..") { - if (reduced.length > 1) { - if (reduced[reduced.length - 1] !== "..") { - reduced.pop(); - continue; - } - } - else if (reduced[0]) - continue; - } - reduced.push(component); + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); } - return reduced; - } - ts.reducePathComponents = reducePathComponents; - function getNormalizedPathComponents(path, currentDirectory) { - return reducePathComponents(getPathComponents(path, currentDirectory)); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - function getPathFromPathComponents(pathComponents) { - if (pathComponents.length === 0) - return ""; - var root = pathComponents[0] && ts.ensureTrailingDirectorySeparator(pathComponents[0]); - return root + pathComponents.slice(1).join(ts.directorySeparator); - } - ts.getPathFromPathComponents = getPathFromPathComponents; - function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { - return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; - function getPathWithoutRoot(pathComponents) { - if (pathComponents.length === 0) - return ""; - return pathComponents.slice(1).join(ts.directorySeparator); + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); } })(ts || (ts = {})); (function (ts) { - function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { - var fromComponents = ts.reducePathComponents(ts.getPathComponents(from)); - var toComponents = ts.reducePathComponents(ts.getPathComponents(to)); - var start; - for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { - var fromComponent = getCanonicalFileName(fromComponents[start]); - var toComponent = getCanonicalFileName(toComponents[start]); - var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; - if (!comparer(fromComponent, toComponent)) - break; - } - if (start === 0) { - return toComponents; - } - var components = toComponents.slice(start); - var relative = []; - for (; start < fromComponents.length; start++) { - relative.push(".."); - } - return __spreadArrays([""], relative, components); - } - ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; - function getRelativePathFromFile(from, to, getCanonicalFileName) { - return ensurePathIsNonModuleName(getRelativePathFromDirectory(ts.getDirectoryPath(from), to, getCanonicalFileName)); - } - ts.getRelativePathFromFile = getRelativePathFromFile; - function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { - ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); - var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; - var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; - var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); - return ts.getPathFromPathComponents(pathComponents); - } - ts.getRelativePathFromDirectory = getRelativePathFromDirectory; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); - var firstComponent = pathComponents[0]; - if (isAbsolutePathAnUrl && ts.isRootedDiskPath(firstComponent)) { - var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; - pathComponents[0] = prefix + firstComponent; - } - return ts.getPathFromPathComponents(pathComponents); - } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - function ensurePathIsNonModuleName(path) { - return ts.getRootLength(path) === 0 && !ts.pathIsRelative(path) ? "./" + path : path; - } - ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; - function getBaseFileName(path, extensions, ignoreCase) { - path = ts.normalizeSlashes(path); - var rootLength = ts.getRootLength(path); - if (rootLength === path.length) - return ""; - path = removeTrailingDirectorySeparator(path); - var name = path.slice(Math.max(ts.getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); - var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; - return extension ? name.slice(0, name.length - extension.length) : name; - } - ts.getBaseFileName = getBaseFileName; - function combinePaths(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; - } - if (path) - path = ts.normalizeSlashes(path); - for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { - var relativePath = paths_1[_a]; - if (!relativePath) - continue; - relativePath = ts.normalizeSlashes(relativePath); - if (!path || ts.getRootLength(relativePath) !== 0) { - path = relativePath; - } - else { - path = ensureTrailingDirectorySeparator(path) + relativePath; - } - } - return path; - } - ts.combinePaths = combinePaths; - function resolvePath(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; - } - var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); - var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); - return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; - } - ts.resolvePath = resolvePath; - function hasTrailingDirectorySeparator(path) { - if (path.length === 0) - return false; - var ch = path.charCodeAt(path.length - 1); - return ch === 47 || ch === 92; - } - ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; - function removeTrailingDirectorySeparator(path) { - if (hasTrailingDirectorySeparator(path)) { - return path.substr(0, path.length - 1); - } - return path; - } - ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; - function ensureTrailingDirectorySeparator(path) { - if (!hasTrailingDirectorySeparator(path)) { - return path + ts.directorySeparator; - } - return path; - } - ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; - function comparePathsWorker(a, b, componentComparer) { - if (a === b) - return 0; - if (a === undefined) - return -1; - if (b === undefined) - return 1; - var aRoot = a.substring(0, ts.getRootLength(a)); - var bRoot = b.substring(0, ts.getRootLength(b)); - var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0) { - return result; - } - var aRest = a.substring(aRoot.length); - var bRest = b.substring(bRoot.length); - if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { - return componentComparer(aRest, bRest); - } - var aComponents = ts.reducePathComponents(ts.getPathComponents(a)); - var bComponents = ts.reducePathComponents(ts.getPathComponents(b)); - var sharedLength = Math.min(aComponents.length, bComponents.length); - for (var i = 1; i < sharedLength; i++) { - var result_1 = componentComparer(aComponents[i], bComponents[i]); - if (result_1 !== 0) { - return result_1; - } - } - return ts.compareValues(aComponents.length, bComponents.length); - } - function comparePathsCaseSensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); - } - ts.comparePathsCaseSensitive = comparePathsCaseSensitive; - function comparePathsCaseInsensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); - } - ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; - function comparePaths(a, b, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - a = combinePaths(currentDirectory, a); - b = combinePaths(currentDirectory, b); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; - } - return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); - } - ts.comparePaths = comparePaths; - function containsPath(parent, child, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - parent = combinePaths(currentDirectory, parent); - child = combinePaths(currentDirectory, child); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; - } - if (parent === undefined || child === undefined) - return false; - if (parent === child) - return true; - var parentComponents = ts.reducePathComponents(ts.getPathComponents(parent)); - var childComponents = ts.reducePathComponents(ts.getPathComponents(child)); - if (childComponents.length < parentComponents.length) { - return false; - } - var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; - for (var i = 0; i < parentComponents.length; i++) { - var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; - if (!equalityComparer(parentComponents[i], childComponents[i])) { - return false; - } - } - return true; - } - ts.containsPath = containsPath; - function isDirectorySeparator(charCode) { - return charCode === 47 || charCode === 92; - } function stripLeadingDirectorySeparator(s) { - return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; } function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); @@ -13013,10 +13453,6 @@ var ts; return "\\" + match; } var wildcardCharCodes = [42, 63]; - function hasExtension(fileName) { - return ts.stringContains(getBaseFileName(fileName), "."); - } - ts.hasExtension = hasExtension; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; var filesMatcher = { @@ -13071,7 +13507,7 @@ var ts; if (usage !== "exclude" && lastComponent === "**") { return undefined; } - components[0] = removeTrailingDirectorySeparator(components[0]); + components[0] = ts.removeTrailingDirectorySeparator(components[0]); if (isImplicitGlob(lastComponent)) { components.push("**", "*"); } @@ -13123,7 +13559,7 @@ var ts; function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = ts.normalizePath(path); currentDirectory = ts.normalizePath(currentDirectory); - var absolutePath = combinePaths(currentDirectory, path); + var absolutePath = ts.combinePaths(currentDirectory, path); return { includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), @@ -13149,7 +13585,7 @@ var ts; var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; - visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth); + visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); } return ts.flatten(results); function visitDirectory(path, absolutePath, depth) { @@ -13159,8 +13595,8 @@ var ts; visited.set(canonicalPath, true); var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; var _loop_1 = function (current) { - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if (extensions && !ts.fileExtensionIsOneOf(name, extensions)) return "continue"; if (excludeRegex && excludeRegex.test(absoluteName)) @@ -13187,8 +13623,8 @@ var ts; } for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) { var current = _d[_c]; - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { visitDirectory(name, absoluteName, depth); @@ -13203,12 +13639,12 @@ var ts; var includeBasePaths = []; for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) { var include = includes_1[_i]; - var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(combinePaths(path, include)); + var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include)); includeBasePaths.push(getIncludeBasePath(absolute)); } includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames)); var _loop_2 = function (includeBasePath) { - if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; @@ -13222,9 +13658,9 @@ var ts; function getIncludeBasePath(absolute) { var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes); if (wildcardOffset < 0) { - return !hasExtension(absolute) + return !ts.hasExtension(absolute) ? absolute - : removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); + : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); } return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); } @@ -13359,14 +13795,9 @@ var ts; } ts.removeExtension = removeExtension; function changeExtension(path, newExtension) { - return changeAnyExtension(path, newExtension, extensionsToRemove, false); + return ts.changeAnyExtension(path, newExtension, extensionsToRemove, false); } ts.changeExtension = changeExtension; - function changeAnyExtension(path, ext, extensions, ignoreCase) { - var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); - return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; - } - ts.changeAnyExtension = changeAnyExtension; function tryParsePattern(pattern) { ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern)); var indexOfStar = pattern.indexOf("*"); @@ -13401,34 +13832,6 @@ var ts; return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); }); } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; - function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { - if (typeof extensions === "string") - extensions = [extensions]; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - if (!ts.startsWith(extension, ".")) - extension = "." + extension; - if (path.length >= extension.length && path.charAt(path.length - extension.length) === ".") { - var pathExtension = path.slice(path.length - extension.length); - if (stringEqualityComparer(pathExtension, extension)) { - return pathExtension; - } - } - } - return ""; - } - function getAnyExtensionFromPath(path, extensions, ignoreCase) { - if (extensions) { - return getAnyExtensionFromPathWorker(path, extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); - } - var baseFileName = getBaseFileName(path); - var extensionIndex = baseFileName.lastIndexOf("."); - if (extensionIndex >= 0) { - return baseFileName.substring(extensionIndex); - } - return ""; - } - ts.getAnyExtensionFromPath = getAnyExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } @@ -13551,8 +13954,10 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + function skipTypeChecking(sourceFile, options, host) { + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { @@ -13644,10 +14049,10 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 285) { + if (kind === 288) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73) { + else if (kind === 75) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -13682,19 +14087,19 @@ var ts; } ts.isJSDocLikeText = isJSDocLikeText; function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 148) { + if (!node || node.kind <= 151) { return; } switch (node.kind) { - case 149: + case 152: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151: + case 154: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277: + case 280: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13702,9 +14107,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278: + case 281: return visitNode(cbNode, node.expression); - case 152: + case 155: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -13712,7 +14117,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155: + case 158: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13720,51 +14125,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154: + case 157: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 276: + case 279: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 238: + case 241: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 187: + case 190: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); + case 169: + case 170: + case 164: + case 165: case 166: - case 167: - case 161: - case 162: - case 163: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 157: - case 156: - case 158: - case 159: case 160: - case 197: - case 240: - case 198: + case 159: + case 161: + case 162: + case 163: + case 200: + case 243: + case 201: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13776,345 +14181,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165: + case 168: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164: - return visitNode(cbNode, node.parameterName) || + case 167: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168: + case 171: return visitNode(cbNode, node.exprName); - case 169: + case 172: return visitNodes(cbNode, cbNodes, node.members); - case 170: + case 173: return visitNode(cbNode, node.elementType); - case 171: - return visitNodes(cbNode, cbNodes, node.elementTypes); case 174: - case 175: + return visitNodes(cbNode, cbNodes, node.elementTypes); + case 177: + case 178: return visitNodes(cbNode, cbNodes, node.types); - case 176: + case 179: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177: + case 180: return visitNode(cbNode, node.typeParameter); - case 184: + case 187: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178: - case 180: - return visitNode(cbNode, node.type); case 181: + case 183: + return visitNode(cbNode, node.type); + case 184: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182: + case 185: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183: - return visitNode(cbNode, node.literal); - case 185: case 186: - return visitNodes(cbNode, cbNodes, node.elements); + return visitNode(cbNode, node.literal); case 188: - return visitNodes(cbNode, cbNodes, node.elements); case 189: + return visitNodes(cbNode, cbNodes, node.elements); + case 191: + return visitNodes(cbNode, cbNodes, node.elements); + case 192: return visitNodes(cbNode, cbNodes, node.properties); - case 190: + case 193: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191: + case 194: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192: - case 193: + case 195: + case 196: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194: + case 197: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195: + case 198: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196: - return visitNode(cbNode, node.expression); case 199: return visitNode(cbNode, node.expression); - case 200: - return visitNode(cbNode, node.expression); - case 201: + case 202: return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: + return visitNode(cbNode, node.expression); + case 206: return visitNode(cbNode, node.operand); - case 208: + case 211: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202: + case 205: return visitNode(cbNode, node.expression); - case 204: + case 207: return visitNode(cbNode, node.operand); - case 205: + case 208: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213: + case 216: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214: + case 217: return visitNode(cbNode, node.expression); - case 215: + case 218: return visitNode(cbNode, node.name); - case 206: + case 209: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209: + case 212: return visitNode(cbNode, node.expression); - case 219: - case 246: + case 222: + case 249: return visitNodes(cbNode, cbNodes, node.statements); - case 285: + case 288: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220: + case 224: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239: + case 242: return visitNodes(cbNode, cbNodes, node.declarations); - case 222: + case 225: return visitNode(cbNode, node.expression); - case 223: + case 226: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224: + case 227: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225: + case 228: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226: + case 229: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227: + case 230: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228: + case 231: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229: - case 230: + case 232: + case 233: return visitNode(cbNode, node.label); - case 231: + case 234: return visitNode(cbNode, node.expression); - case 232: + case 235: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233: + case 236: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247: + case 250: return visitNodes(cbNode, cbNodes, node.clauses); - case 272: + case 275: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273: + case 276: return visitNodes(cbNode, cbNodes, node.statements); - case 234: + case 237: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235: + case 238: return visitNode(cbNode, node.expression); - case 236: + case 239: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275: + case 278: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153: + case 156: return visitNode(cbNode, node.expression); - case 241: - case 210: + case 244: + case 213: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 242: + case 245: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 243: + case 246: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 244: + case 247: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279: + case 282: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245: + case 248: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249: + case 252: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250: + case 253: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251: + case 254: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248: + case 251: return visitNode(cbNode, node.name); - case 252: + case 255: return visitNode(cbNode, node.name); - case 253: - case 257: - return visitNodes(cbNode, cbNodes, node.elements); case 256: + case 260: + return visitNodes(cbNode, cbNodes, node.elements); + case 259: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254: - case 258: + case 257: + case 261: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255: + case 258: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207: + case 210: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217: + case 220: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150: + case 153: return visitNode(cbNode, node.expression); - case 274: + case 277: return visitNodes(cbNode, cbNodes, node.types); - case 212: + case 215: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260: + case 263: return visitNode(cbNode, node.expression); - case 259: + case 262: return visitNodes(cbNode, cbNodes, node.decorators); - case 317: + case 320: return visitNodes(cbNode, cbNodes, node.elements); - case 261: + case 264: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265: + case 268: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262: - case 263: + case 265: + case 266: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269: + case 272: return visitNodes(cbNode, cbNodes, node.properties); - case 268: + case 271: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270: + case 273: return visitNode(cbNode, node.expression); - case 271: + case 274: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264: + case 267: return visitNode(cbNode, node.tagName); - case 172: - case 173: - case 289: - case 293: + case 175: + case 176: case 292: - case 294: case 296: - return visitNode(cbNode, node.type); case 295: + case 297: + case 299: + return visitNode(cbNode, node.type); + case 298: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 298: + case 301: return visitNodes(cbNode, cbNodes, node.tags); - case 307: - case 313: + case 310: + case 316: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 303: + case 306: return visitNode(cbNode, node.tagName); - case 302: + case 305: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 311: + case 314: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 312: + case 315: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 + node.typeExpression.kind === 292 ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 305: + case 308: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 308: - case 310: + case 311: + case 313: + case 312: case 309: - case 306: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 300: + case 303: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 299: + case 302: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 301: case 304: + case 307: return visitNode(cbNode, node.tagName); - case 316: + case 319: return visitNode(cbNode, node.expression); } } @@ -14151,7 +14561,7 @@ var ts; function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) { if (aggressiveChecks === void 0) { aggressiveChecks = false; } var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); - newSourceFile.flags |= (sourceFile.flags & 1572864); + newSourceFile.flags |= (sourceFile.flags & 3145728); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -14170,7 +14580,7 @@ var ts; var Parser; (function (Parser) { var scanner = ts.createScanner(99, true); - var disallowInAndDecoratorContext = 2048 | 8192; + var disallowInAndDecoratorContext = 4096 | 16384; var NodeConstructor; var TokenConstructor; var IdentifierConstructor; @@ -14228,18 +14638,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222); + var statement = createNode(225); switch (token()) { case 22: statement.expression = parseArrayLiteralExpression(); break; - case 103: - case 88: - case 97: + case 105: + case 90: + case 99: statement.expression = parseTokenNode(); break; - case 39: - if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 57; })) { + case 40: + if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -14248,7 +14658,7 @@ var ts; break; case 8: case 10: - if (lookAhead(function () { return nextToken() !== 57; })) { + if (lookAhead(function () { return nextToken() !== 58; })) { statement.expression = parseLiteralNode(); break; } @@ -14263,6 +14673,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -14287,10 +14700,10 @@ var ts; switch (scriptKind) { case 1: case 2: - contextFlags = 65536; + contextFlags = 131072; break; case 6: - contextFlags = 65536 | 16777216; + contextFlags = 131072 | 33554432; break; default: contextFlags = 0; @@ -14315,7 +14728,7 @@ var ts; function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304; + contextFlags |= 8388608; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -14369,7 +14782,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { - var sourceFile = new SourceFileConstructor(285, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(288, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14390,16 +14803,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048); + setContextFlag(val, 4096); } function setYieldContext(val) { - setContextFlag(val, 4096); + setContextFlag(val, 8192); } function setDecoratorContext(val) { - setContextFlag(val, 8192); + setContextFlag(val, 16384); } function setAwaitContext(val) { - setContextFlag(val, 16384); + setContextFlag(val, 32768); } function doOutsideOfContext(context, func) { var contextFlagsToClear = context & contextFlags; @@ -14422,40 +14835,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048, func); + return doOutsideOfContext(4096, func); } function disallowInAnd(func) { - return doInsideOfContext(2048, func); + return doInsideOfContext(4096, func); } function doInYieldContext(func) { - return doInsideOfContext(4096, func); + return doInsideOfContext(8192, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192, func); + return doInsideOfContext(16384, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384, func); + return doInsideOfContext(32768, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384, func); + return doOutsideOfContext(32768, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 | 16384, func); + return doInsideOfContext(8192 | 32768, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096); + return inContext(8192); } function inDisallowInContext() { - return inContext(2048); + return inContext(4096); } function inDecoratorContext() { - return inContext(8192); + return inContext(16384); } function inAwaitContext() { - return inContext(16384); + return inContext(32768); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -14538,16 +14951,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 73) { + if (token() === 75) { return true; } - if (token() === 118 && inYieldContext()) { + if (token() === 120 && inYieldContext()) { return false; } - if (token() === 123 && inAwaitContext()) { + if (token() === 126 && inAwaitContext()) { return false; } - return token() > 109; + return token() > 111; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -14631,7 +15044,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 ? new NodeConstructor(kind, p, p) : - kind === 73 ? new IdentifierConstructor(kind, p, p) : + kind === 75 ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -14655,7 +15068,7 @@ var ts; } if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768; + node.flags |= 65536; } return node; } @@ -14667,7 +15080,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73) { + if (kind === 75) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -14685,8 +15098,8 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73); - if (token() !== 73) { + var node = createNode(75); + if (token() !== 75) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -14694,7 +15107,12 @@ var ts; return finishNode(node); } var reportAtCurrentPosition = token() === 1; - return createMissingNode(73, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var isReservedWord = scanner.isReservedWord(); + var msgArg = scanner.getTokenText(); + var defaultMessage = isReservedWord ? + ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : + ts.Diagnostics.Identifier_expected; + return createMissingNode(75, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -14722,7 +15140,7 @@ var ts; return parsePropertyNameWorker(true); } function parseComputedPropertyName() { - var node = createNode(150); + var node = createNode(153); parseExpected(22); node.expression = allowInAnd(parseExpression); parseExpected(23); @@ -14740,19 +15158,19 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78: - return nextToken() === 85; - case 86: + case 80: + return nextToken() === 87; + case 88: nextToken(); - if (token() === 81) { + if (token() === 83) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 && token() !== 120 && token() !== 18 && canFollowModifier(); - case 81: + return token() !== 41 && token() !== 122 && token() !== 18 && canFollowModifier(); + case 83: return nextTokenCanFollowDefaultKeyword(); - case 117: - case 127: - case 138: + case 119: + case 130: + case 141: nextToken(); return canFollowModifier(); default: @@ -14765,16 +15183,16 @@ var ts; function canFollowModifier() { return token() === 22 || token() === 18 - || token() === 40 + || token() === 41 || token() === 25 || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 || token() === 91 || - token() === 111 || - (token() === 119 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 || token() === 93 || + token() === 113 || + (token() === 121 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -14787,7 +15205,7 @@ var ts; case 3: return !(token() === 26 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 75 || token() === 81; + return token() === 77 || token() === 83; case 4: return lookAhead(isTypeMemberStart); case 5: @@ -14797,7 +15215,7 @@ var ts; case 12: switch (token()) { case 22: - case 40: + case 41: case 25: case 24: return true; @@ -14854,7 +15272,7 @@ var ts; ts.Debug.assert(token() === 18); if (nextToken() === 19) { var next = nextToken(); - return next === 27 || next === 18 || next === 87 || next === 110; + return next === 27 || next === 18 || next === 89 || next === 112; } return true; } @@ -14871,8 +15289,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 || - token() === 87) { + if (token() === 112 || + token() === 89) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -14900,13 +15318,13 @@ var ts; case 23: return token() === 19; case 3: - return token() === 19 || token() === 75 || token() === 81; + return token() === 19 || token() === 77 || token() === 83; case 7: - return token() === 18 || token() === 87 || token() === 110; + return token() === 18 || token() === 89 || token() === 112; case 8: return isVariableDeclaratorListTerminator(); case 19: - return token() === 30 || token() === 20 || token() === 18 || token() === 87 || token() === 110; + return token() === 31 || token() === 20 || token() === 18 || token() === 89 || token() === 112; case 11: return token() === 21 || token() === 26; case 15: @@ -14922,9 +15340,9 @@ var ts; case 22: return token() === 18 || token() === 19; case 13: - return token() === 30 || token() === 42; + return token() === 31 || token() === 43; case 14: - return token() === 28 && lookAhead(nextTokenIsSlash); + return token() === 29 && lookAhead(nextTokenIsSlash); default: return false; } @@ -14936,7 +15354,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 37) { + if (token() === 38) { return true; } return false; @@ -14984,7 +15402,7 @@ var ts; if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) { return undefined; } - var nodeContextFlags = node.flags & 12679168; + var nodeContextFlags = node.flags & 25358336; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -15042,17 +15460,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158: + case 161: + case 166: + case 162: case 163: - case 159: - case 160: - case 155: - case 218: + case 158: + case 221: return true; - case 157: + case 160: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 73 && - methodDeclaration.name.originalKeywordKind === 125; + var nameIsConstructor = methodDeclaration.name.kind === 75 && + methodDeclaration.name.originalKeywordKind === 128; return !nameIsConstructor; } } @@ -15061,8 +15479,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272: - case 273: + case 275: + case 276: return true; } } @@ -15071,65 +15489,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240: - case 220: - case 219: - case 223: + case 243: + case 224: case 222: - case 235: - case 231: + case 226: + case 225: + case 238: + case 234: + case 236: case 233: + case 232: case 230: + case 231: case 229: - case 227: case 228: - case 226: - case 225: - case 232: - case 221: - case 236: - case 234: - case 224: + case 235: + case 223: + case 239: case 237: - case 250: - case 249: - case 256: - case 255: - case 245: - case 241: - case 242: + case 227: + case 240: + case 253: + case 252: + case 259: + case 258: + case 248: case 244: - case 243: + case 245: + case 247: + case 246: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279; + return node.kind === 282; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162: - case 156: - case 163: - case 154: - case 161: + case 165: + case 159: + case 166: + case 157: + case 164: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238) { + if (node.kind !== 241) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152) { + if (node.kind !== 155) { return false; } var parameter = node; @@ -15190,7 +15608,7 @@ var ts; if (isListTerminator(kind)) { break; } - parseExpected(27); + parseExpected(27, getExpectedCommaDiagnostic(kind)); if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) { nextToken(); } @@ -15213,6 +15631,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -15233,7 +15654,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24)) { - if (token() === 28) { + if (token() === 29) { entity.jsdocDotPos = dotPos; break; } @@ -15243,7 +15664,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149, entity.pos); + var node = createNode(152, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -15252,13 +15673,13 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(73, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207); + var template = createNode(210); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15, "Template head has wrong token kind"); var list = []; @@ -15270,7 +15691,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217); + var span = createNode(220); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19) { @@ -15323,23 +15744,23 @@ var ts; return node; } function parseTypeReference() { - var node = createNode(165); + var node = createNode(168); node.typeName = parseEntityName(true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28) { - node.typeArguments = parseBracketedList(20, parseType, 28, 30); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) { + node.typeArguments = parseBracketedList(20, parseType, 29, 31); } return finishNode(node); } function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165: + case 168: return ts.nodeIsMissing(node.typeName); - case 166: - case 167: { + case 169: + case 170: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178: + case 181: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -15347,20 +15768,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164, lhs.pos); + var node = createNode(167, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179); + var node = createNode(182); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290); + var result = createNode(293); if (postFixEquals) { - return createPostfixType(294, result); + return createPostfixType(297, result); } else { nextToken(); @@ -15368,7 +15789,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293); + var result = createNode(296); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -15379,43 +15800,43 @@ var ts; if (token() === 27 || token() === 19 || token() === 21 || - token() === 30 || - token() === 60 || - token() === 50) { - var result = createNode(291, pos); + token() === 31 || + token() === 62 || + token() === 51) { + var result = createNode(294, pos); return finishNode(result); } else { - var result = createNode(292, pos); + var result = createNode(295, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295); + var result = createNodeWithJSDoc(298); nextToken(); - fillSignature(57, 4 | 32, result); + fillSignature(58, 4 | 32, result); return finishNode(result); } - var node = createNode(165); + var node = createNode(168); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152); - if (token() === 101 || token() === 96) { + var parameter = createNode(155); + if (token() === 103 || token() === 98) { parameter.name = parseIdentifierName(); - parseExpected(57); + parseExpected(58); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var moduleSpecifier = parseOptionalToken(131); + var moduleSpecifier = parseOptionalToken(134); if (moduleSpecifier) { - var moduleTag = createNode(297, moduleSpecifier.pos); + var moduleTag = createNode(300, moduleSpecifier.pos); terminate: while (true) { switch (token()) { case 19: @@ -15434,25 +15855,25 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296, dotdotdot.pos); + var variadic = createNode(299, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60) { - return createPostfixType(294, type); + if (token() === 62) { + return createPostfixType(297, type); } return type; } function parseTypeQuery() { - var node = createNode(168); - parseExpected(105); + var node = createNode(171); + parseExpected(107); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151); + var node = createNode(154); node.name = parseIdentifier(); - if (parseOptional(87)) { + if (parseOptional(89)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -15460,18 +15881,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60)) { + if (parseOptional(62)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28) { - return parseBracketedList(19, parseTypeParameter, 28, 30); + if (token() === 29) { + return parseBracketedList(19, parseTypeParameter, 29, 31); } } function parseParameterType() { - if (parseOptional(57)) { + if (parseOptional(58)) { return parseType(); } return undefined; @@ -15480,12 +15901,12 @@ var ts; return token() === 25 || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 || + token() === 59 || isStartOfType(!isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152); - if (token() === 101) { + var node = createNodeWithJSDoc(155); + if (token() === 103) { node.name = createIdentifier(true); node.type = parseParameterType(); return finishNode(node); @@ -15497,7 +15918,7 @@ var ts; if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(56); + node.questionToken = parseOptionalToken(57); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -15515,15 +15936,15 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37) { + if (returnToken === 38) { parseExpected(returnToken); return true; } - else if (parseOptional(57)) { + else if (parseOptional(58)) { return true; } - else if (isType && token() === 37) { - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57)); + else if (isType && token() === 38) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58)); nextToken(); return true; } @@ -15553,10 +15974,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162) { - parseExpected(96); + if (kind === 165) { + parseExpected(98); } - fillSignature(57, 4, node); + fillSignature(58, 4, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -15580,17 +16001,17 @@ var ts; else { nextToken(); } - if (token() === 57 || token() === 27) { + if (token() === 58 || token() === 27) { return true; } - if (token() !== 56) { + if (token() !== 57) { return false; } nextToken(); - return token() === 57 || token() === 27 || token() === 23; + return token() === 58 || token() === 27 || token() === 23; } function parseIndexSignatureDeclaration(node) { - node.kind = 163; + node.kind = 166; node.parameters = parseBracketedList(16, parseParameter, 22, 23); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -15598,15 +16019,15 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56); - if (token() === 20 || token() === 28) { - node.kind = 156; - fillSignature(57, 4, node); + node.questionToken = parseOptionalToken(57); + if (token() === 20 || token() === 29) { + node.kind = 159; + fillSignature(58, 4, node); } else { - node.kind = 154; + node.kind = 157; node.type = parseTypeAnnotation(); - if (token() === 60) { + if (token() === 62) { node.initializer = parseInitializer(); } } @@ -15614,7 +16035,7 @@ var ts; return finishNode(node); } function isTypeMemberStart() { - if (token() === 20 || token() === 28) { + if (token() === 20 || token() === 29) { return true; } var idToken = false; @@ -15631,20 +16052,20 @@ var ts; } if (idToken) { return token() === 20 || - token() === 28 || - token() === 56 || + token() === 29 || token() === 57 || + token() === 58 || token() === 27 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 || token() === 28) { - return parseSignatureMember(161); + if (token() === 20 || token() === 29) { + return parseSignatureMember(164); } - if (token() === 96 && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162); + if (token() === 98 && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165); } var node = createNodeWithJSDoc(0); node.modifiers = parseModifiers(); @@ -15655,7 +16076,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 || token() === 28; + return token() === 20 || token() === 29; } function nextTokenIsDot() { return nextToken() === 24; @@ -15663,14 +16084,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20: - case 28: + case 29: case 24: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169); + var node = createNode(172); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -15687,37 +16108,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 || token() === 39) { - return nextToken() === 134; + if (token() === 39 || token() === 40) { + return nextToken() === 137; } - if (token() === 134) { + if (token() === 137) { nextToken(); } - return token() === 22 && nextTokenIsIdentifier() && nextToken() === 94; + return token() === 22 && nextTokenIsIdentifier() && nextToken() === 96; } function parseMappedTypeParameter() { - var node = createNode(151); + var node = createNode(154); node.name = parseIdentifier(); - parseExpected(94); + parseExpected(96); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182); + var node = createNode(185); parseExpected(18); - if (token() === 134 || token() === 38 || token() === 39) { + if (token() === 137 || token() === 39 || token() === 40) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134) { - parseExpectedToken(134); + if (node.readonlyToken.kind !== 137) { + parseExpectedToken(137); } } parseExpected(22); node.typeParameter = parseMappedTypeParameter(); parseExpected(23); - if (token() === 56 || token() === 38 || token() === 39) { + if (token() === 57 || token() === 39 || token() === 40) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56) { - parseExpectedToken(56); + if (node.questionToken.kind !== 57) { + parseExpectedToken(57); } } node.type = parseTypeAnnotation(); @@ -15728,23 +16149,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25)) { - var node = createNode(173, pos); + var node = createNode(176, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152) && type.kind === 292 && type.pos === type.type.pos) { - type.kind = 172; + if (!(contextFlags & 4194304) && type.kind === 295 && type.pos === type.type.pos) { + type.kind = 175; } return type; } function parseTupleType() { - var node = createNode(171); + var node = createNode(174); node.elementTypes = parseBracketedList(21, parseTupleElementType, 22, 23); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178); + var node = createNode(181); parseExpected(20); node.type = parseType(); parseExpected(21); @@ -15752,9 +16173,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96) ? 167 : 166; + var kind = parseOptional(98) ? 170 : 169; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37, 4, node); + fillSignature(38, 4, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -15762,14 +16183,14 @@ var ts; return token() === 24 ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183); + var node = createNode(186); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203); - unaryMinusExpression.operator = 39; + unaryMinusExpression = createNode(206); + unaryMinusExpression.operator = 40; nextToken(); } - var expression = token() === 103 || token() === 88 + var expression = token() === 105 || token() === 90 ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -15782,23 +16203,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93; + return token() === 95; } function parseImportType() { - sourceFile.flags |= 524288; - var node = createNode(184); - if (parseOptional(105)) { + sourceFile.flags |= 1048576; + var node = createNode(187); + if (parseOptional(107)) { node.isTypeOf = true; } - parseExpected(93); + parseExpected(95); parseExpected(20); node.argument = parseType(); parseExpected(21); if (parseOptional(24)) { node.qualifier = parseEntityName(true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28) { - node.typeArguments = parseBracketedList(20, parseType, 28, 30); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) { + node.typeArguments = parseBracketedList(20, parseType, 29, 31); } return finishNode(node); } @@ -15808,49 +16229,51 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121: - case 144: + case 124: + case 147: + case 142: case 139: + case 150: + case 143: + case 127: + case 145: case 136: - case 147: case 140: - case 124: - case 142: - case 133: - case 137: return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40: + case 41: return parseJSDocAllType(false); - case 63: + case 65: return parseJSDocAllType(true); - case 56: + case 60: + scanner.reScanQuestionToken(); + case 57: return parseJSDocUnknownOrNullableType(); - case 91: + case 93: return parseJSDocFunctionType(); - case 52: + case 53: return parseJSDocNonNullableType(); case 14: case 10: case 8: case 9: - case 103: - case 88: + case 105: + case 90: return parseLiteralTypeNode(); - case 39: + case 40: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference(); - case 107: - case 97: + case 109: + case 99: return parseTokenNode(); - case 101: { + case 103: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105: + case 107: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -15858,51 +16281,54 @@ var ts; return parseTupleType(); case 20: return parseParenthesizedType(); - case 93: + case 95: return parseImportType(); + case 123: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121: - case 144: - case 139: - case 136: - case 147: case 124: - case 134: - case 140: + case 147: + case 142: + case 139: + case 150: + case 127: + case 137: case 143: + case 146: + case 109: + case 145: + case 99: + case 103: case 107: - case 142: - case 97: - case 101: - case 105: - case 133: + case 136: case 18: case 22: - case 28: + case 29: + case 51: case 50: - case 49: - case 96: + case 98: case 10: case 8: case 9: - case 103: - case 88: - case 137: - case 40: - case 56: - case 52: + case 105: + case 90: + case 140: + case 41: + case 57: + case 53: case 25: - case 128: - case 93: + case 131: + case 95: + case 123: return true; - case 91: + case 93: return !inStartOfParameter; - case 39: + case 40: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20: return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); @@ -15918,26 +16344,26 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52: - type = createPostfixType(293, type); + case 53: + type = createPostfixType(296, type); break; - case 56: - if (!(contextFlags & 2097152) && lookAhead(nextTokenIsStartOfType)) { + case 57: + if (!(contextFlags & 4194304) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292, type); + type = createPostfixType(295, type); break; case 22: parseExpected(22); if (isStartOfType()) { - var node = createNode(181, type.pos); + var node = createNode(184, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23); type = finishNode(node); } else { - var node = createNode(170, type.pos); + var node = createNode(173, type.pos); node.elementType = type; parseExpected(23); type = finishNode(node); @@ -15956,16 +16382,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180); + var node = createNode(183); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177); - parseExpected(128); - var typeParameter = createNode(151); + var node = createNode(180); + parseExpected(131); + var typeParameter = createNode(154); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -15973,11 +16399,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130: - case 143: - case 134: + case 133: + case 146: + case 137: return parseTypeOperator(operator); - case 128: + case 131: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -15998,13 +16424,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175, parseTypeOperatorOrHigher, 49); + return parseUnionOrIntersectionType(178, parseTypeOperatorOrHigher, 50); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174, parseIntersectionTypeOrHigher, 50); + return parseUnionOrIntersectionType(177, parseIntersectionTypeOrHigher, 51); } function isStartOfFunctionType() { - if (token() === 28) { + if (token() === 29) { return true; } return token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -16013,7 +16439,7 @@ var ts; if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 101) { + if (isIdentifier() || token() === 103) { nextToken(); return true; } @@ -16030,13 +16456,13 @@ var ts; return true; } if (skipParameterStart()) { - if (token() === 57 || token() === 27 || - token() === 56 || token() === 60) { + if (token() === 58 || token() === 27 || + token() === 57 || token() === 62) { return true; } if (token() === 21) { nextToken(); - if (token() === 37) { + if (token() === 38) { return true; } } @@ -16047,7 +16473,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164, typePredicateVariable.pos); + var node = createNode(167, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -16058,41 +16485,48 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167); + node.assertsModifier = parseExpectedToken(123); + node.parameterName = token() === 103 ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132) ? parseType() : undefined; + return finishNode(node); + } function parseType() { - return doOutsideOfContext(20480, parseTypeWorker); + return doOutsideOfContext(40960, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96) { + if (isStartOfFunctionType() || token() === 98) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87)) { - var node = createNode(176, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89)) { + var node = createNode(179, type.pos); node.checkType = type; node.extendsType = parseTypeWorker(true); - parseExpected(56); - node.trueType = parseTypeWorker(); parseExpected(57); + node.trueType = parseTypeWorker(); + parseExpected(58); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57) ? parseType() : undefined; + return parseOptional(58) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { + case 103: case 101: case 99: - case 97: - case 103: - case 88: + case 105: + case 90: case 8: case 9: case 10: @@ -16101,14 +16535,14 @@ var ts; case 20: case 22: case 18: - case 91: - case 77: - case 96: - case 42: - case 65: - case 73: - return true; case 93: + case 79: + case 98: + case 43: + case 67: + case 75: + return true; + case 95: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -16119,18 +16553,18 @@ var ts; return true; } switch (token()) { - case 38: case 39: + case 40: + case 54: case 53: - case 52: - case 82: - case 105: + case 84: case 107: - case 44: + case 109: case 45: - case 28: - case 123: - case 118: + case 46: + case 29: + case 126: + case 120: return true; default: if (isBinaryOperator()) { @@ -16141,9 +16575,9 @@ var ts; } function isStartOfExpressionStatement() { return token() !== 18 && - token() !== 91 && - token() !== 77 && - token() !== 58 && + token() !== 93 && + token() !== 79 && + token() !== 59 && isStartOfExpression(); } function parseExpression() { @@ -16162,7 +16596,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { if (isYieldExpression()) { @@ -16173,7 +16607,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 73 && token() === 37) { + if (expr.kind === 75 && token() === 38) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -16182,7 +16616,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118) { + if (token() === 120) { if (inYieldContext()) { return true; } @@ -16195,11 +16629,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208); + var node = createNode(211); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 40 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40); + (token() === 41 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -16208,20 +16642,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198, asyncModifier.pos); + node = createNode(201, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198, identifier.pos); + node = createNode(201, identifier.pos); } - var parameter = createNode(152, identifier.pos); + var parameter = createNode(155, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37); + node.equalsGreaterThanToken = parseExpectedToken(38); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -16238,28 +16672,28 @@ var ts; } var isAsync = ts.hasModifier(arrowFunction, 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(37); - arrowFunction.body = (lastToken === 37 || lastToken === 18) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38); + arrowFunction.body = (lastToken === 38 || lastToken === 18) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); } function isParenthesizedArrowFunctionExpression() { - if (token() === 20 || token() === 28 || token() === 122) { + if (token() === 20 || token() === 29 || token() === 125) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37) { + if (token() === 38) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122) { + if (token() === 125) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 20 && token() !== 28) { + if (token() !== 20 && token() !== 29) { return 0; } } @@ -16269,8 +16703,8 @@ var ts; if (second === 21) { var third = nextToken(); switch (third) { - case 37: - case 57: + case 38: + case 58: case 18: return 1; default: @@ -16283,41 +16717,41 @@ var ts; if (second === 25) { return 1; } - if (ts.isModifierKind(second) && second !== 122 && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 && lookAhead(nextTokenIsIdentifier)) { return 1; } - if (!isIdentifier() && second !== 101) { + if (!isIdentifier() && second !== 103) { return 0; } switch (nextToken()) { - case 57: + case 58: return 1; - case 56: + case 57: nextToken(); - if (token() === 57 || token() === 27 || token() === 60 || token() === 21) { + if (token() === 58 || token() === 27 || token() === 62 || token() === 21) { return 1; } return 0; case 27: - case 60: + case 62: case 21: return 2; } return 0; } else { - ts.Debug.assert(first === 28); + ts.Debug.assert(first === 29); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87) { + if (third === 89) { var fourth = nextToken(); switch (fourth) { - case 60: - case 30: + case 62: + case 31: return false; default: return true; @@ -16348,7 +16782,7 @@ var ts; return result; } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 122) { + if (token() === 125) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(0); @@ -16358,27 +16792,27 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 122) { + if (token() === 125) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 37) { + if (scanner.hasPrecedingLineBreak() || token() === 38) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 && token() === 37) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 && token() === 38) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198); + var node = createNodeWithJSDoc(201); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256) ? 2 : 0; - if (!fillSignature(57, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58, isAsync, node) && !allowAmbiguity) { return undefined; } var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 && (hasJSDocFunctionType || token() !== 18)) { + if (!allowAmbiguity && token() !== 38 && (hasJSDocFunctionType || token() !== 18)) { return undefined; } return node; @@ -16388,8 +16822,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 : 0); } if (token() !== 26 && - token() !== 91 && - token() !== 77 && + token() !== 93 && + token() !== 79 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(16 | (isAsync ? 2 : 0)); @@ -16399,18 +16833,18 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(56); + var questionToken = parseOptionalToken(57); if (!questionToken) { return leftOperand; } - var node = createNode(206, leftOperand.pos); + var node = createNode(209, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57); + node.colonToken = parseExpectedToken(58); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73, false, ts.Diagnostics._0_expected, ts.tokenToString(57)); + : createMissingNode(75, false, ts.Diagnostics._0_expected, ts.tokenToString(58)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -16418,22 +16852,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 || t === 148; + return t === 96 || t === 151; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = ts.getBinaryOperatorPrecedence(token()); - var consumeCurrentOperator = token() === 41 ? + var consumeCurrentOperator = token() === 42 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 && inDisallowInContext()) { + if (token() === 96 && inDisallowInContext()) { break; } - if (token() === 120) { + if (token() === 122) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -16449,51 +16883,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94) { + if (inDisallowInContext() && token() === 96) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205, left.pos); + var node = createNode(208, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213, left.pos); + var node = createNode(216, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203); + var node = createNode(206); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199); + var node = createNode(202); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200); + var node = createNode(203); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201); + var node = createNode(204); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123) { + if (token() === 126) { if (inAwaitContext()) { return true; } @@ -16502,7 +16936,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202); + var node = createNode(205); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16510,16 +16944,16 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 ? + return token() === 42 ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41) { + if (token() === 42) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195) { + if (simpleUnaryExpression.kind === 198) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -16530,20 +16964,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 38: case 39: + case 40: + case 54: case 53: - case 52: return parsePrefixUnaryExpression(); - case 82: + case 84: return parseDeleteExpression(); - case 105: - return parseTypeOfExpression(); case 107: + return parseTypeOfExpression(); + case 109: return parseVoidExpression(); - case 28: + case 29: return parseTypeAssertion(); - case 123: + case 126: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -16553,16 +16987,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 38: case 39: + case 40: + case 54: case 53: - case 52: - case 82: - case 105: + case 84: case 107: - case 123: + case 109: + case 126: return false; - case 28: + case 29: if (sourceFile.languageVariant !== 1) { return false; } @@ -16571,20 +17005,20 @@ var ts; } } function parseUpdateExpression() { - if (token() === 44 || token() === 45) { - var node = createNode(203); + if (token() === 45 || token() === 46) { + var node = createNode(206); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 28 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 && token() === 29 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { return parseJsxElementOrSelfClosingElementOrFragment(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 || token() === 45) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204, expression.pos); + if ((token() === 45 || token() === 46) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -16594,37 +17028,37 @@ var ts; } function parseLeftHandSideExpressionOrHigher() { var expression; - if (token() === 93) { + if (token() === 95) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { - sourceFile.flags |= 524288; + sourceFile.flags |= 1048576; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { var fullStart = scanner.getStartPos(); nextToken(); nextToken(); - var node = createNode(215, fullStart); - node.keywordToken = 93; + var node = createNode(218, fullStart); + node.keywordToken = 95; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576; + sourceFile.flags |= 2097152; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 ? parseSuperExpression() : parseMemberExpressionOrHigher(); } return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28) { + if (token() === 29) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -16634,7 +17068,7 @@ var ts; if (token() === 20 || token() === 24 || token() === 22) { return expression; } - var node = createNode(190, expression.pos); + var node = createNode(193, expression.pos); node.expression = expression; parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); @@ -16643,8 +17077,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263) { - var node = createNode(261, opening.pos); + if (opening.kind === 266) { + var node = createNode(264, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16653,22 +17087,22 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266) { - var node = createNode(265, opening.pos); + else if (opening.kind === 269) { + var node = createNode(268, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262); + ts.Debug.assert(opening.kind === 265); result = opening; } - if (inExpressionContext && token() === 28) { + if (inExpressionContext && token() === 29) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205, result.pos); + var badNode = createNode(208, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -16696,7 +17130,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29: + case 30: case 7: return undefined; case 11: @@ -16704,7 +17138,7 @@ var ts; return parseJsxText(); case 18: return parseJsxExpression(false); - case 28: + case 29: return parseJsxElementOrSelfClosingElementOrFragment(false); default: return ts.Debug.assertNever(token); @@ -16725,15 +17159,15 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269); + var jsxAttributes = createNode(272); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28); - if (token() === 30) { - var node_1 = createNode(266, fullStart); + parseExpected(29); + if (token() === 31) { + var node_1 = createNode(269, fullStart); scanJsxText(); return finishNode(node_1); } @@ -16741,20 +17175,20 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30) { - node = createNode(263, fullStart); + if (token() === 31) { + node = createNode(266, fullStart); scanJsxText(); } else { - parseExpected(42); + parseExpected(43); if (inExpressionContext) { - parseExpected(30); + parseExpected(31); } else { - parseExpected(30, undefined, false); + parseExpected(31, undefined, false); scanJsxText(); } - node = createNode(262, fullStart); + node = createNode(265, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -16763,10 +17197,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 101 ? + var expression = token() === 103 ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24)) { - var propertyAccess = createNode(190, expression.pos); + var propertyAccess = createNode(193, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -16774,7 +17208,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271); + var node = createNode(274); if (!parseExpected(18)) { return undefined; } @@ -16797,9 +17231,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268); + var node = createNode(271); node.name = parseIdentifierName(); - if (token() === 60) { + if (token() === 62) { switch (scanJsxAttributeValue()) { case 10: node.initializer = parseLiteralNode(); @@ -16812,7 +17246,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270); + var node = createNode(273); parseExpected(18); parseExpected(25); node.expression = parseExpression(); @@ -16820,77 +17254,109 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264); - parseExpected(29); + var node = createNode(267); + parseExpected(30); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30); + parseExpected(31); } else { - parseExpected(30, undefined, false); + parseExpected(31, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267); - parseExpected(29); + var node = createNode(270); + parseExpected(30); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30); + parseExpected(31); } else { - parseExpected(30, undefined, false); + parseExpected(31, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195); - parseExpected(28); + var node = createNode(198); + parseExpected(29); node.type = parseType(); - parseExpected(30); + parseExpected(31); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(true); + if (questionDotToken || expression.flags & 32) { + propertyAccess.flags |= 32; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23) { + indexedAccess.argumentExpression = createMissingNode(75, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23); + if (questionDotToken || expression.flags & 32) { + indexedAccess.flags |= 32; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24); - if (dotToken) { - var propertyAccess = createNode(190, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214, expression.pos); + var nonNullExpression = createNode(217, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(22)) { - var indexedAccess = createNode(191, expression.pos); - indexedAccess.expression = expression; - if (token() === 23) { - indexedAccess.argumentExpression = createMissingNode(73, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, undefined); continue; } return expression; @@ -16899,43 +17365,64 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 || token() === 15; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32) { + tagExpression.flags |= 32; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); - if (token() === 28 || token() === 46) { + expression = parseMemberExpressionRest(expression, true); + var questionDotToken = parseOptionalToken(28); + if (token() === 29 || token() === 47) { var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32) { + callExpr.flags |= 32; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20) { - var callExpr = createNode(192, expression.pos); + var callExpr = createNode(195, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32) { + callExpr.flags |= 32; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + var propertyAccess = createNode(193, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75, false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20); @@ -16944,12 +17431,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28) { + if (reScanLessThanToken() !== 29) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20, parseType); - if (!parseExpected(30)) { + if (!parseExpected(31)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -16964,18 +17451,19 @@ var ts; case 24: case 21: case 23: - case 57: + case 58: case 26: - case 56: - case 33: - case 35: + case 57: case 34: case 36: - case 54: + case 35: + case 37: case 55: - case 51: - case 49: + case 56: + case 60: + case 52: case 50: + case 51: case 19: case 1: return true; @@ -16992,11 +17480,11 @@ var ts; case 10: case 14: return parseLiteralNode(); + case 103: case 101: case 99: - case 97: - case 103: - case 88: + case 105: + case 90: return parseTokenNode(); case 20: return parseParenthesizedExpression(); @@ -17004,19 +17492,19 @@ var ts; return parseArrayLiteralExpression(); case 18: return parseObjectLiteralExpression(); - case 122: + case 125: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 77: + case 79: return parseClassExpression(); - case 91: + case 93: return parseFunctionExpression(); - case 96: + case 98: return parseNewExpressionOrNewDotTarget(); - case 42: - case 65: + case 43: + case 67: if (reScanSlashToken() === 13) { return parseLiteralNode(); } @@ -17027,28 +17515,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196); + var node = createNodeWithJSDoc(199); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209); + var node = createNode(212); parseExpected(25); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 ? parseSpreadElement() : - token() === 27 ? createNode(211) : + token() === 27 ? createNode(214) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188); + var node = createNode(191); parseExpected(22); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17060,44 +17548,44 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0); if (parseOptionalToken(25)) { - node.kind = 278; + node.kind = 281; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127)) { - return parseAccessorDeclaration(node, 159); + if (parseContextualModifier(130)) { + return parseAccessorDeclaration(node, 162); } - if (parseContextualModifier(138)) { - return parseAccessorDeclaration(node, 160); + if (parseContextualModifier(141)) { + return parseAccessorDeclaration(node, 163); } - var asteriskToken = parseOptionalToken(40); + var asteriskToken = parseOptionalToken(41); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56); - node.exclamationToken = parseOptionalToken(52); - if (asteriskToken || token() === 20 || token() === 28) { + node.questionToken = parseOptionalToken(57); + node.exclamationToken = parseOptionalToken(53); + if (asteriskToken || token() === 20 || token() === 29) { return parseMethodDeclaration(node, asteriskToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58); if (isShorthandPropertyAssignment) { - node.kind = 277; - var equalsToken = parseOptionalToken(60); + node.kind = 280; + var equalsToken = parseOptionalToken(62); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276; - parseExpected(57); + node.kind = 279; + parseExpected(58); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189); + var node = createNode(192); parseExpected(18); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17111,10 +17599,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNodeWithJSDoc(197); + var node = createNodeWithJSDoc(200); node.modifiers = parseModifiers(); - parseExpected(91); - node.asteriskToken = parseOptionalToken(40); + parseExpected(93); + node.asteriskToken = parseOptionalToken(41); var isGenerator = node.asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; node.name = @@ -17122,7 +17610,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57, isGenerator | isAsync, node); + fillSignature(58, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(true); @@ -17134,26 +17622,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96); + parseExpected(98); if (parseOptional(24)) { - var node_2 = createNode(215, fullStart); - node_2.keywordToken = 96; + var node_2 = createNode(218, fullStart); + node_2.keywordToken = 98; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193, fullStart); + var node = createNode(196, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20) { @@ -17162,7 +17650,7 @@ var ts; return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219); + var node = createNode(222); if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -17193,25 +17681,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221); + var node = createNode(223); parseExpected(26); return finishNode(node); } function parseIfStatement() { - var node = createNode(223); - parseExpected(92); + var node = createNode(226); + parseExpected(94); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224); - parseExpected(83); + var node = createNode(227); + parseExpected(85); node.statement = parseStatement(); - parseExpected(108); + parseExpected(110); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -17219,8 +17707,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225); - parseExpected(108); + var node = createNode(228); + parseExpected(110); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); @@ -17229,12 +17717,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90); - var awaitToken = parseOptionalToken(123); + parseExpected(92); + var awaitToken = parseOptionalToken(126); parseExpected(20); var initializer; if (token() !== 26) { - if (token() === 106 || token() === 112 || token() === 78) { + if (token() === 108 || token() === 114 || token() === 80) { initializer = parseVariableDeclarationList(true); } else { @@ -17242,23 +17730,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148) : parseOptional(148)) { - var forOfStatement = createNode(228, pos); + if (awaitToken ? parseExpected(151) : parseOptional(151)) { + var forOfStatement = createNode(231, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94)) { - var forInStatement = createNode(227, pos); + else if (parseOptional(96)) { + var forInStatement = createNode(230, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226, pos); + var forStatement = createNode(229, pos); forStatement.initializer = initializer; parseExpected(26); if (token() !== 26 && token() !== 21) { @@ -17276,7 +17764,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 ? 74 : 79); + parseExpected(kind === 233 ? 76 : 81); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17284,8 +17772,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231); - parseExpected(98); + var node = createNode(234); + parseExpected(100); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -17293,39 +17781,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232); - parseExpected(109); + var node = createNode(235); + parseExpected(111); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); - node.statement = doInsideOfContext(8388608, parseStatement); + node.statement = doInsideOfContext(16777216, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272); - parseExpected(75); + var node = createNode(275); + parseExpected(77); node.expression = allowInAnd(parseExpression); - parseExpected(57); + parseExpected(58); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273); - parseExpected(81); - parseExpected(57); + var node = createNode(276); + parseExpected(83); + parseExpected(58); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 ? parseCaseClause() : parseDefaultClause(); + return token() === 77 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233); - parseExpected(100); + var node = createNode(236); + parseExpected(102); parseExpected(20); node.expression = allowInAnd(parseExpression); parseExpected(21); - var caseBlock = createNode(247); + var caseBlock = createNode(250); parseExpected(18); caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); parseExpected(19); @@ -17333,26 +17821,26 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(235); - parseExpected(102); + var node = createNode(238); + parseExpected(104); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(236); - parseExpected(104); + var node = createNode(239); + parseExpected(106); node.tryBlock = parseBlock(false); - node.catchClause = token() === 76 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 89) { - parseExpected(89); + node.catchClause = token() === 78 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 91) { + parseExpected(91); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275); - parseExpected(76); + var result = createNode(278); + parseExpected(78); if (parseOptional(20)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21); @@ -17364,21 +17852,21 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237); - parseExpected(80); + var node = createNode(240); + parseExpected(82); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var node = createNodeWithJSDoc(0); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 && parseOptional(57)) { - node.kind = 234; + if (expression.kind === 75 && parseOptional(58)) { + node.kind = 237; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222; + node.kind = 225; node.expression = expression; parseSemicolon(); } @@ -17390,11 +17878,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 && !scanner.hasPrecedingLineBreak(); + return token() === 79 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 && !scanner.hasPrecedingLineBreak(); + return token() === 93 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -17403,47 +17891,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106: - case 112: - case 78: - case 91: - case 77: - case 85: + case 108: + case 114: + case 80: + case 93: + case 79: + case 87: return true; - case 111: - case 141: + case 113: + case 144: return nextTokenIsIdentifierOnSameLine(); - case 131: - case 132: + case 134: + case 135: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119: - case 122: - case 126: - case 114: - case 115: + case 121: + case 125: + case 129: case 116: - case 134: + case 117: + case 118: + case 137: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146: + case 149: nextToken(); - return token() === 18 || token() === 73 || token() === 86; - case 93: + return token() === 18 || token() === 75 || token() === 88; + case 95: nextToken(); - return token() === 10 || token() === 40 || + return token() === 10 || token() === 41 || token() === 18 || ts.tokenIsIdentifierOrKeyword(token()); - case 86: + case 88: nextToken(); - if (token() === 60 || token() === 40 || - token() === 18 || token() === 81 || - token() === 120) { + if (token() === 62 || token() === 41 || + token() === 18 || token() === 83 || + token() === 122) { return true; } continue; - case 117: + case 119: nextToken(); continue; default: @@ -17456,47 +17944,47 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58: + case 59: case 26: case 18: - case 106: - case 112: - case 91: - case 77: - case 85: - case 92: - case 83: case 108: - case 90: + case 114: + case 93: case 79: - case 74: - case 98: - case 109: + case 87: + case 94: + case 85: + case 110: + case 92: + case 81: + case 76: case 100: + case 111: case 102: case 104: - case 80: - case 76: - case 89: + case 106: + case 82: + case 78: + case 91: return true; - case 93: + case 95: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78: - case 86: + case 80: + case 88: return isStartOfDeclaration(); - case 122: - case 126: - case 111: - case 131: - case 132: - case 141: - case 146: + case 125: + case 129: + case 113: + case 134: + case 135: + case 144: + case 149: return true; + case 118: case 116: - case 114: - case 115: case 117: - case 134: + case 119: + case 137: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -17515,62 +18003,62 @@ var ts; return parseEmptyStatement(); case 18: return parseBlock(false); - case 106: - return parseVariableStatement(createNodeWithJSDoc(238)); - case 112: + case 108: + return parseVariableStatement(createNodeWithJSDoc(241)); + case 114: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238)); + return parseVariableStatement(createNodeWithJSDoc(241)); } break; - case 91: - return parseFunctionDeclaration(createNodeWithJSDoc(240)); - case 77: - return parseClassDeclaration(createNodeWithJSDoc(241)); - case 92: + case 93: + return parseFunctionDeclaration(createNodeWithJSDoc(243)); + case 79: + return parseClassDeclaration(createNodeWithJSDoc(244)); + case 94: return parseIfStatement(); - case 83: + case 85: return parseDoStatement(); - case 108: + case 110: return parseWhileStatement(); - case 90: + case 92: return parseForOrForInOrForOfStatement(); - case 79: - return parseBreakOrContinueStatement(229); - case 74: - return parseBreakOrContinueStatement(230); - case 98: + case 81: + return parseBreakOrContinueStatement(232); + case 76: + return parseBreakOrContinueStatement(233); + case 100: return parseReturnStatement(); - case 109: + case 111: return parseWithStatement(); - case 100: - return parseSwitchStatement(); case 102: - return parseThrowStatement(); + return parseSwitchStatement(); case 104: - case 76: - case 89: + return parseThrowStatement(); + case 106: + case 78: + case 91: return parseTryStatement(); - case 80: + case 82: return parseDebuggerStatement(); - case 58: + case 59: return parseDeclaration(); - case 122: - case 111: - case 141: - case 131: - case 132: - case 126: - case 78: - case 85: - case 86: - case 93: - case 114: - case 115: + case 125: + case 113: + case 144: + case 134: + case 135: + case 129: + case 80: + case 87: + case 88: + case 95: case 116: - case 119: case 117: - case 134: - case 146: + case 118: + case 121: + case 119: + case 137: + case 149: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -17579,59 +18067,75 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126; + return modifier.kind === 129; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304; + m.flags |= 8388608; } - return doInsideOfContext(4194304, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106: - case 112: - case 78: + case 108: + case 114: + case 80: return parseVariableStatement(node); - case 91: + case 93: return parseFunctionDeclaration(node); - case 77: + case 79: return parseClassDeclaration(node); - case 111: + case 113: return parseInterfaceDeclaration(node); - case 141: + case 144: return parseTypeAliasDeclaration(node); - case 85: + case 87: return parseEnumDeclaration(node); - case 146: - case 131: - case 132: + case 149: + case 134: + case 135: return parseModuleDeclaration(node); - case 93: + case 95: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86: + case 88: nextToken(); switch (token()) { - case 81: - case 60: + case 83: + case 62: return parseExportAssignment(node); - case 120: + case 122: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); } default: if (node.decorators || node.modifiers) { - var missing = createMissingNode(259, true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262, true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -17653,24 +18157,24 @@ var ts; } function parseArrayBindingElement() { if (token() === 27) { - return createNode(211); + return createNode(214); } - var node = createNode(187); + var node = createNode(190); node.dotDotDotToken = parseOptionalToken(25); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187); + var node = createNode(190); node.dotDotDotToken = parseOptionalToken(25); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57) { + if (tokenIsIdentifier && token() !== 58) { node.name = propertyName; } else { - parseExpected(57); + parseExpected(58); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -17678,14 +18182,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185); + var node = createNode(188); parseExpected(18); node.elements = parseDelimitedList(9, parseObjectBindingElement); parseExpected(19); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186); + var node = createNode(189); parseExpected(22); node.elements = parseDelimitedList(10, parseArrayBindingElement); parseExpected(23); @@ -17707,10 +18211,10 @@ var ts; return parseVariableDeclaration(true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238); + var node = createNode(241); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 && - token() === 52 && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 && + token() === 53 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -17720,21 +18224,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239); + var node = createNode(242); switch (token()) { - case 106: + case 108: break; - case 112: + case 114: node.flags |= 1; break; - case 78: + case 80: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 148 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17749,25 +18253,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21; } function parseVariableStatement(node) { - node.kind = 220; + node.kind = 224; node.declarationList = parseVariableDeclarationList(false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240; - parseExpected(91); - node.asteriskToken = parseOptionalToken(40); + node.kind = 243; + parseExpected(93); + node.asteriskToken = parseOptionalToken(41); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; - fillSignature(57, isGenerator | isAsync, node); + fillSignature(58, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125) { - return parseExpected(125); + if (token() === 128) { + return parseExpected(128); } if (token() === 10 && lookAhead(nextToken) === 20) { return tryParse(function () { @@ -17779,39 +18283,39 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158; - fillSignature(57, 0, node); + node.kind = 161; + fillSignature(58, 0, node); node.body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157; + node.kind = 160; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 : 0; var isAsync = ts.hasModifier(node, 256) ? 2 : 0; - fillSignature(57, isGenerator | isAsync, node); + fillSignature(58, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155; - if (!node.questionToken && token() === 52 && !scanner.hasPrecedingLineBreak()) { + node.kind = 158; + if (!node.questionToken && token() === 53 && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); node.initializer = ts.hasModifier(node, 32) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 | 2048, parseInitializer); + : doOutsideOfContext(8192 | 4096, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40); + var asteriskToken = parseOptionalToken(41); node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56); - if (asteriskToken || token() === 20 || token() === 28) { + node.questionToken = parseOptionalToken(57); + if (asteriskToken || token() === 20 || token() === 29) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -17819,13 +18323,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57, 0, node); + fillSignature(58, 0, node); node.body = parseFunctionBlockOrSemicolon(0); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58) { + if (token() === 59) { return true; } while (ts.isModifierKind(token())) { @@ -17835,7 +18339,7 @@ var ts; } nextToken(); } - if (token() === 40) { + if (token() === 41) { return true; } if (isLiteralPropertyName()) { @@ -17846,16 +18350,16 @@ var ts; return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 138 || idToken === 127) { + if (!ts.isKeyword(idToken) || idToken === 141 || idToken === 130) { return true; } switch (token()) { case 20: - case 28: - case 52: + case 29: + case 53: + case 58: + case 62: case 57: - case 60: - case 56: return true; default: return canParseSemicolon(); @@ -17868,10 +18372,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58)) { + if (!parseOptional(59)) { break; } - var decorator = createNode(153, decoratorStart); + var decorator = createNode(156, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -17884,7 +18388,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 && permitInvalidConstAsModifier) { + if (token() === 80 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -17901,7 +18405,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122) { + if (token() === 125) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -17912,20 +18416,20 @@ var ts; } function parseClassElement() { if (token() === 26) { - var result = createNode(218); + var result = createNode(221); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0); node.decorators = parseDecorators(); node.modifiers = parseModifiers(true); - if (parseContextualModifier(127)) { - return parseAccessorDeclaration(node, 159); + if (parseContextualModifier(130)) { + return parseAccessorDeclaration(node, 162); } - if (parseContextualModifier(138)) { - return parseAccessorDeclaration(node, 160); + if (parseContextualModifier(141)) { + return parseAccessorDeclaration(node, 163); } - if (token() === 125 || token() === 10) { + if (token() === 128 || token() === 10) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -17937,25 +18441,35 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 || token() === 8 || - token() === 40 || + token() === 41 || token() === 22) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608; + } + return doInsideOfContext(8388608, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { - node.name = createMissingNode(73, true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 210); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0), 213); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241); + return parseClassDeclarationOrExpression(node, 244); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77); + parseExpected(79); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -17974,7 +18488,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { if (isHeritageClause()) { @@ -17984,33 +18498,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 || tok === 110); - var node = createNode(274); + ts.Debug.assert(tok === 89 || tok === 112); + var node = createNode(277); node.token = tok; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212); + var node = createNode(215); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 - ? parseBracketedList(20, parseType, 28, 30) - : undefined; + return token() === 29 ? + parseBracketedList(20, parseType, 29, 31) : undefined; } function isHeritageClause() { - return token() === 87 || token() === 110; + return token() === 89 || token() === 112; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242; - parseExpected(111); + node.kind = 245; + parseExpected(113); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -18018,24 +18531,24 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243; - parseExpected(141); + node.kind = 246; + parseExpected(144); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60); + parseExpected(62); node.type = parseType(); parseSemicolon(); return finishNode(node); } function parseEnumMember() { - var node = createNodeWithJSDoc(279); + var node = createNodeWithJSDoc(282); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244; - parseExpected(85); + node.kind = 247; + parseExpected(87); node.name = parseIdentifier(); if (parseExpected(18)) { node.members = parseDelimitedList(6, parseEnumMember); @@ -18047,7 +18560,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246); + var node = createNode(249); if (parseExpected(18)) { node.statements = parseList(1, parseStatement); parseExpected(19); @@ -18058,7 +18571,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245; + node.kind = 248; var namespaceFlag = flags & 16; node.flags |= flags; node.name = parseIdentifier(); @@ -18068,10 +18581,10 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245; - if (token() === 146) { + node.kind = 248; + if (token() === 149) { node.name = parseIdentifier(); - node.flags |= 512; + node.flags |= 1024; } else { node.name = parseLiteralNode(); @@ -18087,14 +18600,14 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146) { + if (token() === 149) { return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132)) { + else if (parseOptional(135)) { flags |= 16; } else { - parseExpected(131); + parseExpected(134); if (token() === 10) { return parseAmbientExternalModuleDeclaration(node); } @@ -18102,60 +18615,60 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 && + return token() === 138 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20; } function nextTokenIsSlash() { - return nextToken() === 42; + return nextToken() === 43; } function parseNamespaceExportDeclaration(node) { - node.kind = 248; - parseExpected(120); - parseExpected(132); + node.kind = 251; + parseExpected(122); + parseExpected(135); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93); + parseExpected(95); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 && token() !== 145) { + if (token() !== 27 && token() !== 148) { return parseImportEqualsDeclaration(node, identifier); } } - node.kind = 250; + node.kind = 253; if (identifier || - token() === 40 || + token() === 41 || token() === 18) { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145); + parseExpected(148); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249; + node.kind = 252; node.name = identifier; - parseExpected(60); + parseExpected(62); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); } function parseImportClause(identifier, fullStart) { - var importClause = createNode(251, fullStart); + var importClause = createNode(254, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || parseOptional(27)) { - importClause.namedBindings = token() === 40 ? parseNamespaceImport() : parseNamedImportsOrExports(253); + importClause.namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(256); } return finishNode(importClause); } @@ -18165,8 +18678,8 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(260); - parseExpected(135); + var node = createNode(263); + parseExpected(138); parseExpected(20); node.expression = parseModuleSpecifier(); parseExpected(21); @@ -18183,22 +18696,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(252); - parseExpected(40); - parseExpected(120); + var namespaceImport = createNode(255); + parseExpected(41); + parseExpected(122); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(23, kind === 253 ? parseImportSpecifier : parseExportSpecifier, 18, 19); + node.elements = parseBracketedList(23, kind === 256 ? parseImportSpecifier : parseExportSpecifier, 18, 19); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258); + return parseImportOrExportSpecifier(261); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254); + return parseImportOrExportSpecifier(257); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18206,9 +18719,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120) { + if (token() === 122) { node.propertyName = identifierName; - parseExpected(120); + parseExpected(122); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -18217,21 +18730,21 @@ var ts; else { node.name = identifierName; } - if (kind === 254 && checkIdentifierIsKeyword) { + if (kind === 257 && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256; - if (parseOptional(40)) { - parseExpected(145); + node.kind = 259; + if (parseOptional(41)) { + parseExpected(148); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257); - if (token() === 145 || (token() === 10 && !scanner.hasPrecedingLineBreak())) { - parseExpected(145); + node.exportClause = parseNamedImportsOrExports(260); + if (token() === 148 || (token() === 10 && !scanner.hasPrecedingLineBreak())) { + parseExpected(148); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -18239,12 +18752,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255; - if (parseOptional(60)) { + node.kind = 258; + if (parseOptional(62)) { node.isExportEquals = true; } else { - parseExpected(81); + parseExpected(83); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -18257,15 +18770,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1) - || node.kind === 249 && node.moduleReference.kind === 260 - || node.kind === 250 - || node.kind === 255 - || node.kind === 256 - ? node - : undefined; + || node.kind === 252 && node.moduleReference.kind === 263 + || node.kind === 253 + || node.kind === 258 + || node.kind === 259 ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 ? + return sourceFile.flags & 2097152 ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -18273,7 +18784,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 && node.name.escapedText === "meta"; } var JSDocParser; (function (JSDocParser) { @@ -18289,9 +18800,9 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289); + var result = createNode(292); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18); - result.type = doInsideOfContext(2097152, parseJSDocType); + result.type = doInsideOfContext(4194304, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19); } @@ -18302,7 +18813,7 @@ var ts; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99, undefined, 1); sourceFile = { languageVariant: 0, text: content }; - var jsDoc = doInsideOfContext(2097152, function () { return parseJSDocCommentWorker(start, length); }); + var jsDoc = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -18313,11 +18824,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(2097152, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536) { + if (contextFlags & 131072) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -18364,7 +18875,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58: + case 59: if (state === 0 || state === 1) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -18380,7 +18891,7 @@ var ts; state = 0; indent = 0; break; - case 40: + case 41: var asterisk = scanner.getTokenText(); if (state === 1 || state === 2) { state = 2; @@ -18425,7 +18936,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(298, start); + var result = createNode(301, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -18460,14 +18971,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40) || token() === 5 || token() === 4) { + while ((precedingLineBreak && token() === 41) || token() === 5 || token() === 4) { indentText += scanner.getTokenText(); if (token() === 4) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40) { + else if (token() === 41) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -18475,7 +18986,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58); + ts.Debug.assert(token() === 59); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(undefined); @@ -18556,7 +19067,7 @@ var ts; } indent = 0; break; - case 58: + case 59: if (state === 3) { comments.push(scanner.getTokenText()); break; @@ -18578,7 +19089,7 @@ var ts; break; case 18: state = 2; - if (lookAhead(function () { return nextTokenJSDoc() === 58 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -18586,7 +19097,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59: + case 61: if (state === 3) { state = 2; } @@ -18595,7 +19106,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40: + case 41: if (state === 0) { state = 1; indent += 1; @@ -18615,7 +19126,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(301, start); + var result = createNode(304, start); result.tagName = tagName; return finishNode(result); } @@ -18641,14 +19152,14 @@ var ts; if (isBracketed) { skipWhitespace(); } - var isBackquoted = parseOptionalJsdoc(59); + var isBackquoted = parseOptionalJsdoc(61); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59); + parseExpectedTokenJSDoc(61); } if (isBracketed) { skipWhitespace(); - if (parseOptionalToken(60)) { + if (parseOptionalToken(62)) { parseExpression(); } parseExpected(23); @@ -18657,9 +19168,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137: + case 140: return true; - case 170: + case 173: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -18675,8 +19186,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 ? - createNode(313, start) : - createNode(307, start); + createNode(316, start) : + createNode(310, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -18693,20 +19204,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 307 || child.kind === 313) { + if (child.kind === 310 || child.kind === 316) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(299, start_3); + jsdocTypeLiteral = createNode(302, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170) { + if (typeExpression.type.kind === 173) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -18718,7 +19229,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(308, start); + var result = createNode(311, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -18727,13 +19238,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(310, start); + var result = createNode(313, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(303, start); + var result = createNode(306, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -18755,20 +19266,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73: + case 75: case 5: case 24: - case 58: + case 59: comments.push(scanner.getTokenText()); break; - case 28: + case 29: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30: + case 31: if (!seenLessThan || seenGreaterThan) { return; } @@ -18787,14 +19298,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(302, start); + var result = createNode(305, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18); - var node = createNode(212); + var node = createNode(215); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -18806,7 +19317,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24)) { - var prop = createNode(190, node.pos); + var prop = createNode(193, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -18814,19 +19325,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(304, start); + var tag = createNode(307, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(309, start); + var tag = createNode(312, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(306, start); + var tag = createNode(309, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(true); skipWhitespace(); @@ -18835,7 +19346,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(312, start); + var typedefTag = createNode(315, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -18849,9 +19360,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(299, start); + jsdocTypeLiteral = createNode(302, start); } - if (child.kind === 310) { + if (child.kind === 313) { if (childTypeTag) { break; } @@ -18864,7 +19375,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170) { + if (typeExpression && typeExpression.type.kind === 173) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -18882,7 +19393,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24)) { - var jsDocNamespaceNode = createNode(245, pos); + var jsDocNamespaceNode = createNode(248, pos); if (nested) { jsDocNamespaceNode.flags |= 4; } @@ -18896,22 +19407,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(305, start); + var callbackTag = createNode(308, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(300, start); + var jsdocSignature = createNode(303, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(58)) { + if (parseOptionalJsdoc(59)) { var tag = parseTag(indent); - if (tag && tag.kind === 308) { + if (tag && tag.kind === 311) { return tag; } } @@ -18953,10 +19464,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58: + case 59: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 307 || child.kind === 313) && + if (child && (child.kind === 310 || child.kind === 316) && target !== 4 && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -18969,13 +19480,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40: + case 41: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73: + case 75: canParseTag = false; break; case 1: @@ -18984,7 +19495,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58); + ts.Debug.assert(token() === 59); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -19019,13 +19530,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151); + var typeParameter = createNode(154); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27)); - var result = createNode(311, start); + var result = createNode(314, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -19055,13 +19566,13 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73, !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75, !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73, pos); - if (token() !== 73) { + var result = createNode(75, pos); + if (token() !== 75) { result.originalKeywordKind = token(); } result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -19143,7 +19654,7 @@ var ts; switch (node.kind) { case 10: case 8: - case 73: + case 75: return true; } return false; @@ -19558,10 +20069,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73) { + if (lhs.kind === 75) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101) { + if (lhs.kind === 103) { return true; } return lhs.name.escapedText === rhs.name.escapedText && @@ -19688,6 +20199,14 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", @@ -19751,6 +20270,15 @@ var ts; isCommandLineOnly: true, description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, + { + name: "listFilesOnly", + type: "boolean", + category: ts.Diagnostics.Command_line_Options, + affectsSemanticDiagnostics: true, + affectsEmit: true, + isCommandLineOnly: true, + description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing + }, { name: "target", shortName: "t", @@ -20291,6 +20819,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -20386,6 +20920,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -20471,7 +21012,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; function convertEnableAutoDiscoveryToEnable(typeAcquisition) { @@ -20693,92 +21235,7 @@ var ts; var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } - function printVersion() { - ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); - } - ts.printVersion = printVersion; - function printHelp(optionsList, syntaxPrefix) { - if (syntaxPrefix === void 0) { syntaxPrefix = ""; } - var output = []; - var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; - var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; - var marginLength = Math.max(syntaxLength, examplesLength); - var syntax = makePadding(marginLength - syntaxLength); - syntax += "tsc " + syntaxPrefix + "[" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + "...]"; - output.push(getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax)); - output.push(ts.sys.newLine + ts.sys.newLine); - var padding = makePadding(marginLength); - output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine); - output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine); - output.push(padding + "tsc @args.txt" + ts.sys.newLine); - output.push(padding + "tsc --build tsconfig.json" + ts.sys.newLine); - output.push(ts.sys.newLine); - output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); - marginLength = 0; - var usageColumn = []; - var descriptionColumn = []; - var optionsDescriptionMap = ts.createMap(); - for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) { - var option = optionsList_1[_i]; - if (!option.description) { - continue; - } - var usageText_1 = " "; - if (option.shortName) { - usageText_1 += "-" + option.shortName; - usageText_1 += getParamType(option); - usageText_1 += ", "; - } - usageText_1 += "--" + option.name; - usageText_1 += getParamType(option); - usageColumn.push(usageText_1); - var description = void 0; - if (option.name === "lib") { - description = getDiagnosticText(option.description); - var element = option.element; - var typeMap = element.type; - optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; })); - } - else { - description = getDiagnosticText(option.description); - } - descriptionColumn.push(description); - marginLength = Math.max(usageText_1.length, marginLength); - } - var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; - usageColumn.push(usageText); - descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); - marginLength = Math.max(usageText.length, marginLength); - for (var i = 0; i < usageColumn.length; i++) { - var usage = usageColumn[i]; - var description = descriptionColumn[i]; - var kindsList = optionsDescriptionMap.get(description); - output.push(usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine); - if (kindsList) { - output.push(makePadding(marginLength + 4)); - for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) { - var kind = kindsList_1[_a]; - output.push(kind + " "); - } - output.push(ts.sys.newLine); - } - } - for (var _b = 0, output_1 = output; _b < output_1.length; _b++) { - var line = output_1[_b]; - ts.sys.write(line); - } - return; - function getParamType(option) { - if (option.paramType !== undefined) { - return " " + getDiagnosticText(option.paramType); - } - return ""; - } - function makePadding(paddingLength) { - return Array(paddingLength + 1).join(" "); - } - } - ts.printHelp = printHelp; + ts.getDiagnosticText = getDiagnosticText; function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache) { var configFileText; try { @@ -20916,7 +21373,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276) { + if (element.kind !== 279) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -20966,13 +21423,13 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103: + case 105: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88: + case 90: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97: + case 99: reportInvalidOptionValue(option && option.name === "extends"); return null; case 10: @@ -20991,13 +21448,13 @@ var ts; case 8: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203: - if (valueExpression.operator !== 39 || valueExpression.operand.kind !== 8) { + case 206: + if (valueExpression.operator !== 40 || valueExpression.operand.kind !== 8) { break; } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189: + case 192: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; if (option) { @@ -21007,7 +21464,7 @@ var ts; else { return convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined); } - case 188: + case 191: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -21048,7 +21505,7 @@ var ts; } function convertToTSConfig(configParseResult, configFileName, host) { var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); + var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs, host)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; @@ -21069,12 +21526,12 @@ var ts; return undefined; return specs; } - function matchesSpecs(path, includeSpecs, excludeSpecs) { + function matchesSpecs(path, includeSpecs, excludeSpecs, host) { if (!includeSpecs) return function (_) { return true; }; - var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); - var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); - var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames); if (includeRe) { if (excludeRe) { return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); }; @@ -21232,6 +21689,34 @@ var ts; } } ts.generateTSConfig = generateTSConfig; + function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) { + var result = {}; + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name in options) { + if (ts.hasProperty(options, name)) { + result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); + } + } + if (result.configFilePath) { + result.configFilePath = toAbsolutePath(result.configFilePath); + } + return result; + } + ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; + function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { + if (option) { + if (option.type === "list") { + var values = value; + if (option.element.isFilePath && values.length) { + return values.map(toAbsolutePath); + } + } + else if (option.isFilePath) { + return toAbsolutePath(value); + } + } + return value; + } function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache) { return parseJsonConfigFileContentWorker(json, undefined, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache); } @@ -21644,7 +22129,7 @@ var ts; } function normalizeNonListOptionValue(option, basePath, value) { if (option.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + value = ts.getNormalizedAbsolutePath(value, basePath); if (value === "") { value = "."; } @@ -22953,30 +23438,60 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { switch (node.kind) { - case 242: - case 243: + case 245: + case 246: return 0; - case 244: + case 247: if (ts.isEnumConst(node)) { return 2; } break; - case 250: - case 249: + case 253: + case 252: if (!(ts.hasModifier(node, 1))) { return 0; } break; - case 246: { + case 259: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1) { + return state; + } + } + return state; + } + break; + case 249: { var state_1 = 0; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0: return; @@ -22992,16 +23507,50 @@ var ts; }); return state_1; } - case 245: - return getModuleInstanceState(node); - case 73: + case 248: + return getModuleInstanceState(node, visited); + case 75: if (node.isInJSDocNamespace) { return 0; } } return 1; } - var flowNodeCreated = ts.identity; + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1; + } + function initFlowNode(node) { + ts.Debug.attachFlowNodeDebugInfo(node); + return node; + } + var flowNodeCreated = initFlowNode; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -23053,6 +23602,8 @@ var ts; symbolCount = 0; skipTransformFlagAggregation = file.isDeclarationFile; Symbol = ts.objectAllocator.getSymbolConstructor(); + ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); + ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { bind(file); file.symbolCount = symbolCount; @@ -23096,7 +23647,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 | 384 | 1536 | 3) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -23119,7 +23670,7 @@ var ts; } } function getDeclarationName(node) { - if (node.kind === 255) { + if (node.kind === 258) { return node.isExportEquals ? "export=" : "default"; } var name = ts.getNameOfDeclaration(node); @@ -23128,7 +23679,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150) { + if (name.kind === 153) { var nameExpression = name.expression; if (ts.isStringOrNumericLiteralLike(nameExpression)) { return ts.escapeLeadingUnderscores(nameExpression.text); @@ -23139,34 +23690,37 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158: - return "__constructor"; - case 166: case 161: - case 300: + return "__constructor"; + case 169: + case 164: + case 303: return "__call"; - case 167: - case 162: + case 170: + case 165: return "__new"; - case 163: + case 166: return "__index"; - case 256: + case 259: return "__export"; - case 285: + case 288: return "export="; - case 205: + case 208: if (ts.getAssignmentDeclarationKind(node) === 2) { return "export="; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295: + case 298: return (ts.isJSDocConstructSignature(node) ? "__new" : "__call"); - case 152: - ts.Debug.assert(node.parent.kind === 295, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + case 155: + ts.Debug.assert(node.parent.kind === 298, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -23221,7 +23775,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (node.kind === 255 && !node.isExportEquals)) { + (node.kind === 258 && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -23256,7 +23810,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 2097152) { - if (node.kind === 258 || (node.kind === 249 && hasExportModifier)) { + if (node.kind === 261 || (node.kind === 252 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -23266,7 +23820,7 @@ var ts; else { if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || ts.isJSDocTypeAlias(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64)) || ts.isJSDocTypeAlias(node)) { if (!container.locals || (ts.hasModifier(node, 512) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } @@ -23286,7 +23840,7 @@ var ts; var saveThisParentContainer = thisParentContainer; var savedBlockScopeContainer = blockScopeContainer; if (containerFlags & 1) { - if (node.kind !== 198) { + if (node.kind !== 201) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -23310,31 +23864,32 @@ var ts; var isIIFE = containerFlags & 16 && !ts.hasModifier(node, 256) && !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node); if (!isIIFE) { - currentFlow = { flags: 2 }; + currentFlow = initFlowNode({ flags: 2 }); if (containerFlags & (16 | 128)) { - currentFlow.container = node; + currentFlow.node = node; } } - currentReturnTarget = isIIFE || node.kind === 158 ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; hasExplicitReturn = false; - flowNodeCreated = ts.identity; + flowNodeCreated = initFlowNode; bindChildren(node); - node.flags &= ~1408; + node.flags &= ~2816; if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) { - node.flags |= 128; + node.flags |= 256; if (hasExplicitReturn) - node.flags |= 256; + node.flags |= 512; + node.endFlowNode = currentFlow; } - if (node.kind === 285) { + if (node.kind === 288) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158) { + if (node.kind === 161) { node.returnFlowNode = currentFlow; } } @@ -23351,7 +23906,7 @@ var ts; else if (containerFlags & 64) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 : node.flags & ~64; + node.flags = seenThisKeyword ? node.flags | 128 : node.flags & ~128; } else { bindChildren(node); @@ -23378,8 +23933,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -23411,79 +23966,89 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 && node.kind <= 240 && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225: + case 228: bindWhileStatement(node); break; - case 224: + case 227: bindDoStatement(node); break; - case 226: + case 229: bindForStatement(node); break; - case 227: - case 228: + case 230: + case 231: bindForInOrForOfStatement(node); break; - case 223: + case 226: bindIfStatement(node); break; - case 231: - case 235: + case 234: + case 238: bindReturnOrThrow(node); break; - case 230: - case 229: + case 233: + case 232: bindBreakOrContinueStatement(node); break; - case 236: + case 239: bindTryStatement(node); break; - case 233: + case 236: bindSwitchStatement(node); break; - case 247: + case 250: bindCaseBlock(node); break; - case 272: + case 275: bindCaseClause(node); break; - case 234: + case 225: + bindExpressionStatement(node); + break; + case 237: bindLabeledStatement(node); break; - case 203: + case 206: bindPrefixUnaryExpressionFlow(node); break; - case 204: + case 207: bindPostfixUnaryExpressionFlow(node); break; - case 205: + case 208: bindBinaryExpressionFlow(node); break; - case 199: + case 202: bindDeleteExpressionFlow(node); break; - case 206: + case 209: bindConditionalExpressionFlow(node); break; - case 238: + case 241: bindVariableDeclarationFlow(node); break; - case 192: + case 193: + case 194: + bindAccessExpressionFlow(node); + break; + case 195: bindCallExpressionFlow(node); break; - case 312: - case 305: - case 306: + case 315: + case 308: + case 309: bindJSDocTypeAlias(node); break; - case 285: { + case 288: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219: - case 246: + case 222: + case 249: bindEachFunctionsFirst(node.statements); break; default: @@ -23494,30 +24059,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73: - case 101: - case 190: - case 191: + case 75: + case 103: + case 193: + case 194: return isNarrowableReference(expr); - case 192: + case 195: return hasNarrowableArgument(expr); - case 196: + case 199: return isNarrowingExpression(expr.expression); - case 205: + case 208: return isNarrowingBinaryExpression(expr); + case 206: + return expr.operator === 53 && isNarrowingExpression(expr.operand); case 203: - return expr.operator === 52 && isNarrowingExpression(expr.operand); - case 200: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 || expr.kind === 101 || expr.kind === 99 || + return expr.kind === 75 || expr.kind === 103 || expr.kind === 101 || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && - isNarrowableReference(expr.expression); + ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || + ts.isOptionalChain(expr); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -23528,7 +24092,7 @@ var ts; } } } - if (expr.expression.kind === 190 && + if (expr.expression.kind === 193 && isNarrowableReference(expr.expression.expression)) { return true; } @@ -23542,17 +24106,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60: + case 62: return isNarrowableReference(expr.left); - case 33: case 34: case 35: case 36: + case 37: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95: + case 97: return isNarrowableOperand(expr.left); - case 94: + case 96: return isNarrowableInOperands(expr.left, expr.right); case 27: return isNarrowingExpression(expr.right); @@ -23561,11 +24125,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196: + case 199: return isNarrowableOperand(expr.expression); - case 205: + case 208: switch (expr.operatorToken.kind) { - case 60: + case 62: return isNarrowableOperand(expr.left); case 27: return isNarrowableOperand(expr.right); @@ -23574,19 +24138,13 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4, - antecedents: undefined - }; + return initFlowNode({ flags: 4, antecedents: undefined }); } function createLoopLabel() { - return { - flags: 8, - antecedents: undefined - }; + return initFlowNode({ flags: 8, antecedents: undefined }); } function setFlowNodeReferenced(flow) { - flow.flags |= flow.flags & 512 ? 1024 : 512; + flow.flags |= flow.flags & 1024 ? 2048 : 1024; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) { @@ -23601,31 +24159,35 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 103 && flags & 64 || - expression.kind === 88 && flags & 32) { + if ((expression.kind === 105 && flags & 64 || + expression.kind === 90 && flags & 32) && + !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -23640,47 +24202,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223: - case 225: - case 224: - return parent.expression === node; case 226: - case 206: + case 228: + case 227: + return parent.expression === node; + case 229: + case 209: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196) { + if (node.kind === 199) { node = node.expression; } - else if (node.kind === 203 && node.operator === 52) { + else if (node.kind === 206 && node.operator === 53) { node = node.operand; } else { - return node.kind === 205 && (node.operatorToken.kind === 54 || - node.operatorToken.kind === 55); + return node.kind === 208 && (node.operatorToken.kind === 55 || + node.operatorToken.kind === 56 || + node.operatorToken.kind === 60); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 || - node.parent.kind === 203 && - node.parent.operator === 52) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node)); } @@ -23708,7 +24275,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 + var enclosingLabeledStatement = node.parent.kind === 237 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -23738,15 +24305,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228) { + if (node.kind === 231) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239) { + if (node.initializer.kind !== 242) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -23768,7 +24335,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231) { + if (node.kind === 234) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -23788,7 +24355,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -23813,7 +24380,7 @@ var ts; var tryPriors = []; var oldFlowNodeCreated = flowNodeCreated; if (node.catchClause || node.finallyBlock) { - flowNodeCreated = function (node) { return (tryPriors.push(node), node); }; + flowNodeCreated = function (node) { return (tryPriors.push(node), initFlowNode(node)); }; } bind(node.tryBlock); flowNodeCreated = oldFlowNodeCreated; @@ -23848,7 +24415,7 @@ var ts; preFinallyPrior = finishFlowLabel(preFinallyFlow_1); } } - var preFinallyFlow = { flags: 2048, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = initFlowNode({ flags: 4096, antecedent: preFinallyPrior, lock: {} }); addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -23860,7 +24427,7 @@ var ts; } } if (!(currentFlow.flags & 1)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -23878,7 +24445,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -23906,7 +24473,7 @@ var ts; bind(clause); fallthroughFlow = currentFlow; if (!(currentFlow.flags & 1) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { - errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + clause.fallthroughFlowNode = currentFlow; } } clauses.transformFlags = subtreeTransformFlags | 536870912; @@ -23932,6 +24499,15 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + if (node.expression.kind === 195) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -23943,13 +24519,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224) { + if (!node.statement || node.statement.kind !== 227) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 && node.operatorToken.kind === 60) { + if (node.kind === 208 && node.operatorToken.kind === 62) { bindAssignmentTargetFlow(node.left); } else { @@ -23960,10 +24536,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188) { + else if (node.kind === 191) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209) { + if (e.kind === 212) { bindAssignmentTargetFlow(e.expression); } else { @@ -23971,16 +24547,16 @@ var ts; } } } - else if (node.kind === 189) { + else if (node.kind === 192) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276) { + if (p.kind === 279) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277) { + else if (p.kind === 280) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278) { + else if (p.kind === 281) { bindAssignmentTargetFlow(p.expression); } } @@ -23988,7 +24564,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54) { + if (node.operatorToken.kind === 55) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -23999,7 +24575,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52) { + if (node.operator === 53) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -24009,20 +24585,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 || node.operator === 45) { + if (node.operator === 45 || node.operator === 46) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 || node.operator === 45) { + if (node.operator === 45 || node.operator === 46) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 || operator === 55) { + if (operator === 55 || operator === 56 || operator === 60) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -24036,7 +24612,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 && node.left.kind === 191) { + if (operator === 62 && node.left.kind === 194) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -24047,7 +24623,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190) { + if (node.expression.kind === 193) { bindAssignmentTargetFlow(node.expression); } } @@ -24086,24 +24662,88 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.kind !== 306 && node.fullName) { + if (node.kind !== 309 && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - var expr = node.expression; - while (expr.kind === 196) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160) { + addDeclarationToSymbol(host.symbol, host, 32); + } + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node)); } - if (expr.kind === 197 || expr.kind === 198) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193: + bind(node.name); + break; + case 194: + bind(node.argumentExpression); + break; + case 195: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 || expr.kind === 201) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -24112,53 +24752,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210: - case 241: + case 213: case 244: - case 189: - case 169: - case 299: - case 269: + case 247: + case 192: + case 172: + case 302: + case 272: return 1; - case 242: - return 1 | 64; case 245: - case 243: - case 182: + return 1 | 64; + case 248: + case 246: + case 185: return 1 | 32; - case 285: + case 288: return 1 | 4 | 32; - case 157: + case 160: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 158: - case 240: - case 156: - case 159: - case 160: case 161: - case 300: - case 295: - case 166: + case 243: + case 159: case 162: case 163: - case 167: + case 164: + case 303: + case 298: + case 169: + case 165: + case 166: + case 170: return 1 | 4 | 32 | 8; - case 197: - case 198: + case 200: + case 201: return 1 | 4 | 32 | 8 | 16; - case 246: + case 249: return 4; - case 155: + case 158: return node.initializer ? 4 : 0; - case 275: - case 226: - case 227: - case 228: - case 247: + case 278: + case 229: + case 230: + case 231: + case 250: return 2; - case 219: + case 222: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -24171,40 +24811,40 @@ var ts; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 245: + case 248: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285: + case 288: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210: - case 241: - return declareClassMember(node, symbolFlags, symbolExcludes); + case 213: case 244: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 247: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169: - case 299: - case 189: - case 242: - case 269: + case 172: + case 302: + case 192: + case 245: + case 272: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); + case 169: + case 170: + case 164: + case 165: + case 303: case 166: - case 167: + case 160: + case 159: case 161: case 162: - case 300: case 163: - case 157: - case 156: - case 158: - case 159: - case 160: - case 240: - case 197: - case 198: - case 295: - case 312: - case 305: case 243: - case 182: + case 200: + case 201: + case 298: + case 315: + case 308: + case 246: + case 185: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -24223,11 +24863,11 @@ var ts; return !!body && body.statements.some(function (s) { return ts.isExportDeclaration(s) || ts.isExportAssignment(s); }); } function setExportContextFlag(node) { - if (node.flags & 4194304 && !hasExportDeclarations(node)) { - node.flags |= 32; + if (node.flags & 8388608 && !hasExportDeclarations(node)) { + node.flags |= 64; } else { - node.flags &= ~32; + node.flags &= ~64; } } function bindModuleDeclaration(node) { @@ -24283,11 +24923,11 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 || prop.name.kind !== 73) { + if (prop.kind === 281 || prop.name.kind !== 75) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 276 || prop.kind === 277 || prop.kind === 157 + var currentKind = prop.kind === 279 || prop.kind === 280 || prop.kind === 160 ? 1 : 2; var existingKind = seen.get(identifier.escapedText); @@ -24319,10 +24959,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245: + case 248: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285: + case 288: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -24349,19 +24989,24 @@ var ts; var host = ts.getJSDocHost(typeAlias); container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = { flags: 2 }; + currentFlow = initFlowNode({ flags: 2 }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) { var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); if (isTopLevel) { - bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; })); + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { case 1: case 2: - container = file; + if (!ts.isExternalOrCommonJsModule(file)) { + container = undefined; + } + else { + container = file; + } break; case 4: container = declName.parent.expression; @@ -24375,11 +25020,13 @@ var ts; case 0: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } - declareModuleMember(typeAlias, 524288, 788968); + if (container) { + declareModuleMember(typeAlias, 524288, 788968); + } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288, 788968); } @@ -24395,11 +25042,11 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 && - node.originalKeywordKind <= 118 && + node.originalKeywordKind >= 112 && + node.originalKeywordKind <= 120 && !ts.isIdentifierName(node) && - !(node.flags & 4194304) && - !(node.flags & 2097152)) { + !(node.flags & 8388608) && + !(node.flags & 4194304)) { if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); } @@ -24425,7 +25072,7 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 73) { + if (inStrictMode && node.expression.kind === 75) { var span = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } @@ -24434,7 +25081,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73) { + if (name && name.kind === 75) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span = ts.getErrorSpanForNode(file, name); @@ -24467,8 +25114,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 285 && - blockScopeContainer.kind !== 245 && + if (blockScopeContainer.kind !== 288 && + blockScopeContainer.kind !== 248 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -24487,7 +25134,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 44 || node.operator === 45) { + if (node.operator === 45 || node.operator === 46) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -24530,7 +25177,7 @@ var ts; node.parent = parent; var saveInStrictMode = inStrictMode; bindWorker(node); - if (node.kind > 148) { + if (node.kind > 151) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -24570,8 +25217,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -24588,7 +25235,7 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 73: + case 75: if (node.isInJSDocNamespace) { var parentNode = node.parent; while (parentNode && !ts.isJSDocTypeAlias(parentNode)) { @@ -24597,27 +25244,28 @@ var ts; bindBlockScopedDeclaration(parentNode, 524288, 788968); break; } - case 101: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277)) { + case 103: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190: - case 191: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193: + case 194: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, undefined, node.expression, 1 | 134217728, 111550); + declareSymbol(file.locals, undefined, expr.expression, 1 | 134217728, 111550); } break; - case 205: + case 208: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1: @@ -24644,72 +25292,74 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275: + case 278: return checkStrictModeCatchClause(node); - case 199: + case 202: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 204: + case 207: return checkStrictModePostfixUnaryExpression(node); - case 203: + case 206: return checkStrictModePrefixUnaryExpression(node); - case 232: + case 235: return checkStrictModeWithStatement(node); - case 234: + case 237: return checkStrictModeLabeledStatement(node); - case 179: + case 182: seenThisKeyword = true; return; - case 164: + case 167: break; - case 151: + case 154: return bindTypeParameter(node); - case 152: + case 155: return bindParameter(node); - case 238: + case 241: return bindVariableDeclarationOrBindingElement(node); - case 187: + case 190: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155: - case 154: + case 158: + case 157: return bindPropertyWorker(node); - case 276: - case 277: - return bindPropertyOrMethodOrAccessor(node, 4, 0); case 279: + case 280: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 282: return bindPropertyOrMethodOrAccessor(node, 8, 900095); - case 161: - case 162: - case 163: + case 164: + case 165: + case 166: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 157: - case 156: + case 160: + case 159: return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359); - case 240: + case 243: return bindFunctionDeclaration(node); - case 158: + case 161: return declareSymbolAndAddToSymbolTable(node, 16384, 0); - case 159: + case 162: return bindPropertyOrMethodOrAccessor(node, 32768, 46015); - case 160: + case 163: return bindPropertyOrMethodOrAccessor(node, 65536, 78783); - case 166: - case 295: - case 300: - case 167: - return bindFunctionOrConstructorType(node); case 169: - case 299: - case 182: + case 298: + case 303: + case 170: + return bindFunctionOrConstructorType(node); + case 172: + case 302: + case 185: return bindAnonymousTypeWorker(node); - case 189: + case 307: + return bindJSDocClassTag(node); + case 192: return bindObjectLiteralExpression(node); - case 197: - case 198: + case 200: + case 201: return bindFunctionExpression(node); - case 192: + case 195: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7: @@ -24727,60 +25377,60 @@ var ts; bindCallExpression(node); } break; - case 210: - case 241: + case 213: + case 244: inStrictMode = true; return bindClassLikeDeclaration(node); - case 242: + case 245: return bindBlockScopedDeclaration(node, 64, 788872); - case 243: + case 246: return bindBlockScopedDeclaration(node, 524288, 788968); - case 244: + case 247: return bindEnumDeclaration(node); - case 245: + case 248: return bindModuleDeclaration(node); - case 269: + case 272: return bindJsxAttributes(node); - case 268: + case 271: return bindJsxAttribute(node, 4, 0); - case 249: case 252: - case 254: - case 258: + case 255: + case 257: + case 261: return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152); - case 248: - return bindNamespaceExportDeclaration(node); case 251: + return bindNamespaceExportDeclaration(node); + case 254: return bindImportClause(node); - case 256: + case 259: return bindExportDeclaration(node); - case 255: + case 258: return bindExportAssignment(node); - case 285: + case 288: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219: + case 222: if (!ts.isFunctionLike(node.parent)) { return; } - case 246: + case 249: return updateStrictModeStatementList(node.statements); - case 307: - if (node.parent.kind === 300) { + case 310: + if (node.parent.kind === 303) { return bindParameter(node); } - if (node.parent.kind !== 299) { + if (node.parent.kind !== 302) { break; } - case 313: + case 316: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 ? 4 | 16777216 : 4; return declareSymbolAndAddToSymbolTable(propTag, flags, 0); - case 312: - case 305: - case 306: + case 315: + case 308: + case 309: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -24877,8 +25527,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 | 67108864); } @@ -24888,7 +25537,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 | 1048576 | 32 : 4 | 1048576; - declareSymbol(symbol.exports, symbol, lhs, flags, 0); + declareSymbol(symbol.exports, symbol, node.left, flags, 0); } } function bindModuleExportsAssignment(node) { @@ -24902,36 +25551,48 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 : 4 | 1048576 | 512; - declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0); + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0); + setValueDeclaration(symbol, node); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, false); switch (thisContainer.kind) { - case 240: - case 197: + case 243: + case 200: var constructorSymbol = thisContainer.symbol; - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 60) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } - if (constructorSymbol) { + if (constructorSymbol && constructorSymbol.valueDeclaration) { constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4, 0 & ~4); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 | 67108864, 0 & ~4); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32); } break; + case 161: case 158: - case 155: - case 157: - case 159: case 160: + case 162: + case 163: var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members; - declareSymbol(symbolTable, containingClass.symbol, node, 4, 0, true); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 | 67108864, 0, true); + } break; - case 285: + case 288: if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0); } @@ -24943,11 +25604,21 @@ var ts; ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4, "__computed"); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101) { + if (node.expression.kind === 103) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -24959,11 +25630,13 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, false); + bindPropertyAssignment(node.left.expression, node.left, false, true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + if (namespaceSymbol) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32); + } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, true); } function bindPrototypePropertyAssignment(lhs, parent) { @@ -24972,34 +25645,40 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, true); + bindPropertyAssignment(constructorFunction, lhs, true, true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false); + var isToplevel = node.parent.parent.kind === 288; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 | 67108864, "__computed"); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, false); + bindPropertyAssignment(node.expression, node, false, false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { if (isToplevel && !isPrototypeProperty) { var flags_1 = 1536 | 67108864; var excludeFlags_1 = 110735 & ~67108864; @@ -25015,6 +25694,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -25024,20 +25706,43 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 : 4; - var excludes = isMethod ? 103359 : 0; + var includes = 0; + var excludes = 0; + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192; + excludes = 103359; + } + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + includes |= 65536 | 4; + excludes |= 78783; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 | 4; + excludes |= 46015; + } + } + if (includes === 0) { + includes = 4; + excludes = 0; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 - : propertyAccess.parent.parent.kind === 285; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 + : propertyAccess.parent.parent.kind === 288; } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } function isExpandoSymbol(symbol) { @@ -25056,7 +25761,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 || init.operatorToken.kind === 60) ? init.right : init, isPrototypeAssignment); } return false; } @@ -25073,7 +25778,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -25085,7 +25790,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -25094,7 +25799,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241) { + if (node.kind === 244) { bindBlockScopedDeclaration(node, 32, 899503); } else { @@ -25138,10 +25843,10 @@ var ts; } } function bindParameter(node) { - if (node.kind === 307 && container.kind !== 300) { + if (node.kind === 310 && container.kind !== 303) { return; } - if (inStrictMode && !(node.flags & 4194304)) { + if (inStrictMode && !(node.flags & 8388608)) { checkStrictModeEvalOrArguments(node, node.name); } if (ts.isBindingPattern(node.name)) { @@ -25156,9 +25861,9 @@ var ts; } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304)) { + if (!file.isDeclarationFile && !(node.flags & 8388608)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024; + emitFlags |= 2048; } } checkStrictModeFunctionName(node); @@ -25171,9 +25876,9 @@ var ts; } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304)) { + if (!file.isDeclarationFile && !(node.flags & 8388608)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024; + emitFlags |= 2048; } } if (currentFlow) { @@ -25184,8 +25889,8 @@ var ts; return bindAnonymousDeclaration(node, 16, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304) && ts.isAsyncFunction(node)) { - emitFlags |= 1024; + if (!file.isDeclarationFile && !(node.flags & 8388608) && ts.isAsyncFunction(node)) { + emitFlags |= 2048; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -25211,7 +25916,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144, 526824); } } - else if (node.parent.kind === 177) { + else if (node.parent.kind === 180) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -25236,14 +25941,14 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 221) || - node.kind === 241 || - (node.kind === 245 && shouldReportErrorOnModuleDeclaration(node)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 223) || + node.kind === 244 || + (node.kind === 248 && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304) && + !(node.flags & 8388608) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -25270,12 +25975,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242: - case 243: - return true; case 245: + case 246: + return true; + case 248: return getModuleInstanceState(s) !== 1; - case 244: + case 247: return ts.hasModifier(s, 2048); default: return false; @@ -25287,7 +25992,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -25318,58 +26023,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192: + case 195: return computeCallExpression(node, subtreeFlags); - case 193: + case 196: return computeNewExpression(node, subtreeFlags); - case 245: + case 248: return computeModuleDeclaration(node, subtreeFlags); - case 196: + case 199: return computeParenthesizedExpression(node, subtreeFlags); - case 205: + case 208: return computeBinaryExpression(node, subtreeFlags); - case 222: + case 225: return computeExpressionStatement(node, subtreeFlags); - case 152: + case 155: return computeParameter(node, subtreeFlags); - case 198: + case 201: return computeArrowFunction(node, subtreeFlags); - case 197: + case 200: return computeFunctionExpression(node, subtreeFlags); - case 240: + case 243: return computeFunctionDeclaration(node, subtreeFlags); - case 238: + case 241: return computeVariableDeclaration(node, subtreeFlags); - case 239: + case 242: return computeVariableDeclarationList(node, subtreeFlags); - case 220: + case 224: return computeVariableStatement(node, subtreeFlags); - case 234: + case 237: return computeLabeledStatement(node, subtreeFlags); - case 241: + case 244: return computeClassDeclaration(node, subtreeFlags); - case 210: + case 213: return computeClassExpression(node, subtreeFlags); - case 274: + case 277: return computeHeritageClause(node, subtreeFlags); - case 275: + case 278: return computeCatchClause(node, subtreeFlags); - case 212: + case 215: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158: + case 161: return computeConstructor(node, subtreeFlags); - case 155: + case 158: return computePropertyDeclaration(node, subtreeFlags); - case 157: - return computeMethod(node, subtreeFlags); - case 159: case 160: + return computeMethod(node, subtreeFlags); + case 162: + case 163: return computeAccessor(node, subtreeFlags); - case 249: + case 252: return computeImportEquals(node, subtreeFlags); - case 190: + case 193: return computePropertyAccess(node, subtreeFlags); - case 191: + case 194: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -25380,6 +26085,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32) { + transformFlags |= 4; + } if (node.typeArguments) { transformFlags |= 1; } @@ -25389,7 +26097,7 @@ var ts; transformFlags |= 2048; } } - if (expression.kind === 93) { + if (expression.kind === 95) { transformFlags |= 524288; } node.transformFlags = transformFlags | 536870912; @@ -25410,14 +26118,17 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 && leftKind === 189) { + if (operatorTokenKind === 60) { + transformFlags |= 4; + } + else if (operatorTokenKind === 62 && leftKind === 192) { transformFlags |= 16 | 128 | 512; } - else if (operatorTokenKind === 60 && leftKind === 188) { + else if (operatorTokenKind === 62 && leftKind === 191) { transformFlags |= 128 | 512; } - else if (operatorTokenKind === 41 - || operatorTokenKind === 64) { + else if (operatorTokenKind === 42 + || operatorTokenKind === 66) { transformFlags |= 64; } node.transformFlags = transformFlags | 536870912; @@ -25450,8 +26161,8 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 213 - || expressionKind === 195) { + if (expressionKind === 216 + || expressionKind === 198) { transformFlags |= 1; } node.transformFlags = transformFlags | 536870912; @@ -25484,10 +26195,10 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87: + case 89: transformFlags |= 128; break; - case 110: + case 112: transformFlags |= 1; break; default: @@ -25638,7 +26349,10 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.kind === 99) { + if (node.flags & 32) { + transformFlags |= 4; + } + if (node.expression.kind === 101) { transformFlags |= 32 | 16; } node.transformFlags = transformFlags | 536870912; @@ -25646,7 +26360,10 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; - if (node.expression.kind === 99) { + if (node.flags & 32) { + transformFlags |= 4; + } + if (node.expression.kind === 101) { transformFlags |= 32 | 16; } node.transformFlags = transformFlags | 536870912; @@ -25725,51 +26442,51 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912; switch (kind) { - case 122: - case 202: + case 125: + case 205: transformFlags |= 16 | 32; break; - case 195: - case 213: - case 316: + case 198: + case 216: + case 319: transformFlags |= 1; excludeFlags = 536870912; break; + case 118: case 116: - case 114: - case 115: - case 119: - case 126: - case 78: - case 244: - case 279: - case 214: - case 134: + case 117: + case 121: + case 129: + case 80: + case 247: + case 282: + case 217: + case 137: transformFlags |= 1; break; - case 261: - case 262: - case 263: - case 11: case 264: case 265: case 266: + case 11: case 267: case 268: case 269: case 270: case 271: + case 272: + case 273: + case 274: transformFlags |= 2; break; case 14: case 15: case 16: case 17: - case 207: - case 194: - case 277: - case 117: - case 215: + case 210: + case 197: + case 280: + case 119: + case 218: transformFlags |= 128; break; case 10: @@ -25785,30 +26502,27 @@ var ts; case 9: transformFlags |= 4; break; - case 228: + case 231: if (node.awaitModifier) { transformFlags |= 16; } transformFlags |= 128; break; - case 208: + case 211: transformFlags |= 16 | 128 | 131072; break; - case 121: - case 136: - case 147: - case 133: - case 137: - case 139: case 124: + case 139: + case 150: + case 136: case 140: - case 107: - case 151: + case 142: + case 127: + case 143: + case 109: case 154: - case 156: - case 161: - case 162: - case 163: + case 157: + case 159: case 164: case 165: case 166: @@ -25824,54 +26538,57 @@ var ts; case 176: case 177: case 178: - case 242: - case 243: case 179: case 180: case 181: + case 245: + case 246: case 182: case 183: - case 248: + case 184: + case 185: + case 186: + case 251: transformFlags = 1; excludeFlags = -2; break; - case 150: + case 153: transformFlags |= 16384; break; - case 209: + case 212: transformFlags |= 128 | 4096; break; - case 278: + case 281: transformFlags |= 16 | 8192; break; - case 99: + case 101: transformFlags |= 128; excludeFlags = 536870912; break; - case 101: + case 103: transformFlags |= 2048; break; - case 185: + case 188: transformFlags |= 128 | 65536; if (subtreeFlags & 4096) { transformFlags |= 16 | 8192; } excludeFlags = 536875008; break; - case 186: + case 189: transformFlags |= 128 | 65536; excludeFlags = 536875008; break; - case 187: + case 190: transformFlags |= 128; if (node.dotDotDotToken) { transformFlags |= 4096; } break; - case 153: + case 156: transformFlags |= 1 | 1024; break; - case 189: + case 192: excludeFlags = 536896512; if (subtreeFlags & 16384) { transformFlags |= 128; @@ -25880,24 +26597,24 @@ var ts; transformFlags |= 16; } break; - case 188: + case 191: excludeFlags = 536875008; break; - case 224: - case 225: - case 226: case 227: + case 228: + case 229: + case 230: if (subtreeFlags & 32768) { transformFlags |= 128; } break; - case 285: + case 288: break; - case 231: + case 234: transformFlags |= 262144 | 16; break; - case 229: - case 230: + case 232: + case 233: transformFlags |= 262144; break; } @@ -25908,67 +26625,67 @@ var ts; return transformFlags | (node.transformFlags & 2048); } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 && kind <= 184) { + if (kind >= 167 && kind <= 187) { return -2; } switch (kind) { - case 192: - case 193: - case 188: + case 195: + case 196: + case 191: return 536875008; - case 245: + case 248: return 537168896; - case 152: + case 155: return 536870912; - case 198: + case 201: return 537371648; - case 197: - case 240: + case 200: + case 243: return 537373696; - case 239: + case 242: return 536944640; - case 241: - case 210: + case 244: + case 213: return 536888320; - case 158: + case 161: return 537372672; - case 157: - case 159: case 160: + case 162: + case 163: return 537372672; - case 121: - case 136: - case 147: - case 133: - case 139: - case 137: case 124: + case 139: + case 150: + case 136: + case 142: case 140: - case 107: - case 151: + case 127: + case 143: + case 109: case 154: - case 156: - case 161: - case 162: - case 163: - case 242: - case 243: + case 157: + case 159: + case 164: + case 165: + case 166: + case 245: + case 246: return -2; - case 189: + case 192: return 536896512; - case 275: + case 278: return 536879104; - case 185: - case 186: + case 188: + case 189: return 536875008; - case 195: - case 213: - case 316: - case 196: - case 99: + case 198: + case 216: + case 319: + case 199: + case 101: return 536870912; - case 190: - case 191: + case 193: + case 194: return 536870912; default: return 536870912; @@ -25982,7 +26699,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -26052,7 +26769,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -26130,7 +26847,7 @@ var ts; symbol.exports.forEach(visitSymbol); } ts.forEach(symbol.declarations, function (d) { - if (d.type && d.type.kind === 168) { + if (d.type && d.type.kind === 171) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -26286,8 +27003,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -26353,9 +27073,9 @@ var ts; }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (nodeIn) { + getContextualType: function (nodeIn, contextFlags) { var node = ts.getParseTreeNode(nodeIn, ts.isExpression); - return node ? getContextualType(node) : undefined; + return node ? getContextualType(node, contextFlags) : undefined; }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); @@ -26404,7 +27124,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -26418,6 +27138,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -26436,6 +27159,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -26464,7 +27188,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -26524,6 +27248,7 @@ var ts; var unknownType = createIntrinsicType(2, "unknown"); var undefinedType = createIntrinsicType(32768, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 262144); + var optionalType = createIntrinsicType(32768, "undefined"); var nullType = createIntrinsicType(65536, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 262144); var stringType = createIntrinsicType(4, "string"); @@ -26551,6 +27276,7 @@ var ts; var silentNeverType = createIntrinsicType(131072, "never"); var nonInferrableType = createIntrinsicType(131072, "never", 1048576); var implicitNeverType = createIntrinsicType(131072, "never"); + var unreachableNeverType = createIntrinsicType(131072, "never"); var nonPrimitiveType = createIntrinsicType(67108864, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -26572,11 +27298,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, false, false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, false, false); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, false, false); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, false, false); + var noTypePredicate = createTypePredicate(1, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, 0); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, 0); var enumNumberIndexInfo = createIndexInfo(stringType, true); var iterationTypesCache = ts.createMap(); var noIterationTypes = { @@ -26660,6 +27386,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -26672,13 +27401,13 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -26717,7 +27446,7 @@ var ts; var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { - return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; + return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText; } } } @@ -26727,7 +27456,7 @@ var ts; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); if (_jsxFactoryEntity) { - _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).escapedText; + _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText; } } else if (compilerOptions.reactNamespace) { @@ -26850,7 +27579,9 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864) { - ts.Debug.assert(source !== target); + if (source === target) { + return target; + } if (!(target.flags & 33554432)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -26967,7 +27698,7 @@ var ts; mergeSymbolTable(globals, moduleAugmentation.symbol.exports); } else { - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true); @@ -27017,7 +27748,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -27053,7 +27784,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304) { + declaration.flags & 8388608) { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { @@ -27063,15 +27794,15 @@ var ts; return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 187) { - var errorBindingElement = ts.getAncestor(usage, 187); + if (declaration.kind === 190) { + var errorBindingElement = ts.getAncestor(usage, 190); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 238), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241), usage); } - else if (declaration.kind === 238) { + else if (declaration.kind === 241) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } else if (ts.isClassDeclaration(declaration)) { @@ -27082,20 +27813,20 @@ var ts; } return true; } - if (usage.parent.kind === 258 || (usage.parent.kind === 255 && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 || (usage.parent.kind === 258 && usage.parent.isExportEquals)) { return true; } - if (usage.kind === 255 && usage.isExportEquals) { + if (usage.kind === 258 && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220: - case 226: - case 228: + case 224: + case 229: + case 231: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } @@ -27113,16 +27844,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 && + current.parent.kind === 158 && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32)) { - if (declaration.kind === 157) { + if (declaration.kind === 160) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 && !ts.hasModifier(declaration, 32); + var isDeclarationInstanceProperty = declaration.kind === 158 && !ts.hasModifier(declaration, 32); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -27140,14 +27871,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198: - case 155: + case 201: + case 158: return true; - case 219: + case 222: switch (node.parent.kind) { - case 159: - case 157: + case 162: case 160: + case 163: return true; default: return false; @@ -27179,11 +27910,11 @@ var ts; if (result = lookup(location.locals, name, meaning)) { var useResult = true; if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) { - if (meaning & result.flags & 788968 && lastLocation.kind !== 298) { + if (meaning & result.flags & 788968 && lastLocation.kind !== 301) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 152 || - lastLocation.kind === 151 + lastLocation.kind === 155 || + lastLocation.kind === 154 : false; } if (meaning & result.flags & 3) { @@ -27194,13 +27925,13 @@ var ts; } else if (result.flags & 1) { useResult = - lastLocation.kind === 152 || + lastLocation.kind === 155 || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176) { + else if (location.kind === 179) { useResult = lastLocation === location.trueType; } if (useResult) { @@ -27213,13 +27944,13 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285: + case 288: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 245: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 || ts.isAmbientModule(location)) { + case 248: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) { @@ -27230,7 +27961,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 && - ts.getDeclarationOfKind(moduleExport, 258)) { + ts.getDeclarationOfKind(moduleExport, 261)) { break; } } @@ -27243,12 +27974,12 @@ var ts; } } break; - case 244: + case 247: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; - case 155: + case 158: if (!ts.hasModifier(location, 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -27258,9 +27989,9 @@ var ts; } } break; - case 241: - case 210: - case 242: + case 244: + case 213: + case 245: if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -27272,7 +28003,7 @@ var ts; } break loop; } - if (location.kind === 210 && meaning & 32) { + if (location.kind === 213 && meaning & 32) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -27280,8 +28011,8 @@ var ts; } } break; - case 212: - if (lastLocation === location.expression && location.parent.token === 87) { + case 215: + if (lastLocation === location.expression && location.parent.token === 89) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) { if (nameNotFoundMessage) { @@ -27291,30 +28022,30 @@ var ts; } } break; - case 150: + case 153: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245) { if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 198: + case 201: if (compilerOptions.target >= 2) { break; } - case 157: - case 158: - case 159: case 160: - case 240: + case 161: + case 162: + case 163: + case 243: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197: + case 200: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -27327,28 +28058,28 @@ var ts; } } break; - case 153: - if (location.parent && location.parent.kind === 152) { + case 156: + if (location.parent && location.parent.kind === 155) { location = location.parent; } - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244)) { location = location.parent; } break; - case 312: - case 305: - case 306: + case 315: + case 308: + case 309: location = ts.getJSDocHost(location); break; - case 152: + case 155: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187: + case 190: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152) { + if (root.kind === 155) { associatedDeclarationForContainingInitializer = location; } } @@ -27365,7 +28096,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285); + ts.Debug.assert(lastLocation.kind === 288); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -27423,7 +28154,7 @@ var ts; checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } - if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 2097152)) { + if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); @@ -27443,9 +28174,9 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 && location.kind !== 197) { + if (location.kind !== 201 && location.kind !== 200) { return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name)); + (location.kind === 158 && !ts.hasModifier(location, 32))) && (!lastLocation || lastLocation !== location.name)); } if (lastLocation && lastLocation === location.name) { return false; @@ -27457,12 +28188,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240: - case 241: - case 242: - case 244: case 243: + case 244: case 245: + case 247: + case 246: + case 248: return true; default: return false; @@ -27474,7 +28205,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151) { + if (decl.kind === 154) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); @@ -27522,10 +28253,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73: - case 190: + case 75: + case 193: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212: + case 215: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -27612,10 +28343,13 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 244); }); + if (result.flags & (16 | 1 | 67108864) && result.flags & 32) { + return; + } + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2) { @@ -27643,13 +28377,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249: + case 252: return node; - case 251: + case 254: return node.parent; - case 252: + case 255: return node.parent.parent; - case 254: + case 257: return node.parent.parent.parent; default: return undefined; @@ -27659,7 +28393,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260) { + if (node.moduleReference.kind === 263) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -27713,7 +28447,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -27724,7 +28463,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, false); } function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) { @@ -27760,9 +28499,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -27794,7 +28534,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default")) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -27814,34 +28559,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } var aliasLike = resolveEntityName(expression, 111551 | 788968 | 1920, true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249: + case 252: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251: + case 254: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252: + case 255: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254: + case 257: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258: + case 261: return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve); - case 255: - case 205: + case 258: + case 208: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248: + case 251: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280: + return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve); + case 279: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -27903,14 +28670,14 @@ var ts; } } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { - if (entityName.kind === 73 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 73 || entityName.parent.kind === 149) { + if (entityName.kind === 75 || entityName.parent.kind === 152) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 249); + ts.Debug.assert(entityName.parent.kind === 252); return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias); } } @@ -27923,17 +28690,17 @@ var ts; } var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0); var symbol; - if (name.kind === 73) { - var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); + if (name.kind === 75) { + var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true); if (!symbol) { return symbolFromJSPrototype; } } - else if (name.kind === 149 || name.kind === 190) { - var left = name.kind === 149 ? name.left : name.expression; - var right = name.kind === 149 ? name.right : name.name; + else if (name.kind === 152 || name.kind === 193) { + var left = name.kind === 152 ? name.left : name.expression; + var right = name.kind === 152 ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -27979,7 +28746,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -28016,6 +28783,14 @@ var ts; undefined; return initializer || decl; } + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -28027,9 +28802,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -28120,7 +28892,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -28129,9 +28901,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512; if (merged.exports === undefined) { - merged.flags = merged.flags | 512; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -28139,12 +28915,13 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 285)) { + if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 288)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -28217,7 +28994,7 @@ var ts; return type.flags & 131068 ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : + return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") : symbol.flags & 1536 ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -28339,7 +29116,7 @@ var ts; } function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + if (container && !(symbol.flags & 262144)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) { @@ -28348,7 +29125,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -28356,27 +29144,31 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export="); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { if (container === getParentOfSymbol(symbol)) { return symbol; } + var exportEquals = container.exports && container.exports.get("export="); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { @@ -28389,7 +29181,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 && ts.nodeIsPresent(member.body)) { return member; } } @@ -28463,23 +29255,42 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285: + case 288: if (!ts.isExternalOrCommonJsModule(location)) { break; } + case 248: + var sym = getSymbolOfNode(location); + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244: + case 213: case 245: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + var table_1; + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 & ~67108864)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } @@ -28510,9 +29321,9 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { if (isAccessible(symbols.get(symbol.escapedName), undefined, ignoreQualification)) { @@ -28524,7 +29335,7 @@ var ts; && symbolFromSymbolTable.escapedName !== "default" && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 258))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -28553,7 +29364,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 258)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -28567,10 +29378,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155: - case 157: - case 159: + case 158: case 160: + case 162: + case 163: continue; default: return false; @@ -28658,14 +29469,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -28701,19 +29512,19 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 168 || + if (entityName.parent.kind === 171 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150) { + entityName.parent.kind === 153) { meaning = 111551 | 1048576; } - else if (entityName.kind === 149 || entityName.kind === 190 || - entityName.parent.kind === 249) { + else if (entityName.kind === 152 || entityName.kind === 193 || + entityName.parent.kind === 252) { meaning = 1920; } else { meaning = 788968; } - var firstIdentifier = getFirstIdentifier(entityName); + var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false); return (symbol && hasVisibleDeclarations(symbol, true)) || { accessibility: 1, @@ -28752,15 +29563,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144) { - sigOutput = kind === 1 ? 167 : 166; + sigOutput = kind === 1 ? 170 : 169; } else { - sigOutput = kind === 1 ? 162 : 161; + sigOutput = kind === 1 ? 165 : 164; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); + printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); return writer; } } @@ -28783,14 +29594,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, undefined, 64); rightStr = typeToString(right, undefined, 64); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0; } return flags & 9469291; @@ -28821,6 +29635,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0); @@ -28830,7 +29647,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -28858,26 +29676,26 @@ var ts; } if (type.flags & 1) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121); + return ts.createKeywordTypeNode(124); } if (type.flags & 2) { - return ts.createKeywordTypeNode(144); + return ts.createKeywordTypeNode(147); } if (type.flags & 4) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139); + return ts.createKeywordTypeNode(142); } if (type.flags & 8) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136); + return ts.createKeywordTypeNode(139); } if (type.flags & 64) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147); + return ts.createKeywordTypeNode(150); } if (type.flags & 16) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124); + return ts.createKeywordTypeNode(127); } if (type.flags & 1024 && !(type.flags & 1048576)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -28897,7 +29715,7 @@ var ts; if (type.flags & 256) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -28918,31 +29736,31 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143, ts.createKeywordTypeNode(140)); + return ts.createTypeOperatorNode(146, ts.createKeywordTypeNode(143)); } if (type.flags & 16384) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107); + return ts.createKeywordTypeNode(109); } if (type.flags & 32768) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142); + return ts.createKeywordTypeNode(145); } if (type.flags & 65536) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97); + return ts.createKeywordTypeNode(99); } if (type.flags & 131072) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133); + return ts.createKeywordTypeNode(136); } if (type.flags & 4096) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140); + return ts.createKeywordTypeNode(143); } if (type.flags & 67108864) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137); + return ts.createKeywordTypeNode(140); } if (isThisTypeParameter(type)) { if (context.flags & 4194304) { @@ -28956,10 +29774,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4) { ts.Debug.assert(!!(type.flags & 524288)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 || objectFlags & 3) { if (type.flags & 262144 && ts.contains(context.inferTypeParameters, type)) { @@ -28967,6 +29791,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined)); } if (context.flags & 4 && + type.flags & 262144 && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -28976,12 +29801,6 @@ var ts; ? symbolToTypeNode(type.symbol, context, 788968) : ts.createTypeReferenceNode(ts.createIdentifier("?"), undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes); - } if (type.flags & (1048576 | 2097152)) { var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -28989,7 +29808,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 174 : 175, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 ? 177 : 178, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -29050,15 +29869,12 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { - var isInstanceType = type === getInferredClassType(symbol) ? 788968 : 111551; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 : 111551; return symbolToTypeNode(symbol, context, isInstanceType); } - else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 210 && context.flags & 2048) || + else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 && context.flags & 2048) || symbol.flags & (384 | 512) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 111551); @@ -29073,22 +29889,7 @@ var ts; } } else { - if (!context.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -29100,7 +29901,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 || declaration.parent.kind === 246; + return declaration.parent.kind === 288 || declaration.parent.kind === 249; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return (!!(context.flags & 4096) || (context.visitedTypes && context.visitedTypes.has(typeId))) && @@ -29108,6 +29909,34 @@ var ts; } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32; + var id = ts.getObjectFlags(type) & 4 && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -29120,12 +29949,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170, context); return signatureNode; } } @@ -29138,7 +29967,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -29146,7 +29975,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137, arrayType); } else if (type.target.objectFlags & 8) { if (typeArguments.length > 0) { @@ -29160,12 +29989,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; @@ -29253,11 +30082,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -29304,7 +30133,7 @@ var ts; if (!(context.flags & 1)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), undefined); } - return ts.createKeywordTypeNode(121); + return ts.createKeywordTypeNode(124); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192); @@ -29315,24 +30144,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } var propertyName = symbolToName(propertySymbol, context, 111551, true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(56) : undefined; + var optionalToken = propertySymbol.flags & 16777216 ? ts.createToken(57) : undefined; if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -29343,18 +30177,28 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, undefined); - if (propertySymbol.valueDeclaration) { - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -29395,14 +30239,14 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 139 : 136); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 142 : 139); var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined); var typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context); if (!indexInfo.type && !(context.flags & 2097152)) { context.encounteredError = true; } context.approximateLength += (name.length + 4); - return ts.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.createToken(134)] : undefined, [indexingParameter], typeNode); + return ts.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.createToken(137)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -29413,7 +30257,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -29421,23 +30265,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 ? + var assertsModifier = typePredicate.kind === 2 || typePredicate.kind === 3 ? + ts.createToken(123) : + undefined; + var parameterName = typePredicate.kind === 1 || typePredicate.kind === 3 ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256) { - if (returnTypeNode && returnTypeNode.kind === 121) { + if (returnTypeNode && returnTypeNode.kind === 124) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121); + returnTypeNode = ts.createKeywordTypeNode(124); } context.approximateLength += 3; return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -29457,9 +30304,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 307); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -29469,15 +30316,14 @@ var ts; var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768; var dotDotDotToken = isRest ? ts.createToken(25) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : - parameterDeclaration.name.kind === 149 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216) : + parameterDeclaration.name.kind === 152 ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384; - var questionToken = isOptional ? ts.createToken(56) : undefined; + var questionToken = isOptional ? ts.createToken(57) : undefined; var parameterNode = ts.createParameter(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined); context.approximateLength += ts.symbolName(parameterSymbol).length + 3; return parameterNode; @@ -29485,21 +30331,21 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187) { + if (clone.kind === 190) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 | 16777216); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; - var firstIdentifier = getFirstIdentifier(node.expression); + var firstIdentifier = ts.getFirstIdentifier(accessExpression); var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 | 1048576, undefined, undefined, true); if (name) { context.tracker.trackSymbol(name, enclosingDeclaration, 111551); @@ -29507,6 +30353,9 @@ var ts; } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { var chain; var isTypeParameter = symbol.flags & 262144; if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64) && !(context.flags & 134217728)) { @@ -29536,6 +30385,11 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false); if (parentChain) { + if (parent.exports && parent.exports.get("export=") && + getSymbolIfSameReference(parent.exports.get("export="), symbol)) { + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -29606,7 +30460,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285); + var file = ts.getDeclarationOfKind(symbol, 288); if (file && file.moduleName !== undefined) { return file.moduleName; } @@ -29689,16 +30543,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216; } - var parent = chain[index - 1]; - if (!(context.flags & 16) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=") { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { return ts.createIndexedAccessTypeNode(LHS, ts.createLiteralTypeNode(ts.createLiteral(symbolName))); @@ -29730,6 +30600,9 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968, true); + if (!(result.kind & 75)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4) { var rawtext = result.escapedText; var i = 0; @@ -29775,9 +30648,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216; } @@ -29786,6 +30656,9 @@ var ts; context.flags ^= 16777216; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216); @@ -29813,12 +30686,872 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160, true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159, false); + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, false); + if (accessibleResult.accessibility === 0) { + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + ts.forEachEntry(symbolTable, function (symbol, name) { + var baseName = ts.unescapeLeadingUnderscores(name); + void getInternalSymbolName(symbol, baseName); + }); + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export="); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152) { + symbolTable = ts.createSymbolTable(); + symbolTable.set("export=", exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(undefined, id); })), undefined)])); + } + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0); + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), undefined)]); + } + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1) & ~2; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + var skipMembershipCheck = !isPrivate; + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default"; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + context.encounteredError = true; + return; + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 + || (symbol.flags & 16 && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152); + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 : 0) | (isDefault && !needsPostExportDefault ? 512 : 0); + var isConstMergedWithNS = symbol.flags & 1536 && + symbol.flags & (2 | 1 | 4) && + symbol.escapedName !== "export="; + var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); + if (symbol.flags & 16 || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + if (symbol.flags & (2 | 1 | 4) + && symbol.escapedName !== "export=" + && !(symbol.flags & 4194304) + && !(symbol.flags & 32) + && !isConstMergedWithNSPrintableAsSignatureMerge) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32) { + if (symbol.flags & 4) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if ((symbol.flags & (512 | 1024) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 && symbol.escapedName === "export=") { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(undefined, undefined, undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(undefined, undefined, false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0); + } + } + function includePrivateSymbol(symbol) { + if (ts.some(symbol.declarations, ts.isParameterDeclaration)) + return; + ts.Debug.assertDefined(deferredPrivates); + getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol); + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0; + if (additionalModifierFlags & 1 && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + newModifierFlags |= 1; + } + if (addingDeclare && !(newModifierFlags & 1) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + newModifierFlags |= 2; + } + if ((additionalModifierFlags & 512) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0, interfaceType, baseType, 164); + var constructSignatures = serializeSignatures(1, interfaceType, baseType, 165); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function getNamespaceMembersForSerialization(symbol) { + return !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304) || (p.escapedName === "prototype")); }); + } + function isTypeOnlyNamespace(symbol) { + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551); }); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = getNamespaceMembersForSerialization(symbol); + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 | 67108864))); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration(undefined, undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export="; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s); + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true); + includePrivateSymbol(target || s); + var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName; + return ts.createExportSpecifier(name === targetName ? undefined : targetName, name); + })))]); + addResult(ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), nsBody, 16), 0); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration(undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8); }), function (p) { + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + var flags = !(symbol.flags & 2) ? undefined + : isConstVariable(symbol) ? 2 + : 1; + var name = (needsPostExportDefault || !(symbol.flags & 4)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 : modifierFlags); + if (name !== localName && !isPrivate) { + addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + var decl = signatureToSignatureDeclarationHelper(sig, 243, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + if (!(symbol.flags & (512 | 1024) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + var fakespace = ts.createModuleDeclaration(undefined, undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16); + fakespace.flags ^= 8; + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8; + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, false, baseTypes[0]); }); + var staticMembers = symbol.flags & (16 | 512) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, true, staticBaseType); }); + var constructors = serializeSignatures(1, staticType, baseTypes[0], 161); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration(undefined, undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + verbatimTargetName = "default"; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); + switch (node.kind) { + case 252: + var isLocalImport = !(target.flags & 512); + addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863, false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0); + break; + case 251: + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0); + break; + case 254: + addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(ts.createIdentifier(localName), undefined), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0); + break; + case 255: + addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0); + break; + case 257: + addResult(ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0); + break; + case 261: + var specifier = node.parent.parent.moduleSpecifier; + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258: + serializeMaybeAliasAssignment(symbol); + break; + case 208: + case 193: + if (symbol.escapedName === "default" || symbol.escapedName === "export=") { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export="; + var isDefault = name === "default"; + var isExportAssignment = isExportEquals || isDefault; + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true); + if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) { + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863, true, true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863))); + } + else { + if (first_1 === expr) { + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration(undefined, undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + var varName = getUnusedName(name, symbol); + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 : 1); + } + else { + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2)); + addResult(statement, name === varName ? 1 : 0); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment(undefined, undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 | 32) && + !getIndexInfoOfType(typeToSerialize, 0) && + !getIndexInfoOfType(typeToSerialize, 1) && + !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1)) && + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 | 1920 | 2097152))) { + return []; + } + if (p.flags & 4194304 || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 && useAccessors) { + var result = []; + if (p.flags & 65536) { + result.push(ts.setTextRange(ts.createSetAccessor(undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter(undefined, undefined, undefined, "arg", undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768) { + result.push(ts.setTextRange(ts.createGetAccessor(undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + else if (p.flags & (4 | 3)) { + return ts.setTextRange(createProperty(undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 : 0) | staticFlag), name, p.flags & 16777216 ? ts.createToken(57) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 | 16)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216) { + decl.questionToken = ts.createToken(57); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 && + type.symbol === symbol) { + context.flags |= 1048576; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature(undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "x", undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter(undefined, undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter(undefined, undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = ts.getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863, true, true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; + } + if (baseType) { + var baseSigs = getSignaturesOfType(baseType, 1); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], false, false, true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0, 1]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2)); + addResult(statement, 0); + return ts.createExpressionWithTypeArguments(undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551, false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551, false)) { + reference = symbolToExpression(t.symbol, context, 788968); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (symbol) { + input = getNameCandidateWorker(symbol, input); + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getNameCandidateWorker(symbol, localName) { + if (localName === "default" || localName === "__class" || localName === "__function") { + var flags = context.flags; + context.flags |= 16777216; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; + } + if (localName === "default") { + localName = "_default"; + } + else if (localName === "export=") { + localName = "_exports"; + } + localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); + return localName; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + localName = getNameCandidateWorker(symbol, localName); + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 || typePredicate.kind === 3 ? ts.createToken(123) : undefined, typePredicate.kind === 1 || typePredicate.kind === 3 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512)); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4, predicate, sourceFile, writer); @@ -29863,8 +31596,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178; }); - if (node.kind === 243) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181; }); + if (node.kind === 246) { return getSymbolOfNode(node); } } @@ -29872,11 +31605,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 && + node.parent.kind === 249 && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 || ts.isAmbientModule(location); + return location.kind === 288 || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -29904,9 +31637,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -29918,17 +31651,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238) { + if (!declaration) { + declaration = symbol.declarations[0]; + } + if (declaration.parent && declaration.parent.kind === 241) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210: - case 197: - case 198: + case 213: + case 200: + case 201: if (context && !context.encounteredError && !(context.flags & 131072)) { context.encounteredError = true; } - return declaration.kind === 210 ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -29945,67 +31681,67 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 305: - case 312: - case 306: + case 308: + case 315: + case 309: return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187: + case 190: return isDeclarationVisible(node.parent.parent); - case 238: + case 241: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } + case 248: + case 244: case 245: - case 241: - case 242: + case 246: case 243: - case 240: - case 244: - case 249: + case 247: + case 252: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 249 && parent.kind !== 285 && parent.flags & 4194304)) { + !(node.kind !== 252 && parent.kind !== 288 && parent.flags & 8388608)) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); - case 155: - case 154: - case 159: - case 160: + case 158: case 157: - case 156: + case 162: + case 163: + case 160: + case 159: if (ts.hasModifier(node, 8 | 16)) { return false; } - case 158: - case 162: case 161: - case 163: - case 152: - case 246: + case 165: + case 164: case 166: - case 167: + case 155: + case 249: case 169: - case 165: case 170: - case 171: + case 172: + case 168: + case 173: case 174: - case 175: + case 177: case 178: + case 181: return isDeclarationVisible(node.parent); - case 251: - case 252: case 254: + case 255: + case 257: return false; - case 151: - case 285: - case 248: + case 154: + case 288: + case 251: return true; - case 255: + case 258: return false; default: return false; @@ -30014,14 +31750,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255) { + if (node.parent && node.parent.kind === 258) { exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false); } - else if (node.parent.kind === 258) { + else if (node.parent.kind === 261) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -30037,9 +31776,11 @@ var ts; } if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); + var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 | 788968 | 1920, undefined, undefined, false); - if (importSymbol) { + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -30087,6 +31828,8 @@ var ts; return !!target.immediateBaseConstraint; case 6: return !!getSymbolLinks(target).resolvedJSDocType; + case 7: + return !!target.resolvedTypeArguments; } return ts.Debug.assertNever(propertyName); } @@ -30098,12 +31841,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238: - case 239: + case 241: + case 242: + case 257: + case 256: + case 255: case 254: - case 253: - case 252: - case 251: return false; default: return true; @@ -30129,7 +31872,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 150 && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304); }); @@ -30172,7 +31915,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191, node.pos, node.end); + var result = ts.createNode(194, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10, node.pos, node.end); @@ -30187,23 +31930,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187: - case 276: + case 190: + case 279: return getSyntheticElementAccess(ancestor); - case 188: + case 191: return getSyntheticElementAccess(node.parent); - case 238: + case 241: return ancestor.initializer; - case 205: + case 208: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 && parent.kind === 185) { + if (node.kind === 190 && parent.kind === 188) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 || node.kind === 277) { + if (node.kind === 279 || node.kind === 280) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -30218,11 +31961,11 @@ var ts; if (!parentType || isTypeAny(parentType)) { return parentType; } - if (strictNullChecks && declaration.flags & 4194304 && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 8388608 && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185) { + if (pattern.kind === 188) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -30281,27 +32024,27 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 || expr.kind === 73 && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 || expr.kind === 75 && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 && expr.elements.length === 0; + return expr.kind === 191 && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 && - (node.parent.kind === 197 || node.parent.kind === 198) && + return node.kind === 155 && + (node.parent.kind === 200 || node.parent.kind === 201) && !!getContextualType(node.parent); } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231) { var forOfStatement = declaration.parent.parent; return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } @@ -30315,8 +32058,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 4194304)) { + declaration.kind === 241 && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 8388608)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } @@ -30324,10 +32067,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152) { + if (declaration.kind === 155) { var func = declaration.parent; - if (func.kind === 160 && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159); + if (func.kind === 163 && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -30384,12 +32127,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -30407,6 +32152,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; if (definedInMethod) { var propType = getTypeOfAssignmentDeclarationPropertyOfBaseType(symbol); @@ -30431,9 +32179,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -30523,9 +32271,9 @@ var ts; } function isDeclarationInConstructor(expression) { var thisContainer = ts.getThisContainer(expression, false); - return thisContainer.kind === 158 || - thisContainer.kind === 240 || - (thisContainer.kind === 197 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 || + thisContainer.kind === 243 || + (thisContainer.kind === 200 && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -30593,7 +32341,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType; } @@ -30609,7 +32357,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 + return pattern.kind === 188 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -30636,7 +32384,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 ? root.parent : root; + var memberDeclaration = root.kind === 155 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -30683,22 +32431,26 @@ var ts; return type_1; } if (!pushTypeResolution(symbol, 0)) { - if (symbol.flags & 512) { + if (symbol.flags & 512 && !(symbol.flags & 67108864)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 255) { + if (declaration.kind === 258) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -30736,11 +32488,14 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } if (!popTypeResolution()) { - if (symbol.flags & 512) { + if (symbol.flags & 512 && !(symbol.flags & 67108864)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -30749,7 +32504,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159) { + if (accessor.kind === 162) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -30776,30 +32531,40 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159); - var setter = ts.getDeclarationOfKind(symbol, 160); + if (!pushTypeResolution(symbol, 0)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162); + var setter = ts.getDeclarationOfKind(symbol, 163); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0)) { - return errorType; - } - var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } else { if (setter) { @@ -30808,25 +32573,21 @@ var ts; } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + } } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 ? baseConstructorType : + baseConstructorType.flags & 2097152 ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -30834,18 +32595,9 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -30857,8 +32609,9 @@ var ts; if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 || - declaration.kind === 190 && declaration.parent.kind === 205) { + else if (declaration.kind === 208 || + (declaration.kind === 193 || declaration.kind === 194) && + declaration.parent.kind === 208) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -30918,7 +32671,7 @@ var ts; error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); return errorType; } - if (noImplicitAny && (declaration.kind !== 152 || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } return anyType; @@ -30991,56 +32744,67 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; + if (node && ts.isBinaryExpression(node)) { + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 || assignmentKind === 3) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241: - case 210: - case 242: - case 161: - case 162: - case 156: - case 166: - case 167: - case 295: - case 240: - case 157: - case 197: - case 198: + case 244: + case 213: + case 245: + case 164: + case 165: + case 159: + case 169: + case 170: + case 298: case 243: - case 311: - case 312: - case 306: - case 305: - case 182: - case 176: + case 160: + case 200: + case 201: + case 246: + case 314: + case 315: + case 309: + case 308: + case 185: + case 179: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182) { + if (node.kind === 185) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176) { + else if (node.kind === 179) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 || node.kind === 210 || node.kind === 242) && + (node.kind === 244 || node.kind === 213 || node.kind === 245 || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245); + ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 || - node.kind === 241 || - node.kind === 210 || + if (node.kind === 245 || + node.kind === 244 || + node.kind === 213 || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -31055,19 +32819,19 @@ var ts; var signatures = getSignaturesOfType(type, 1); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1).length > 0) { + if (getSignaturesOfType(type, 1).length > 0) { return true; } if (type.flags & 8650752) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -31150,21 +32914,15 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 && areAllOuterTypeParametersApplied(originalBaseType)) { - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { @@ -31193,12 +32951,18 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } function isValidBaseType(type) { + if (type.flags & 262144) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } return !!(type.flags & (524288 | 67108864 | 1)) && !isGenericMappedType(type) || !!(type.flags & 2097152) && ts.every(type.types, isValidBaseType); } @@ -31206,7 +32970,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -31235,8 +32999,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242) { - if (declaration.flags & 64) { + if (declaration.kind === 245) { + if (declaration.flags & 128) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -31257,9 +33021,14 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 ? 1 : 2; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (outerTypeParameters || localTypeParameters || kind === 1 || !isThislessInterface(symbol)) { @@ -31270,7 +33039,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -31307,10 +33076,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205) { + else if (expr.kind === 208) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -31318,18 +33087,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304); + return !(member.flags & 8388608); } switch (expr.kind) { case 10: case 8: + case 14: return true; - case 203: - return expr.operator === 39 && + case 206: + return expr.operator === 40 && expr.operand.kind === 8; - case 73: + case 75: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205: + case 208: return isStringConcatExpression(expr); default: return false; @@ -31343,10 +33113,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244) { + if (declaration.kind === 247) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1; } if (!isLiteralEnumMember(member)) { @@ -31370,7 +33140,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244) { + if (declaration.kind === 247) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -31437,23 +33207,23 @@ var ts; } function isThislessType(node) { switch (node.kind) { - case 121: - case 144: - case 139: - case 136: - case 147: case 124: - case 140: - case 137: - case 107: + case 147: case 142: - case 97: - case 133: - case 183: + case 139: + case 150: + case 127: + case 143: + case 140: + case 109: + case 145: + case 99: + case 136: + case 186: return true; - case 170: + case 173: return isThislessType(node.elementType); - case 165: + case 168: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -31469,7 +33239,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -31478,14 +33248,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155: - case 154: - return isThislessVariableLikeDeclaration(declaration); - case 157: - case 156: case 158: - case 159: + case 157: + return isThislessVariableLikeDeclaration(declaration); case 160: + case 159: + case 161: + case 162: + case 163: return isThislessFunctionLikeDeclaration(declaration); } } @@ -31526,9 +33296,12 @@ var ts; return !!(type.flags & 8576); } function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 && @@ -31575,7 +33348,8 @@ var ts; var links = getNodeLinks(decl); if (!links.resolvedSymbol) { links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -31585,9 +33359,9 @@ var ts; var earlySymbol = earlySymbols && earlySymbols.get(memberName); if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) { var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0, memberName, 4096); } lateSymbol.nameType = type; @@ -31624,12 +33398,27 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 + || assignmentKind === 4 + || assignmentKind === 9 + || assignmentKind === 6; + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; } function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 + return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers") : symbol.members || emptySymbols; } @@ -31652,7 +33441,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -31715,12 +33504,12 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } - function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { - var sig = new Signature(checker); + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) { + var sig = new Signature(checker, flags); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; @@ -31728,14 +33517,12 @@ var ts; sig.resolvedReturnType = resolvedReturnType; sig.resolvedTypePredicate = resolvedTypePredicate; sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasLiteralTypes = hasLiteralTypes; sig.target = undefined; sig.mapper = undefined; return sig; } function cloneSignature(sig) { - var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); + var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.flags & 3); result.target = sig.target; result.mapper = sig.mapper; return result; @@ -31747,13 +33534,22 @@ var ts; result.mapper = undefined; return result; } + function getOptionalCallSignature(signature) { + return signatureIsOptionalCall(signature) ? signature : + (signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature))); + } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.flags |= 4; + return result; + } function getExpandedParameters(sig) { - if (sig.hasRestParameter) { + if (signatureHasRestParameter(sig)) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -31773,7 +33569,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, undefined, 0, false, false)]; + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, undefined, 0, 0)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -31856,7 +33652,7 @@ var ts; if (!ts.length(result) && indexWithLengthOverOne !== -1) { var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -31868,8 +33664,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -31920,9 +33716,7 @@ var ts; var params = combineUnionParameters(left, right); var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter); var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); - var hasRestParam = left.hasRestParameter || right.hasRestParameter; - var hasLiteralTypes = left.hasLiteralTypes || right.hasLiteralTypes; - var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, undefined, undefined, minArgCount, hasRestParam, hasLiteralTypes); + var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, undefined, undefined, minArgCount, (left.flags | right.flags) & 3); result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); return result; } @@ -31985,7 +33779,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; if (!mixinFlags[i]) { var signatures = getSignaturesOfType(t, 1); @@ -32003,24 +33797,24 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, false, false, false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false); @@ -32071,13 +33865,17 @@ var ts; setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } if (symbol.flags & 32) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor")); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor")) : ts.emptyArray; + if (symbol.flags & 16) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, undefined, sig.minArgumentCount, sig.flags & 3) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -32204,8 +34002,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); - return constraintDeclaration.kind === 180 && - constraintDeclaration.operator === 130; + return constraintDeclaration.kind === 183 && + constraintDeclaration.operator === 133; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -32223,8 +34021,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 ? 2 : 1 : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 39 ? 8 : 4 : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 ? 2 : 1 : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 ? 8 : 4 : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -32417,11 +34215,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; if (t.flags & 63176704) { var constraint = getConstraintOfType(t); while (constraint && constraint.flags & (262144 | 4194304 | 16777216)) { @@ -32429,6 +34227,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908) { @@ -32437,8 +34238,8 @@ var ts; } if (constraints && (targetIsUnion || hasDisjointDomainType)) { if (hasDisjointDomainType) { - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908) { constraints = ts.append(constraints, t); } @@ -32511,8 +34312,8 @@ var ts; if (t.flags & 3145728) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -32813,10 +34614,10 @@ var ts; return result; } function isJSDocOptionalParameter(node) { - return ts.isInJSFile(node) && (node.type && node.type.kind === 294 + return ts.isInJSFile(node) && (node.type && node.type.kind === 297 || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -32849,13 +34650,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294; - } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297; } - function createThisTypePredicate(type) { - return { kind: 0, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } function getMinTypeArgumentCount(typeParameters) { var minTypeArgumentCount = 0; @@ -32896,7 +34694,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var hasLiteralTypes = false; + var flags = 0; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -32922,8 +34720,8 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183) { - hasLiteralTypes = true; + if (type && type.kind === 186) { + flags |= 2; } var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || param.initializer || param.questionToken || param.dotDotDotToken || @@ -32934,21 +34732,23 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 159 || declaration.kind === 160) && + if ((declaration.kind === 162 || declaration.kind === 163) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 ? 160 : 159; + var otherKind = declaration.kind === 162 ? 163 : 162; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 ? + var classType = declaration.kind === 161 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); - var hasRestLikeParameter = ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters); - links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, undefined, undefined, minArgumentCount, hasRestLikeParameter, hasLiteralTypes); + if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { + flags |= 1; + } + links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, undefined, undefined, minArgumentCount, flags); } return links.resolvedSignature; } @@ -32993,13 +34793,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73: + case 75: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155: - case 157: - case 159: + case 158: case 160: - return node.name.kind === 150 + case 162: + case 163: + return node.name.kind === 153 && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -33039,9 +34839,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -33070,13 +34867,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 ? + createTypePredicate(node.assertsModifier ? 2 : 0, undefined, undefined, type) : + createTypePredicate(node.assertsModifier ? 3 : 1, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -33086,8 +34880,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signatureIsOptionalCall(signature)) { + type = addOptionalTypeMarker(type); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -33112,7 +34908,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158) { + if (declaration.kind === 161) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -33122,12 +34918,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -33142,7 +34938,7 @@ var ts; return tryGetRestTypeOfSignature(signature) || anyType; } function tryGetRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType; return restType && getIndexTypeOfType(restType, 1); @@ -33206,7 +35002,7 @@ var ts; function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0; - var isConstructor = kind === 158 || kind === 162 || kind === 167; + var isConstructor = kind === 161 || kind === 165 || kind === 170; var type = createObjectType(16); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -33220,7 +35016,7 @@ var ts; return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 136 : 139; + var syntaxKind = kind === 1 ? 139 : 142; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -33254,9 +35050,9 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177) { + if (declaration.parent.kind === 180) { var grandParent = declaration.parent.parent; - if (grandParent.kind === 165) { + if (grandParent.kind === 168) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -33273,7 +35069,7 @@ var ts; } } } - else if (grandParent.kind === 152 && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -33296,7 +35092,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -33325,8 +35121,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -33341,7 +35137,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -33350,13 +35146,47 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; + return type; + } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; return type; } + function getTypeArguments(type) { + var _a, _b; + if (!type.resolvedTypeArguments) { + if (!pushTypeResolution(type, 7)) { + return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; + } + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + if (popTypeResolution()) { + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + else { + type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray; + error(type.node || currentNode, type.target.symbol + ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves + : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol)); + } + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -33366,20 +35196,23 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, undefined, 2); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { return errorType; } } - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + if (node.kind === 168 && isAliasedType(node)) { + return createDeferredTypeReference(type, node, undefined); + } + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -33395,27 +35228,27 @@ var ts; } return instantiation; } - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165: + case 168: return node.typeName; - case 212: + case 215: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -33430,13 +35263,15 @@ var ts; return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 | 64)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288) { + return getTypeFromTypeAliasReference(node, symbol); } var res = tryGetDeclaredTypeOfSymbol(symbol); if (res) { @@ -33444,46 +35279,37 @@ var ts; res.flags & 262144 ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 111551 && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; - } - resolveTypeReferenceName(getTypeReferenceName(node), 788968); - return getTypeOfSymbol(symbol); - } - function getJSDocTypeReference(node, symbol, typeArguments) { - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; + if (symbol.flags & 111551 && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSDocValueReference(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + resolveTypeReferenceName(getTypeReferenceName(node), 788968); + return getTypeOfSymbol(symbol); + } } + return errorType; } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 | 64)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + function getTypeFromJSDocValueReference(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType; + if (symbol.valueDeclaration) { + var decl = ts.getRootDeclaration(symbol.valueDeclaration); + var isRequireAlias = false; + if (ts.isVariableDeclaration(decl) && decl.initializer) { + var expr = decl.initializer; + while (ts.isPropertyAccessExpression(expr)) { + expr = expr.expression; } + isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, true) && !!valueType.symbol; } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); + var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol; + if (isRequireAlias || node.kind === 187 || isDelayedMergeClass) { + typeType = getTypeReferenceType(node, valueType.symbol); } } + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } function getSubstitutionType(typeVariable, substitute) { if (substitute.flags & 3 || substitute === typeVariable) { @@ -33501,7 +35327,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 && node.elementTypes.length === 1; + return node.kind === 174 && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -33510,9 +35336,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 298) { + while (node && !ts.isStatement(node) && node.kind !== 301) { var parent = node.parent; - if (parent.kind === 176 && node === parent.trueType) { + if (parent.kind === 179 && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -33523,7 +35349,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152) && (node.kind === 165 || node.kind === 184); + return !!(node.flags & 4194304) && (node.kind === 168 || node.kind === 187); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -33560,10 +35386,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -33575,7 +35401,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -33627,9 +35453,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241: - case 242: case 244: + case 245: + case 247: return declaration; } } @@ -33744,15 +35570,52 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, undefined); + } + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181: + case 168: + case 177: + case 178: + case 184: + case 179: + case 183: + return isAliasedType(parent); + case 246: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, undefined); + } + else { + var elementTypes = node.kind === 173 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134; + return ts.isTypeOperatorNode(node) && node.operator === 137; } function createTupleTypeOfArity(arity, minLength, hasRestElement, readonly, associatedNames) { var typeParameters; @@ -33782,7 +35645,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -33816,26 +35679,12 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 && n !== restElement_1; }) + 1; - var elementTypes = ts.map(node.elementTypes, function (n) { - var type = getTypeFromTypeNode(n); - return n === restElement_1 && getIndexTypeOfType(type, 1) || type; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -33881,8 +35730,8 @@ var ts; return includes; } function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -33911,8 +35760,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { var estimatedCount = (count / (len - i)) * len; @@ -33985,10 +35834,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 || pred.kind === 3) { continue; } if (first) { @@ -34005,14 +35854,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { if (types.length === 0) { @@ -34068,8 +35913,8 @@ var ts; return includes; } function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -34306,17 +36151,19 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130: + case 133: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143: - links.resolvedType = node.type.kind === 140 + case 146: + links.resolvedType = node.type.kind === 143 ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134: + case 137: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } return links.resolvedType; @@ -34346,7 +36193,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -34356,13 +36203,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 101); + markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 103); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -34493,13 +36340,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 - ? accessNode.argumentExpression - : accessNode.kind === 181 - ? accessNode.indexType - : accessNode.kind === 150 - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 ? accessNode.argumentExpression : + accessNode.kind === 184 ? accessNode.indexType : + accessNode.kind === 153 ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 | 131072); @@ -34592,7 +36436,7 @@ var ts; if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) { indexType = stringType; } - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184) && isGenericObjectType(objectType)) { if (objectType.flags & 3) { return objectType; } @@ -34780,7 +36624,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 : node.flags & 2097152 ? 111551 | 788968 : 788968; + var targetMeaning = node.isTypeOf ? 111551 : node.flags & 4194304 ? 111551 | 788968 : 788968; var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { links.resolvedSymbol = unknownSymbol; @@ -34802,11 +36646,11 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { var errorMessage = targetMeaning === 111551 @@ -34824,10 +36668,10 @@ var ts; var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; if (meaning === 111551) { - return links.resolvedType = getTypeOfSymbol(symbol); + return getTypeOfSymbol(symbol); } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); + return getTypeReferenceType(node, resolvedSymbol); } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -34850,7 +36694,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 137) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -35025,12 +36873,22 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245)) { if (!ts.hasModifier(container, 32) && - (container.kind !== 158 || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + var host = node.flags & 4194304 ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -35043,87 +36901,87 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121: - case 290: - case 291: + case 124: + case 293: + case 294: return anyType; - case 144: + case 147: return unknownType; - case 139: + case 142: return stringType; - case 136: + case 139: return numberType; - case 147: + case 150: return bigintType; - case 124: + case 127: return booleanType; - case 140: + case 143: return esSymbolType; - case 107: + case 109: return voidType; - case 142: + case 145: return undefinedType; - case 97: + case 99: return nullType; - case 133: + case 136: return neverType; - case 137: - return node.flags & 65536 ? anyType : nonPrimitiveType; - case 179: - case 101: + case 140: + return node.flags & 131072 ? anyType : nonPrimitiveType; + case 182: + case 103: return getTypeFromThisTypeNode(node); - case 183: + case 186: return getTypeFromLiteralTypeNode(node); - case 165: + case 168: return getTypeFromTypeReference(node); - case 164: - return booleanType; - case 212: + case 167: + return node.assertsModifier ? voidType : booleanType; + case 215: return getTypeFromTypeReference(node); - case 168: - return getTypeFromTypeQueryNode(node); - case 170: - return getTypeFromArrayTypeNode(node); case 171: - return getTypeFromTupleTypeNode(node); - case 172: - return getTypeFromOptionalTypeNode(node); + return getTypeFromTypeQueryNode(node); + case 173: case 174: - return getTypeFromUnionTypeNode(node); + return getTypeFromArrayOrTupleTypeNode(node); case 175: + return getTypeFromOptionalTypeNode(node); + case 177: + return getTypeFromUnionTypeNode(node); + case 178: return getTypeFromIntersectionTypeNode(node); - case 292: + case 295: return getTypeFromJSDocNullableTypeNode(node); - case 294: + case 297: return addOptionality(getTypeFromTypeNode(node.type)); - case 178: - case 173: - case 293: - case 289: - return getTypeFromTypeNode(node.type); + case 181: case 296: + case 292: + return getTypeFromTypeNode(node.type); + case 176: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299: return getTypeFromJSDocVariadicType(node); - case 166: - case 167: case 169: - case 299: - case 295: - case 300: + case 170: + case 172: + case 302: + case 298: + case 303: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180: + case 183: return getTypeFromTypeOperatorNode(node); - case 181: + case 184: return getTypeFromIndexedAccessTypeNode(node); - case 182: + case 185: return getTypeFromMappedTypeNode(node); - case 176: + case 179: return getTypeFromConditionalTypeNode(node); - case 177: + case 180: return getTypeFromInferTypeNode(node); - case 184: + case 187: return getTypeFromImportTypeNode(node); - case 73: - case 149: + case 75: + case 152: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -35208,20 +37066,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -35233,7 +37078,7 @@ var ts; tp.mapper = mapper; } } - var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), undefined, undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasLiteralTypes); + var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), undefined, undefined, signature.minArgumentCount, signature.flags & 3); result.target = signature; result.mapper = mapper; return result; @@ -35260,13 +37105,13 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -35282,7 +37127,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 || target.symbol.flags & 2048) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -35292,13 +37137,14 @@ var ts; } } if (typeParameters.length) { - var combinedMapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -35306,15 +37152,15 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 || - node.parent.kind === 165 && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 184 && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.kind === 152 || + node.parent.kind === 168 && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 || n.kind === 176 && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 || n.kind === 179 && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -35323,12 +37169,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179: + case 182: return !!tp.isThisType; - case 73: + case 75: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168: + case 171: return true; } return !!ts.forEachChild(node, containsReference); @@ -35372,7 +37218,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -35455,15 +37301,18 @@ var ts; var objectFlags = type.objectFlags; if (objectFlags & 16) { return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -35520,34 +37369,34 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197: - case 198: - case 157: - case 240: + case 200: + case 201: + case 160: + case 243: return isContextSensitiveFunctionLikeDeclaration(node); - case 189: + case 192: return ts.some(node.properties, isContextSensitive); - case 188: + case 191: return ts.some(node.elements, isContextSensitive); - case 206: + case 209: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205: - return node.operatorToken.kind === 55 && + case 208: + return (node.operatorToken.kind === 56 || node.operatorToken.kind === 60) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276: + case 279: return isContextSensitive(node.initializer); - case 196: + case 199: return isContextSensitive(node.expression); - case 269: + case 272: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268: { + case 271: { var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 271: { + case 274: { var expression = node.expression; return !!expression && isContextSensitive(expression); } @@ -35564,7 +37413,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198) { + if (node.kind !== 201) { var parameter = ts.firstOrUndefined(node.parameters); if (!(parameter && ts.parameterIsThisKeyword(parameter))) { return true; @@ -35573,7 +37422,7 @@ var ts; return hasContextSensitiveReturnExpression(node); } function hasContextSensitiveReturnExpression(node) { - return !!node.body && node.body.kind !== 219 && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -35653,23 +37502,23 @@ var ts; return true; } switch (node.kind) { - case 271: - case 196: + case 274: + case 199: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205: + case 208: switch (node.operatorToken.kind) { - case 60: + case 62: case 27: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189: + case 192: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188: + case 191: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269: + case 272: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198: + case 201: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -35830,16 +37679,16 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271: + case 274: return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11: if (child.containsOnlyTriviaWhiteSpaces) { break; } return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261: - case 262: + case 264: case 265: + case 268: return { errorNode: child, innerExpression: child, nameType: nameType }; default: return ts.Debug.assertNever(child, "Found invalid jsx child"); @@ -35976,11 +37825,11 @@ var ts; } _b = prop.kind; switch (_b) { + case 163: return [3, 2]; + case 162: return [3, 2]; case 160: return [3, 2]; - case 159: return [3, 2]; - case 157: return [3, 2]; - case 277: return [3, 2]; - case 276: return [3, 4]; + case 280: return [3, 2]; + case 279: return [3, 4]; } return [3, 6]; case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -36010,14 +37859,14 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, 0, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; + return compareSignaturesRelated(source, target, 0, ignoreReturnTypes, false, undefined, undefined, compareTypesAssignable) !== 0; } function isAnySignature(s) { return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 && - s.hasRestParameter && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && + signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && isTypeAny(getReturnTypeOfSignature(s)); } - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { if (source === target) { return -1; } @@ -36039,8 +37888,8 @@ var ts; return 0; } var kind = target.declaration ? target.declaration.kind : 0; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 && - kind !== 156 && kind !== 158; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 && + kind !== 159 && kind !== 161; var result = -1; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -36064,10 +37913,10 @@ var ts; var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : getTypeAtPosition(target, i); var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304); var related = callbacks ? - compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 : 1, false, reportErrors, errorReporter, compareTypes) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 : 1, false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -36078,13 +37927,15 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol)) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol)) + : getReturnTypeOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { var sourceTypePredicate = getTypePredicateOfSignature(source); @@ -36101,6 +37952,9 @@ var ts; else { result &= callbackCheck === 1 && compareTypes(targetReturnType, sourceReturnType, false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -36113,7 +37967,7 @@ var ts; } return 0; } - if (source.kind === 1) { + if (source.kind === 1 || source.kind === 3) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -36122,7 +37976,9 @@ var ts; return 0; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0; if (related === 0 && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -36167,12 +38023,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 && errorReporter)) { - return relation === 1; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4) && entry & 2 && errorReporter)) { + return !!(entry & 1); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) { - enumRelation.set(id, 3); + enumRelation.set(id, 2 | 4); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -36183,7 +38039,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64)); - enumRelation.set(id, 3); + enumRelation.set(id, 2 | 4); } else { enumRelation.set(id, 2); @@ -36257,9 +38113,9 @@ var ts; return true; } if (source.flags & 524288 && target.flags & 524288) { - var related = relation.get(getRelationKey(source, target, relation)); + var related = relation.get(getRelationKey(source, target, false, relation)); if (related !== undefined) { - return related === 1; + return !!(related & 1); } } if (source.flags & 66846720 || target.flags & 66846720) { @@ -36280,9 +38136,14 @@ var ts; var depth = 0; var expandingFlags = 0; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -36323,8 +38184,119 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; + lastSkippedInfo = undefined; + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + reportRelationError.apply(void 0, __spreadArrays([undefined], info)); + } + return; + } + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + if (path.length === 0) { + path = "" + str; + } + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + reportRelationError.apply(void 0, __spreadArrays([undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -36337,6 +38309,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -36355,8 +38329,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -36452,11 +38426,11 @@ var ts; return 0; } var result = 0; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); var isIntersectionConstituent = !!isApparentIntersectionConstituent; if (source.flags & 1048576) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), isIntersectionConstituent) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068)) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068)); } else { @@ -36479,30 +38453,34 @@ var ts; } } else if (source.flags & 2097152) { - result = someTypeRelatedToType(source, target, false, true); + result = someTypeRelatedToType(source, target, false); } if (!result && (source.flags & 66846720 || target.flags & 66846720)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152) { - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + if (!result && source.flags & (2097152 | 262144)) { + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576)); + if (constraint && (source.flags & 2097152 || target.flags & 1048576)) { + if (everyType(constraint, function (c) { return c !== source; })) { + if (result = isRelatedTo(constraint, target, false, undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 && target.flags & 524288) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 && target.flags & 131068) { @@ -36521,6 +38499,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; return result; } reportRelationError(headMessage, source, target); @@ -36555,13 +38534,16 @@ var ts; if (discriminant) { return hasExcessProperties(source, discriminant, undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { var errorTarget = filterType(target, isExcessPropertyCheckTarget); if (!errorNode) return { value: ts.Debug.fail() }; if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) { + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -36589,9 +38571,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -36722,14 +38704,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { + function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; if (source.flags & 1048576 && containsType(sourceTypes, target)) { return -1; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, undefined, isIntersectionConstituent); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); if (related) { return related; } @@ -36794,37 +38776,26 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } function recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) { if (overflow) { return 0; } - var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2) { + var id = getRelationKey(source, target, isIntersectionConstituent, relation); + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 && !(entry & 4)) { } else { if (outofbandVarianceMarkerHandler) { - if (source.flags & (524288 | 16777216) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24; + if (saved & 8) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 ? -1 : 0; + return entry & 1 ? -1 : 0; } } if (!maybeKeys) { @@ -36854,19 +38825,31 @@ var ts; expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 : 8; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 || depth === 0) { for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1); + relation.set(maybeKeys[i], 1 | propagatingVarianceFlags); } maybeCount = maybeStart; } } else { - relation.set(id, reportErrors ? 3 : 2); + relation.set(id, (reportErrors ? 4 : 0) | 2 | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -36906,7 +38889,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); if (source.flags & (524288 | 16777216) && source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { @@ -36980,7 +38963,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -36990,7 +38973,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -36998,35 +38981,44 @@ var ts; var constraint = getConstraintOfType(source); if (!constraint || (source.flags & 262144 && constraint.flags & 1)) { if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } else if (result = isRelatedTo(constraint, target, false, undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } else if (source.flags & 16777216) { if (target.flags & 16777216) { - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 | 128); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -37035,14 +39027,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -37055,7 +39047,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -37071,7 +39063,7 @@ var ts; if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target && !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) { var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -37088,7 +39080,7 @@ var ts; return 0; } if (source.flags & (524288 | 2097152) && target.flags & 524288) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors); @@ -37103,7 +39095,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; } else if (result) { return result; @@ -37126,7 +39118,7 @@ var ts; } if (ts.some(variances, function (v) { return !!(v & 24); })) { originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -37136,7 +39128,7 @@ var ts; return 0; } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -37191,11 +39183,11 @@ var ts; } var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -37208,8 +39200,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -37222,9 +39214,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } var result = -1; for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) { @@ -37341,7 +39333,7 @@ var ts; var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0; } @@ -37373,8 +39365,8 @@ var ts; if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, false)) { @@ -37384,8 +39376,8 @@ var ts; else { reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } } @@ -37396,7 +39388,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -37421,8 +39413,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -37434,10 +39427,12 @@ var ts; } } var properties = target.flags & 1048576 ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { @@ -37498,10 +39493,11 @@ var ts; } } var result = -1; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 && ts.getObjectFlags(target) & 64 && source.symbol === target.symbol) { for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0; } @@ -37510,7 +39506,7 @@ var ts; } else if (sourceSignatures.length === 1 && targetSignatures.length === 1) { var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -37518,10 +39514,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -37534,8 +39530,20 @@ var ts; } return result; } - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0, false, reportErrors, reportError, isRelatedTo); + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0, false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -37597,7 +39605,7 @@ var ts; return indexInfoRelatedTo(sourceInfo, targetInfo, reportErrors); } if (isGenericMappedType(source)) { - return (kind === 0 && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); + return kind === 0 ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0; } if (isObjectTypeWithInferableIndex(source)) { var related = -1; @@ -37710,7 +39718,7 @@ var ts; if (!variances) { cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -37735,7 +39743,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -37758,13 +39766,16 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -37783,17 +39794,18 @@ var ts; } return result; } - function getRelationKey(source, target, relation) { + function getRelationKey(source, target, isIntersectionConstituent, relation) { if (relation === identityRelation && source.id > target.id) { var temp = source; source = target; target = temp; } + var intersection = isIntersectionConstituent ? "&" : ""; if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { var typeParameters = []; - return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + intersection; } - return source.id + "," + target.id; + return source.id + "," + target.id + intersection; } function forEachProperty(prop, callback) { if (ts.getCheckFlags(prop) & 6) { @@ -37955,19 +39967,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 : + source.type === target.type ? -1 : + source.type && target.type ? compareTypes(source.type, target.type) : + 0; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -38002,13 +40017,13 @@ var ts; return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -38088,7 +40103,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -38103,8 +40118,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -38160,13 +40175,30 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function isNotOptionalTypeMarker(type) { + return type !== optionalType; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function getOptionalExpressionType(exprType, expression) { + return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) : + ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : + exprType; + } function isCoercibleUnderDoubleEquals(source, target) { return ((source.flags & (8 | 4 | 512)) !== 0) && ((target.flags & (8 | 4 | 16)) !== 0); } function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8); @@ -38308,7 +40340,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -38334,7 +40366,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -38363,12 +40395,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205: - case 155: - case 154: + case 208: + case 158: + case 157: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 152: + case 155: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -38383,22 +40415,22 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187: + case 190: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { return; } break; - case 295: + case 298: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240: - case 157: - case 156: - case 159: + case 243: case 160: - case 197: - case 198: + case 159: + case 162: + case 163: + case 200: + case 201: if (noImplicitAny && !declaration.name) { if (wideningKind === 1) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -38412,7 +40444,7 @@ var ts; wideningKind === 1 ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182: + case 185: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -38453,8 +40485,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -38523,13 +40554,19 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 || - objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations || objectFlags & 32 || type.flags & 3145728 && !(type.flags & 1024) && couldUnionOrIntersectionContainTypeVariables(type)); @@ -38583,10 +40620,10 @@ var ts; return undefined; } if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames); @@ -38701,10 +40738,7 @@ var ts; } target = getUnionType(targets); if (sources.length === 0) { - var savePriority = priority; - priority |= 1; - inferFromTypes(source, target); - priority = savePriority; + inferWithPriority(source, target, 1); return; } source = getUnionType(sources); @@ -38772,8 +40806,9 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) { - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 && target.flags & 4194304) { contravariant = !contravariant; @@ -38783,10 +40818,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - var savePriority = priority; - priority |= 32; - inferFromTypes(empty, target.type); - priority = savePriority; + inferWithPriority(empty, target.type, 32); contravariant = !contravariant; } else if (source.flags & 8388608 && target.flags & 8388608) { @@ -38827,6 +40859,12 @@ var ts; } } } + function inferWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromTypes(source, target); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -38892,6 +40930,18 @@ var ts; } return undefined; } + function getSingleTypeVariableFromIntersectionTypes(types) { + var typeVariable; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var type = types_13[_i]; + var t = type.flags & 2097152 && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + if (!t || typeVariable && t !== typeVariable) { + return undefined; + } + typeVariable = t; + } + return typeVariable; + } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; if (targetFlags & 1048576) { @@ -38917,6 +40967,13 @@ var ts; } } } + if (typeVariableCount === 0) { + var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); + if (intersectionTypeVariable) { + inferWithPriority(source, intersectionTypeVariable, 1); + } + return; + } if (typeVariableCount === 1 && !inferenceCircularity) { var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; }); if (unmatched.length) { @@ -38937,15 +40994,12 @@ var ts; } } if (targetFlags & 2097152 ? typeVariableCount === 1 : typeVariableCount > 0) { - var savePriority = priority; - priority |= 1; for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferFromTypes(source, t); + inferWithPriority(source, t, 1); } } - priority = savePriority; } } function inferToMappedType(source, target, constraintType) { @@ -38962,20 +41016,15 @@ var ts; if (inference && !inference.isFixed) { var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); if (inferredType) { - var savePriority = priority; - priority |= ts.getObjectFlags(source) & 1048576 ? - 4 : 2; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 1048576 ? + 4 : + 2); } } return true; } if (constraintType.flags & 262144) { - var savePriority = priority; - priority |= 8; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; + inferWithPriority(getIndexType(source), constraintType, 8); var extendedConstraint = getConstraintOfType(constraintType); if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) { return true; @@ -39007,6 +41056,10 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } if (isGenericMappedType(source) && isGenericMappedType(target)) { inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); @@ -39033,10 +41086,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -39075,7 +41128,7 @@ var ts; if (!skipParameters) { var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0; - bivariant = bivariant || kind === 157 || kind === 156 || kind === 158; + bivariant = bivariant || kind === 160 || kind === 159 || kind === 161; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -39227,7 +41280,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277) { + if (node.parent.kind === 280) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -39244,20 +41297,20 @@ var ts; return links.resolvedSymbol; } function isInTypeQuery(node) { - return !!ts.findAncestor(node, function (n) { return n.kind === 168 ? true : n.kind === 73 || n.kind === 149 ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 ? true : n.kind === 75 || n.kind === 152 ? false : "quit"; }); } function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73: + case 75: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101: + case 103: return "0"; - case 214: - case 196: + case 217: + case 199: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190: - case 191: + case 193: + case 194: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -39268,24 +41321,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196: - case 214: + case 199: + case 217: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73: - return target.kind === 73 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 || target.kind === 187) && + case 75: + return target.kind === 75 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 || target.kind === 190) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); + case 103: + return target.kind === 103; case 101: return target.kind === 101; - case 99: - return target.kind === 99; - case 214: - case 196: + case 217: + case 199: return isMatchingReference(source.expression, target); - case 190: - case 191: + case 193: + case 194: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -39293,8 +41346,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -39306,6 +41359,15 @@ var ts; } return false; } + function optionalChainContainsReference(source, target) { + while (ts.isOptionalChain(source)) { + source = source.expression; + if (isMatchingReference(source, target)) { + return true; + } + } + return false; + } function containsMatchingReferenceDiscriminant(source, target) { var name; return ts.isAccessExpression(target) && @@ -39314,7 +41376,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73) { + if (expr.kind === 75) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -39345,7 +41407,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 && !!(expr.expression.flags & 8); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 && !!(expr.expression.flags & 8); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -39373,14 +41435,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 && + if (callExpression.expression.kind === 193 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -39415,8 +41477,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -39519,15 +41581,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 && parent.parent.left === parent || - parent.parent.kind === 228 && parent.parent.initializer === parent; + return parent.parent.kind === 208 && parent.parent.left === parent || + parent.parent.kind === 231 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -39544,21 +41606,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227: + case 230: return stringType; - case 228: + case 231: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205: + case 208: return getAssignedTypeOfBinaryExpression(parent); - case 199: + case 202: return undefinedType; - case 188: + case 191: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209: + case 212: return getAssignedTypeOfSpreadExpression(parent); - case 276: + case 279: return getAssignedTypeOfPropertyAssignment(parent); - case 277: + case 280: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -39566,7 +41628,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 ? + var type = pattern.kind === 188 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -39581,37 +41643,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227) { + if (node.parent.parent.kind === 230) { return stringType; } - if (node.parent.parent.kind === 228) { + if (node.parent.parent.kind === 231) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 ? + return node.kind === 241 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 || node.kind === 187 ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 && node.initializer && + return node.kind === 241 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 && node.parent.kind === 205 && + node.kind !== 190 && node.parent.kind === 208 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196: + case 199: return getReferenceCandidate(node.expression); - case 205: + case 208: switch (node.operatorToken.kind) { - case 60: + case 62: return getReferenceCandidate(node.left); case 27: return getReferenceCandidate(node.right); @@ -39621,13 +41678,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 || - parent.kind === 205 && parent.operatorToken.kind === 60 && parent.left === node || - parent.kind === 205 && parent.operatorToken.kind === 27 && parent.right === node ? + return parent.kind === 199 || + parent.kind === 208 && parent.operatorToken.kind === 62 && parent.left === node || + parent.kind === 208 && parent.operatorToken.kind === 27 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272) { + if (clause.kind === 275) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -39647,8 +41704,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272) { - if (clause.expression.kind === 10) { + if (clause.kind === 275) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -39728,8 +41785,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) : t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) : - t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : - t; + t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : t; }); } return typeWithPrimitives; @@ -39773,8 +41829,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 131072)) { if (!(ts.getObjectFlags(t) & 256)) { return false; @@ -39792,33 +41848,86 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 && (parent.name.escapedText === "length" || - parent.parent.kind === 192 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 && + var isLengthPushOrUnshift = parent.kind === 193 && (parent.name.escapedText === "length" || + parent.parent.kind === 195 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 && parent.expression === root && - parent.parent.kind === 205 && - parent.parent.operatorToken.kind === 60 && + parent.parent.kind === 208 && + parent.parent.operatorToken.kind === 62 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 || declaration.kind === 155 || + declaration.kind === 158 || declaration.kind === 157) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 | 8192 | 32 | 512)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 | 4)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0), signatureHasTypePredicate); + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216)) { + switch (node.kind) { + case 75: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 ? resolveAlias(symbol) : symbol, diagnostic); + case 103: + return getExplicitThisType(node); + case 193: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + var funcType = void 0; + if (node.parent.kind === 225) { + funcType = getTypeOfDottedName(node.expression, undefined); + } + else if (node.expression.kind !== 101) { + if (ts.isOptionalChain(node)) { + funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); + } + else { + funcType = checkNonNullExpression(node.expression); + } + } + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072); + } + function getTypePredicateArgument(predicate, callExpression) { + if (predicate.kind === 1 || predicate.kind === 3) { + return callExpression.arguments[predicate.parameterIndex]; + } + var invokedExpression = ts.skipParentheses(callExpression.expression); + return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined; } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -39826,6 +41935,77 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 && flow.lock.locked) && isReachableFlowNodeWorker(flow, false); + } + function isFalseExpression(expr) { + var node = ts.skipParentheses(expr); + return node.kind === 90 || node.kind === 208 && (node.operatorToken.kind === 55 && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 && isFalseExpression(node.left) && isFalseExpression(node.right)); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, true)); + } + noCacheCheck = false; + } + if (flags & (16 | 96 | 256 | 4096)) { + flow = flow.antecedent; + } + else if (flags & 512) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && predicate.kind === 3) { + var predicateArgument = flow.node.arguments[predicate.parameterIndex]; + if (predicateArgument && isFalseExpression(predicateArgument)) { + return false; + } + } + if (getReturnTypeOfSignature(signature).flags & 131072) { + return false; + } + } + flow = flow.antecedent; + } + else if (flags & 4) { + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8) { + flow = flow.antecedents[0]; + } + else if (flags & 128) { + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192) { + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, false); + flow.locked = false; + return result; + } + else { + return !(flags & 1); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -39837,11 +42017,12 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 && getTypeWithFacts(resultType, 2097152).flags & 131072) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 && getTypeWithFacts(resultType, 2097152).flags & 131072) { return declaredType; } return resultType; @@ -39861,16 +42042,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024) { + if (flags & 2048) { for (var i = sharedFlowStart; i < sharedFlowCount; i++) { if (sharedFlowNodes[i] === flow) { flowDepth--; @@ -39879,12 +42051,12 @@ var ts; } } var type = void 0; - if (flags & 4096) { + if (flags & 8192) { flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048) { + else if (flags & 4096) { flow = flow.antecedent; continue; } @@ -39894,14 +42066,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96) { @@ -39927,11 +42097,11 @@ var ts; } } else if (flags & 2) { - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 && - reference.kind !== 191 && - reference.kind !== 101) { + reference.kind !== 193 && + reference.kind !== 194 && + reference.kind !== 103) { flow = container.flowNode; continue; } @@ -39940,7 +42110,7 @@ var ts; else { type = convertAutoToAny(declaredType); } - if (flags & 1024) { + if (flags & 2048) { sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; sharedFlowCount++; @@ -39949,9 +42119,30 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 || node.kind === 190 ? + getInitialType(node) : + getAssignedType(node), reference); + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -39960,32 +42151,68 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 197 || init.kind === 198)) { + if (init && (init.kind === 200 || init.kind === 201)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 227 && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 90) { + return unreachableNeverType; + } + if (node.kind === 208) { + if (node.operatorToken.kind === 55) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 || predicate.kind === 3)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) : + predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 ? + var expr = node.kind === 195 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -39993,7 +42220,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 192) { + if (node.kind === 195) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -40020,7 +42247,7 @@ var ts; } var assumeTrue = (flow.flags & 32) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -40035,14 +42262,27 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); - } - else if (expr.kind === 200 && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (containsMatchingReferenceDiscriminant(reference, expr)) { - type = declaredType; + else { + if (strictNullChecks) { + if (optionalChainContainsReference(expr, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 | 131072)); }); + } + else if (expr.kind === 203 && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 || t.flags & 128 && t.value === "undefined"); }); + } + } + if (isMatchingReferenceDiscriminant(expr, type)) { + type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + } + else if (containsMatchingReferenceDiscriminant(reference, expr)) { + type = declaredType; + } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } } return createFlowType(type, isIncomplete(flowType)); } @@ -40052,7 +42292,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 && antecedent.lock.locked) { + if (antecedent.flags & 4096 && antecedent.lock.locked) { continue; } var flowType = getTypeAtFlowNode(antecedent); @@ -40089,22 +42329,25 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); if (!isTypeSubsetOf(type, declaredType)) { subtypeReduction = true; @@ -40143,6 +42386,9 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608); } + if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { + type = getTypeWithFacts(type, 2097152); + } if (isMatchingReferenceDiscriminant(expr, declaredType)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); }); } @@ -40170,19 +42416,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60: + case 62: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33: case 34: case 35: case 36: + case 37: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -40191,6 +42437,14 @@ var ts; if (isMatchingReference(reference, right_1)) { return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); } + if (strictNullChecks) { + if (optionalChainContainsReference(left_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + } + else if (optionalChainContainsReference(right_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + } + } if (isMatchingReferenceDiscriminant(left_1, declaredType)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } @@ -40201,9 +42455,9 @@ var ts; return declaredType; } break; - case 95: + case 97: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94: + case 96: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -40214,15 +42468,21 @@ var ts; } return type; } + function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { + var effectiveTrue = operator === 34 || operator === 36 ? assumeTrue : !assumeTrue; + var doubleEquals = operator === 34 || operator === 35; + var valueNonNullish = !(getTypeFacts(getTypeOfExpression(value)) & (doubleEquals ? 262144 : 65536)); + return effectiveTrue === valueNonNullish ? getTypeWithFacts(type, 2097152) : type; + } function narrowTypeByEquality(type, operator, value, assumeTrue) { if (type.flags & 1) { return type; } - if (operator === 34 || operator === 36) { + if (operator === 35 || operator === 37) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2) && (operator === 35) && assumeTrue) { + if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) { if (valueType.flags & (131068 | 67108864)) { return valueType; } @@ -40235,7 +42495,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 || operator === 34; + var doubleEquals = operator === 34 || operator === 35; var facts = doubleEquals ? assumeTrue ? 262144 : 2097152 : valueType.flags & 65536 ? @@ -40247,7 +42507,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 ? + var filterFn = operator === 34 ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -40260,16 +42520,19 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { + if (operator === 35 || operator === 37) { + assumeTrue = !assumeTrue; + } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { + if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { + return getTypeWithFacts(type, 2097152); + } if (containsMatchingReference(reference, target)) { return declaredType; } return type; } - if (operator === 34 || operator === 36) { - assumeTrue = !assumeTrue; - } if (type.flags & 1 && literal.text === "function") { return type; } @@ -40299,6 +42562,10 @@ var ts; return type; } } + function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { + var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); + return everyClauseChecks ? getTypeWithFacts(type, 2097152) : type; + } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { var switchTypes = getSwitchClauseTypes(switchStatement); if (!switchTypes.length) { @@ -40392,6 +42659,9 @@ var ts; function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { + if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { + return getTypeWithFacts(type, 2097152); + } if (containsMatchingReference(reference, left) && !isSyntheticThisPropertyAccess(reference)) { return declaredType; } @@ -40435,37 +42705,28 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; - } - if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 || predicate.kind === 1)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } - if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { + if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) { + var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } - if (containsMatchingReference(reference, predicateArgument)) { - return declaredType; + if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && + !(getTypeFacts(predicate.type) & 65536)) { + return getTypeWithFacts(type, 2097152); } - } - } - else { - var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { - var possibleReference = ts.skipParentheses(invokedExpression.expression); - if (isMatchingReference(reference, possibleReference)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); - } - if (containsMatchingReference(reference, possibleReference)) { + if (containsMatchingReference(reference, predicateArgument)) { return declaredType; } } @@ -40473,31 +42734,47 @@ var ts; return type; } function narrowType(type, expr, assumeTrue) { + if (ts.isExpressionOfOptionalChainRoot(expr) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73: + case 75: + case 103: case 101: - case 99: - case 190: - case 191: + case 193: + case 194: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196: + case 195: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199: return narrowType(type, expr.expression, assumeTrue); - case 205: + case 208: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203: - if (expr.operator === 52) { + case 206: + if (expr.operator === 53) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 : 262144); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; - if (location.kind === 73) { + if (location.kind === 75) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -40513,9 +42790,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 || - node.kind === 285 || - node.kind === 155; + node.kind === 249 || + node.kind === 288 || + node.kind === 158; }); } function isParameterAssigned(symbol) { @@ -40533,10 +42810,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); }); } function markParameterAssignments(node) { - if (node.kind === 73) { + if (node.kind === 75) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155) { symbol.isAssigned = true; } } @@ -40550,7 +42827,7 @@ var ts; } function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 && + declaration.kind === 155 && declaration.initializer && getFalsyFlags(declaredType) & 32768 && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768); @@ -40558,10 +42835,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 || - parent.kind === 192 && parent.expression === node || - parent.kind === 191 && parent.expression === node || - parent.kind === 187 && parent.name === node && !!parent.initializer; + return parent.kind === 193 || + parent.kind === 195 && parent.expression === node || + parent.kind === 194 && parent.expression === node || + parent.kind === 190 && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304); @@ -40588,7 +42865,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 198) { + if (container.kind === 201) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { @@ -40604,7 +42881,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); var declaration = localOrExportSymbol.valueDeclaration; if (localOrExportSymbol.flags & 32) { - if (declaration.kind === 241 + if (declaration.kind === 244 && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -40616,11 +42893,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210) { + else if (declaration.kind === 213) { var container = ts.getThisContainer(node, false); - while (container.kind !== 285) { + while (container.kind !== 288) { if (container.parent === declaration) { - if (container.kind === 155 && ts.hasModifier(container, 32)) { + if (container.kind === 158 && ts.hasModifier(container, 32)) { getNodeLinks(declaration).flags |= 16777216; getNodeLinks(node).flags |= 33554432; } @@ -40664,23 +42941,23 @@ var ts; if (!declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 152; + var isParameter = ts.getRootDeclaration(declaration).kind === 155; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent); var isModuleExports = symbol.flags & 134217728; - while (flowContainer !== declarationContainer && (flowContainer.kind === 197 || - flowContainer.kind === 198 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 || + flowContainer.kind === 201 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258) || - node.parent.kind === 214 || - declaration.kind === 238 && declaration.exclamationToken || - declaration.flags & 4194304; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261) || + node.parent.kind === 217 || + declaration.kind === 241 && declaration.exclamationToken || + declaration.flags & 8388608; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -40710,7 +42987,7 @@ var ts; if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275) { + symbol.valueDeclaration.parent.kind === 278) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -40728,7 +43005,7 @@ var ts; if (usedInFunction) { var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -40744,8 +43021,8 @@ var ts; getNodeLinks(current).flags |= 65536; } } - if (container.kind === 226 && - ts.getAncestor(symbol.valueDeclaration, 239).parent === container && + if (container.kind === 229 && + ts.getAncestor(symbol.valueDeclaration, 242).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304; } @@ -40761,16 +43038,16 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 196) { + while (current.parent.kind === 199) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 || current.parent.kind === 204)) { + else if ((current.parent.kind === 206 || current.parent.kind === 207)) { var expr = current.parent; - isAssigned = expr.operator === 44 || expr.operator === 45; + isAssigned = expr.operator === 45 || expr.operator === 46; } if (!isAssigned) { return false; @@ -40779,7 +43056,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 155 || container.kind === 158) { + if (container.kind === 158 || container.kind === 161) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -40823,32 +43100,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var capturedByArrowFunction = false; - if (container.kind === 158) { + if (container.kind === 161) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 198) { + if (container.kind === 201) { container = ts.getThisContainer(container, false); capturedByArrowFunction = true; } switch (container.kind) { - case 245: + case 248: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 244: + case 247: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 158: + case 161: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 155: - case 154: + case 158: + case 157: if (ts.hasModifier(container, 32)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 150: + case 153: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -40883,19 +43160,15 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } else if (isInJS && - (container.kind === 197 || container.kind === 240) && + (container.kind === 200 || container.kind === 243) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -40923,8 +43196,21 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { - if (container.kind === 197 && + if (container.kind === 200 && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3) { return container.parent @@ -40932,20 +43218,20 @@ var ts; .expression .expression; } - else if (container.kind === 157 && - container.parent.kind === 189 && + else if (container.kind === 160 && + container.parent.kind === 192 && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6) { return container.parent.parent.left.expression; } - else if (container.kind === 197 && - container.parent.kind === 276 && - container.parent.parent.kind === 189 && + else if (container.kind === 200 && + container.parent.kind === 279 && + container.parent.parent.kind === 192 && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) { return container.parent.parent.parent.left.expression; } - else if (container.kind === 197 && + else if (container.kind === 200 && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -40967,7 +43253,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295) { + if (jsdocType && jsdocType.kind === 298) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -40981,14 +43267,14 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 198) { + while (container && container.kind === 201) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -40996,14 +43282,14 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (!canUseSuperExpression) { - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150; }); - if (current && current.kind === 150) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153; }); + if (current && current.kind === 153) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 189)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -41011,7 +43297,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158) { + if (!isCallExpression && container.kind === 161) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32) || isCallExpression) { @@ -41021,7 +43307,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 157 && ts.hasModifier(container, 256)) { + if (container.kind === 160 && ts.hasModifier(container, 256)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -41032,7 +43318,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189) { + if (container.parent.kind === 192) { if (languageVersion < 2) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -41051,7 +43337,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; } @@ -41063,24 +43349,24 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 158; + return container.kind === 161; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 189) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192) { if (ts.hasModifier(container, 32)) { - return container.kind === 157 || - container.kind === 156 || + return container.kind === 160 || container.kind === 159 || - container.kind === 160; + container.kind === 162 || + container.kind === 163; } else { - return container.kind === 157 || - container.kind === 156 || + return container.kind === 160 || container.kind === 159 || - container.kind === 160 || - container.kind === 155 || - container.kind === 154 || - container.kind === 158; + container.kind === 162 || + container.kind === 163 || + container.kind === 158 || + container.kind === 157 || + container.kind === 161; } } } @@ -41088,14 +43374,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 || - func.kind === 159 || - func.kind === 160) && func.parent.kind === 189 ? func.parent : - func.kind === 197 && func.parent.kind === 276 ? func.parent.parent : + return (func.kind === 160 || + func.kind === 162 || + func.kind === 163) && func.parent.kind === 192 ? func.parent : + func.kind === 200 && func.parent.kind === 279 ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -41103,7 +43389,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198) { + if (func.kind === 201) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -41127,7 +43413,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276) { + if (literal.parent.kind !== 279) { break; } literal = literal.parent.parent; @@ -41136,9 +43422,9 @@ var ts; return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral)); } var parent = func.parent; - if (parent.kind === 205 && parent.operatorToken.kind === 60) { + if (parent.kind === 208 && parent.operatorToken.kind === 62) { var target = parent.left; - if (target.kind === 190 || target.kind === 191) { + if (target.kind === 193 || target.kind === 194) { var expression = target.expression; if (inJs && ts.isIdentifier(expression)) { var sourceFile = ts.getSourceFileOfNode(parent); @@ -41195,9 +43481,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152: + case 155: return getContextuallyTypedParameterType(declaration, false); - case 187: + case 190: return getContextualTypeForBindingElement(declaration); } } @@ -41298,20 +43584,24 @@ var ts; } return undefined; } - function getContextualTypeForArgument(callTarget, arg) { + function getContextualTypeForArgument(callTarget, arg, contextFlags) { var args = getEffectiveCallArguments(callTarget); var argIndex = args.indexOf(arg); - return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); + return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags); } - function getContextualTypeForArgumentAtIndex(callTarget, argIndex) { + function getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags) { var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } + if (contextFlags && contextFlags & 4 && signature.target) { + var baseSignature = getBaseSignature(signature.target); + return intersectTypes(getTypeAtPosition(signature, argIndex), getTypeAtPosition(baseSignature, argIndex)); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194) { + if (template.parent.kind === 197) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -41320,7 +43610,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60: + case 62: if (node !== right) { return undefined; } @@ -41329,11 +43619,12 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55: + case 56: + case 60: var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54: + case 55: case 27: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -41357,7 +43648,7 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); @@ -41368,8 +43659,11 @@ var ts; if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -41391,12 +43685,13 @@ var ts; } if (kind === 2) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7: case 8: case 9: @@ -41437,7 +43732,7 @@ var ts; } function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608) { + if (node.flags & 16777216) { return undefined; } return getContextualTypeForObjectLiteralElement(node, contextFlags); @@ -41510,32 +43805,32 @@ var ts; case 8: case 9: case 14: - case 103: - case 88: - case 97: - case 73: - case 142: + case 105: + case 90: + case 99: + case 75: + case 145: return true; - case 190: - case 196: + case 193: + case 199: return isPossiblyDiscriminantValue(node.expression); - case 271: + case 274: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 276 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 279 && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 271 && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function getApparentTypeOfContextualType(node, contextFlags) { var contextualType = ts.isObjectLiteralMethod(node) ? getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType) { + if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) { var apparentType = mapType(instantiatedType, getApparentType, true); if (apparentType.flags & 1048576) { if (ts.isObjectLiteralExpression(node)) { @@ -41575,7 +43870,7 @@ var ts; return type; } function getContextualType(node, contextFlags) { - if (node.flags & 8388608) { + if (node.flags & 16777216) { return undefined; } if (node.contextualType) { @@ -41583,56 +43878,56 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238: - case 152: + case 241: case 155: - case 154: - case 187: + case 158: + case 157: + case 190: return getContextualTypeForInitializerExpression(node); - case 198: - case 231: + case 201: + case 234: return getContextualTypeForReturnExpression(node); - case 208: + case 211: return getContextualTypeForYieldOperand(parent); - case 202: + case 205: return getContextualTypeForAwaitOperand(parent); - case 192: - if (parent.expression.kind === 93) { + case 195: + if (parent.expression.kind === 95) { return stringType; } - case 193: - return getContextualTypeForArgument(parent, node); - case 195: - case 213: + case 196: + return getContextualTypeForArgument(parent, node, contextFlags); + case 198: + case 216: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205: + case 208: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276: - case 277: + case 279: + case 280: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278: + case 281: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188: { + case 191: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206: + case 209: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217: - ts.Debug.assert(parent.parent.kind === 207); + case 220: + ts.Debug.assert(parent.parent.kind === 210); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196: { + case 199: { var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 271: + case 274: return getContextualTypeForJsxExpression(parent); - case 268: - case 270: + case 271: + case 273: return getContextualTypeForJsxAttribute(parent); - case 263: - case 262: + case 266: + case 265: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -41770,7 +44065,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 || node.kind === 198; + return node.kind === 200 || node.kind === 201; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -41778,7 +44073,7 @@ var ts; : undefined; } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -41792,8 +44087,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -41819,8 +44114,8 @@ var ts; return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 && !!node.initializer) || - (node.kind === 205 && node.operatorToken.kind === 60); + return (node.kind === 190 && !!node.initializer) || + (node.kind === 208 && node.operatorToken.kind === 62); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -41832,7 +44127,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209) { + if (inDestructuringPattern && e.kind === 212) { var restArrayType = checkExpression(e.expression, checkMode, forceTuple); var restElementType = getIndexTypeOfType(restArrayType, 1) || getIteratedTypeOrElementType(65, restArrayType, undefinedType, undefined, false); @@ -41845,12 +44140,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209) { + if (index < elementCount - 1 && e.kind === 212) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212; var minLength = elementCount - (hasRestElement ? 1 : 0); var tupleResult = void 0; if (inDestructuringPattern && minLength > 0) { @@ -41889,9 +44184,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150: + case 153: return isNumericComputedName(name); - case 73: + case 75: return isNumericLiteralName(name.escapedText); case 8: case 10: @@ -41953,7 +44248,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 || contextualType.pattern.kind === 189); + (contextualType.pattern.kind === 188 || contextualType.pattern.kind === 192); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -41968,13 +44263,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 || - memberDecl.kind === 277 || + if (memberDecl.kind === 279 || + memberDecl.kind === 280 || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -41995,8 +44290,8 @@ var ts; prop.nameType = nameType; } if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 276 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } @@ -42019,7 +44314,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278) { + else if (memberDecl.kind === 281) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -42040,7 +44335,7 @@ var ts; continue; } else { - ts.Debug.assert(memberDecl.kind === 159 || memberDecl.kind === 160); + ts.Debug.assert(memberDecl.kind === 162 || memberDecl.kind === 163); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576)) { @@ -42098,7 +44393,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 | 67108864 | 524288 | 58982400) || + if (type.flags & 63176704) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 | 67108864 | 524288 | 58982400) || getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 && ts.every(type.types, isValidSpreadType)); } @@ -42137,7 +44438,7 @@ var ts; return !ts.stringContains(name, "-"); } function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 73 && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -42173,7 +44474,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270); + ts.Debug.assert(attributeDecl.kind === 273); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false); attributesTable = ts.createSymbolTable(); @@ -42195,7 +44496,7 @@ var ts; spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false); } } - var parent = openingLikeElement.parent.kind === 261 ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 ? openingLikeElement.parent : undefined; if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { @@ -42517,7 +44818,7 @@ var ts; } function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 ? node.right : node.kind === 184 ? node : node.name; + var errorNode = node.kind === 152 ? node.right : node.kind === 187 ? node : node.name; if (ts.getCheckFlags(prop) & 1024) { error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); return false; @@ -42587,32 +44888,43 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192); }); } - function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + function checkNonNullExpression(node) { + return checkNonNullType(checkExpression(node), node); + } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304); } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; } - function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + function reportObjectPossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 ? flags & 65536 ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + } + function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 ? flags & 65536 ? + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); + } + function checkNonNullTypeWithReporter(type, node, reportError) { if (strictNullChecks && type.flags & 2) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304; if (kind) { - error(node, kind & 32768 ? kind & 65536 ? - (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : - (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : - (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); + reportError(node, kind); var t = getNonNullableType(type); return t.flags & (98304 | 131072) ? errorType : t; } return type; } + function checkNonNullType(type, node) { + return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError); + } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); if (nonNullType !== errorType && nonNullType.flags & 16384) { @@ -42621,20 +44933,24 @@ var ts; return nonNullType; } function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + return node.flags & 32 ? checkPropertyAccessChain(node) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + } + function checkPropertyAccessChain(node) { + var leftType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(leftType, node.expression); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType); } function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196) { + while (node.parent.kind === 199) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -42648,6 +44964,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -42675,9 +44992,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101); + markPropertyAsReferenced(prop, node, left.kind === 103); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -42690,17 +45007,17 @@ var ts; } function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) { var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 && node.kind !== 190 || + if (node.kind !== 194 && node.kind !== 193 || assignmentKind === 1 || prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) { return propType; } var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 101) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -42730,9 +45047,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 && - node.parent.kind !== 165 && - !(valueDeclaration.flags & 4194304) && + else if (valueDeclaration.kind === 244 && + node.parent.kind !== 168 && + !(valueDeclaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -42743,22 +45060,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155: + case 158: return true; - case 276: - case 157: - case 159: + case 279: case 160: - case 278: - case 150: - case 217: - case 271: - case 268: - case 269: - case 270: - case 263: - case 212: + case 162: + case 163: + case 281: + case 153: + case 220: case 274: + case 271: + case 272: + case 273: + case 266: + case 215: + case 277: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -42794,7 +45111,7 @@ var ts; if (containingType.flags & 1048576 && !(containingType.flags & 131068)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -42907,16 +45224,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190: - return isValidPropertyAccessWithType(node, node.expression.kind === 99, propertyName, getWidenedType(checkExpression(node.expression))); - case 149: + case 193: + return isValidPropertyAccessWithType(node, node.expression.kind === 101, propertyName, getWidenedType(checkExpression(node.expression))); + case 152: return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left))); - case 184: + case 187: return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 && node.expression.kind === 99, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 && node.expression.kind === 101, property.escapedName, type); } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { if (type === errorType || isTypeAny(type)) { @@ -42928,13 +45245,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239) { + if (initializer.kind === 242) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73) { + else if (initializer.kind === 75) { return getResolvedSymbol(initializer); } return undefined; @@ -42944,13 +45261,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73) { + if (e.kind === 75) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 && + if (node.kind === 230 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -42964,28 +45281,22 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + return node.flags & 32 ? checkElementAccessChain(node) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + } + function checkElementAccessChain(node) { + var exprType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(exprType, node.expression); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType); + } + function checkElementAccessExpression(node, exprType) { var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -43033,13 +45344,13 @@ var ts; if (callLikeExpressionMayHaveTypeArguments(node)) { ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194) { + if (node.kind === 197) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153) { + else if (node.kind !== 156) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -43050,7 +45361,7 @@ var ts; resolveUntypedCall(node); return unknownSignature; } - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -43058,8 +45369,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -43076,7 +45387,7 @@ var ts; lastParent = parent; } lastSymbol = symbol; - if (signature.hasLiteralTypes) { + if (signatureHasLiteralTypes(signature)) { specializedIndex++; spliceIndex = specializedIndex; cutoffIndex++; @@ -43084,11 +45395,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 || arg.kind === 216 && arg.isSpread); + return !!arg && (arg.kind === 212 || arg.kind === 219 && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -43102,9 +45413,9 @@ var ts; var callIsIncomplete = false; var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194) { + if (node.kind === 197) { argCount = args.length; - if (node.template.kind === 207) { + if (node.template.kind === 210) { var lastSpan = ts.last(node.template.templateSpans); callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated; } @@ -43114,7 +45425,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153) { + else if (node.kind === 156) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -43128,7 +45439,7 @@ var ts; } else { if (!node.arguments) { - ts.Debug.assert(node.kind === 193); + ts.Debug.assert(node.kind === 196); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -43204,7 +45515,7 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { return inferJsxTypeArguments(node, signature, checkMode, context); } - if (node.kind !== 153) { + if (node.kind !== 156) { var contextualType = getContextualType(node); if (contextualType) { var outerContext = getInferenceContext(node); @@ -43219,7 +45530,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -43232,7 +45543,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211) { + if (arg.kind !== 214) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -43254,7 +45565,7 @@ var ts; if (index >= argCount - 1) { var arg = args[argCount - 1]; if (isSpreadArgument(arg)) { - return arg.kind === 216 ? + return arg.kind === 219 ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0)); } @@ -43324,9 +45635,21 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193) { + if (thisType && thisType !== voidType && node.kind !== 196) { var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + var thisArgumentType = void 0; + if (thisArgumentNode) { + thisArgumentType = checkExpression(thisArgumentNode); + if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { + thisArgumentType = getNonNullableType(thisArgumentType); + } + else if (ts.isOptionalChain(thisArgumentNode.parent)) { + thisArgumentType = removeOptionalTypeMarker(thisArgumentType); + } + } + else { + thisArgumentType = voidType; + } var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -43339,7 +45662,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211) { + if (arg.kind !== 214) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode); var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType; @@ -43373,32 +45696,32 @@ var ts; } } function getThisArgumentOfCall(node) { - if (node.kind === 192) { + if (node.kind === 195) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 || callee.kind === 191) { + if (callee.kind === 193 || callee.kind === 194) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216, parent.pos, parent.end); + var result = ts.createNode(219, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; return result; } function getEffectiveCallArguments(node) { - if (node.kind === 194) { + if (node.kind === 197) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207) { + if (template.kind === 210) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153) { + if (node.kind === 156) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -43410,7 +45733,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -43422,23 +45745,23 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241: - case 210: + case 244: + case 213: return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 152: + case 155: var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 158 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155: - case 157: - case 159: + case 158: case 160: - var hasPropDesc = parent.kind !== 155 && languageVersion !== 0; + case 162: + case 163: + var hasPropDesc = parent.kind !== 158 && languageVersion !== 0; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -43449,16 +45772,16 @@ var ts; } function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241: - case 210: + case 244: + case 213: return 1; - case 155: + case 158: return 2; - case 157: - case 159: case 160: + case 162: + case 163: return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3; - case 152: + case 155: return 3; default: return ts.Debug.fail(); @@ -43496,8 +45819,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -43526,7 +45849,7 @@ var ts; if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(getFirstIdentifier(paramDecl.name)) : undefined); + related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); } } if (min < argCount && argCount < max) { @@ -43564,8 +45887,8 @@ var ts; } var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -43580,20 +45903,20 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194; - var isDecorator = node.kind === 153; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197; + var isDecorator = node.kind === 156; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 99) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -43607,7 +45930,7 @@ var ts; var candidateForArgumentArityError; var candidateForTypeArgumentError; var result; - var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 192 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 195 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -43646,7 +45969,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2); if (diags_2) { @@ -43664,7 +45987,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -43784,30 +46107,31 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { - var symbols = ts.mapDefined(candidates, function (_a) { - var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; - return hasRestParameter ? - i < parameters.length - 1 ? parameters[i] : ts.last(parameters) : - i < parameters.length ? parameters[i] : undefined; - }); + var _loop_15 = function (i) { + var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? + i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : + i < s.parameters.length ? s.parameters[i] : undefined; }); ts.Debug.assert(symbols.length !== 0); parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } - var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); - var hasRestParameter = restParameterSymbols.length !== 0; - if (hasRestParameter) { + var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); + var flags = 0; + if (restParameterSymbols.length !== 0) { var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); + flags |= 1; } - return createSignature(candidates[0].declaration, undefined, thisParameter, parameters, getIntersectionType(candidates.map(getReturnTypeOfSignature)), undefined, minArgumentCount, hasRestParameter, candidates.some(function (c) { return c.hasLiteralTypes; })); + if (candidates.some(signatureHasLiteralTypes)) { + flags |= 2; + } + return createSignature(candidates[0].declaration, undefined, thisParameter, parameters, getIntersectionType(candidates.map(getReturnTypeOfSignature)), undefined, minArgumentCount, flags); } function getNumNonRestParameters(signature) { var numParams = signature.parameters.length; - return signature.hasRestParameter ? numParams - 1 : numParams; + return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2)); @@ -43861,7 +46185,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -43874,12 +46198,22 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var isOptional; + var funcType = checkExpression(node.expression); + if (ts.isCallChain(node)) { + var nonOptionalType = getOptionalExpressionType(funcType, node.expression); + isOptional = nonOptionalType !== funcType; + funcType = nonOptionalType; + } + else { + isOptional = false; + } + funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { return silentNeverSignature; } @@ -43919,7 +46253,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -43959,11 +46293,11 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, false); } var callSignatures = getSignaturesOfType(expressionType, 0); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -44045,8 +46379,8 @@ var ts; if (apparentType.flags & 1048576) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var constituent = types_14[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var constituent = types_17[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -44130,20 +46464,20 @@ var ts; invocationError(node.tag, apparentType, 0); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, false); } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241: - case 210: + case 244: + case 213: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152: - return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; case 155: + return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; + case 158: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157: - case 159: case 160: + case 162: + case 163: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -44177,17 +46511,17 @@ var ts; invocationErrorRecovery(apparentType, 0, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, false, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); var exports = namespace && getExportsOfSymbol(namespace); var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968); var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node); - var declaration = ts.createFunctionTypeNode(undefined, [ts.createParameter(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, undefined) : ts.createKeywordTypeNode(121)); + var declaration = ts.createFunctionTypeNode(undefined, [ts.createParameter(undefined, undefined, undefined, "props", undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, undefined) : ts.createKeywordTypeNode(124)); var parameterSymbol = createSymbol(1, "props"); parameterSymbol.type = result; - return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, false, false); + return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -44209,27 +46543,27 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, false); } function isPotentiallyUncalledDecorator(decorator, signatures) { return signatures.length && ts.every(signatures, function (signature) { return signature.minArgumentCount === 0 && - !signature.hasRestParameter && + !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192: + case 195: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193: + case 196: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194: + case 197: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153: + case 156: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263: - case 262: + case 266: + case 265: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -44258,57 +46592,52 @@ var ts; if (ts.getJSDocClassTag(node)) return true; var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function isJSConstructorType(type) { - if (type.flags & 524288) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); - } - return false; - } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190) { + while (parent && parent.kind === 193) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); - } - return links.inferredClassType; - } function checkCallExpression(node, checkMode) { if (!checkGrammarTypeArguments(node, node.typeArguments)) checkGrammarArguments(node.arguments); @@ -44316,15 +46645,15 @@ var ts; if (signature === resolvingSignature) { return nonInferrableType; } - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return voidType; } - if (node.kind === 193) { + if (node.kind === 196) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 && - declaration.kind !== 162 && - declaration.kind !== 167 && + declaration.kind !== 161 && + declaration.kind !== 165 && + declaration.kind !== 170 && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { if (noImplicitAny) { @@ -44340,18 +46669,28 @@ var ts; if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 && node.parent.kind === 225 && + returnType.flags & 16384 && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -44385,7 +46724,7 @@ var ts; } var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -44431,18 +46770,19 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 240 + ? 243 : resolvedRequire.flags & 3 - ? 238 + ? 241 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); - return !!decl && !!(decl.flags & 4194304); + return !!decl && !!(decl.flags & 8388608); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2) { checkExternalEmitHelpers(node, 131072); } @@ -44457,20 +46797,20 @@ var ts; case 14: case 8: case 9: - case 103: - case 88: - case 188: - case 189: + case 105: + case 90: + case 191: + case 192: return true; - case 196: + case 199: return isValidConstAssertionArgument(node.expression); - case 203: + case 206: var op = node.operator; var arg = node.operand; - return op === 39 && (arg.kind === 8 || arg.kind === 9) || - op === 38 && arg.kind === 8; - case 190: - case 191: + return op === 40 && (arg.kind === 8 || arg.kind === 9) || + op === 39 && arg.kind === 8; + case 193: + case 194: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -44506,10 +46846,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96) { + if (node.keywordToken === 98) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93) { + if (node.keywordToken === 95) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -44520,7 +46860,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 158) { + else if (container.kind === 161) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -44534,7 +46874,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -44549,7 +46889,7 @@ var ts; return type; } function getParameterNameAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return signature.parameters[pos].escapedName; } @@ -44566,14 +46906,14 @@ var ts; return tryGetTypeAtPosition(signature, pos) || anyType; } function tryGetTypeAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return getTypeOfParameter(signature.parameters[pos]); } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -44602,16 +46942,16 @@ var ts; } function getParameterCount(signature) { var length = signature.parameters.length; - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; } function getMinArgumentCount(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { var minLength = restType.target.minLength; @@ -44623,14 +46963,14 @@ var ts; return signature.minArgumentCount; } function hasEffectiveRestParameter(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return !isTupleType(restType) || restType.target.hasRestElement; } return false; } function getEffectiveRestType(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType; } @@ -44647,7 +46987,7 @@ var ts; return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType; } function inferFromAnnotatedParameters(signature, context, inferenceContext) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -44676,7 +47016,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter)); } } - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -44684,7 +47024,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { var contextualParameterType = getRestTypeAtPosition(context, len); @@ -44696,7 +47036,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 73) { + if (element.name.kind === 75) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -44710,7 +47050,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73) { + if (decl.name.kind !== 75) { if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); } @@ -44760,7 +47100,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219) { + if (func.body.kind !== 222) { returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8); if (isAsync) { returnType = checkAwaitedType(returnType, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -44908,10 +47248,11 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203) { var operandType = getTypeOfExpression(node.expression.expression); var witnesses = getSwitchClauseTypeOfWitnesses(node); var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true); @@ -44929,13 +47270,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } function checkAndAggregateReturnExpressionTypes(func, checkMode) { var functionFlags = ts.getFunctionFlags(func); @@ -44969,11 +47304,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197: - case 198: + case 200: + case 201: return true; - case 157: - return func.parent.kind === 189; + case 160: + return func.parent.kind === 192; default: return false; } @@ -44987,10 +47322,10 @@ var ts; if (type && maybeTypeOfKind(type, 1 | 16384)) { return; } - if (func.kind === 156 || ts.nodeIsMissing(func.body) || func.body.kind !== 219 || !functionHasImplicitReturn(func)) { + if (func.kind === 159 || ts.nodeIsMissing(func.body) || func.body.kind !== 222 || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256; + var hasExplicitReturn = func.flags & 512; if (type && type.flags & 131072) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -45014,7 +47349,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); if (checkMode && checkMode & 4 && isContextSensitive(node)) { if (!ts.getEffectiveReturnTypeNode(node) && hasContextSensitiveReturnExpression(node)) { @@ -45023,7 +47358,7 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, false, false); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, 0); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); returnOnlyType.objectFlags |= 1048576; return links.contextFreeType = returnOnlyType; @@ -45031,7 +47366,7 @@ var ts; return anyFunctionType; } var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197) { + if (!hasGrammarError && node.kind === 200) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -45081,7 +47416,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -45089,7 +47424,7 @@ var ts; if (!ts.getEffectiveReturnTypeNode(node)) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219) { + if (node.body.kind === 222) { checkSourceElement(node.body); } else { @@ -45154,10 +47489,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 190 || expr.kind === 191) && - expr.expression.kind === 101) { + (expr.kind === 193 || expr.kind === 194) && + expr.expression.kind === 103) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158)) { + if (!(func && func.kind === 161)) { return true; } return !symbol.valueDeclaration || !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); @@ -45167,30 +47502,34 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 || expr.kind === 191) { + if (expr.kind === 193 || expr.kind === 194) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73) { + if (node.kind === 75) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252; + return !!declaration && declaration.kind === 255; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { var node = ts.skipOuterExpressions(expr, 2 | 1); - if (node.kind !== 73 && node.kind !== 190 && node.kind !== 191) { + if (node.kind !== 75 && node.kind !== 193 && node.kind !== 194) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 && expr.kind !== 191) { + if (expr.kind !== 193 && expr.kind !== 194) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -45211,13 +47550,13 @@ var ts; } function checkAwaitExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 16384)) { + if (!(node.flags & 32768)) { var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158) { + if (func && func.kind !== 161) { ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -45244,14 +47583,14 @@ var ts; switch (node.operand.kind) { case 8: switch (node.operator) { - case 39: + case 40: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38: + case 39: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9: - if (node.operator === 39) { + if (node.operator === 40) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -45259,31 +47598,31 @@ var ts; } } switch (node.operator) { - case 38: case 39: - case 53: + case 40: + case 54: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38) { + if (node.operator === 39) { if (maybeTypeOfKind(operandType, 2112)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52: + case 53: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 | 8388608); return facts === 4194304 ? falseType : facts === 8388608 ? trueType : booleanType; - case 44: case 45: + case 46: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -45296,7 +47635,7 @@ var ts; } var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -45314,8 +47653,8 @@ var ts; } if (type.flags & 3145728) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -45393,7 +47732,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 || property.kind === 277) { + if (property.kind === 279 || property.kind === 280) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -45406,9 +47745,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 ? property : property.initializer, type); } - else if (property.kind === 278) { + else if (property.kind === 281) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -45448,8 +47787,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211) { - if (element.kind !== 209) { + if (element.kind !== 214) { + if (element.kind !== 212) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { var accessFlags = hasDefaultValue(element) ? 8 : 0; @@ -45465,7 +47804,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 && restExpression.operatorToken.kind === 60) { + if (restExpression.kind === 208 && restExpression.operatorToken.kind === 62) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -45481,7 +47820,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277) { + if (exprOrAssignment.kind === 280) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && @@ -45495,24 +47834,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 && target.operatorToken.kind === 60) { + if (target.kind === 208 && target.operatorToken.kind === 62) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189) { + if (target.kind === 192) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188) { + if (target.kind === 191) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 278 ? + var error = target.parent.kind === 281 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - if (checkReferenceExpression(target, error)) { + var optionalError = target.parent.kind === 281 ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -45520,50 +47862,50 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73: + case 75: case 10: case 13: - case 194: - case 207: + case 197: + case 210: case 14: case 8: case 9: - case 103: - case 88: - case 97: - case 142: - case 197: - case 210: - case 198: - case 188: - case 189: + case 105: + case 90: + case 99: + case 145: case 200: - case 214: - case 262: - case 261: + case 213: + case 201: + case 191: + case 192: + case 203: + case 217: + case 265: + case 264: return true; - case 206: + case 209: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205: + case 208: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203: - case 204: + case 206: + case 207: switch (node.operator) { - case 52: - case 38: - case 39: case 53: + case 39: + case 40: + case 54: return true; } return false; - case 201: - case 195: - case 213: + case 204: + case 198: + case 216: default: return false; } @@ -45575,15 +47917,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 || left.operatorToken.kind === 55)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 || right.operatorToken.kind === 55)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 && (left.kind === 189 || left.kind === 188)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101); + if (operator === 62 && (left.kind === 192 || left.kind === 191)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103); } var leftType; - if (operator === 54 || operator === 55) { + if (operator === 55 || operator === 56 || operator === 60) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -45591,28 +47945,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40: case 41: - case 63: - case 64: case 42: case 65: - case 43: case 66: - case 39: - case 62: - case 46: + case 43: case 67: - case 47: + case 44: case 68: - case 48: + case 40: + case 64: + case 47: case 69: - case 50: + case 48: + case 70: + case 49: case 71: case 51: + case 73: + case 52: + case 74: + case 50: case 72: - case 49: - case 70: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -45633,16 +47987,16 @@ var ts; !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) { resultType_1 = numberType; } - else if (isTypeAssignableToKind(leftType, 2112) && isTypeAssignableToKind(rightType, 2112)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48: - case 69: + case 49: + case 71: reportOperatorError(); } resultType_1 = bigintType; } else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112) && isTypeAssignableToKind(awaitedRight, 2112); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -45650,8 +48004,8 @@ var ts; } return resultType_1; } - case 38: - case 61: + case 39: + case 63: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -45677,20 +48031,20 @@ var ts; } if (!resultType) { var closeEnoughKind_1 = 296 | 2112 | 132 | 3; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61) { + if (operator === 63) { checkAssignmentOperator(resultType); } return resultType; - case 28: - case 30: + case 29: case 31: case 32: + case 33: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -45699,25 +48053,29 @@ var ts; }); } return booleanType; - case 33: case 34: case 35: case 36: + case 37: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95: + case 97: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94: + case 96: return checkInExpression(left, right, leftType, rightType); - case 54: + case 55: return getTypeFacts(leftType) & 4194304 ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55: + case 56: return getTypeFacts(leftType) & 8388608 ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) : leftType; case 60: + return getTypeFacts(leftType) & 262144 ? + getUnionType([getNonNullableType(leftType), rightType], 2) : + leftType; + case 62: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -45743,6 +48101,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -45760,7 +48121,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 && node.escapedText === "eval"; + return node.kind === 75 && node.escapedText === "eval"; } function checkForDisallowedESSymbolOperand(operator) { var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left : @@ -45774,22 +48135,22 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50: - case 71: - return 55; case 51: + case 73: + return 56; + case 52: + case 74: + return 37; + case 50: case 72: - return 36; - case 49: - case 70: - return 54; + return 55; default: return undefined; } } function checkAssignmentOperator(valueType) { if (produceDiagnostics && ts.isAssignmentOperator(operator)) { - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); } @@ -45819,17 +48180,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; + } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -45837,12 +48204,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35: - case 33: - typeName = "false"; - break; case 36: case 34: + typeName = "false"; + break; + case 37: + case 35: typeName = "true"; } if (typeName) { @@ -45851,6 +48218,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -45868,7 +48246,7 @@ var ts; } function checkYieldExpression(node) { if (produceDiagnostics) { - if (!(node.flags & 4096) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -45927,7 +48305,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; } return node; @@ -45960,12 +48338,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 || node.kind === 213; + return node.kind === 198 || node.kind === 216; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 || @@ -45987,10 +48365,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -46034,14 +48412,14 @@ var ts; getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node)); } function checkPropertyAssignment(node, checkMode) { - if (node.name.kind === 150) { + if (node.name.kind === 153) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); } function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 150) { + if (node.name.kind === 153) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -46053,8 +48431,8 @@ var ts; var constructSignature = getSingleSignature(type, 1, true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 : 1, false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8) { @@ -46159,11 +48537,22 @@ var ts; } function getTypeOfExpression(node, cache) { var expr = ts.skipParentheses(node); - if (expr.kind === 192 && expr.expression.kind !== 99 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) { + var isOptional = void 0; + var funcType = void 0; + if (ts.isCallChain(expr)) { + funcType = checkExpression(expr.expression); + var nonOptionalType = getOptionalExpressionType(funcType, expr.expression); + isOptional = funcType !== nonOptionalType; + funcType = checkNonNullType(nonOptionalType, expr.expression); + } + else { + isOptional = false; + funcType = checkNonNullExpression(expr.expression); + } var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -46195,18 +48584,18 @@ var ts; return type; } function checkConstEnumAccess(node, type) { - var ok = (node.parent.kind === 190 && node.parent.expression === node) || - (node.parent.kind === 191 && node.parent.expression === node) || - ((node.kind === 73 || node.kind === 149) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 && node.parent.exprName === node)) || - (node.parent.kind === 258 && (compilerOptions.preserveConstEnums || node.flags & 4194304)); + var ok = (node.parent.kind === 193 && node.parent.expression === node) || + (node.parent.kind === 194 && node.parent.expression === node) || + ((node.kind === 75 || node.kind === 152) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 && node.parent.exprName === node)) || + (node.parent.kind === 261); if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304) { + if (constEnumDeclaration.flags & 8388608) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -46222,20 +48611,20 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 210: - case 197: - case 198: + case 213: + case 200: + case 201: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 73: + case 75: return checkIdentifier(node); - case 101: + case 103: return checkThisExpression(node); - case 99: + case 101: return checkSuperExpression(node); - case 97: + case 99: return nullWideningType; case 14: case 10: @@ -46246,81 +48635,81 @@ var ts; case 9: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103: + case 105: return trueType; - case 88: + case 90: return falseType; - case 207: + case 210: return checkTemplateExpression(node); case 13: return globalRegExpType; - case 188: + case 191: return checkArrayLiteral(node, checkMode, forceTuple); - case 189: + case 192: return checkObjectLiteral(node, checkMode); - case 190: + case 193: return checkPropertyAccessExpression(node); - case 149: + case 152: return checkQualifiedName(node); - case 191: + case 194: return checkIndexedAccess(node); - case 192: - if (node.expression.kind === 93) { + case 195: + if (node.expression.kind === 95) { return checkImportCallExpression(node); } - case 193: + case 196: return checkCallExpression(node, checkMode); - case 194: + case 197: return checkTaggedTemplateExpression(node); - case 196: + case 199: return checkParenthesizedExpression(node, checkMode); - case 210: + case 213: return checkClassExpression(node); - case 197: - case 198: - return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); case 200: + case 201: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 203: return checkTypeOfExpression(node); - case 195: - case 213: + case 198: + case 216: return checkAssertion(node); - case 214: + case 217: return checkNonNullAssertion(node); - case 215: + case 218: return checkMetaProperty(node); - case 199: + case 202: return checkDeleteExpression(node); - case 201: + case 204: return checkVoidExpression(node); - case 202: + case 205: return checkAwaitExpression(node); - case 203: + case 206: return checkPrefixUnaryExpression(node); - case 204: + case 207: return checkPostfixUnaryExpression(node); - case 205: + case 208: return checkBinaryExpression(node, checkMode); - case 206: - return checkConditionalExpression(node, checkMode); case 209: + return checkConditionalExpression(node, checkMode); + case 212: return checkSpreadExpression(node, checkMode); - case 211: + case 214: return undefinedWideningType; - case 208: + case 211: return checkYieldExpression(node); - case 216: + case 219: return node.type; - case 271: + case 274: return checkJsxExpression(node, checkMode); - case 261: + case 264: return checkJsxElement(node, checkMode); - case 262: - return checkJsxSelfClosingElement(node, checkMode); case 265: + return checkJsxSelfClosingElement(node, checkMode); + case 268: return checkJsxFragment(node); - case 269: + case 272: return checkJsxAttributes(node, checkMode); - case 263: + case 266: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -46350,7 +48739,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92)) { - if (!(func.kind === 158 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -46361,10 +48750,10 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 158 || func.kind === 162 || func.kind === 167) { + if (func.kind === 161 || func.kind === 165 || func.kind === 170) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198) { + if (func.kind === 201) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -46385,17 +48774,19 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 || typePredicate.kind === 2) { getTypeFromThisTypeNode(parameterName); } else { if (typePredicate.parameterIndex >= 0) { - if (signature.hasRestParameter && typePredicate.parameterIndex === signature.parameters.length - 1) { + if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError); + } } } else if (parameterName) { @@ -46416,13 +48807,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198: - case 161: - case 240: - case 197: - case 166: - case 157: - case 156: + case 201: + case 164: + case 243: + case 200: + case 169: + case 160: + case 159: var parent = node.parent; if (node === parent.type) { return parent; @@ -46436,11 +48827,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 && name.escapedText === predicateVariableName) { + if (name.kind === 75 && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 186 || name.kind === 185) { + else if (name.kind === 189 || name.kind === 188) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -46448,12 +48839,12 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 163) { + if (node.kind === 166) { checkGrammarIndexSignature(node); } - else if (node.kind === 166 || node.kind === 240 || node.kind === 167 || - node.kind === 161 || node.kind === 158 || - node.kind === 162) { + else if (node.kind === 169 || node.kind === 243 || node.kind === 170 || + node.kind === 164 || node.kind === 161 || + node.kind === 165) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -46478,10 +48869,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162: + case 165: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161: + case 164: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -46505,7 +48896,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 && node.kind !== 295) { + if (node.kind !== 166 && node.kind !== 298) { registerForUnusedIdentifiersCheck(node); } } @@ -46515,7 +48906,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158) { + if (member.kind === 161) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { @@ -46530,16 +48921,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159: + case 162: addName(names, name, memberName, 1); break; - case 160: + case 163: addName(names, name, memberName, 2); break; - case 155: + case 158: addName(names, name, memberName, 3); break; - case 157: + case 160: addName(names, name, memberName, 8); break; } @@ -46591,7 +48982,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154) { + if (member.kind === 157) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -46599,7 +48990,7 @@ var ts; case 8: memberName = name.text; break; - case 73: + case 75: memberName = ts.idText(name); break; default: @@ -46616,7 +49007,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242) { + if (node.kind === 245) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -46631,7 +49022,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139: + case 142: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -46639,7 +49030,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136: + case 139: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -46661,7 +49052,7 @@ var ts; if (!checkGrammarMethod(node)) checkGrammarComputedPropertyName(node.name); checkFunctionOrMethodDeclaration(node); - if (ts.hasModifier(node, 128) && node.kind === 157 && node.body) { + if (ts.hasModifier(node, 128) && node.kind === 160 && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -46682,7 +49073,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 && + return n.kind === 158 && !ts.hasModifier(n, 32) && !!n.initializer; } @@ -46700,9 +49091,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -46726,18 +49117,18 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159) { - if (!(node.flags & 4194304) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { - if (!(node.flags & 256)) { + if (node.kind === 162) { + if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) { + if (!(node.flags & 512)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 150) { + if (node.name.kind === 153) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { - var otherKind = node.kind === 159 ? 160 : 159; + var otherKind = node.kind === 162 ? 163 : 162; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -46753,7 +49144,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159) { + if (node.kind === 162) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -46801,18 +49192,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 && getNodeLinks(node).resolvedSymbol.flags & 8) { @@ -46848,16 +49237,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173) { + if (e.kind === 176) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172) { + else if (e.kind === 175) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -46877,7 +49266,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) { - if (accessNode.kind === 191 && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -46926,7 +49315,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -46937,14 +49326,14 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8) && !!(node.flags & 4194304); + return ts.hasModifier(node, 8) && !!(node.flags & 8388608); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 242 && - n.parent.kind !== 241 && - n.parent.kind !== 210 && - n.flags & 4194304) { + if (n.parent.kind !== 245 && + n.parent.kind !== 244 && + n.parent.kind !== 213 && + n.flags & 8388608) { if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { flags |= 1; } @@ -47023,7 +49412,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 || node.kind === 156) && + var reportError = (node.kind === 160 || node.kind === 159) && ts.hasModifier(node, 32) !== ts.hasModifier(subsequentNode, 32); if (reportError) { var diagnostic = ts.hasModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -47056,15 +49445,15 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304; - var inAmbientContextOrInterface = node.parent.kind === 242 || node.parent.kind === 169 || inAmbientContext; + var inAmbientContext = node.flags & 8388608; + var inAmbientContextOrInterface = node.parent.kind === 245 || node.parent.kind === 172 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if ((node.kind === 241 || node.kind === 210) && !inAmbientContext) { + if ((node.kind === 244 || node.kind === 213) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 240 || node.kind === 157 || node.kind === 156 || node.kind === 158) { + if (node.kind === 243 || node.kind === 160 || node.kind === 159 || node.kind === 161) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -47120,8 +49509,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -47182,37 +49571,37 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242: - case 243: - case 312: - case 305: - case 306: - return 2; case 245: + case 246: + case 315: + case 308: + case 309: + return 2; + case 248: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4 | 1 : 4; - case 241: case 244: + case 247: return 2 | 1; - case 285: + case 288: return 2 | 1 | 4; - case 255: + case 258: if (!ts.isEntityNameExpression(d.expression)) { return 1; } d = d.expression; - case 249: case 252: - case 251: + case 255: + case 254: var result_8 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238: - case 187: - case 240: - case 254: + case 241: + case 190: + case 243: + case 257: return 1; default: return ts.Debug.failBadSyntaxKind(d); @@ -47232,7 +49621,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); if (isTypeAny(thenFunction)) { @@ -47333,7 +49722,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) { + if (promiseConstructorName.kind === 75 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -47349,7 +49738,7 @@ var ts; if (!checkTypeAssignableTo(promiseConstructorType, globalPromiseConstructorLikeType, returnTypeNode, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value)) { return; } - var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); @@ -47368,22 +49757,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241: + case 244: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152: + case 155: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 155: + case 158: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 157: - case 159: case 160: + case 162: + case 163: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -47399,8 +49788,8 @@ var ts; function markEntityNameOrEntityExpressionAsReference(typeName) { if (!typeName) return; - var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 ? 788968 : 1920) | 2097152; + var rootName = ts.getFirstIdentifier(typeName); + var meaning = (typeName.kind === 75 ? 788968 : 1920) | 2097152; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true); if (rootSymbol && rootSymbol.flags & 2097152 @@ -47418,29 +49807,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175: - case 174: + case 178: + case 177: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176: + case 179: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178: + case 181: return getEntityNameForDecoratorMetadata(node.type); - case 165: + case 168: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var typeNode = types_16[_i]; - while (typeNode.kind === 178) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181) { typeNode = typeNode.type; } - if (typeNode.kind === 133) { + if (typeNode.kind === 136) { continue; } - if (!strictNullChecks && (typeNode.kind === 97 || typeNode.kind === 142)) { + if (!strictNullChecks && (typeNode.kind === 99 || typeNode.kind === 145)) { continue; } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -47476,13 +49865,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 152) { + if (node.kind === 155) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 241: + case 244: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -47491,23 +49880,23 @@ var ts; } } break; - case 159: - case 160: - var otherKind = node.kind === 159 ? 160 : 159; + case 162: + case 163: + var otherKind = node.kind === 162 ? 163 : 162; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157: + case 160: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 155: + case 158: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152: + case 155: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -47566,7 +49955,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 149 ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 152 ? node.name.right : node.name)); } } } @@ -47599,9 +49988,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73: + case 75: return node; - case 190: + case 193: return node.name; default: return undefined; @@ -47611,13 +50000,13 @@ var ts; checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); - if (node.name && node.name.kind === 150) { + if (node.name && node.name.kind === 153) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { var symbol = getSymbolOfNode(node); var localSymbol = node.localSymbol || symbol; - var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536); }); + var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); }); if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); } @@ -47627,7 +50016,7 @@ var ts; } } } - var body = node.kind === 156 ? undefined : node.body; + var body = node.kind === 159 ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -47646,7 +50035,7 @@ var ts; } } function registerForUnusedIdentifiersCheck(node) { - if (produceDiagnostics && !(node.flags & 4194304)) { + if (produceDiagnostics && !(node.flags & 8388608)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -47660,42 +50049,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241: - case 210: + case 244: + case 213: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285: - case 245: - case 219: - case 247: - case 226: - case 227: - case 228: + case 288: + case 248: + case 222: + case 250: + case 229: + case 230: + case 231: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158: - case 197: - case 240: - case 198: - case 157: - case 159: + case 161: + case 200: + case 243: + case 201: case 160: + case 162: + case 163: if (node.body) { checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156: - case 161: - case 162: - case 166: - case 167: - case 243: - case 242: + case 159: + case 164: + case 165: + case 169: + case 170: + case 246: + case 245: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177: + case 180: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -47715,11 +50104,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157: - case 155: - case 159: case 160: - if (member.kind === 160 && member.symbol.flags & 32768) { + case 158: + case 162: + case 163: + if (member.kind === 163 && member.symbol.flags & 32768) { break; } var symbol = getSymbolOfNode(member); @@ -47727,7 +50116,7 @@ var ts; addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 158: + case 161: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { @@ -47735,8 +50124,8 @@ var ts; } } break; - case 163: - case 218: + case 166: + case 221: break; default: ts.Debug.fail(); @@ -47760,7 +50149,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) ? ts.rangeOfNode(parent) @@ -47793,7 +50182,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304) + if (nodeWithLocals.flags & 8388608) return; var unusedImports = ts.createMap(); var unusedDestructures = ts.createMap(); @@ -47839,7 +50228,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0, unuseds.length === 1 @@ -47857,7 +50246,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 238 && bindingPattern.parent.parent.kind === 239) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 && bindingPattern.parent.parent.kind === 242) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -47878,7 +50267,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 220 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -47890,23 +50279,23 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73: + case 75: return ts.idText(name); - case 186: - case 185: + case 189: + case 188: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 || node.kind === 254 || node.kind === 252; + return node.kind === 254 || node.kind === 257 || node.kind === 255; } function importClauseFromImported(decl) { - return decl.kind === 251 ? decl : decl.kind === 252 ? decl.parent : decl.parent.parent; + return decl.kind === 254 ? decl : decl.kind === 255 ? decl.parent : decl.parent.parent; } function checkBlock(node) { - if (node.kind === 219) { + if (node.kind === 222) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -47922,7 +50311,7 @@ var ts; } } function checkCollisionWithArgumentsInGeneratedCode(node) { - if (languageVersion >= 2 || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -47935,19 +50324,19 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 || - node.kind === 154 || + if (node.kind === 158 || node.kind === 157 || - node.kind === 156 || + node.kind === 160 || node.kind === 159 || - node.kind === 160) { + node.kind === 162 || + node.kind === 163) { return false; } - if (node.flags & 4194304) { + if (node.flags & 8388608) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -47955,7 +50344,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 73; + var isDeclaration_1 = node.kind !== 75; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -47970,7 +50359,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8) { - var isDeclaration_2 = node.kind !== 73; + var isDeclaration_2 = node.kind !== 75; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -47993,7 +50382,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 285 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 && ts.isExternalOrCommonJsModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -48005,7 +50394,7 @@ var ts; return; } var parent = getDeclarationContainer(node); - if (parent.kind === 285 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 288 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } } @@ -48013,7 +50402,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 238 && !node.initializer) { + if (node.kind === 241 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -48025,15 +50414,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239); - var container = varDeclList.parent.kind === 220 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242); + var container = varDeclList.parent.kind === 224 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 219 && ts.isFunctionLike(container.parent) || - container.kind === 246 || - container.kind === 245 || - container.kind === 285); + (container.kind === 222 && ts.isFunctionLike(container.parent) || + container.kind === 249 || + container.kind === 248 || + container.kind === 288); if (!namesShareScope) { var name = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); @@ -48053,17 +50442,17 @@ var ts; if (!node.name) { return; } - if (node.name.kind === 150) { + if (node.name.kind === 153) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187) { - if (node.parent.kind === 185 && languageVersion < 99) { + if (node.kind === 190) { + if (node.parent.kind === 188 && languageVersion < 99) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 150) { + if (node.propertyName && node.propertyName.kind === 153) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -48076,23 +50465,23 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, undefined, false); - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101, parentType, property); } } } } if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 && languageVersion < 2 && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 && languageVersion < 2 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512); } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 152 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { var widenedType = getWidenedTypeForVariableLikeDeclaration(node); @@ -48125,7 +50514,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined); } } @@ -48149,9 +50538,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 && node.kind !== 154) { + if (node.kind !== 158 && node.kind !== 157) { checkExportsOnMergedDeclarations(node); - if (node.kind === 238 || node.kind === 187) { + if (node.kind === 241 || node.kind === 190) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -48160,7 +50549,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 || nextDeclaration.kind === 154 + var message = nextDeclaration.kind === 158 || nextDeclaration.kind === 157 ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -48170,8 +50559,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 && right.kind === 238) || - (left.kind === 238 && right.kind === 152)) { + if ((left.kind === 155 && right.kind === 241) || + (left.kind === 241 && right.kind === 155)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -48204,13 +50593,51 @@ var ts; } function checkIfStatement(node) { checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221) { + if (node.thenStatement.kind === 223) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + var callSignatures = getSignaturesOfType(type, 0); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { checkGrammarStatementInAmbientContext(node); checkSourceElement(node.statement); @@ -48230,12 +50657,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239) { + if (node.initializer && node.initializer.kind === 242) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239) { + if (node.initializer.kind === 242) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -48262,18 +50689,18 @@ var ts; else if (compilerOptions.downlevelIteration && languageVersion < 2) { checkExternalEmitHelpers(node, 256); } - if (node.initializer.kind === 239) { + if (node.initializer.kind === 242) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); - if (varExpr.kind === 188 || varExpr.kind === 189) { + if (varExpr.kind === 191 || varExpr.kind === 192) { checkDestructuringAssignment(varExpr, iteratedType || errorType); } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); if (iteratedType) { checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression); } @@ -48287,7 +50714,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression)); - if (node.initializer.kind === 239) { + if (node.initializer.kind === 242) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -48297,14 +50724,14 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 188 || varExpr.kind === 189) { + if (varExpr.kind === 191 || varExpr.kind === 192) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any); } else { - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) { @@ -48560,12 +50987,12 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } if (isReferenceToType(type, resolver.getGlobalGeneratorType(false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -48604,7 +51031,7 @@ var ts; function getIterationTypesOfIteratorFast(type, resolver) { var globalType = resolver.getGlobalIterableIteratorType(false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) || getIterationTypesOfIteratorSlow(globalType, resolver, undefined); var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType; @@ -48612,7 +51039,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -48635,11 +51062,11 @@ var ts; return cachedTypes; } if (isReferenceToType(type, getGlobalIteratorYieldResultType(false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, undefined, undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(undefined, returnType_1, undefined); } var yieldIteratorResult = filterType(type, isYieldIteratorResult); @@ -48685,11 +51112,11 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + nextType = methodParameterType; } else if (methodName === "return") { + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -48763,12 +51190,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160) { + if (func.kind === 163) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158) { + else if (func.kind === 161) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -48783,13 +51210,13 @@ var ts; } } } - else if (func.kind !== 158 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } function checkWithStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384) { + if (node.flags & 32768) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -48808,19 +51235,16 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 273 && !hasDuplicateDefaultClause) { + if (clause.kind === 276 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272) { + if (produceDiagnostics && clause.kind === 275) { var caseType = checkExpression(clause.expression); var caseIsLiteral = isLiteralType(caseType); var comparedExpressionType = expressionType; @@ -48833,6 +51257,9 @@ var ts; } } ts.forEach(clause.statements, checkSourceElement); + if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) { + error(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } }); if (node.caseBlock.locals) { registerForUnusedIdentifiersCheck(node.caseBlock); @@ -48844,7 +51271,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -48939,8 +51366,8 @@ var ts; } var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 205 || - name.kind === 150 || + (propDeclaration.kind === 208 || + name.kind === 153 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -49005,7 +51432,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165) { + if (node.kind === 168) { var type = getTypeFromTypeReference(node); if (type.flags & 262144) { for (var i = index; i < typeParameters.length; i++) { @@ -49094,7 +51521,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304)) { + if (!(node.flags & 8388608)) { checkClassNameCollisionWithObject(node.name); } } @@ -49106,11 +51533,12 @@ var ts; var staticType = getTypeOfSymbol(symbol); checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); - if (!(node.flags & 4194304)) { + if (!(node.flags & 8388608)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2) { checkExternalEmitHelpers(baseTypeNode.parent, 1); } @@ -49146,7 +51574,7 @@ var ts; } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) { var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -49188,7 +51616,7 @@ var ts; } function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -49206,7 +51634,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag); @@ -49229,7 +51657,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 || d.kind === 242; + return d.kind === 244 || d.kind === 245; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -49256,7 +51684,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 210) { + if (derivedClassDecl.kind === 213) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -49269,16 +51697,50 @@ var ts; if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { continue; } - if (isPrototypeProperty(base) || base.flags & 98308 && derived.flags & 98308) { - continue; - } var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + var basePropertyFlags = base.flags & 98308; + var derivedPropertyFlags = derived.flags & 98308; + if (basePropertyFlags && derivedPropertyFlags) { + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + continue; + } + if (basePropertyFlags !== 4 && derivedPropertyFlags === 4) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; + } + else if (basePropertyFlags === 4 && derivedPropertyFlags !== 4) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432) + && !(baseDeclarationFlags & 128) + && !(derivedDeclarationFlags & 128) + && !derived.declarations.some(function (d) { return d.flags & 8388608; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } + } + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived) || derived.flags & 4) { + continue; + } + else { + ts.Debug.assert(!!(derived.flags & 98304)); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } else if (base.flags & 98304) { @@ -49324,12 +51786,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -49344,7 +51809,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 && + return node.kind === 158 && !ts.hasModifier(node, 32 | 128) && !node.exclamationToken && !node.initializer; @@ -49366,7 +51831,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -49425,7 +51890,7 @@ var ts; if (member.initializer) { return computeConstantValue(member); } - if (member.parent.flags & 4194304 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) { + if (member.parent.flags & 8388608 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) { return undefined; } if (autoValue !== undefined) { @@ -49453,7 +51918,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304) { + else if (member.parent.flags & 8388608) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -49462,66 +51927,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203: + case 206: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38: return value_2; - case 39: return -value_2; - case 53: return ~value_2; + case 39: return value_2; + case 40: return -value_2; + case 54: return ~value_2; } } break; - case 205: + case 208: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 50: return left | right; - case 49: return left & right; - case 47: return left >> right; - case 48: return left >>> right; - case 46: return left << right; - case 51: return left ^ right; - case 40: return left * right; - case 42: return left / right; - case 38: return left + right; - case 39: return left - right; - case 43: return left % right; - case 41: return Math.pow(left, right); + case 51: return left | right; + case 50: return left & right; + case 48: return left >> right; + case 49: return left >>> right; + case 47: return left << right; + case 52: return left ^ right; + case 41: return left * right; + case 43: return left / right; + case 39: return left + right; + case 40: return left - right; + case 44: return left % right; + case 42: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39) { return left + right; } break; case 10: + case 14: return expr.text; case 8: checkGrammarNumericLiteral(expr); return +expr.text; - case 196: + case 199: return evaluate(expr.expression); - case 73: + case 75: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191: - case 190: + case 194: + case 193: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384) { var name = void 0; - if (ex.kind === 190) { + if (ex.kind === 193) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -49546,10 +52010,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 || - node.kind === 190 && isConstantMemberAccess(node.expression) || - node.kind === 191 && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10; + return node.kind === 75 || + node.kind === 193 && isConstantMemberAccess(node.expression) || + node.kind === 194 && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -49574,7 +52038,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 244) { + if (declaration.kind !== 247) { return false; } var enumDeclaration = declaration; @@ -49597,9 +52061,9 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 || - (declaration.kind === 240 && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304)) { + if ((declaration.kind === 244 || + (declaration.kind === 243 && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608)) { return declaration; } } @@ -49621,7 +52085,7 @@ var ts; function checkModuleDeclaration(node) { if (produceDiagnostics) { var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304; + var inAmbientContext = node.flags & 8388608; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -49656,7 +52120,7 @@ var ts; error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged); } } - var mergedClass = ts.getDeclarationOfKind(symbol, 241); + var mergedClass = ts.getDeclarationOfKind(symbol, 244); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -49699,22 +52163,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220: + case 224: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255: - case 256: + case 258: + case 259: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249: - case 250: + case 252: + case 253: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187: - case 238: + case 190: + case 241: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -49723,12 +52187,12 @@ var ts; } break; } - case 241: case 244: - case 240: - case 242: - case 245: + case 247: case 243: + case 245: + case 248: + case 246: if (isGlobalAugmentation) { return; } @@ -49742,19 +52206,22 @@ var ts; break; } } - function getFirstIdentifier(node) { + function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 73: + case 75: return node; - case 149: + case 152: do { node = node.left; - } while (node.kind !== 73); + } while (node.kind !== 75); return node; - case 190: + case 193: do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } node = node.expression; - } while (node.kind !== 73); + } while (node.kind !== 75); return node; } } @@ -49767,9 +52234,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 ? + var inAmbientExternalModule = node.parent.kind === 249 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -49787,19 +52254,20 @@ var ts; var target = resolveAlias(symbol); var shouldSkipWithJSExpandoTargets = symbol.flags & 67108864; if (!shouldSkipWithJSExpandoTargets && target !== unknownSymbol) { + symbol = getMergedSymbol(symbol.exportSymbol || symbol); var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) | (symbol.flags & 788968 ? 788968 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 ? + var message = node.kind === 261 ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } if (compilerOptions.isolatedModules - && node.kind === 258 + && node.kind === 261 && !(target.flags & 111551) - && !(node.flags & 4194304)) { + && !(node.flags & 8388608)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -49823,7 +52291,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252) { + if (importClause.namedBindings.kind === 255) { checkImportBinding(importClause.namedBindings); } else { @@ -49846,11 +52314,11 @@ var ts; if (ts.hasModifier(node, 1)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260) { + if (node.moduleReference.kind !== 263) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551) { - var moduleName = getFirstIdentifier(node.moduleReference); + var moduleName = ts.getFirstIdentifier(node.moduleReference); if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } @@ -49861,7 +52329,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608)) { grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } @@ -49877,10 +52345,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 && - !node.moduleSpecifier && node.flags & 4194304; - if (node.parent.kind !== 285 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 && + !node.moduleSpecifier && node.flags & 8388608; + if (node.parent.kind !== 288 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -49896,7 +52364,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 || node.parent.kind === 246 || node.parent.kind === 245; + var isInAppropriateContext = node.parent.kind === 288 || node.parent.kind === 249 || node.parent.kind === 248; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -49910,7 +52378,7 @@ var ts; if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true); - if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { @@ -49926,8 +52394,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 285 ? node.parent : node.parent.parent; - if (container.kind === 245 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 ? node.parent : node.parent.parent; + if (container.kind === 248 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -49939,7 +52407,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73) { + if (node.expression.kind === 75) { var id = node.expression; var sym = resolveEntityName(id, 67108863, true, true, node); if (sym) { @@ -49957,10 +52425,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304)) { + if (node.isExportEquals && !(node.flags & 8388608)) { if (moduleKind >= ts.ModuleKind.ES2015) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -49983,9 +52451,9 @@ var ts; error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -50029,158 +52497,161 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { + case 248: + case 244: case 245: - case 241: - case 242: - case 240: + case 243: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 && kind <= 240 && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151: + case 154: return checkTypeParameter(node); - case 152: - return checkParameter(node); case 155: - case 154: + return checkParameter(node); + case 158: + case 157: return checkPropertyDeclaration(node); + case 169: + case 170: + case 164: + case 165: case 166: - case 167: - case 161: - case 162: - case 163: return checkSignatureDeclaration(node); - case 157: - case 156: + case 160: + case 159: return checkMethodDeclaration(node); - case 158: + case 161: return checkConstructorDeclaration(node); - case 159: - case 160: + case 162: + case 163: return checkAccessorDeclaration(node); - case 165: + case 168: return checkTypeReferenceNode(node); - case 164: + case 167: return checkTypePredicate(node); - case 168: + case 171: return checkTypeQuery(node); - case 169: + case 172: return checkTypeLiteral(node); - case 170: + case 173: return checkArrayType(node); - case 171: - return checkTupleType(node); case 174: - case 175: - return checkUnionOrIntersectionType(node); + return checkTupleType(node); + case 177: case 178: - case 172: - case 173: + return checkUnionOrIntersectionType(node); + case 181: + case 175: + case 176: return checkSourceElement(node.type); - case 179: + case 182: return checkThisType(node); - case 180: + case 183: return checkTypeOperator(node); - case 176: + case 179: return checkConditionalType(node); - case 177: + case 180: return checkInferType(node); - case 184: + case 187: return checkImportType(node); - case 302: - return checkJSDocAugmentsTag(node); - case 312: case 305: - case 306: + return checkJSDocAugmentsTag(node); + case 315: + case 308: + case 309: return checkJSDocTypeAliasTag(node); - case 311: + case 314: return checkJSDocTemplateTag(node); - case 310: + case 313: return checkJSDocTypeTag(node); - case 307: + case 310: return checkJSDocParameterTag(node); - case 295: + case 298: checkJSDocFunctionType(node); + case 296: + case 295: case 293: - case 292: - case 290: - case 291: - case 299: + case 294: + case 302: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296: + case 299: checkJSDocVariadicType(node); return; - case 289: + case 292: return checkSourceElement(node.type); - case 181: + case 184: return checkIndexedAccessType(node); - case 182: + case 185: return checkMappedType(node); - case 240: + case 243: return checkFunctionDeclaration(node); - case 219: - case 246: + case 222: + case 249: return checkBlock(node); - case 220: + case 224: return checkVariableStatement(node); - case 222: + case 225: return checkExpressionStatement(node); - case 223: + case 226: return checkIfStatement(node); - case 224: + case 227: return checkDoStatement(node); - case 225: + case 228: return checkWhileStatement(node); - case 226: + case 229: return checkForStatement(node); - case 227: + case 230: return checkForInStatement(node); - case 228: + case 231: return checkForOfStatement(node); - case 229: - case 230: + case 232: + case 233: return checkBreakOrContinueStatement(node); - case 231: + case 234: return checkReturnStatement(node); - case 232: + case 235: return checkWithStatement(node); - case 233: + case 236: return checkSwitchStatement(node); - case 234: + case 237: return checkLabeledStatement(node); - case 235: + case 238: return checkThrowStatement(node); - case 236: + case 239: return checkTryStatement(node); - case 238: + case 241: return checkVariableDeclaration(node); - case 187: + case 190: return checkBindingElement(node); - case 241: + case 244: return checkClassDeclaration(node); - case 242: + case 245: return checkInterfaceDeclaration(node); - case 243: + case 246: return checkTypeAliasDeclaration(node); - case 244: + case 247: return checkEnumDeclaration(node); - case 245: + case 248: return checkModuleDeclaration(node); - case 250: + case 253: return checkImportDeclaration(node); - case 249: + case 252: return checkImportEqualsDeclaration(node); - case 256: + case 259: return checkExportDeclaration(node); - case 255: + case 258: return checkExportAssignment(node); - case 221: - case 237: + case 223: + case 240: checkGrammarStatementInAmbientContext(node); return; - case 259: + case 262: return checkMissingDeclaration(node); } } @@ -50256,23 +52727,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197: - case 198: - case 157: - case 156: + case 200: + case 201: + case 160: + case 159: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159: - case 160: + case 162: + case 163: checkAccessorDeclaration(node); break; - case 210: + case 213: checkClassExpressionDeferred(node); break; - case 262: + case 265: checkJsxSelfClosingElementDeferred(node); break; - case 261: + case 264: checkJsxElementDeferred(node); break; } @@ -50300,7 +52771,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } checkGrammarSourceFile(node); @@ -50372,7 +52843,7 @@ var ts; } } function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608) { + if (location.flags & 16777216) { return []; } var symbols = ts.createSymbolTable(); @@ -50386,27 +52857,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285: + case 288: if (!ts.isExternalOrCommonJsModule(location)) break; - case 245: + case 248: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475); break; - case 244: + case 247: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 210: + case 213: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 241: - case 242: + case 244: + case 245: if (!isStatic) { copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968); } break; - case 197: + case 200: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -50438,33 +52909,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 && + return name.kind === 75 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151: - case 241: - case 242: - case 243: + case 154: case 244: + case 245: + case 246: + case 247: return true; default: return false; } } function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149) { + while (node.parent.kind === 152) { node = node.parent; } - return node.parent.kind === 165; + return node.parent.kind === 168; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190) { + while (node.parent.kind === 193) { node = node.parent; } - return node.parent.kind === 212; + return node.parent.kind === 215; } function forEachEnclosingClass(node, callback) { var result; @@ -50492,13 +52963,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149) { + while (nodeOnRightSide.parent.kind === 152) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249) { + if (nodeOnRightSide.parent.kind === 252) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255) { + if (nodeOnRightSide.parent.kind === 258) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -50524,7 +52995,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 && parent.qualifier === node) { + if (parent && parent.kind === 187 && parent.qualifier === node) { return parent; } return undefined; @@ -50534,21 +53005,21 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 && + entityName.parent.kind === 193 && entityName.parent === entityName.parent.parent.left) { var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); if (specialPropertyAssignmentSymbol) { return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 && ts.isEntityNameExpression(entityName)) { var success = resolveEntityName(entityName, 111551 | 788968 | 1920 | 2097152, true); if (success && success !== unknownSymbol) { return success; } } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 249); + var importEqualsDeclaration = ts.getAncestor(entityName, 252); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -50565,7 +53036,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 212) { + if (entityName.parent.kind === 215) { meaning = 788968; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 111551; @@ -50580,10 +53051,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 307) { + if (entityName.parent.kind === 310) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 && entityName.parent.parent.kind === 311) { + if (entityName.parent.kind === 154 && entityName.parent.parent.kind === 314) { ts.Debug.assert(!ts.isInJSFile(entityName)); var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -50592,19 +53063,19 @@ var ts; if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 73) { + if (entityName.kind === 75) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 111551, false, true); } - else if (entityName.kind === 190 || entityName.kind === 149) { + else if (entityName.kind === 193 || entityName.kind === 152) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190) { + if (entityName.kind === 193) { checkPropertyAccessExpression(entityName); } else { @@ -50614,21 +53085,21 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 ? 788968 : 1920; + var meaning = entityName.parent.kind === 168 ? 788968 : 1920; return resolveEntityName(entityName, meaning, false, true); } - if (entityName.parent.kind === 164) { + if (entityName.parent.kind === 167) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285) { + if (node.kind === 288) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608) { + if (node.flags & 16777216) { return undefined; } if (isDeclarationNameOrImportPropertyName(node)) { @@ -50640,12 +53111,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73) { + if (node.kind === 75) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 && - grandParent.kind === 185 && + else if (parent.kind === 190 && + grandParent.kind === 188 && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -50655,11 +53126,11 @@ var ts; } } switch (node.kind) { - case 73: - case 190: - case 149: + case 75: + case 193: + case 152: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101: + case 103: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -50670,20 +53141,20 @@ var ts; if (ts.isInExpressionContext(node)) { return checkExpression(node).symbol; } - case 179: + case 182: return getTypeFromThisTypeNode(node).symbol; - case 99: + case 101: return checkExpression(node).symbol; - case 125: + case 128: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158) { + if (constructorDeclaration && constructorDeclaration.kind === 161) { return constructorDeclaration.parent.symbol; } return undefined; case 10: case 14: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 250 || node.parent.kind === 256) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 || node.parent.kind === 259) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -50698,21 +53169,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81: - case 91: - case 37: - case 77: + case 83: + case 93: + case 38: + case 79: return getSymbolOfNode(node.parent); - case 184: + case 187: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86: + case 88: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277) { + if (location && location.kind === 280) { return resolveEntityName(location.name, 111551 | 2097152); } return undefined; @@ -50723,7 +53194,7 @@ var ts; resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152); } function getTypeOfNode(node) { - if (node.flags & 8388608) { + if (node.flags & 16777216) { return errorType; } var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node); @@ -50768,20 +53239,20 @@ var ts; return errorType; } function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 || expr.kind === 188); - if (expr.parent.kind === 228) { + ts.Debug.assert(expr.kind === 192 || expr.kind === 191); + if (expr.parent.kind === 231) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 205) { + if (expr.parent.kind === 208) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } - if (expr.parent.kind === 276) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType; @@ -50807,17 +53278,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73: + case 75: return getLiteralType(ts.idText(name)); case 8: case 10: return getLiteralType(name.text); - case 150: + case 153: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } function getAugmentedPropertiesOfType(type) { @@ -50866,7 +53336,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -50908,7 +53378,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 285) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 288) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; @@ -50931,7 +53401,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -50946,7 +53416,7 @@ var ts; else if (nodeLinks_1.flags & 262144) { var isDeclaredInLoop = nodeLinks_1.flags & 524288; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 219 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 222 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -50982,26 +53452,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249: - case 251: case 252: case 254: - case 258: + case 255: + case 257: + case 261: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256: + case 259: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255: - return node.expression - && node.expression.kind === 73 - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258: + return node.expression && node.expression.kind === 75 ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -51087,15 +53556,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279: - case 190: - case 191: + case 282: + case 193: + case 194: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279) { + if (node.kind === 282) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -51175,7 +53644,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121); + return ts.createToken(124); } var symbol = getSymbolOfNode(declaration); var type = symbol && !(symbol.flags & (2048 | 131072)) @@ -51193,7 +53662,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121); + return ts.createToken(124); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker); @@ -51201,7 +53670,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121); + return ts.createToken(124); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker); @@ -51316,12 +53785,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); - var otherKind = accessor.kind === 160 ? 159 : 160; + var otherKind = accessor.kind === 163 ? 162 : 163; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 160 ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -51334,17 +53803,26 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 && node.parent.parent && node.parent.parent.kind === 274; + return node.parent && node.parent.kind === 215 && node.parent.parent && node.parent.parent.kind === 277; } function getTypeReferenceDirectivesForEntityName(node) { if (!fileToDirective) { return undefined; } var meaning = 788968 | 1920; - if ((node.kind === 73 && isInTypeQuery(node)) || (node.kind === 190 && !isInHeritageClause(node))) { + if ((node.kind === 75 && isInTypeQuery(node)) || (node.kind === 193 && !isInHeritageClause(node))) { meaning = 111551 | 1048576; } var symbol = resolveEntityName(node, meaning, true); @@ -51387,7 +53865,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -51414,12 +53892,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined); if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 285); + return ts.getDeclarationOfKind(moduleSymbol, 288); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -51532,7 +54010,7 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; @@ -51541,7 +54019,7 @@ var ts; var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -51587,14 +54065,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 159 || node.kind === 160) { + else if (node.kind === 162 || node.kind === 163) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -51611,23 +54089,23 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 134) { - if (node.kind === 154 || node.kind === 156) { + if (modifier.kind !== 137) { + if (node.kind === 157 || node.kind === 159) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163) { + if (node.kind === 166) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78: - if (node.kind !== 244) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78)); + case 80: + if (node.kind !== 247) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80)); } break; + case 118: + case 117: case 116: - case 115: - case 114: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -51641,11 +54119,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 246 || node.parent.kind === 285) { + else if (node.parent.kind === 249 || node.parent.kind === 288) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 114) { + if (modifier.kind === 116) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -51654,7 +54132,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117: + case 119: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -51664,10 +54142,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 || node.parent.kind === 285) { + else if (node.parent.kind === 249 || node.parent.kind === 288) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152) { + else if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -51676,17 +54154,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 134: + case 137: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 && node.kind !== 154 && node.kind !== 163 && node.kind !== 152) { + else if (node.kind !== 158 && node.kind !== 157 && node.kind !== 166 && node.kind !== 155) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 86: + case 88: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -51699,52 +54177,52 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152) { + else if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 81: - var container = node.parent.kind === 285 ? node.parent : node.parent.parent; - if (container.kind === 245 && !ts.isAmbientModule(container)) { + case 83: + var container = node.parent.kind === 288 ? node.parent : node.parent.parent; + if (container.kind === 248 && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512; break; - case 126: + case 129: if (flags & 2) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152) { + else if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304) && node.parent.kind === 246) { + else if ((node.parent.flags & 8388608) && node.parent.kind === 249) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 119: + case 121: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241) { - if (node.kind !== 157 && - node.kind !== 155 && - node.kind !== 159 && - node.kind !== 160) { + if (node.kind !== 244) { + if (node.kind !== 160 && + node.kind !== 158 && + node.kind !== 162 && + node.kind !== 163) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 && ts.hasModifier(node.parent, 128))) { + if (!(node.parent.kind === 244 && ts.hasModifier(node.parent, 128))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -51756,14 +54234,14 @@ var ts; } flags |= 128; break; - case 122: + case 125: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 || node.parent.flags & 4194304) { + else if (flags & 2 || node.parent.flags & 8388608) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152) { + else if (node.kind === 155) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -51771,7 +54249,7 @@ var ts; break; } } - if (node.kind === 158) { + if (node.kind === 161) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -51786,13 +54264,13 @@ var ts; } return false; } - else if ((node.kind === 250 || node.kind === 249) && flags & 2) { + else if ((node.kind === 253 || node.kind === 252) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 152 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 155 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -51809,38 +54287,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159: - case 160: + case 162: + case 163: + case 161: case 158: - case 155: - case 154: case 157: - case 156: - case 163: - case 245: - case 250: - case 249: - case 256: - case 255: - case 197: - case 198: - case 152: + case 160: + case 159: + case 166: + case 248: + case 253: + case 252: + case 259: + case 258: + case 200: + case 201: + case 155: return false; default: - if (node.parent.kind === 246 || node.parent.kind === 285) { + if (node.parent.kind === 249 || node.parent.kind === 288) { return false; } switch (node.kind) { - case 240: - return nodeHasAnyModifiersExcept(node, 122); - case 241: - return nodeHasAnyModifiersExcept(node, 119); - case 242: - case 220: case 243: - return true; + return nodeHasAnyModifiersExcept(node, 125); case 244: - return nodeHasAnyModifiersExcept(node, 78); + return nodeHasAnyModifiersExcept(node, 121); + case 245: + case 224: + case 246: + return true; + case 247: + return nodeHasAnyModifiersExcept(node, 80); default: ts.Debug.fail(); return false; @@ -51852,10 +54330,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157: - case 240: - case 197: - case 198: + case 160: + case 243: + case 200: + case 201: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -51884,7 +54362,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304)) { + if (!(parameter.flags & 8388608)) { checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -51969,15 +54447,15 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 && parameter.type.kind !== 136) { + if (parameter.type.kind !== 142 && parameter.type.kind !== 139) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 || type.flags & 8) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); } - if (type.flags & 1048576 && allTypesAssignableToKind(type, 128, true)) { + if (type.flags & 1048576 && allTypesAssignableToKind(type, 384, true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -52000,11 +54478,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211) { + if (arg.kind === 214) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -52034,7 +54518,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87) { + if (heritageClause.token === 89) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -52047,7 +54531,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110); + ts.Debug.assert(heritageClause.token === 112); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -52062,14 +54546,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87) { + if (heritageClause.token === 89) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110); + ts.Debug.assert(heritageClause.token === 112); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -52078,21 +54562,21 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 150) { + if (node.kind !== 153) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 && computedPropertyName.expression.operatorToken.kind === 27) { + if (computedPropertyName.expression.kind === 208 && computedPropertyName.expression.operatorToken.kind === 27) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 240 || - node.kind === 197 || - node.kind === 157); - if (node.flags & 4194304) { + ts.Debug.assert(node.kind === 243 || + node.kind === 200 || + node.kind === 160); + if (node.flags & 8388608) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -52110,7 +54594,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278) { + if (prop.kind === 281) { if (inDestructuring) { var expression = ts.skipParentheses(prop.expression); if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) { @@ -52120,38 +54604,38 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150) { + if (name.kind === 153) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 122 || prop.kind !== 157) { + if (mod.kind !== 125 || prop.kind !== 160) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; switch (prop.kind) { - case 277: + case 280: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - case 276: + case 279: checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } currentKind = 4; break; - case 157: + case 160: currentKind = 8; break; - case 159: + case 162: currentKind = 1; break; - case 160: + case 163: currentKind = 2; break; default: @@ -52188,7 +54672,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270) { + if (attr.kind === 273) { continue; } var name = attr.name, initializer = attr.initializer; @@ -52198,7 +54682,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 && !initializer.expression) { + if (initializer && initializer.kind === 274 && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -52212,13 +54696,13 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384) === 0) { + if (forInOrOfStatement.kind === 231 && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768) === 0) { var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158) { + if (func && func.kind !== 161) { ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -52229,7 +54713,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239) { + if (forInOrOfStatement.initializer.kind === 242) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -52237,20 +54721,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 + var diagnostic = forInOrOfStatement.kind === 230 ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 227 + var diagnostic = forInOrOfStatement.kind === 230 ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 227 + var diagnostic = forInOrOfStatement.kind === 230 ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -52260,7 +54744,7 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 4194304)) { + if (!(accessor.flags & 8388608)) { if (languageVersion < 1) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -52275,11 +54759,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 159 ? + return grammarErrorOnNode(accessor.name, accessor.kind === 162 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 160) { + if (accessor.kind === 163) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -52297,23 +54781,23 @@ var ts; return false; } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 159 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143) { - if (node.type.kind !== 140) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140)); + if (node.operator === 146) { + if (node.type.kind !== 143) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238: + case 241: var decl = parent; - if (decl.name.kind !== 73) { + if (decl.name.kind !== 75) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -52323,13 +54807,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155: + case 158: if (!ts.hasModifier(parent, 32) || !ts.hasModifier(parent, 64)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 154: + case 157: if (!ts.hasModifier(parent, 64)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -52338,9 +54822,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134) { - if (node.type.kind !== 170 && node.type.kind !== 171) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140)); + else if (node.operator === 137) { + if (node.type.kind !== 173 && node.type.kind !== 174) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143)); } } } @@ -52353,9 +54837,9 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157) { - if (node.parent.kind === 189) { - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 122)) { + if (node.kind === 160) { + if (node.parent.kind === 192) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -52373,17 +54857,17 @@ var ts; } } if (ts.isClassLike(node.parent)) { - if (node.flags & 4194304) { + if (node.flags & 8388608) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 157 && !node.body) { + else if (node.kind === 160 && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 242) { + else if (node.parent.kind === 245) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 169) { + else if (node.parent.kind === 172) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -52394,9 +54878,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234: + case 237: if (node.label && current.label.escapedText === node.label.escapedText) { - var isMisplacedContinueLabel = node.kind === 229 + var isMisplacedContinueLabel = node.kind === 232 && !ts.isIterationStatement(current.statement, true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -52404,8 +54888,8 @@ var ts; return false; } break; - case 233: - if (node.kind === 230 && !node.label) { + case 236: + if (node.kind === 233 && !node.label) { return false; } break; @@ -52418,13 +54902,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 + var message = node.kind === 233 ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 230 + var message = node.kind === 233 ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -52446,13 +54930,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 || expr.kind === 8 || - expr.kind === 203 && expr.operator === 39 && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 && expr.operator === 40 && expr.operand.kind === 8; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 || - expr.kind === 203 && expr.operator === 39 && + expr.kind === 206 && expr.operator === 40 && expr.operand.kind === 9; } function isSimpleLiteralEnumReference(expr) { @@ -52465,7 +54949,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 || initializer.kind === 88 || + initializer.kind === 105 || initializer.kind === 90 || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -52482,8 +54966,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 && node.parent.parent.kind !== 228) { - if (node.flags & 4194304) { + if (node.parent.parent.kind !== 230 && node.parent.parent.kind !== 231) { + if (node.flags & 8388608) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -52495,18 +54979,18 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 || !node.type || node.initializer || node.flags & 4194304)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 || !node.type || node.initializer || node.flags & 8388608)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304) && ts.hasModifier(node.parent.parent, 1)) { + !(node.parent.parent.flags & 8388608) && ts.hasModifier(node.parent.parent, 1)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73) { + if (name.kind === 75) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -52523,8 +55007,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73) { - if (name.originalKeywordKind === 112) { + if (name.kind === 75) { + if (name.originalKeywordKind === 114) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -52551,15 +55035,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223: - case 224: - case 225: - case 232: case 226: case 227: case 228: + case 235: + case 229: + case 230: + case 231: return false; - case 234: + case 237: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -52577,12 +55061,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96: + case 98: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 93: + case 95: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -52640,7 +55124,7 @@ var ts; return true; } } - else if (node.parent.kind === 242) { + else if (node.parent.kind === 245) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -52648,7 +55132,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169) { + else if (node.parent.kind === 172) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -52656,22 +55140,22 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304) { + if (node.flags & 8388608) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 || ts.hasModifier(node, 32 | 128))) { + node.flags & 8388608 || ts.hasModifier(node, 32 | 128))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 242 || - node.kind === 243 || - node.kind === 250 || - node.kind === 249 || - node.kind === 256 || - node.kind === 255 || - node.kind === 248 || + if (node.kind === 245 || + node.kind === 246 || + node.kind === 253 || + node.kind === 252 || + node.kind === 259 || + node.kind === 258 || + node.kind === 251 || ts.hasModifier(node, 2 | 1 | 512)) { return false; } @@ -52680,7 +55164,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 220) { + if (ts.isDeclaration(decl) || decl.kind === 224) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -52689,15 +55173,15 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304) { + if (node.flags & 8388608) { var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } - if (node.parent.kind === 219 || node.parent.kind === 246 || node.parent.kind === 285) { + if (node.parent.kind === 222 || node.parent.kind === 249 || node.parent.kind === 288) { var links_1 = getNodeLinks(node.parent); if (!links_1.hasReportedStatementInAmbientContext) { return links_1.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts); @@ -52714,20 +55198,31 @@ var ts; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 183)) { + else if (ts.isChildOfNodeWithKind(node, 186)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279)) { + else if (ts.isChildOfNodeWithKind(node, 282)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -52762,7 +55257,7 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd); } if (node.typeArguments) { return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); @@ -52783,13 +55278,13 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 240 && declaration.kind !== 157) || + return (declaration.kind !== 243 && declaration.kind !== 160) || !!declaration.body; } function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254: - case 258: + case 257: + case 261: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -52797,13 +55292,13 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251: - case 249: - case 252: case 254: + case 252: + case 255: + case 257: return true; - case 73: - return decl.parent.kind === 254; + case 75: + return decl.parent.kind === 257; default: return false; } @@ -52827,6 +55322,18 @@ var ts; case 2: return "nextType"; } } + function signatureHasRestParameter(s) { + return !!(s.flags & 1); + } + ts.signatureHasRestParameter = signatureHasRestParameter; + function signatureHasLiteralTypes(s) { + return !!(s.flags & 2); + } + ts.signatureHasLiteralTypes = signatureHasLiteralTypes; + function signatureIsOptionalCall(s) { + return !!(s.flags & 4); + } + ts.signatureIsOptionalCall = signatureIsOptionalCall; })(ts || (ts = {})); var ts; (function (ts) { @@ -52925,7 +55432,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73); + var node = createSynthesizedNode(75); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateFlags = 0; @@ -53001,23 +55508,23 @@ var ts; } ts.createToken = createToken; function createSuper() { - return createSynthesizedNode(99); + return createSynthesizedNode(101); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101); + return createSynthesizedNode(103); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97); + return createSynthesizedNode(99); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103); + return createSynthesizedNode(105); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88); + return createSynthesizedNode(90); } ts.createFalse = createFalse; function createModifier(kind) { @@ -53027,43 +55534,43 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1) { - result.push(createModifier(86)); + result.push(createModifier(88)); } if (flags & 2) { - result.push(createModifier(126)); + result.push(createModifier(129)); } if (flags & 512) { - result.push(createModifier(81)); + result.push(createModifier(83)); } if (flags & 2048) { - result.push(createModifier(78)); + result.push(createModifier(80)); } if (flags & 4) { - result.push(createModifier(116)); + result.push(createModifier(118)); } if (flags & 8) { - result.push(createModifier(114)); + result.push(createModifier(116)); } if (flags & 16) { - result.push(createModifier(115)); + result.push(createModifier(117)); } if (flags & 128) { - result.push(createModifier(119)); + result.push(createModifier(121)); } if (flags & 32) { - result.push(createModifier(117)); + result.push(createModifier(119)); } if (flags & 64) { - result.push(createModifier(134)); + result.push(createModifier(137)); } if (flags & 256) { - result.push(createModifier(122)); + result.push(createModifier(125)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; function createQualifiedName(left, right) { - var node = createSynthesizedNode(149); + var node = createSynthesizedNode(152); node.left = left; node.right = asName(right); return node; @@ -53082,7 +55589,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150); + var node = createSynthesizedNode(153); node.expression = parenthesizeForComputedName(expression); return node; } @@ -53094,7 +55601,7 @@ var ts; } ts.updateComputedPropertyName = updateComputedPropertyName; function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151); + var node = createSynthesizedNode(154); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -53110,7 +55617,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152); + var node = createSynthesizedNode(155); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -53134,7 +55641,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153); + var node = createSynthesizedNode(156); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -53146,7 +55653,7 @@ var ts; } ts.updateDecorator = updateDecorator; function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154); + var node = createSynthesizedNode(157); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -53166,12 +55673,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155); + var node = createSynthesizedNode(158); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -53181,8 +55688,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -53190,7 +55697,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156, typeParameters, parameters, type); + var node = createSignatureDeclaration(159, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -53207,7 +55714,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157); + var node = createSynthesizedNode(160); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -53220,6 +55727,35 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -53235,7 +55771,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158); + var node = createSynthesizedNode(161); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -53255,7 +55791,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159); + var node = createSynthesizedNode(162); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -53278,7 +55814,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160); + var node = createSynthesizedNode(163); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -53299,7 +55835,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161, typeParameters, parameters, type); + return createSignatureDeclaration(164, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -53307,7 +55843,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162, typeParameters, parameters, type); + return createSignatureDeclaration(165, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -53315,7 +55851,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163); + var node = createSynthesizedNode(166); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -53353,21 +55889,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164); + return createTypePredicateNodeWithModifier(undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165); + var node = createSynthesizedNode(168); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -53381,7 +55927,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166, typeParameters, parameters, type); + return createSignatureDeclaration(169, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -53389,7 +55935,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167, typeParameters, parameters, type); + return createSignatureDeclaration(170, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -53397,7 +55943,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168); + var node = createSynthesizedNode(171); node.exprName = exprName; return node; } @@ -53409,7 +55955,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169); + var node = createSynthesizedNode(172); node.members = createNodeArray(members); return node; } @@ -53421,7 +55967,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170); + var node = createSynthesizedNode(173); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -53433,7 +55979,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171); + var node = createSynthesizedNode(174); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -53445,7 +55991,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172); + var node = createSynthesizedNode(175); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -53457,7 +56003,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173); + var node = createSynthesizedNode(176); node.type = type; return node; } @@ -53469,7 +56015,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174, types); + return createUnionOrIntersectionTypeNode(177, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -53477,7 +56023,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175, types); + return createUnionOrIntersectionTypeNode(178, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -53496,7 +56042,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(179); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -53514,7 +56060,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(180); node.typeParameter = typeParameter; return node; } @@ -53526,7 +56072,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(187); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -53544,7 +56090,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(181); node.type = type; return node; } @@ -53556,12 +56102,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179); + return createSynthesizedNode(182); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130; + var node = createSynthesizedNode(183); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -53571,7 +56117,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(184); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -53585,7 +56131,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(185); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -53603,7 +56149,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(186); node.literal = literal; return node; } @@ -53615,7 +56161,7 @@ var ts; } ts.updateLiteralTypeNode = updateLiteralTypeNode; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(188); node.elements = createNodeArray(elements); return node; } @@ -53627,7 +56173,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(189); node.elements = createNodeArray(elements); return node; } @@ -53639,7 +56185,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(190); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -53657,7 +56203,7 @@ var ts; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(191); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -53671,7 +56217,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(192); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -53685,7 +56231,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(193); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072); @@ -53693,28 +56239,71 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + if (ts.isOptionalChain(node)) { + return updatePropertyAccessChain(node, expression, node.questionDotToken, name); + } return node.expression !== expression || node.name !== name ? updateNode(setEmitFlags(createPropertyAccess(expression, name), ts.getEmitFlags(node)), node) : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193); + node.flags |= 32; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(194); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + if (ts.isOptionalChain(node)) { + return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression); + } return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194); + node.flags |= 32; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(195); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -53722,6 +56311,9 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + if (ts.isOptionalChain(node)) { + return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray); + } return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -53729,8 +56321,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195); + node.flags |= 32; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(196); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -53746,7 +56358,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(197); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -53769,7 +56381,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(198); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -53783,7 +56395,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196); + var node = createSynthesizedNode(199); node.expression = expression; return node; } @@ -53795,7 +56407,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(200); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -53819,12 +56431,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(201); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -53841,7 +56453,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199); + var node = createSynthesizedNode(202); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53853,7 +56465,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(203); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53865,7 +56477,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(204); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53877,7 +56489,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(205); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -53889,7 +56501,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203); + var node = createSynthesizedNode(206); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -53902,7 +56514,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(207); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -53915,7 +56527,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205); + var node = createSynthesizedNode(208); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -53932,11 +56544,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206); + var node = createSynthesizedNode(209); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57); + node.colonToken = whenFalse ? colonToken : createToken(58); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -53952,7 +56564,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(210); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -54049,9 +56661,9 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -54063,7 +56675,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(212); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -54075,7 +56687,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(213); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54096,11 +56708,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211); + return createSynthesizedNode(214); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212); + var node = createSynthesizedNode(215); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -54114,7 +56726,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213); + var node = createSynthesizedNode(216); node.expression = expression; node.type = type; return node; @@ -54128,7 +56740,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214); + var node = createSynthesizedNode(217); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -54140,7 +56752,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215); + var node = createSynthesizedNode(218); node.keywordToken = keywordToken; node.name = name; return node; @@ -54153,7 +56765,7 @@ var ts; } ts.updateMetaProperty = updateMetaProperty; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(220); node.expression = expression; node.literal = literal; return node; @@ -54167,11 +56779,11 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218); + return createSynthesizedNode(221); } ts.createSemicolonClassElement = createSemicolonClassElement; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219); + var block = createSynthesizedNode(222); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -54185,7 +56797,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(224); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -54200,11 +56812,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221); + return createSynthesizedNode(223); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(225); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -54218,7 +56830,7 @@ var ts; ts.createStatement = createExpressionStatement; ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(226); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -54234,7 +56846,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224); + var node = createSynthesizedNode(227); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -54248,7 +56860,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(228); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -54262,7 +56874,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(229); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -54280,7 +56892,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(230); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -54296,10 +56908,10 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(231); node.awaitModifier = awaitModifier; node.initializer = initializer; - node.expression = expression; + node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression; node.statement = asEmbeddedStatement(statement); return node; } @@ -54314,7 +56926,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229); + var node = createSynthesizedNode(232); node.label = asName(label); return node; } @@ -54326,7 +56938,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230); + var node = createSynthesizedNode(233); node.label = asName(label); return node; } @@ -54338,7 +56950,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231); + var node = createSynthesizedNode(234); node.expression = expression; return node; } @@ -54350,7 +56962,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232); + var node = createSynthesizedNode(235); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -54364,7 +56976,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233); + var node = createSynthesizedNode(236); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -54378,7 +56990,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(237); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -54392,7 +57004,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235); + var node = createSynthesizedNode(238); node.expression = expression; return node; } @@ -54404,7 +57016,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(239); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -54420,11 +57032,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237); + return createSynthesizedNode(240); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238); + var node = createSynthesizedNode(241); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -54441,7 +57053,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(242); node.flags |= flags & 3; node.declarations = createNodeArray(declarations); return node; @@ -54454,7 +57066,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(243); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -54480,7 +57092,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(244); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54502,7 +57114,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(245); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54524,7 +57136,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(246); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54544,7 +57156,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(247); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54563,8 +57175,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0; } - var node = createSynthesizedNode(245); - node.flags |= flags & (16 | 4 | 512); + var node = createSynthesizedNode(248); + node.flags |= flags & (16 | 4 | 1024); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -54582,7 +57194,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246); + var node = createSynthesizedNode(249); node.statements = createNodeArray(statements); return node; } @@ -54594,7 +57206,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(250); node.clauses = createNodeArray(clauses); return node; } @@ -54606,7 +57218,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(251); node.name = asName(name); return node; } @@ -54618,7 +57230,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(252); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -54636,7 +57248,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(253); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -54654,7 +57266,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(254); node.name = name; node.namedBindings = namedBindings; return node; @@ -54668,7 +57280,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252); + var node = createSynthesizedNode(255); node.name = name; return node; } @@ -54680,7 +57292,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253); + var node = createSynthesizedNode(256); node.elements = createNodeArray(elements); return node; } @@ -54692,7 +57304,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(257); node.propertyName = propertyName; node.name = name; return node; @@ -54706,11 +57318,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255); + var node = createSynthesizedNode(258); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62, expression, false, undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -54723,7 +57335,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(259); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -54740,8 +57352,12 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + function createEmptyExports() { + return createExportDeclaration(undefined, undefined, createNamedExports([]), undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(260); node.elements = createNodeArray(elements); return node; } @@ -54753,7 +57369,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(261); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -54767,7 +57383,7 @@ var ts; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260); + var node = createSynthesizedNode(263); node.expression = expression; return node; } @@ -54779,33 +57395,33 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289); + var node = createSynthesizedNode(292); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(310, "type"); + var tag = createJSDocTag(313, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; } ts.createJSDocTypeTag = createJSDocTypeTag; function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(308, "returns"); + var tag = createJSDocTag(311, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; } ts.createJSDocReturnTag = createJSDocReturnTag; function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(309, "this"); + var tag = createJSDocTag(312, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(307, "param"); + var tag = createJSDocTag(310, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -54814,7 +57430,7 @@ var ts; } ts.createJSDocParamTag = createJSDocParamTag; function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(298); + var node = createSynthesizedNode(301); node.comment = comment; node.tags = tags; return node; @@ -54826,7 +57442,7 @@ var ts; return node; } function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261); + var node = createSynthesizedNode(264); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -54842,7 +57458,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262); + var node = createSynthesizedNode(265); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -54858,7 +57474,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(266); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -54874,7 +57490,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264); + var node = createSynthesizedNode(267); node.tagName = tagName; return node; } @@ -54886,7 +57502,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265); + var node = createSynthesizedNode(268); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -54908,11 +57524,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266); + return createSynthesizedNode(269); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267); + return createSynthesizedNode(270); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -54924,7 +57540,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268); + var node = createSynthesizedNode(271); node.name = name; node.initializer = initializer; return node; @@ -54938,7 +57554,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269); + var node = createSynthesizedNode(272); node.properties = createNodeArray(properties); return node; } @@ -54950,7 +57566,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270); + var node = createSynthesizedNode(273); node.expression = expression; return node; } @@ -54962,7 +57578,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271); + var node = createSynthesizedNode(274); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -54975,7 +57591,7 @@ var ts; } ts.updateJsxExpression = updateJsxExpression; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272); + var node = createSynthesizedNode(275); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -54989,7 +57605,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273); + var node = createSynthesizedNode(276); node.statements = createNodeArray(statements); return node; } @@ -55001,7 +57617,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274); + var node = createSynthesizedNode(277); node.token = token; node.types = createNodeArray(types); return node; @@ -55014,7 +57630,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275); + var node = createSynthesizedNode(278); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -55028,7 +57644,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276); + var node = createSynthesizedNode(279); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -55043,7 +57659,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277); + var node = createSynthesizedNode(280); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -55057,7 +57673,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278); + var node = createSynthesizedNode(281); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -55069,7 +57685,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279); + var node = createSynthesizedNode(282); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -55089,7 +57705,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285); + var updated = createSynthesizedNode(288); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -55163,28 +57779,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(315); + var node = createSynthesizedNode(318); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(319); + var node = createSynthesizedNode(322); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(318); + var node = createSynthesizedNode(321); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(316); + var node = createSynthesizedNode(319); node.expression = expression; node.original = original; setTextRange(node, original); @@ -55200,7 +57816,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 317) { + if (node.kind === 320) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) { @@ -55210,7 +57826,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(317); + var node = createSynthesizedNode(320); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -55221,9 +57837,23 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286); + var node = ts.createNode(289); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -55254,7 +57884,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287); + var node = ts.createNode(290); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -55336,8 +57966,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal": - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } case "text": (texts || (texts = [])).push(createUnparsedNode(section, node)); break; @@ -55384,10 +58017,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue": return 280; - case "prepend": return 281; - case "internal": return 283; - case "text": return 282; + case "prologue": return 283; + case "prepend": return 284; + case "internal": return 286; + case "text": return 285; case "emitHelpers": case "no-default-lib": case "reference": @@ -55405,14 +58038,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284, section.pos, section.end); + var node = ts.createNode(287, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288); + var node = ts.createNode(291); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -55458,8 +58091,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -55487,43 +58120,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28, right); + return createBinary(left, 29, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60, right); + return createBinary(left, 62, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35, right); + return createBinary(left, 36, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38, right); + return createBinary(left, 39, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39, right); + return createBinary(left, 40, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44); + return createPostfix(operand, 45); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54, right); + return createBinary(left, 55, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55, right); + return createBinary(left, 56, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52, operand); + return createPrefix(53, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -55542,7 +58179,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -55568,7 +58208,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 285) { + if (node.kind === 288) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -56021,7 +58661,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -56033,20 +58673,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73: + case 75: return cacheIdentifiers; - case 101: + case 103: case 8: case 9: case 10: return false; - case 188: + case 191: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189: + case 192: return target.properties.length > 0; default: return true; @@ -56061,7 +58701,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99) { + else if (callee.kind === 101) { thisArg = ts.createThis(); target = languageVersion < 2 ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -56073,7 +58713,7 @@ var ts; } else { switch (callee.kind) { - case 190: { + case 193: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -56085,7 +58725,7 @@ var ts; } break; } - case 191: { + case 194: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -56138,14 +58778,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159: - case 160: + case 162: + case 163: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276: + case 279: return createExpressionForPropertyAssignment(property, receiver); - case 277: + case 280: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157: + case 160: return createExpressionForMethodDeclaration(property, receiver); } } @@ -56317,8 +58957,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -56350,7 +58990,7 @@ var ts; ts.ensureUseStrict = ensureUseStrict; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 196) { + if (skipped.kind === 199) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -56359,10 +58999,10 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(205, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 && binaryOperatorPrecedence > 3) { return true; } var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); @@ -56370,7 +59010,7 @@ var ts; case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 208) { + && operand.kind === 211) { return false; } return true; @@ -56386,7 +59026,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 38) { + if (binaryOperator === 39) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -56399,35 +59039,33 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 40 + return binaryOperator === 41 + || binaryOperator === 51 || binaryOperator === 50 - || binaryOperator === 49 - || binaryOperator === 51; + || binaryOperator === 52; } function getLiteralKindOfBinaryPlusOperand(node) { node = ts.skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 && node.operatorToken.kind === 38) { + if (node.kind === 208 && node.operatorToken.kind === 39) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0; node.cachedLiteralKind = literalKind; return literalKind; } return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206, 56); + var conditionalPrecedence = ts.getOperatorPrecedence(209, 57); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1) { return ts.createParen(condition); } return condition; @@ -56445,8 +59083,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, false).kind) { - case 210: - case 197: + case 213: + case 200: needsParens = true; } } @@ -56456,9 +59094,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, true); switch (leftmostExpr.kind) { - case 192: + case 195: return ts.createParen(expression); - case 193: + case 196: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -56469,7 +59107,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -56507,7 +59145,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205, 27); + var commaPrecedence = ts.getOperatorPrecedence(208, 27); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -56518,29 +59156,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 || kind === 198) { + if (kind === 200 || kind === 201) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, false).kind; - if (leftmostExpressionKind === 189 || leftmostExpressionKind === 197) { + if (leftmostExpressionKind === 192 || leftmostExpressionKind === 200) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 ? ts.createParenthesizedType(member) : member; + return member.kind === 179 ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174: - case 175: - case 166: - case 167: + case 177: + case 178: + case 169: + case 170: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -56548,9 +59186,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168: + case 171: + case 183: case 180: - case 177: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -56576,27 +59214,27 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204: + case 207: node = node.operand; continue; - case 205: + case 208: node = node.left; continue; - case 206: + case 209: node = node.condition; continue; - case 194: + case 197: node = node.tag; continue; - case 192: + case 195: if (stopAtCallExpressions) { return node; } - case 213: - case 191: - case 190: - case 214: - case 316: + case 216: + case 194: + case 193: + case 217: + case 319: node = node.expression; continue; } @@ -56605,27 +59243,27 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 189)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, false).kind === 192)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 && node.operatorToken.kind === 27 || - node.kind === 317; + return node.kind === 208 && node.operatorToken.kind === 27 || + node.kind === 320; } ts.isCommaSequence = isCommaSequence; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7; } switch (node.kind) { - case 196: + case 199: return (kinds & 1) !== 0; - case 195: - case 213: - case 214: + case 198: + case 216: + case 217: return (kinds & 2) !== 0; - case 316: + case 319: return (kinds & 4) !== 0; } return false; @@ -56650,7 +59288,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214) { + while (ts.isAssertionExpression(node) || node.kind === 217) { node = node.expression; } return node; @@ -56658,15 +59296,15 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196: return ts.updateParen(outerExpression, expression); - case 195: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214: return ts.updateNonNullExpression(outerExpression, expression); - case 316: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199: return ts.updateParen(outerExpression, expression); + case 198: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217: return ts.updateNonNullExpression(outerExpression, expression); + case 319: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } function isIgnorableParen(node) { - return node.kind === 196 + return node.kind === 199 && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -56776,10 +59414,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 && node.importClause) { + if (node.kind === 253 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 && node.moduleSpecifier) { + if (node.kind === 259 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -56842,11 +59480,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276: + case 279: return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277: + case 280: return bindingElement.name; - case 278: + case 281: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -56862,11 +59500,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152: - case 187: + case 155: + case 190: return bindingElement.dotDotDotToken; - case 209: - case 278: + case 212: + case 281: return bindingElement; } return undefined; @@ -56874,7 +59512,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187: + case 190: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) @@ -56882,7 +59520,7 @@ var ts; : propertyName; } break; - case 276: + case 279: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression) @@ -56890,7 +59528,7 @@ var ts; : propertyName; } break; - case 278: + case 281: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -56909,11 +59547,11 @@ var ts; } function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185: - case 186: case 188: - return name.elements; case 189: + case 191: + return name.elements; + case 192: return name.properties; } } @@ -56952,11 +59590,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186: - case 188: - return convertToArrayAssignmentPattern(node); - case 185: case 189: + case 191: + return convertToArrayAssignmentPattern(node); + case 188: + case 192: return convertToObjectAssignmentPattern(node); } } @@ -57091,261 +59729,270 @@ var ts; return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 148) || kind === 179) { + if ((kind > 0 && kind <= 151) || kind === 182) { return node; } switch (kind) { - case 73: + case 75: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149: + case 152: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150: + case 153: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 151: + case 154: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152: + case 155: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153: + case 156: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); - case 154: + case 157: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155: + case 158: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156: + case 159: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157: + case 160: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158: + case 161: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159: + case 162: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160: + case 163: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161: + case 164: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162: + case 165: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163: + case 166: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 164: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165: + case 167: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166: + case 169: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167: + case 170: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168: + case 171: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169: + case 172: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170: + case 173: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171: + case 174: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172: + case 175: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173: + case 176: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174: + case 177: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175: + case 178: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176: + case 179: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177: + case 180: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184: + case 187: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178: + case 181: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180: + case 183: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181: + case 184: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182: + case 185: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183: + case 186: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); - case 185: + case 188: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186: + case 189: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187: + case 190: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); - case 188: + case 191: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189: + case 192: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190: + case 193: + if (node.flags & 32) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191: + case 194: + if (node.flags & 32) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192: + case 195: + if (node.flags & 32) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193: + case 196: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194: + case 197: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195: + case 198: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196: + case 199: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197: + case 200: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198: + case 201: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199: + case 202: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200: + case 203: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201: + case 204: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202: + case 205: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203: + case 206: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204: + case 207: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205: + case 208: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206: + case 209: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207: + case 210: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208: + case 211: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209: + case 212: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210: + case 213: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212: + case 215: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213: + case 216: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214: + case 217: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215: + case 218: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 217: + case 220: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); - case 219: + case 222: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220: + case 224: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222: + case 225: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223: + case 226: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224: + case 227: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225: + case 228: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226: + case 229: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227: + case 230: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228: + case 231: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229: + case 232: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230: + case 233: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231: + case 234: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232: + case 235: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233: + case 236: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234: + case 237: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235: + case 238: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236: + case 239: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238: + case 241: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239: + case 242: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240: + case 243: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241: + case 244: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242: + case 245: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243: + case 246: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244: + case 247: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245: + case 248: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246: + case 249: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247: + case 250: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248: + case 251: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249: + case 252: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250: + case 253: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251: + case 254: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252: + case 255: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253: + case 256: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254: + case 257: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255: + case 258: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256: + case 259: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257: + case 260: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258: + case 261: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 260: + case 263: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); - case 261: + case 264: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262: + case 265: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263: + case 266: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264: + case 267: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265: - return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); case 268: + return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); + case 271: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269: + case 272: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270: + case 273: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271: + case 274: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 272: + case 275: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273: + case 276: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274: + case 277: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275: + case 278: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); - case 276: + case 279: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277: + case 280: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278: + case 281: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 279: + case 282: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 285: + case 288: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); - case 316: + case 319: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 317: + case 320: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: return node; @@ -57371,52 +60018,52 @@ var ts; var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; - if ((kind > 0 && kind <= 148)) { + if ((kind > 0 && kind <= 151)) { return initial; } - if ((kind >= 164 && kind <= 183)) { + if ((kind >= 167 && kind <= 186)) { return initial; } var result = initial; switch (node.kind) { - case 218: case 221: - case 211: - case 237: - case 315: + case 223: + case 214: + case 240: + case 318: break; - case 149: + case 152: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150: + case 153: result = reduceNode(node.expression, cbNode, result); break; - case 152: + case 155: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153: + case 156: result = reduceNode(node.expression, cbNode, result); break; - case 154: + case 157: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155: + case 158: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157: + case 160: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57425,12 +60072,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158: + case 161: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159: + case 162: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57438,56 +60085,56 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160: + case 163: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 185: - case 186: + case 188: + case 189: result = reduceNodes(node.elements, cbNodes, result); break; - case 187: + case 190: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 188: + case 191: result = reduceNodes(node.elements, cbNodes, result); break; - case 189: + case 192: result = reduceNodes(node.properties, cbNodes, result); break; - case 190: + case 193: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191: + case 194: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192: + case 195: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193: + case 196: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194: + case 197: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195: + case 198: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197: + case 200: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -57495,121 +60142,121 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198: + case 201: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196: case 199: - case 200: - case 201: case 202: - case 208: - case 209: - case 214: - result = reduceNode(node.expression, cbNode, result); - break; case 203: case 204: + case 205: + case 211: + case 212: + case 217: + result = reduceNode(node.expression, cbNode, result); + break; + case 206: + case 207: result = reduceNode(node.operand, cbNode, result); break; - case 205: + case 208: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206: + case 209: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207: + case 210: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210: + case 213: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212: + case 215: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213: + case 216: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; - case 217: + case 220: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; - case 219: + case 222: result = reduceNodes(node.statements, cbNodes, result); break; - case 220: + case 224: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222: + case 225: result = reduceNode(node.expression, cbNode, result); break; - case 223: + case 226: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224: + case 227: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225: - case 232: + case 228: + case 235: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226: + case 229: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227: - case 228: + case 230: + case 231: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231: - case 235: + case 234: + case 238: result = reduceNode(node.expression, cbNode, result); break; - case 233: + case 236: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234: + case 237: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236: + case 239: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238: + case 241: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239: + case 242: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240: + case 243: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57618,7 +60265,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241: + case 244: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -57626,132 +60273,132 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244: + case 247: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245: + case 248: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246: + case 249: result = reduceNodes(node.statements, cbNodes, result); break; - case 247: + case 250: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249: + case 252: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250: + case 253: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251: + case 254: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252: + case 255: result = reduceNode(node.name, cbNode, result); break; - case 253: - case 257: + case 256: + case 260: result = reduceNodes(node.elements, cbNodes, result); break; - case 254: - case 258: + case 257: + case 261: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255: + case 258: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256: + case 259: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 260: + case 263: result = reduceNode(node.expression, cbNode, result); break; - case 261: + case 264: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265: + case 268: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262: - case 263: + case 265: + case 266: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269: + case 272: result = reduceNodes(node.properties, cbNodes, result); break; - case 264: + case 267: result = reduceNode(node.tagName, cbNode, result); break; - case 268: + case 271: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270: + case 273: result = reduceNode(node.expression, cbNode, result); break; - case 271: + case 274: result = reduceNode(node.expression, cbNode, result); break; - case 272: + case 275: result = reduceNode(node.expression, cbNode, result); - case 273: + case 276: result = reduceNodes(node.statements, cbNodes, result); break; - case 274: + case 277: result = reduceNodes(node.types, cbNodes, result); break; - case 275: + case 278: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; - case 276: + case 279: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277: + case 280: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278: + case 281: result = reduceNode(node.expression, cbNode, result); break; - case 279: + case 282: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 285: + case 288: result = reduceNodes(node.statements, cbNodes, result); break; - case 316: + case 319: result = reduceNode(node.expression, cbNode, result); break; - case 317: + case 320: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -57804,7 +60451,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 212)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 215)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -58427,7 +61074,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -58472,7 +61119,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250: + case 253: externalImports.push(node); if (!hasImportStar && getImportNeedsImportStarHelper(node)) { hasImportStar = true; @@ -58481,12 +61128,12 @@ var ts; hasImportDefault = true; } break; - case 249: - if (node.moduleReference.kind === 260) { + case 252: + if (node.moduleReference.kind === 263) { externalImports.push(node); } break; - case 256: + case 259: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -58513,12 +61160,12 @@ var ts; } } break; - case 255: + case 258: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 220: + case 224: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -58526,7 +61173,7 @@ var ts; } } break; - case 240: + case 243: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -58544,7 +61191,7 @@ var ts; } } break; - case 241: + case 244: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -58619,7 +61266,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -58644,21 +61291,17 @@ var ts; }; } ts.helperString = helperString; - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); - } - ts.getInitializedProperties = getInitializedProperties; - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); + ts.getProperties = getProperties; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - function isInitializedProperty(member) { - return member.kind === 155 - && member.initializer !== undefined; + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -59027,8 +61670,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190); - context.enableSubstitution(191); + context.enableSubstitution(193); + context.enableSubstitution(194); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -59041,14 +61684,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286) { + if (node.kind === 289) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288) { + if (prepend.kind === 291) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -59081,16 +61724,16 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 285: - case 247: - case 246: - case 219: + case 288: + case 250: + case 249: + case 222: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241: - case 240: + case 244: + case 243: if (ts.hasModifier(node, 2)) { break; } @@ -59098,7 +61741,7 @@ var ts; recordEmittedDeclarationInScope(node); } else { - ts.Debug.assert(node.kind === 241 || ts.hasModifier(node, 512)); + ts.Debug.assert(node.kind === 244 || ts.hasModifier(node, 512)); } if (ts.isClassDeclaration(node)) { currentNameScope = node; @@ -59120,10 +61763,10 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250: - case 249: - case 255: - case 256: + case 253: + case 252: + case 258: + case 259: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -59138,13 +61781,13 @@ var ts; return node; } switch (node.kind) { - case 250: + case 253: return visitImportDeclaration(node); - case 249: + case 252: return visitImportEqualsDeclaration(node); - case 255: + case 258: return visitExportAssignment(node); - case 256: + case 259: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -59154,11 +61797,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 256 || - node.kind === 250 || - node.kind === 251 || - (node.kind === 249 && - node.moduleReference.kind === 260)) { + if (node.kind === 259 || + node.kind === 253 || + node.kind === 254 || + (node.kind === 252 && + node.moduleReference.kind === 263)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -59171,16 +61814,16 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 158: + case 161: return visitConstructor(node); - case 155: + case 158: return visitPropertyDeclaration(node); + case 166: + case 162: case 163: - case 159: case 160: - case 157: return visitorWorker(node); - case 218: + case 221: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -59190,7 +61833,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270) { return undefined; } - else if (currentNamespace && node.kind === 86) { + else if (currentNamespace && node.kind === 88) { return undefined; } return node; @@ -59200,100 +61843,100 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86: - case 81: + case 88: + case 83: return currentNamespace ? undefined : node; + case 118: case 116: - case 114: - case 115: - case 119: - case 78: - case 126: - case 134: - case 170: - case 171: - case 172: - case 173: - case 169: - case 164: - case 151: + case 117: case 121: - case 144: + case 80: + case 129: + case 137: + case 173: + case 174: + case 175: + case 176: + case 172: + case 167: + case 154: case 124: + case 147: + case 127: + case 142: case 139: case 136: - case 133: - case 107: - case 140: - case 167: - case 166: + case 109: + case 143: + case 170: + case 169: + case 171: case 168: - case 165: - case 174: - case 175: - case 176: + case 177: case 178: case 179: - case 180: case 181: case 182: case 183: - case 163: - case 153: - case 243: + case 184: + case 185: + case 186: + case 166: + case 156: + case 246: return undefined; - case 155: + case 158: return visitPropertyDeclaration(node); - case 248: + case 251: return undefined; - case 158: + case 161: return visitConstructor(node); - case 242: + case 245: return ts.createNotEmittedStatement(node); - case 241: + case 244: return visitClassDeclaration(node); - case 210: + case 213: return visitClassExpression(node); - case 274: + case 277: return visitHeritageClause(node); - case 212: + case 215: return visitExpressionWithTypeArguments(node); - case 157: + case 160: return visitMethodDeclaration(node); - case 159: + case 162: return visitGetAccessor(node); - case 160: + case 163: return visitSetAccessor(node); - case 240: + case 243: return visitFunctionDeclaration(node); - case 197: + case 200: return visitFunctionExpression(node); - case 198: + case 201: return visitArrowFunction(node); - case 152: + case 155: return visitParameter(node); - case 196: + case 199: return visitParenthesizedExpression(node); - case 195: - case 213: + case 198: + case 216: return visitAssertionExpression(node); - case 192: + case 195: return visitCallExpression(node); - case 193: + case 196: return visitNewExpression(node); - case 194: + case 197: return visitTaggedTemplateExpression(node); - case 214: + case 217: return visitNonNullExpression(node); - case 244: + case 247: return visitEnumDeclaration(node); - case 220: + case 224: return visitVariableStatement(node); - case 238: + case 241: return visitVariableDeclaration(node); - case 245: + case 248: return visitModuleDeclaration(node); - case 249: + case 252: return visitImportEqualsDeclaration(node); default: return ts.visitEachChild(node, visitor, context); @@ -59323,7 +61966,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99) facts |= 64; if (shouldEmitDecorateCallForClass(node)) facts |= 2; @@ -59352,7 +61995,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, true); + var staticProperties = ts.getProperties(node, true, true); var facts = getClassFacts(node, staticProperties); if (facts & 128) { context.startLexicalEnvironment(); @@ -59508,12 +62151,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159: - case 160: + case 162: + case 163: return getAllDecoratorsOfAccessors(node, member); - case 157: + case 160: return getAllDecoratorsOfMethod(member); - case 155: + case 158: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -59592,7 +62235,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 155 + ? member.kind === 158 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -59661,13 +62304,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(37), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(37), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(37), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(38), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); @@ -59676,22 +62319,22 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 - || kind === 159 - || kind === 160 - || kind === 155; + return kind === 160 + || kind === 162 + || kind === 163 + || kind === 158; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 157; + return node.kind === 160; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241: - case 210: + case 244: + case 213: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157: - case 159: case 160: + case 162: + case 163: return true; } return false; @@ -59703,15 +62346,15 @@ var ts; } function serializeTypeOfNode(node) { switch (node.kind) { + case 158: case 155: - case 152: return serializeTypeNode(node.type); - case 160: - case 159: + case 163: + case 162: return serializeTypeNode(getAccessorTypeNode(node)); - case 241: - case 210: - case 157: + case 244: + case 213: + case 160: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -59743,7 +62386,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159) { + if (container && node.kind === 162) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -59765,69 +62408,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107: - case 142: - case 97: - case 133: + case 109: + case 145: + case 99: + case 136: return ts.createVoidZero(); - case 178: + case 181: return serializeTypeNode(node.type); - case 166: - case 167: - return ts.createIdentifier("Function"); + case 169: case 170: - case 171: + return ts.createIdentifier("Function"); + case 173: + case 174: return ts.createIdentifier("Array"); - case 164: - case 124: + case 167: + case 127: return ts.createIdentifier("Boolean"); - case 139: + case 142: return ts.createIdentifier("String"); - case 137: + case 140: return ts.createIdentifier("Object"); - case 183: + case 186: switch (node.literal.kind) { case 10: return ts.createIdentifier("String"); - case 203: + case 206: case 8: return ts.createIdentifier("Number"); case 9: return getGlobalBigIntNameWithFallback(); - case 103: - case 88: + case 105: + case 90: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136: + case 139: return ts.createIdentifier("Number"); - case 147: + case 150: return getGlobalBigIntNameWithFallback(); - case 140: + case 143: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165: + case 168: return serializeTypeReferenceNode(node); - case 175: - case 174: + case 178: + case 177: return serializeTypeList(node.types); - case 176: + case 179: return serializeTypeList([node.trueType, node.falseType]); - case 180: - if (node.operator === 134) { + case 183: + if (node.operator === 137) { return serializeTypeNode(node.type); } break; - case 168: - case 181: - case 182: - case 169: - case 121: - case 144: - case 179: + case 171: case 184: + case 185: + case 172: + case 124: + case 147: + case 182: + case 187: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -59836,15 +62479,15 @@ var ts; } function serializeTypeList(types) { var serializedUnion; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178) { + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var typeNode = types_20[_i]; + while (typeNode.kind === 181) { typeNode = typeNode.type; } - if (typeNode.kind === 133) { + if (typeNode.kind === 136) { continue; } - if (!strictNullChecks && (typeNode.kind === 97 || typeNode.kind === 142)) { + if (!strictNullChecks && (typeNode.kind === 99 || typeNode.kind === 145)) { continue; } var serializedIndividual = serializeTypeNode(typeNode); @@ -59906,11 +62549,11 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(left), ts.createLiteral("undefined")), right); } function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73) { + if (node.kind === 75) { var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73) { + if (node.left.kind === 75) { return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } var left = serializeEntityNameAsExpressionFallback(node.left); @@ -59919,13 +62562,13 @@ var ts; } function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73: + case 75: var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); return name; - case 149: + case 152: return serializeQualifiedNameAsExpression(node); } } @@ -59968,7 +62611,7 @@ var ts; return ts.visitNode(name, visitor, ts.isPropertyName); } function visitHeritageClause(node) { - if (node.token === 110) { + if (node.token === 112) { return undefined; } return ts.visitEachChild(node, visitor, context); @@ -60253,11 +62896,11 @@ var ts; function addVarForEnumOrModuleDeclaration(statements, node) { var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, false, true)) - ], currentLexicalScope.kind === 285 ? 0 : 1)); + ], currentLexicalScope.kind === 288 ? 0 : 1)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 244) { + if (node.kind === 247) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -60323,7 +62966,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246) { + if (body.kind === 249) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -60347,13 +62990,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 246) { + if (body.kind !== 249) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245) { + if (moduleDeclaration.body.kind === 248) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -60373,7 +63016,7 @@ var ts; return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 252) { + if (node.kind === 255) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -60494,29 +63137,29 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(73); + context.enableSubstitution(75); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(73); + context.enableSubstitution(75); classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(73); - context.enableSubstitution(277); - context.enableEmitNotification(245); + context.enableSubstitution(75); + context.enableSubstitution(280); + context.enableEmitNotification(248); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245; + return ts.getOriginalNode(node).kind === 248; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244; + return ts.getOriginalNode(node).kind === 247; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; @@ -60560,11 +63203,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); - case 190: + case 193: return substitutePropertyAccessExpression(node); - case 191: + case 194: return substituteElementAccessExpression(node); } return node; @@ -60594,9 +63237,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 285) { - var substitute = (applicableSubstitutions & 2 && container.kind === 245) || - (applicableSubstitutions & 8 && container.kind === 244); + if (container && container.kind !== 288) { + var substitute = (applicableSubstitutions & 2 && container.kind === 248) || + (applicableSubstitutions & 8 && container.kind === 247); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -60616,9 +63259,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " "); } return substitute; @@ -60695,7 +63339,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -60706,28 +63352,28 @@ var ts; if (!(node.transformFlags & 1048576)) return node; switch (node.kind) { - case 210: + case 213: return visitClassExpression(node); - case 241: + case 244: return visitClassDeclaration(node); - case 220: + case 224: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); } function classElementVisitor(node) { switch (node.kind) { - case 158: + case 161: return undefined; - case 159: + case 162: + case 163: case 160: - case 157: return ts.visitEachChild(node, classElementVisitor, context); - case 155: + case 158: return visitPropertyDeclaration(node); - case 150: + case 153: return visitComputedPropertyName(node); - case 218: + case 221: return node; default: return visitor(node); @@ -60754,7 +63400,7 @@ var ts; } function visitPropertyDeclaration(node) { ts.Debug.assert(!ts.some(node.decorators)); - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { (pendingExpressions || (pendingExpressions = [])).push(expr); } @@ -60767,7 +63413,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99); var statements = [ ts.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)) ]; @@ -60775,9 +63421,9 @@ var ts; statements.push(ts.createExpressionStatement(ts.inlineExpressions(pendingExpressions))); } pendingExpressions = savedPendingExpressions; - var staticProperties = ts.getInitializedProperties(node, true); + var staticProperties = ts.getProperties(node, true, true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -60788,9 +63434,9 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, true); + var staticProperties = ts.getProperties(node, true, true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { if (isDecoratedClassDeclaration) { @@ -60800,7 +63446,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -60837,8 +63483,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -60849,7 +63495,7 @@ var ts; return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, false); + var properties = ts.getProperties(node, !context.getCompilerOptions().useDefineForClassFields, false); if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(undefined, visitor, context); } @@ -60877,14 +63523,14 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -60908,17 +63554,27 @@ var ts; return expressions; } function transformInitializedProperty(property, receiver) { + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(73); + context.enableSubstitution(75); classAliases = []; } } @@ -60931,7 +63587,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); } return node; @@ -61018,33 +63674,33 @@ var ts; return node; } switch (node.kind) { - case 122: + case 125: return undefined; - case 202: + case 205: return visitAwaitExpression(node); - case 157: + case 160: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 240: + case 243: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197: + case 200: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198: + case 201: return visitArrowFunction(node); - case 190: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99) { + case 193: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191: - if (capturedSuperProperties && node.expression.kind === 99) { + case 194: + if (capturedSuperProperties && node.expression.kind === 101) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 159: - case 160: - case 158: - case 241: - case 210: + case 162: + case 163: + case 161: + case 244: + case 213: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -61053,27 +63709,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220: + case 224: return visitVariableStatementInAsyncBody(node); - case 226: + case 229: return visitForStatementInAsyncBody(node); - case 227: + case 230: return visitForInStatementInAsyncBody(node); - case 228: + case 231: return visitForOfStatementInAsyncBody(node); - case 275: + case 278: return visitCatchClauseInAsyncBody(node); - case 219: - case 233: - case 247: - case 272: - case 273: + case 222: case 236: - case 224: - case 225: - case 223: - case 232: - case 234: + case 250: + case 275: + case 276: + case 239: + case 227: + case 228: + case 226: + case 235: + case 237: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -61222,7 +63878,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 198; + var isArrowFunction = node.kind === 201; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames; enclosingFunctionParameterNames = ts.createUnderscoreEscapedMap(); @@ -61303,15 +63959,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(192); - context.enableSubstitution(190); - context.enableSubstitution(191); - context.enableEmitNotification(241); - context.enableEmitNotification(157); - context.enableEmitNotification(159); + context.enableSubstitution(195); + context.enableSubstitution(193); + context.enableSubstitution(194); + context.enableEmitNotification(244); context.enableEmitNotification(160); - context.enableEmitNotification(158); - context.enableEmitNotification(220); + context.enableEmitNotification(162); + context.enableEmitNotification(163); + context.enableEmitNotification(161); + context.enableEmitNotification(224); } } function onEmitNode(hint, node, emitCallback) { @@ -61343,23 +63999,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190: + case 193: return substitutePropertyAccessExpression(node); - case 191: + case 194: return substituteElementAccessExpression(node); - case 192: + case 195: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -61378,11 +64034,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 - || kind === 158 - || kind === 157 - || kind === 159 - || kind === 160; + return kind === 244 + || kind === 161 + || kind === 160 + || kind === 162 + || kind === 163; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -61425,7 +64081,7 @@ var ts; }; function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); - var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(40), undefined, undefined, [], undefined, body); + var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(41), undefined, undefined, [], undefined, body); (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288; return ts.createCall(ts.getUnscopedHelperName("__awaiter"), undefined, [ hasLexicalThis ? ts.createThis() : ts.createVoidZero(), @@ -61482,7 +64138,7 @@ var ts; return visitorWorker(node, true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122) { + if (node.kind === 125) { return undefined; } return node; @@ -61504,62 +64160,62 @@ var ts; return node; } switch (node.kind) { - case 202: + case 205: return visitAwaitExpression(node); - case 208: + case 211: return visitYieldExpression(node); - case 231: - return visitReturnStatement(node); case 234: + return visitReturnStatement(node); + case 237: return visitLabeledStatement(node); - case 189: + case 192: return visitObjectLiteralExpression(node); - case 205: + case 208: return visitBinaryExpression(node, noDestructuringValue); - case 275: + case 278: return visitCatchClause(node); - case 220: + case 224: return visitVariableStatement(node); - case 238: + case 241: return visitVariableDeclaration(node); - case 228: + case 231: return visitForOfStatement(node, undefined); - case 226: + case 229: return visitForStatement(node); - case 201: + case 204: return visitVoidExpression(node); - case 158: + case 161: return doOutsideOfTopLevel(visitConstructorDeclaration, node); - case 157: + case 160: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 159: + case 162: return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); - case 160: + case 163: return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); - case 240: + case 243: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197: + case 200: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198: + case 201: return visitArrowFunction(node); - case 152: + case 155: return visitParameter(node); - case 222: + case 225: return visitExpressionStatement(node); - case 196: + case 199: return visitParenthesizedExpression(node, noDestructuringValue); - case 190: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99) { + case 193: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191: - if (capturedSuperProperties && node.expression.kind === 99) { + case 194: + if (capturedSuperProperties && node.expression.kind === 101) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 241: - case 210: + case 244: + case 213: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -61592,7 +64248,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 && statement.awaitModifier) { + if (statement.kind === 231 && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -61604,7 +64260,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 278) { + if (e.kind === 281) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -61613,7 +64269,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 + chunkObject = ts.append(chunkObject, e.kind === 279 ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -61626,7 +64282,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 8192) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189) { + if (objects.length && objects[0].kind !== 192) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -61875,7 +64531,7 @@ var ts; var savedHasSuperElementAccess = hasSuperElementAccess; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; - var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(40), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); + var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(41), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048); if (emitSuperHelpers) { enableSubstitutionForAsyncMethodsWithSuper(); @@ -61934,15 +64590,15 @@ var ts; function enableSubstitutionForAsyncMethodsWithSuper() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(192); - context.enableSubstitution(190); - context.enableSubstitution(191); - context.enableEmitNotification(241); - context.enableEmitNotification(157); - context.enableEmitNotification(159); + context.enableSubstitution(195); + context.enableSubstitution(193); + context.enableSubstitution(194); + context.enableEmitNotification(244); context.enableEmitNotification(160); - context.enableEmitNotification(158); - context.enableEmitNotification(220); + context.enableEmitNotification(162); + context.enableEmitNotification(163); + context.enableEmitNotification(161); + context.enableEmitNotification(224); } } function onEmitNode(hint, node, emitCallback) { @@ -61974,23 +64630,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190: + case 193: return substitutePropertyAccessExpression(node); - case 191: + case 194: return substituteElementAccessExpression(node); - case 192: + case 195: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -62009,11 +64665,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 - || kind === 158 - || kind === 157 - || kind === 159 - || kind === 160; + return kind === 244 + || kind === 161 + || kind === 160 + || kind === 162 + || kind === 163; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096) { @@ -62103,7 +64759,7 @@ var ts; return node; } switch (node.kind) { - case 275: + case 278: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -62121,6 +64777,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -62133,10 +64790,135 @@ var ts; return node; } switch (node.kind) { + case 193: + case 194: + case 195: + if (node.flags & 32) { + var updated = visitOptionalExpression(node, false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208: + if (node.operatorToken.kind === 60) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37), ts.createNull()), ts.createToken(55), ts.createBinary(node, ts.createToken(37), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -62165,13 +64947,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261: + case 264: return visitJsxElement(node, false); - case 262: - return visitJsxSelfClosingElement(node, false); case 265: + return visitJsxSelfClosingElement(node, false); + case 268: return visitJsxFragment(node, false); - case 271: + case 274: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -62181,13 +64963,13 @@ var ts; switch (node.kind) { case 11: return visitJsxText(node); - case 271: + case 274: return visitJsxExpression(node); - case 261: + case 264: return visitJsxElement(node, true); - case 262: - return visitJsxSelfClosingElement(node, true); case 265: + return visitJsxSelfClosingElement(node, true); + case 268: return visitJsxFragment(node, true); default: return ts.Debug.failBadSyntaxKind(node); @@ -62251,7 +65033,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271) { + else if (node.kind === 274) { if (node.expression === undefined) { return ts.createTrue(); } @@ -62311,7 +65093,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261) { + if (node.kind === 264) { return getTagName(node.openingElement); } else { @@ -62611,7 +65393,7 @@ var ts; return node; } switch (node.kind) { - case 205: + case 208: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -62619,9 +65401,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64: + case 66: return visitExponentiationAssignmentExpression(node); - case 41: + case 42: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -62701,13 +65483,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192) !== 0 - && node.kind === 231 + && node.kind === 234 && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 219))) + || (hierarchyFacts & 8192 && (ts.isStatement(node) || (node.kind === 222))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432) !== 0; } @@ -62720,72 +65502,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99) { + if (node.kind === 101) { return visitSuperKeyword(true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117: + case 119: return undefined; - case 241: + case 244: return visitClassDeclaration(node); - case 210: + case 213: return visitClassExpression(node); - case 152: + case 155: return visitParameter(node); - case 240: + case 243: return visitFunctionDeclaration(node); - case 198: + case 201: return visitArrowFunction(node); - case 197: + case 200: return visitFunctionExpression(node); - case 238: + case 241: return visitVariableDeclaration(node); - case 73: + case 75: return visitIdentifier(node); - case 239: + case 242: return visitVariableDeclarationList(node); - case 233: + case 236: return visitSwitchStatement(node); - case 247: + case 250: return visitCaseBlock(node); - case 219: + case 222: return visitBlock(node, false); - case 230: - case 229: + case 233: + case 232: return visitBreakOrContinueStatement(node); - case 234: + case 237: return visitLabeledStatement(node); - case 224: - case 225: + case 227: + case 228: return visitDoOrWhileStatement(node, undefined); - case 226: + case 229: return visitForStatement(node, undefined); - case 227: + case 230: return visitForInStatement(node, undefined); - case 228: + case 231: return visitForOfStatement(node, undefined); - case 222: + case 225: return visitExpressionStatement(node); - case 189: + case 192: return visitObjectLiteralExpression(node); - case 275: + case 278: return visitCatchClause(node); - case 277: + case 280: return visitShorthandPropertyAssignment(node); - case 150: + case 153: return visitComputedPropertyName(node); - case 188: + case 191: return visitArrayLiteralExpression(node); - case 192: + case 195: return visitCallExpression(node); - case 193: - return visitNewExpression(node); case 196: + return visitNewExpression(node); + case 199: return visitParenthesizedExpression(node, true); - case 205: + case 208: return visitBinaryExpression(node, true); case 14: case 15: @@ -62796,28 +65578,28 @@ var ts; return visitStringLiteral(node); case 8: return visitNumericLiteral(node); - case 194: + case 197: return visitTaggedTemplateExpression(node); - case 207: + case 210: return visitTemplateExpression(node); - case 208: + case 211: return visitYieldExpression(node); - case 209: + case 212: return visitSpreadElement(node); - case 99: - return visitSuperKeyword(false); case 101: + return visitSuperKeyword(false); + case 103: return visitThisKeyword(node); - case 215: + case 218: return visitMetaProperty(node); - case 157: - return visitMethodDeclaration(node); - case 159: case 160: + return visitMethodDeclaration(node); + case 162: + case 163: return visitAccessorDeclaration(node); - case 220: + case 224: return visitVariableStatement(node); - case 231: + case 234: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -62902,14 +65684,14 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 230 ? 2 : 4; + var jump = node.kind === 233 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 230) { + if (node.kind === 233) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -62919,7 +65701,7 @@ var ts; } } else { - if (node.kind === 230) { + if (node.kind === 233) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker); } @@ -63052,7 +65834,7 @@ var ts; return block; } function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99; if (!constructor) return createDefaultConstructorBody(node, isDerivedClass); var prologue = []; @@ -63105,17 +65887,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 231) { + if (statement.kind === 234) { return true; } - else if (statement.kind === 223) { + else if (statement.kind === 226) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 219) { + else if (statement.kind === 222) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -63198,9 +65980,9 @@ var ts; if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) { return false; } - var declarationName = parameter.name.kind === 73 ? ts.getMutableClone(parameter.name) : ts.createTempVariable(undefined); + var declarationName = parameter.name.kind === 75 ? ts.getMutableClone(parameter.name) : ts.createTempVariable(undefined); ts.setEmitFlags(declarationName, 48); - var expressionName = parameter.name.kind === 73 ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ @@ -63216,14 +65998,14 @@ var ts; ts.setEmitFlags(forStatement, 1048576); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73) { + if (parameter.name.kind !== 75) { prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576)); } ts.insertStatementsAfterCustomPrologue(statements, prologueStatements); return true; } function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 && node.kind !== 198) { + if (hierarchyFacts & 32768 && node.kind !== 201) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -63242,19 +66024,19 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 198: + case 201: return statements; - case 157: - case 159: case 160: + case 162: + case 163: newTarget = ts.createVoidZero(); break; - case 158: + case 161: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 240: - case 197: - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 95, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + case 243: + case 200: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 97, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -63274,20 +66056,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218: + case 221: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157: + case 160: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159: - case 160: + case 162: + case 163: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158: + case 161: break; default: ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName); @@ -63301,11 +66083,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); ts.setEmitFlags(statement, 48); @@ -63407,7 +66200,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 240 || node.kind === 197)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 243 || node.kind === 200)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -63438,7 +66231,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198); + ts.Debug.assert(node.kind === 201); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -63491,9 +66284,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 196: + case 199: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, false)); - case 205: + case 208: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -63501,9 +66294,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 196: + case 199: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 205: + case 208: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -63529,7 +66322,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0); } else { - assignment = ts.createBinary(decl.name, 60, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -63634,14 +66427,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224: - case 225: + case 227: + case 228: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226: + case 229: return visitForStatement(node, outermostLabeledStatement); - case 227: + case 230: return visitForInStatement(node, outermostLabeledStatement); - case 228: + case 231: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -63768,7 +66561,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150) { + if (property.name.kind === 153) { numInitialProperties = i; break; } @@ -63815,7 +66608,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73) { + if (node.kind === 75) { state.hoistedLocalVariables.push(node); } else { @@ -63879,11 +66672,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227: return convertForInStatement(node, convertedLoopBody); - case 228: return convertForOfStatement(node, convertedLoopBody); - case 224: return convertDoStatement(node, convertedLoopBody); - case 225: return convertWhileStatement(node, convertedLoopBody); + case 229: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230: return convertForInStatement(node, convertedLoopBody); + case 231: return convertForOfStatement(node, convertedLoopBody); + case 227: return convertDoStatement(node, convertedLoopBody); + case 228: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -63907,11 +66700,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226: - case 227: - case 228: + case 229: + case 230: + case 231: var initializer = node.initializer; - if (initializer && initializer.kind === 239) { + if (initializer && initializer.kind === 242) { loopInitializer = initializer; } break; @@ -64005,7 +66798,7 @@ var ts; statements.push(ts.createVariableStatement(undefined, node.initializer)); copyOutParameters(currentState.loopOutParameters, 2, 1, statements); var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(40) : undefined, undefined, undefined, undefined, undefined, ts.visitNode(ts.createBlock(statements, true), visitor, ts.isBlock)), emitFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(41) : undefined, undefined, undefined, undefined, undefined, ts.visitNode(ts.createBlock(statements, true), visitor, ts.isBlock)), emitFlags)) ]), 2097152)); var part = ts.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable)); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; @@ -64020,7 +66813,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(52, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -64041,7 +66834,7 @@ var ts; if (containsYield && (hierarchyFacts & 4) !== 0) emitFlags |= 262144; var functionDeclaration = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(40) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags)) + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(41) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags)) ]), 2097152)); var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield); return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part }; @@ -64049,7 +66842,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 60, source); + return ts.createBinary(target, 62, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -64062,7 +66855,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40), ts.setEmitFlags(call, 8388608)) + ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608)) : call; return ts.createStatement(callResult); } @@ -64073,7 +66866,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(40), ts.setEmitFlags(call, 8388608)) + ? ts.createYield(ts.createToken(41), ts.setEmitFlags(call, 8388608)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -64093,10 +66886,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -64170,20 +66963,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159: - case 160: + case 162: + case 163: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157: + case 160: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276: + case 279: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277: + case 280: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -64254,7 +67047,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159) { + if (node.kind === 162) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -64284,7 +67077,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 || + if (expression.kind === 101 || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, true); @@ -64333,20 +67126,20 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { if (node.transformFlags & 4096 || - node.expression.kind === 99 || + node.expression.kind === 101 || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { ts.setEmitFlags(thisArg, 4); } var resultingCall = void 0; if (node.transformFlags & 4096) { - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, false, false, false)); } else { - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } - if (node.expression.kind === 99) { + if (node.expression.kind === 101) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -64505,13 +67298,11 @@ var ts; } } function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 && node.name.escapedText === "target") { + if (node.keywordToken === 98 && node.name.escapedText === "target") { hierarchyFacts |= 16384; return ts.createFileLevelUniqueName("_newTarget"); } @@ -64531,20 +67322,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(73); + context.enableSubstitution(75); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(101); - context.enableEmitNotification(158); - context.enableEmitNotification(157); - context.enableEmitNotification(159); + context.enableSubstitution(103); + context.enableEmitNotification(161); context.enableEmitNotification(160); - context.enableEmitNotification(198); - context.enableEmitNotification(197); - context.enableEmitNotification(240); + context.enableEmitNotification(162); + context.enableEmitNotification(163); + context.enableEmitNotification(201); + context.enableEmitNotification(200); + context.enableEmitNotification(243); } } function onSubstituteNode(hint, node) { @@ -64568,10 +67359,10 @@ var ts; } function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187: - case 241: + case 190: case 244: - case 238: + case 247: + case 241: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -64579,9 +67370,9 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); - case 101: + case 103: return substituteThisKeyword(node); } return node; @@ -64632,19 +67423,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212) { return false; } var expression = callArgument.expression; @@ -64690,24 +67481,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263); - context.enableEmitNotification(264); - context.enableEmitNotification(262); + context.enableEmitNotification(266); + context.enableEmitNotification(267); + context.enableEmitNotification(265); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190); - context.enableSubstitution(276); + context.enableSubstitution(193); + context.enableSubstitution(279); return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263: - case 264: - case 262: + case 266: + case 267: + case 265: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -64743,7 +67534,7 @@ var ts; } function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 && token <= 109) { + if (token !== undefined && token >= 76 && token <= 111) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -64824,13 +67615,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224: + case 227: return visitDoStatement(node); - case 225: + case 228: return visitWhileStatement(node); - case 233: + case 236: return visitSwitchStatement(node); - case 234: + case 237: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -64838,24 +67629,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240: + case 243: return visitFunctionDeclaration(node); - case 197: + case 200: return visitFunctionExpression(node); - case 159: - case 160: + case 162: + case 163: return visitAccessorDeclaration(node); - case 220: + case 224: return visitVariableStatement(node); - case 226: + case 229: return visitForStatement(node); - case 227: - return visitForInStatement(node); case 230: + return visitForInStatement(node); + case 233: return visitBreakStatement(node); - case 229: + case 232: return visitContinueStatement(node); - case 231: + case 234: return visitReturnStatement(node); default: if (node.transformFlags & 131072) { @@ -64871,21 +67662,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205: + case 208: return visitBinaryExpression(node); - case 206: + case 209: return visitConditionalExpression(node); - case 208: + case 211: return visitYieldExpression(node); - case 188: + case 191: return visitArrayLiteralExpression(node); - case 189: + case 192: return visitObjectLiteralExpression(node); - case 191: + case 194: return visitElementAccessExpression(node); - case 192: + case 195: return visitCallExpression(node); - case 193: + case 196: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -64893,9 +67684,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 240: + case 243: return visitFunctionDeclaration(node); - case 197: + case 200: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -65028,23 +67819,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 - && kind <= 72; + return kind >= 63 + && kind <= 74; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61: return 38; - case 62: return 39; - case 63: return 40; - case 64: return 41; - case 65: return 42; - case 66: return 43; - case 67: return 46; - case 68: return 47; - case 69: return 48; - case 70: return 49; - case 71: return 50; - case 72: return 51; + case 63: return 39; + case 64: return 40; + case 65: return 41; + case 66: return 42; + case 67: return 43; + case 68: return 44; + case 69: return 47; + case 70: return 48; + case 71: return 49; + case 72: return 50; + case 73: return 51; + case 74: return 52; } } function visitRightAssociativeBinaryExpression(node) { @@ -65052,10 +67843,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190: + case 193: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191: + case 194: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -65091,7 +67882,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 54) { + if (node.operatorToken.kind === 55) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -65256,35 +68047,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219: - return transformAndEmitBlock(node); case 222: + return transformAndEmitBlock(node); + case 225: return transformAndEmitExpressionStatement(node); - case 223: + case 226: return transformAndEmitIfStatement(node); - case 224: + case 227: return transformAndEmitDoStatement(node); - case 225: + case 228: return transformAndEmitWhileStatement(node); - case 226: + case 229: return transformAndEmitForStatement(node); - case 227: + case 230: return transformAndEmitForInStatement(node); - case 229: + case 232: return transformAndEmitContinueStatement(node); - case 230: + case 233: return transformAndEmitBreakStatement(node); - case 231: + case 234: return transformAndEmitReturnStatement(node); - case 232: + case 235: return transformAndEmitWithStatement(node); - case 233: + case 236: return transformAndEmitSwitchStatement(node); - case 234: + case 237: return transformAndEmitLabeledStatement(node); - case 235: + case 238: return transformAndEmitThrowStatement(node); - case 236: + case 239: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -65578,7 +68369,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 && defaultClauseIndex === -1) { + if (clause.kind === 276 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -65588,7 +68379,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272) { + if (clause.kind === 275) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -65721,11 +68512,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, node); return temp; } @@ -65823,7 +68613,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73); + context.enableSubstitution(75); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -66404,12 +69194,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73); - context.enableSubstitution(205); - context.enableSubstitution(203); - context.enableSubstitution(204); - context.enableSubstitution(277); - context.enableEmitNotification(285); + context.enableSubstitution(75); + context.enableSubstitution(208); + context.enableSubstitution(206); + context.enableSubstitution(207); + context.enableSubstitution(280); + context.enableEmitNotification(288); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -66600,23 +69390,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 250: + case 253: return visitImportDeclaration(node); - case 249: + case 252: return visitImportEqualsDeclaration(node); - case 256: + case 259: return visitExportDeclaration(node); - case 255: + case 258: return visitExportAssignment(node); - case 220: + case 224: return visitVariableStatement(node); - case 240: + case 243: return visitFunctionDeclaration(node); - case 241: + case 244: return visitClassDeclaration(node); - case 318: + case 321: return visitMergeDeclarationMarker(node); - case 319: + case 322: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -66641,24 +69431,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276: + case 279: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277: + case 280: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278: + case 281: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157: - case 159: case 160: + case 162: + case 163: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -66973,7 +69763,7 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -67005,10 +69795,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252: + case 255: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253: + case 256: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -67109,14 +69899,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 86: - case 81: + case 88: + case 83: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285) { + if (node.kind === 288) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -67156,12 +69946,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); - case 205: + case 208: return substituteBinaryExpression(node); - case 204: - case 203: + case 207: + case 206: return substituteUnaryExpression(node); } return node; @@ -67176,7 +69966,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285) { + if (exportContainer && exportContainer.kind === 288) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -67212,15 +70002,15 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 44 || node.operator === 45) + if ((node.operator === 45 || node.operator === 46) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 ? 61 : 62), ts.createLiteral(1)), node) + var expression = node.kind === 207 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 ? 63 : 64), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { var exportName = exportedNames_3[_i]; @@ -67284,13 +70074,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73); - context.enableSubstitution(277); - context.enableSubstitution(205); - context.enableSubstitution(203); - context.enableSubstitution(204); - context.enableSubstitution(215); - context.enableEmitNotification(285); + context.enableSubstitution(75); + context.enableSubstitution(280); + context.enableSubstitution(208); + context.enableSubstitution(206); + context.enableSubstitution(207); + context.enableSubstitution(218); + context.enableEmitNotification(288); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -67395,7 +70185,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 && externalImport.exportClause) { + if (externalImport.kind === 259 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -67418,7 +70208,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256) { + if (externalImport.kind !== 259) { continue; } if (!externalImport.exportClause) { @@ -67461,23 +70251,23 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var group_2 = dependencyGroups_1[_i]; + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 250: + case 253: if (!entry.importClause) { break; } - case 249: + case 252: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256: + case 259: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -67499,13 +70289,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 250: + case 253: return visitImportDeclaration(node); - case 249: + case 252: return visitImportEqualsDeclaration(node); - case 256: + case 259: return undefined; - case 255: + case 258: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -67626,7 +70416,7 @@ var ts; } function shouldHoistVariableDeclarationList(node) { return (ts.getEmitFlags(node) & 2097152) === 0 - && (enclosingBlockScopedContainer.kind === 285 + && (enclosingBlockScopedContainer.kind === 288 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -67648,7 +70438,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -67687,10 +70477,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252: + case 255: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253: + case 256: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -67790,43 +70580,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 220: + case 224: return visitVariableStatement(node); - case 240: + case 243: return visitFunctionDeclaration(node); - case 241: + case 244: return visitClassDeclaration(node); - case 226: + case 229: return visitForStatement(node); - case 227: + case 230: return visitForInStatement(node); - case 228: + case 231: return visitForOfStatement(node); - case 224: + case 227: return visitDoStatement(node); - case 225: + case 228: return visitWhileStatement(node); - case 234: + case 237: return visitLabeledStatement(node); - case 232: + case 235: return visitWithStatement(node); - case 233: + case 236: return visitSwitchStatement(node); - case 247: + case 250: return visitCaseBlock(node); - case 272: + case 275: return visitCaseClause(node); - case 273: + case 276: return visitDefaultClause(node); - case 236: + case 239: return visitTryStatement(node); - case 275: + case 278: return visitCatchClause(node); - case 219: + case 222: return visitBlock(node); - case 318: + case 321: return visitMergeDeclarationMarker(node); - case 319: + case 322: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -67962,7 +70752,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285; + return container !== undefined && container.kind === 288; } else { return false; @@ -67970,14 +70760,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 86: - case 81: + case 88: + case 83: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285) { + if (node.kind === 288) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -68013,7 +70803,7 @@ var ts; } function substituteUnspecified(node) { switch (node.kind) { - case 277: + case 280: return substituteShorthandPropertyAssignment(node); } return node; @@ -68035,14 +70825,14 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73: + case 75: return substituteExpressionIdentifier(node); - case 205: + case 208: return substituteBinaryExpression(node); - case 203: - case 204: + case 206: + case 207: return substituteUnaryExpression(node); - case 215: + case 218: return substituteMetaProperty(node); } return node; @@ -68087,22 +70877,22 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 44 || node.operator === 45) + if ((node.operator === 45 || node.operator === 46) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 + var expression = node.kind === 207 ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 204) { - expression = node.operator === 44 + if (node.kind === 207) { + expression = node.operator === 45 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -68124,7 +70914,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 285) { + if (exportContainer && exportContainer.kind === 288) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -68152,8 +70942,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285); - context.enableSubstitution(73); + context.enableEmitNotification(288); + context.enableSubstitution(75); var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -68177,9 +70967,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249: + case 252: return undefined; - case 255: + case 258: return visitExportAssignment(node); } return node; @@ -68265,7 +71055,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241) { + else if (node.parent.kind === 244) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -68294,7 +71084,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241) { + else if (node.parent.kind === 244) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -68341,15 +71131,15 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 238 || node.kind === 187) { + if (node.kind === 241 || node.kind === 190) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 155 || node.kind === 190 || node.kind === 154 || - (node.kind === 152 && ts.hasModifier(node.parent, 8))) { + else if (node.kind === 158 || node.kind === 193 || node.kind === 157 || + (node.kind === 155 && ts.hasModifier(node.parent, 8))) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -68357,7 +71147,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 || node.kind === 152) { + else if (node.parent.kind === 244 || node.kind === 155) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -68381,7 +71171,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160) { + if (node.kind === 163) { if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 : @@ -68418,23 +71208,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162: + case 165: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 161: + case 164: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 163: + case 166: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 157: - case 156: + case 160: + case 159: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -68442,7 +71232,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 241) { + else if (node.parent.kind === 244) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -68455,7 +71245,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240: + case 243: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -68480,27 +71270,27 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158: + case 161: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 162: - case 167: + case 165: + case 170: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 161: + case 164: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 163: + case 166: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 157: - case 156: + case 160: + case 159: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -68508,7 +71298,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241) { + else if (node.parent.parent.kind === 244) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -68520,13 +71310,20 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 240: - case 166: + case 243: + case 169: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163: + case 162: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -68534,39 +71331,39 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 241: + case 244: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242: + case 245: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182: + case 185: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167: - case 162: + case 170: + case 165: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161: + case 164: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157: - case 156: + case 160: + case 159: if (ts.hasModifier(node.parent, 32)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241) { + else if (node.parent.parent.kind === 244) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 166: - case 240: + case 169: + case 243: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243: + case 246: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -68580,8 +71377,8 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 241) { - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 ? + if (node.parent.parent.kind === 244) { + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -68614,11 +71411,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -68628,7 +71422,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152) { + if (parseTreeNode && parseTreeNode.kind === 155) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -68682,7 +71476,6 @@ var ts; var emittedImports; var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -68760,20 +71553,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(undefined, undefined, ts.createNamedExports([]), undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 && node.isDeclarationFile) { return node; } - if (node.kind === 286) { + if (node.kind === 289) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -68786,18 +71588,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { resultHasExternalModuleIndicator = false; needsDeclare = false; - var statements_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(126)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], true, [], [], false, []); + var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], true, [], [], false, []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288) { + if (prepend.kind === 291) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -68833,12 +71635,20 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -68917,11 +71727,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73) { + if (name.kind === 75) { return name; } else { - if (name.kind === 186) { + if (name.kind === 189) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -68929,7 +71739,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211) { + if (elem.kind === 214) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -68941,7 +71751,7 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } - var newParam = ts.updateParameter(p, undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p)); + var newParam = ts.updateParameter(p, undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(57)) : undefined, ensureType(p, type || p.type, true), ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } @@ -68963,17 +71773,17 @@ var ts; if (shouldPrintWithInitializer(node)) { return; } - var shouldUseResolverType = node.kind === 152 && + var shouldUseResolverType = node.kind === 155 && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124); } - if (node.kind === 160) { - return ts.createKeywordTypeNode(121); + if (node.kind === 163) { + return ts.createKeywordTypeNode(124); } errorNameNode = node.name; var oldDiag; @@ -68981,12 +71791,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 || node.kind === 187) { + if (node.kind === 241 || node.kind === 190) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 - || node.kind === 155 - || node.kind === 154) { + if (node.kind === 155 + || node.kind === 158 + || node.kind === 157) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -68997,25 +71807,25 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121); + return returnValue || ts.createKeywordTypeNode(124); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240: - case 245: - case 242: - case 241: case 243: + case 248: + case 245: case 244: + case 246: + case 247: return !resolver.isDeclarationVisible(node); - case 238: + case 241: return !getBindingNameVisible(node); - case 249: - case 250: - case 256: - case 255: + case 252: + case 253: + case 259: + case 258: return false; } return false; @@ -69092,7 +71902,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 && parent.kind !== 184); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 && parent.kind !== 187); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -69112,7 +71922,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260) { + if (decl.moduleReference.kind === 263) { var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.name, ts.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier))); } @@ -69132,7 +71942,7 @@ var ts; if (!decl.importClause.namedBindings) { return visibleDefaultBinding && ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252) { + if (decl.importClause.namedBindings.kind === 255) { var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; } @@ -69161,10 +71971,10 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -69174,12 +71984,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -69202,7 +72006,7 @@ var ts; var oldDiag = getSymbolAccessibilityDiagnostic; var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 || input.kind === 182) && input.parent.kind !== 243); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 || input.kind === 185) && input.parent.kind !== 246); if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) @@ -69221,63 +72025,55 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212: { + case 215: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165: { + case 168: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162: + case 165: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158: { + case 161: { var isPrivate = ts.hasModifier(input, 8); - var ctor = ts.createSignatureDeclaration(158, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); + var ctor = ts.createSignatureDeclaration(161, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), isPrivate ? undefined : updateParamsList(input, input.parameters, 0), undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157: { - var sig = ts.createSignatureDeclaration(156, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160: { + var sig = ts.createSignatureDeclaration(159, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159: { - if (input.flags & 4194304) { - var isPrivate = ts.hasModifier(input, 8); - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(ts.updateGetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 162: { + var isPrivate = ts.hasModifier(input, 8); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, undefined)); } - case 160: { - if (input.flags & 4194304) { - return cleanup(ts.updateSetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); + case 163: { + return cleanup(ts.updateSetAccessor(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8)), undefined)); } - case 155: + case 158: return cleanup(ts.updateProperty(input, undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154: + case 157: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156: { + case 159: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161: { + case 164: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163: { - return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121))); + case 166: { + return cleanup(ts.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124))); } - case 238: { + case 241: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -69285,13 +72081,13 @@ var ts; suppressNewDiagnosticContexts = true; return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151: { + case 154: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, undefined, undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176: { + case 179: { var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree); var oldEnclosingDecl = enclosingDeclaration; @@ -69301,13 +72097,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166: { + case 169: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167: { + case 170: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184: { + case 187: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -69336,7 +72132,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 160 && ts.hasModifier(node.parent, 8); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -69345,19 +72141,19 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256: { + case 259: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; return ts.updateExportDeclaration(input, undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255: { + case 258: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 73) { + if (input.expression.kind === 75) { return input; } else { @@ -69367,7 +72163,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126)] : [], ts.createVariableDeclarationList([varDecl], 2)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129)] : [], ts.createVariableDeclarationList([varDecl], 2)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -69389,10 +72185,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249: { + case 252: { return transformImportEqualsDeclaration(input); } - case 250: { + case 253: { return transformImportDeclaration(input); } } @@ -69412,12 +72208,12 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243: + case 246: return cleanup(ts.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242: { + case 245: { return cleanup(ts.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240: { + case 243: { var clean = cleanup(ts.updateFunctionDeclaration(input, undefined, ensureModifiers(input), undefined, input.name, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), undefined)); if (clean && resolver.isExpandoFunctionDeclaration(input)) { var props = resolver.getPropertiesOfContainerFunction(input); @@ -69454,22 +72250,22 @@ var ts; return clean; } } - case 245: { + case 248: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246) { + if (inner && inner.kind === 249) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304) { + if (input.flags & 8388608) { needsScopeFixMarker = false; } if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -69493,7 +72289,7 @@ var ts; return cleanup(ts.updateModuleDeclaration(input, undefined, mods, input.name, body)); } } - case 241: { + case 244: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -69504,7 +72300,7 @@ var ts; if (!ts.hasModifier(param, 92) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73) { + if (param.name.kind === 75) { return preserveJsDoc(ts.createProperty(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } else { @@ -69529,7 +72325,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 97) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99) { var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); getSymbolAccessibilityDiagnostic = function () { return ({ @@ -69538,16 +72334,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126)] : [], ts.createVariableDeclarationList([varDecl], 2)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129)] : [], ts.createVariableDeclarationList([varDecl], 2)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87) { + if (clause.token === 89) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 97; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; } @@ -69556,10 +72352,10 @@ var ts; return cleanup(ts.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220: { + case 224: { return cleanup(transformVariableStatement(input)); } - case 244: { + case 247: { return cleanup(ts.updateEnumDeclaration(input, undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -69576,7 +72372,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245) { + if (input.kind === 248) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -69597,7 +72393,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211) { + if (e.kind === 214) { return; } if (e.name) { @@ -69647,7 +72443,7 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 ^ (4 | 256); var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0; - var parentIsFile = node.parent.kind === 285; + var parentIsFile = node.parent.kind === 288; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2; additions = 0; @@ -69666,43 +72462,15 @@ var ts; } return accessorType; } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); - var prop = ts.createProperty(undefined, maskModifiers(node, undefined, (!accessors.setAccessor) ? 64 : 0), node.name, node.questionToken, ensureType(node, accessorType), undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; - } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 87 && t.expression.kind === 97); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 && t.expression.kind === 99); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242) { + if (node.kind === 245) { return true; } return false; @@ -69724,7 +72492,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 + return accessor.kind === 162 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -69733,52 +72501,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155: - case 154: + case 158: + case 157: return !ts.hasModifier(node, 8); - case 152: - case 238: + case 155: + case 241: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240: - case 245: - case 249: - case 242: - case 241: case 243: + case 248: + case 252: + case 245: case 244: - case 220: - case 250: - case 256: - case 255: + case 246: + case 247: + case 224: + case 253: + case 259: + case 258: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { + case 165: + case 161: + case 160: case 162: + case 163: case 158: case 157: case 159: - case 160: - case 155: - case 154: - case 156: - case 161: - case 163: - case 238: - case 151: - case 212: - case 165: - case 176: + case 164: case 166: - case 167: - case 184: + case 241: + case 154: + case 215: + case 168: + case 179: + case 169: + case 170: + case 187: return true; } return false; @@ -69876,7 +72644,7 @@ var ts; } ts.noEmitNotification = noEmitNotification; function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(320); + var enabledSyntaxKindFeatures = new Array(324); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -70091,15 +72859,15 @@ var ts; return ts.fileExtensionIs(file, ".tsbuildinfo"); } ts.isBuildInfoFile = isBuildInfoFile; - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -70109,21 +72877,21 @@ var ts; if (!onlyBuildInfo) { 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); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -70146,20 +72914,20 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo"; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; var jsFilePath = options.emitDeclarationOnly ? undefined : outPath; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286) { + if (sourceFile.kind === 289) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -70168,8 +72936,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -70204,7 +72971,7 @@ var ts; inputFileName; } function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts")); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts"); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -70221,42 +72988,72 @@ var ts; outputFileName : undefined; } - function getAllProjectOutputs(configFile, ignoreCase) { + function createAddOutput() { var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts")) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json")) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } + function getAllProjectOutputs(configFile, ignoreCase) { + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts")) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json")) - continue; - if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath; @@ -70271,17 +73068,17 @@ var ts; return jsFilePath; if (ts.fileExtensionIs(inputFileName, ".json")) continue; - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); } ts.getFirstProjectOutput = getFirstProjectOutput; - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -70294,7 +73091,7 @@ var ts; var emitSkipped = false; var exportedModulesFromDeclarationEmit; enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -70383,14 +73180,17 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle) + return; + if (!declarationFilePath) { + if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly) + emitSkipped = true; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, false); if (ts.length(declarationTransform.diagnostics)) { @@ -70420,7 +73220,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -70428,7 +73228,7 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -70439,7 +73239,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73) { + if (node.expression.kind === 75) { resolver.collectLinkedAliases(node.expression, true); } return; @@ -70451,8 +73251,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -70490,7 +73290,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); + && (sourceFileOrBundle.kind !== 288 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json")); } function getSourceRoot(mapOptions) { var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || ""); @@ -70581,10 +73381,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285, 0, 0); + var sourceFile = ts.createNode(288, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -70596,7 +73397,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222, directive.pos, directive.end); + var statement = ts.createNode(225, directive.pos, directive.end); statement.expression = ts.createNode(10, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -70725,6 +73526,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -70751,9 +73554,9 @@ var ts; break; } switch (node.kind) { - case 285: return printFile(node); - case 286: return printBundle(node); - case 287: return printUnparsedSource(node); + case 288: return printFile(node); + case 289: return printBundle(node); + case 290: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -70920,8 +73723,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -70933,7 +73735,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; sourceMapGenerator = _sourceMapGenerator; @@ -70949,6 +73751,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(undefined, undefined); } function getCurrentLineMap() { @@ -70958,21 +73762,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(4, node); + var substitute = pipelineEmit(4, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(2, node); + return pipelineEmit(2, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(1, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -70985,11 +73800,11 @@ var ts; return pipelineEmitWithSubstitution; } case 2: - if (!commentsDisabled && node.kind !== 285) { + if (!commentsDisabled && node.kind !== 288) { return pipelineEmitWithComments; } case 3: - if (!sourceMapsDisabled && node.kind !== 285 && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } case 4: @@ -71002,10 +73817,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2) @@ -71024,262 +73842,262 @@ var ts; case 16: case 17: return emitLiteral(node); - case 287: - case 281: + case 290: + case 284: return emitUnparsedSourceOrPrepend(node); - case 280: - return writeUnparsedNode(node); - case 282: case 283: + return writeUnparsedNode(node); + case 285: + case 286: return emitUnparsedTextLike(node); - case 284: + case 287: return emitUnparsedSyntheticReference(node); - case 73: + case 75: return emitIdentifier(node); - case 149: + case 152: return emitQualifiedName(node); - case 150: + case 153: return emitComputedPropertyName(node); - case 151: + case 154: return emitTypeParameter(node); - case 152: + case 155: return emitParameter(node); - case 153: + case 156: return emitDecorator(node); - case 154: + case 157: return emitPropertySignature(node); - case 155: + case 158: return emitPropertyDeclaration(node); - case 156: + case 159: return emitMethodSignature(node); - case 157: + case 160: return emitMethodDeclaration(node); - case 158: + case 161: return emitConstructor(node); - case 159: - case 160: + case 162: + case 163: return emitAccessorDeclaration(node); - case 161: + case 164: return emitCallSignature(node); - case 162: + case 165: return emitConstructSignature(node); - case 163: + case 166: return emitIndexSignature(node); - case 164: + case 167: return emitTypePredicate(node); - case 165: + case 168: return emitTypeReference(node); - case 166: + case 169: return emitFunctionType(node); - case 295: + case 298: return emitJSDocFunctionType(node); - case 167: + case 170: return emitConstructorType(node); - case 168: + case 171: return emitTypeQuery(node); - case 169: + case 172: return emitTypeLiteral(node); - case 170: + case 173: return emitArrayType(node); - case 171: + case 174: return emitTupleType(node); - case 172: + case 175: return emitOptionalType(node); - case 174: + case 177: return emitUnionType(node); - case 175: + case 178: return emitIntersectionType(node); - case 176: + case 179: return emitConditionalType(node); - case 177: + case 180: return emitInferType(node); - case 178: + case 181: return emitParenthesizedType(node); - case 212: + case 215: return emitExpressionWithTypeArguments(node); - case 179: + case 182: return emitThisType(); - case 180: + case 183: return emitTypeOperator(node); - case 181: + case 184: return emitIndexedAccessType(node); - case 182: + case 185: return emitMappedType(node); - case 183: + case 186: return emitLiteralType(node); - case 184: + case 187: return emitImportTypeNode(node); - case 290: + case 293: writePunctuation("*"); return; - case 291: + case 294: writePunctuation("?"); return; - case 292: + case 295: return emitJSDocNullableType(node); - case 293: + case 296: return emitJSDocNonNullableType(node); - case 294: + case 297: return emitJSDocOptionalType(node); - case 173: - case 296: + case 176: + case 299: return emitRestOrJSDocVariadicType(node); - case 185: + case 188: return emitObjectBindingPattern(node); - case 186: + case 189: return emitArrayBindingPattern(node); - case 187: + case 190: return emitBindingElement(node); - case 217: + case 220: return emitTemplateSpan(node); - case 218: + case 221: return emitSemicolonClassElement(); - case 219: + case 222: return emitBlock(node); - case 220: + case 224: return emitVariableStatement(node); - case 221: + case 223: return emitEmptyStatement(false); - case 222: + case 225: return emitExpressionStatement(node); - case 223: + case 226: return emitIfStatement(node); - case 224: + case 227: return emitDoStatement(node); - case 225: + case 228: return emitWhileStatement(node); - case 226: + case 229: return emitForStatement(node); - case 227: + case 230: return emitForInStatement(node); - case 228: + case 231: return emitForOfStatement(node); - case 229: + case 232: return emitContinueStatement(node); - case 230: + case 233: return emitBreakStatement(node); - case 231: + case 234: return emitReturnStatement(node); - case 232: + case 235: return emitWithStatement(node); - case 233: + case 236: return emitSwitchStatement(node); - case 234: + case 237: return emitLabeledStatement(node); - case 235: + case 238: return emitThrowStatement(node); - case 236: + case 239: return emitTryStatement(node); - case 237: + case 240: return emitDebuggerStatement(node); - case 238: + case 241: return emitVariableDeclaration(node); - case 239: + case 242: return emitVariableDeclarationList(node); - case 240: + case 243: return emitFunctionDeclaration(node); - case 241: + case 244: return emitClassDeclaration(node); - case 242: + case 245: return emitInterfaceDeclaration(node); - case 243: + case 246: return emitTypeAliasDeclaration(node); - case 244: + case 247: return emitEnumDeclaration(node); - case 245: + case 248: return emitModuleDeclaration(node); - case 246: + case 249: return emitModuleBlock(node); - case 247: + case 250: return emitCaseBlock(node); - case 248: + case 251: return emitNamespaceExportDeclaration(node); - case 249: + case 252: return emitImportEqualsDeclaration(node); - case 250: + case 253: return emitImportDeclaration(node); - case 251: + case 254: return emitImportClause(node); - case 252: + case 255: return emitNamespaceImport(node); - case 253: + case 256: return emitNamedImports(node); - case 254: + case 257: return emitImportSpecifier(node); - case 255: + case 258: return emitExportAssignment(node); - case 256: + case 259: return emitExportDeclaration(node); - case 257: + case 260: return emitNamedExports(node); - case 258: + case 261: return emitExportSpecifier(node); - case 259: + case 262: return; - case 260: + case 263: return emitExternalModuleReference(node); case 11: return emitJsxText(node); - case 263: case 266: + case 269: return emitJsxOpeningElementOrFragment(node); - case 264: case 267: + case 270: return emitJsxClosingElementOrFragment(node); - case 268: + case 271: return emitJsxAttribute(node); - case 269: + case 272: return emitJsxAttributes(node); - case 270: + case 273: return emitJsxSpreadAttribute(node); - case 271: + case 274: return emitJsxExpression(node); - case 272: + case 275: return emitCaseClause(node); - case 273: + case 276: return emitDefaultClause(node); - case 274: + case 277: return emitHeritageClause(node); - case 275: + case 278: return emitCatchClause(node); - case 276: + case 279: return emitPropertyAssignment(node); - case 277: + case 280: return emitShorthandPropertyAssignment(node); - case 278: + case 281: return emitSpreadAssignment(node); - case 279: + case 282: return emitEnumMember(node); - case 307: - case 313: - return emitJSDocPropertyLikeTag(node); - case 308: case 310: + case 316: + return emitJSDocPropertyLikeTag(node); + case 311: + case 313: + case 312: case 309: - case 306: return emitJSDocSimpleTypedTag(node); - case 302: + case 305: return emitJSDocAugmentsTag(node); - case 311: + case 314: return emitJSDocTemplateTag(node); - case 312: + case 315: return emitJSDocTypedefTag(node); - case 305: + case 308: return emitJSDocCallbackTag(node); - case 300: + case 303: return emitJSDocSignature(node); - case 299: + case 302: return emitJSDocTypeLiteral(node); + case 307: case 304: - case 301: return emitJSDocSimpleTag(node); - case 298: + case 301: return emitJSDoc(node); } if (ts.isExpression(node)) { hint = 1; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -71295,79 +74113,79 @@ var ts; case 13: case 14: return emitLiteral(node); - case 73: + case 75: return emitIdentifier(node); - case 88: - case 97: + case 90: case 99: - case 103: case 101: - case 93: + case 105: + case 103: + case 95: writeTokenNode(node, writeKeyword); return; - case 188: + case 191: return emitArrayLiteralExpression(node); - case 189: + case 192: return emitObjectLiteralExpression(node); - case 190: + case 193: return emitPropertyAccessExpression(node); - case 191: + case 194: return emitElementAccessExpression(node); - case 192: + case 195: return emitCallExpression(node); - case 193: + case 196: return emitNewExpression(node); - case 194: + case 197: return emitTaggedTemplateExpression(node); - case 195: + case 198: return emitTypeAssertionExpression(node); - case 196: + case 199: return emitParenthesizedExpression(node); - case 197: + case 200: return emitFunctionExpression(node); - case 198: + case 201: return emitArrowFunction(node); - case 199: + case 202: return emitDeleteExpression(node); - case 200: + case 203: return emitTypeOfExpression(node); - case 201: + case 204: return emitVoidExpression(node); - case 202: + case 205: return emitAwaitExpression(node); - case 203: + case 206: return emitPrefixUnaryExpression(node); - case 204: + case 207: return emitPostfixUnaryExpression(node); - case 205: + case 208: return emitBinaryExpression(node); - case 206: + case 209: return emitConditionalExpression(node); - case 207: + case 210: return emitTemplateExpression(node); - case 208: + case 211: return emitYieldExpression(node); - case 209: + case 212: return emitSpreadExpression(node); - case 210: + case 213: return emitClassExpression(node); - case 211: + case 214: return; - case 213: + case 216: return emitAsExpression(node); - case 214: + case 217: return emitNonNullExpression(node); - case 215: + case 218: return emitMetaProperty(node); - case 261: + case 264: return emitJsxElement(node); - case 262: - return emitJsxSelfClosingElement(node); case 265: + return emitJsxSelfClosingElement(node); + case 268: return emitJsxFragment(node); - case 316: + case 319: return emitPartiallyEmittedExpression(node); - case 317: + case 320: return emitCommaList(node); } } @@ -71380,8 +74198,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -71407,7 +74228,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 ? node : undefined; + var bundle = node.kind === 289 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -71481,7 +74302,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 ? "text" : "internal"); } @@ -71507,7 +74328,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73) { + if (node.kind === 75) { emitExpression(node); } else { @@ -71540,7 +74361,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 && !node.name) { + if (node.parent && node.parent.kind === 298 && !node.name) { emit(node.type); } else { @@ -71598,7 +74419,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 ? "get" : "set"); + writeKeyword(node.kind === 162 ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -71636,11 +74457,17 @@ var ts; writeTrailingSemicolon(); } function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -71772,18 +74599,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134) { + if (node.readonlyToken.kind !== 137) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0, node.typeParameter); - pipelinePhase(3, node.typeParameter); + pipelineEmit(3, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56) { + if (node.questionToken.kind !== 57) { writePunctuation("?"); } } @@ -71857,57 +74683,50 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, false, true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072)) { - var dotToken = ts.createToken(24); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { var text = getLiteralTextOfNode(expression, true); - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576); } function emitNewExpression(node) { - emitTokenWithComment(96, node.pos, writeKeyword, node); + emitTokenWithComment(98, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -71947,22 +74766,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82, node.pos, writeKeyword, node); + emitTokenWithComment(84, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105, node.pos, writeKeyword, node); + emitTokenWithComment(107, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107, node.pos, writeKeyword, node); + emitTokenWithComment(109, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123, node.pos, writeKeyword, node); + emitTokenWithComment(126, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -71975,9 +74794,9 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 203 - && ((node.operator === 38 && (operand.operator === 38 || operand.operator === 44)) - || (node.operator === 39 && (operand.operator === 39 || operand.operator === 45))); + return operand.kind === 206 + && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45)) + || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -71990,7 +74809,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, true); increaseIndentIf(indentAfterOperator, true); emitExpression(node.right); @@ -72018,7 +74837,7 @@ var ts; emitList(node, node.templateSpans, 262144); } function emitYieldExpression(node) { - emitTokenWithComment(118, node.pos, writeKeyword, node); + emitTokenWithComment(120, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -72085,7 +74904,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -72093,8 +74912,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223) { + emitTokenWithComment(86, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226) { writeSpace(); emit(node.elseStatement); } @@ -72104,14 +74923,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83, node.pos, writeKeyword, node); + emitTokenWithComment(85, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -72120,14 +74939,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); @@ -72139,25 +74958,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21, node.expression.end, writePunctuation, node); @@ -72165,7 +74984,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239) { + if (node.kind === 242) { emit(node); } else { @@ -72174,12 +74993,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79, node.pos, writeKeyword, node); + emitTokenWithComment(81, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74, node.pos, writeKeyword, node); + emitTokenWithComment(76, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -72207,12 +75026,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98, node.pos, writeKeyword, node); + emitTokenWithComment(100, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -72220,7 +75039,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -72230,17 +75049,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57, node.label.end, writePunctuation, node); + emitTokenWithComment(58, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102, node.pos, writeKeyword, node); + emitTokenWithComment(104, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104, node.pos, writeKeyword, node); + emitTokenWithComment(106, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -72249,13 +75068,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80, node.pos, writeKeyword); + writeToken(82, node.pos, writeKeyword); writeTrailingSemicolon(); } function emitVariableDeclaration(node) { @@ -72442,7 +75261,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512) { + if (~node.flags & 1024) { writeKeyword(node.flags & 16 ? "namespace" : "module"); writeSpace(); } @@ -72450,7 +75269,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245) { + while (body.kind === 248) { writePunctuation("."); emit(body.name); body = body.body; @@ -72471,17 +75290,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60, node.name.end, writePunctuation, node); + emitTokenWithComment(62, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73) { + if (node.kind === 75) { emitExpression(node); } else { @@ -72490,12 +75309,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -72510,9 +75329,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120, asPos, writeKeyword, node); + emitTokenWithComment(122, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -72523,42 +75342,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60, nextPos, writeOperator, node); + emitTokenWithComment(62, nextPos, writeOperator, node); } else { - emitTokenWithComment(81, nextPos, writeKeyword, node); + emitTokenWithComment(83, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145, fromPos, writeKeyword, node); + emitTokenWithComment(148, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -72578,7 +75397,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -72650,7 +75469,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73) { + if (node.kind === 75) { emitExpression(node); } else { @@ -72658,13 +75477,13 @@ var ts; } } function emitCaseClause(node) { - emitTokenWithComment(75, node.pos, writeKeyword, node); + emitTokenWithComment(77, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -72674,12 +75493,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969; if (emitAsSingleStatement) { - writeToken(57, colonPos, writePunctuation, parentNode); + writeToken(58, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 | 128); } else { - emitTokenWithComment(57, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -72690,7 +75509,7 @@ var ts; emitList(node, node.types, 528); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20, openParenPos, writePunctuation, node); @@ -72744,7 +75563,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 310 && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -72778,7 +75597,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289) { + if (tag.typeExpression.kind === 292) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -72797,7 +75616,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 299) { + if (tag.typeExpression && tag.typeExpression.kind === 302) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -72926,8 +75745,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName }); writeLine(); } - for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { - var directive = types_18[_d]; + for (var _d = 0, types_21 = types; _d < types_21.length; _d++) { + var directive = types_21[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -73097,7 +75916,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -73135,8 +75954,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0, node); - pipelinePhase(5, node); + pipelineEmit(5, node); } else { emit(node); @@ -73511,6 +76329,9 @@ var ts; return (format & 65536) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -73527,7 +76348,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -73586,81 +76407,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219: + case 222: ts.forEach(node.statements, generateNames); break; - case 234: - case 232: - case 224: - case 225: + case 237: + case 235: + case 227: + case 228: generateNames(node.statement); break; - case 223: + case 226: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226: - case 228: - case 227: + case 229: + case 231: + case 230: generateNames(node.initializer); generateNames(node.statement); break; - case 233: + case 236: generateNames(node.caseBlock); break; - case 247: + case 250: ts.forEach(node.clauses, generateNames); break; - case 272: - case 273: + case 275: + case 276: ts.forEach(node.statements, generateNames); break; - case 236: + case 239: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275: + case 278: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220: + case 224: generateNames(node.declarationList); break; - case 239: + case 242: ts.forEach(node.declarations, generateNames); break; - case 238: - case 152: - case 187: case 241: + case 155: + case 190: + case 244: generateNameIfNeeded(node.name); break; - case 240: + case 243: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185: - case 186: + case 188: + case 189: ts.forEach(node.elements, generateNames); break; - case 250: + case 253: generateNames(node.importClause); break; - case 251: + case 254: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252: + case 255: generateNameIfNeeded(node.name); break; - case 253: + case 256: ts.forEach(node.elements, generateNames); break; - case 254: + case 257: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -73669,12 +76490,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276: - case 277: - case 155: - case 157: - case 159: + case 279: + case 280: + case 158: case 160: + case 162: + case 163: generateNameIfNeeded(node.name); break; } @@ -73806,25 +76627,25 @@ var ts; } function generateNameForNode(node, flags) { switch (node.kind) { - case 73: + case 75: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8)); - case 245: - case 244: + case 248: + case 247: return generateNameForModuleOrEnum(node); - case 250: - case 256: + case 253: + case 259: return generateNameForImportOrExportDeclaration(node); - case 240: - case 241: - case 255: + case 243: + case 244: + case 258: return generateNameForExportDefault(); - case 210: + case 213: return generateNameForClassExpression(); - case 157: - case 159: case 160: + case 162: + case 163: return generateNameForMethodOrAccessor(node); - case 150: + case 153: return makeTempVariableName(0, true); default: return makeTempVariableName(0); @@ -73857,11 +76678,12 @@ var ts; return node; } function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 315; + var isEmittedNode = node.kind !== 318; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11; var savedContainerPos = containerPos; @@ -73876,7 +76698,7 @@ var ts; } if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) { containerEnd = end; - if (node.kind === 239) { + if (node.kind === 242) { declarationListContainerEnd = end; } } @@ -73903,6 +76725,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2) { @@ -74096,6 +76919,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -74110,7 +76934,7 @@ var ts; else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 315 + if (node.kind !== 318 && (emitFlags & 16) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -74123,12 +76947,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 315 + if (node.kind !== 318 && (emitFlags & 32) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function skipSourceTrivia(source, pos) { return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos); @@ -74966,6 +77791,7 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + ts.inferredTypesContainingFile = "__inferred type names__.ts"; function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) { if (!program || hasChangedAutomaticTypeDirectiveNames) { return false; @@ -75047,15 +77873,16 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -75111,6 +77938,8 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); var structuralIsReused; structuralIsReused = tryReuseStructureFromOldProgram(); @@ -75121,20 +77950,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, false, false, undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts") && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), false, false, undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts")) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), false, false, undefined); + } } } } @@ -75145,7 +77990,7 @@ var ts; var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray; if (typeReferences.length) { var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -75173,8 +78018,8 @@ var ts; ts.Debug.assert(!!missingFilePaths); if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) { @@ -75188,12 +78033,13 @@ var ts; }); } oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -75230,7 +78076,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -75257,9 +78105,13 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); } @@ -75408,6 +78260,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } var newSourceFiles = []; var modifiedSourceFiles = []; @@ -75473,7 +78331,7 @@ var ts; if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { oldProgram.structureIsReused = 1; } - if ((oldSourceFile.flags & 1572864) !== (newSourceFile.flags & 1572864)) { + if ((oldSourceFile.flags & 3145728) !== (newSourceFile.flags & 3145728)) { oldProgram.structureIsReused = 1; } if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { @@ -75503,25 +78361,23 @@ var ts; for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = getModuleNames(newSourceFile); - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - oldProgram.structureIsReused = 1; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + oldProgram.structureIsReused = 1; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } if (resolveTypeReferenceDirectiveNamesWorker) { var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { + var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -75535,10 +78391,18 @@ var ts; return oldProgram.structureIsReused = 1; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; var filePath = newSourceFile.path; addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); + if (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), undefined); + } + } if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); } @@ -75557,7 +78421,8 @@ var ts; function getEmitHost(writeFileCallback) { return __assign(__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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, 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) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, 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; @@ -75614,15 +78479,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -75643,7 +78508,7 @@ var ts; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -75706,14 +78571,15 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 || - sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7; + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 || + sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -75765,62 +78631,62 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 152: case 155: + case 158: + case 160: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 157: - case 156: - case 158: case 159: - case 160: - case 197: - case 240: - case 198: - case 238: + case 161: + case 162: + case 163: + case 200: + case 243: + case 201: + case 241: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 249: + case 252: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255: + case 258: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274: + case 277: var heritageClause = node; - if (heritageClause.token === 110) { + if (heritageClause.token === 112) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242: + case 245: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245: + case 248: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243: + case 246: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244: + case 247: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214: + case 217: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213: + case 216: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195: + case 198: ts.Debug.fail(); } var prevParent = parent; @@ -75833,46 +78699,47 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241: - case 157: - case 156: - case 158: - case 159: + case 244: + case 213: case 160: - case 197: - case 240: - case 198: + case 161: + case 162: + case 163: + case 200: + case 243: + case 201: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 220: + case 224: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220); + return checkModifiers(parent.modifiers, parent.kind === 224); } break; - case 155: + case 158: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 117) { + if (modifier.kind !== 119) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152: + case 155: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192: - case 193: - case 212: - case 262: - case 263: + case 195: + case 196: + case 215: + case 265: + case 266: + case 197: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; @@ -75888,21 +78755,21 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78: + case 80: if (isConstValid) { continue; } + case 118: case 116: - case 114: - case 115: - case 134: - case 126: - case 119: + case 117: + case 137: + case 129: + case 121: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; - case 117: - case 86: - case 81: + case 119: + case 88: + case 83: } } } @@ -75974,8 +78841,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 - ? b.kind === 73 && a.escapedText === b.escapedText + return a.kind === 75 + ? b.kind === 75 && a.escapedText === b.escapedText : b.kind === 10 && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -76001,7 +78868,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, false); } - if ((file.flags & 524288) || isJavaScriptFile) { + if ((file.flags & 1048576) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -76115,23 +78982,17 @@ var ts; return sourceFileWithAddedExtension; } } - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, diagnostic], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([diagnostic], args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -76153,13 +79014,33 @@ var ts; }); return redirect; } - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (!source && + host.realpath && + options.preserveSymlinks && + ts.isDeclarationFileName(fileName) && + ts.stringContains(fileName, ts.nodeModulesPathPart)) { + var realPath = host.realpath(fileName); + if (realPath !== fileName) + source = getSourceOfProjectReferenceRedirect(realPath); + } + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); - if (file_1 && options.forceConsistentCasingInFileNames) { + var file_2 = filesByName.get(path); + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -76167,31 +79048,32 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -76202,14 +79084,7 @@ var ts; redirectedPath = toPath(redirect); } } - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -76236,7 +79111,7 @@ var ts; var pathLowerCase = path.toLowerCase(); var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -76258,8 +79133,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -76274,7 +79159,7 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts")) { return undefined; } return getResolvedProjectReferenceToRedirect(fileName); @@ -76307,6 +79192,34 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + var outputDts = ts.changeExtension(out, ".d.ts"); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts")) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, undefined, cbResolvedRef, cbRef); @@ -76339,9 +79252,15 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, false, undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, false, undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -76355,10 +79274,16 @@ var ts; var resolvedTypeReferenceDirective = resolutions[i]; var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { return; @@ -76368,27 +79293,27 @@ var ts; if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile); } else { if (previousResolution) { if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -76405,20 +79330,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { + if (!refFile) { return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, message], args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -76450,14 +79375,20 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, false, false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, false, false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -76475,12 +79406,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; 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) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -76535,9 +79469,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -76574,13 +79505,11 @@ var ts; } verifyProjectReferences(); if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -76688,8 +79617,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -76748,8 +79677,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -76775,7 +79737,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -76904,6 +79866,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) { @@ -76946,9 +79914,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { @@ -76989,9 +79954,9 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -77183,7 +80148,7 @@ var ts; } } else { - var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true); var firstDts_1 = emitOutput_1.outputFiles && programOfThisState.getCompilerOptions().declarationMap ? emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : @@ -77276,6 +80241,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; function containsOnlyAmbientModules(sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; @@ -77354,7 +80320,7 @@ var ts; state.program = newProgram; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -77375,7 +80341,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -77412,16 +80379,17 @@ var ts; } }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } + state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit; return state; } function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -77460,7 +80428,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -77517,12 +80486,17 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -77536,7 +80510,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -77552,7 +80526,7 @@ var ts; if (sourceFile) { ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0); } } } @@ -77566,10 +80540,33 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { return; } + if (!isChangedSignagure(state, affectedFile.path)) + return; + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } + } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) { @@ -77618,7 +80615,7 @@ var ts; fn(state, referencingFilePath); }); } - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, isEmitResult) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -77628,8 +80625,8 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); - if (isEmitResult) { - (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; @@ -77639,12 +80636,12 @@ var ts; } } } - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); return { result: result, affected: affected }; } - function toAffectedFileEmitResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, true); + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) { @@ -77665,7 +80662,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -77842,17 +80839,19 @@ var ts; return result; function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } var affected_1 = ts.Debug.assertDefined(state.program); - return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, false, true); + return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -77864,7 +80863,7 @@ var ts; affected = program; } } - return toAffectedFileEmitResult(state, ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + return toAffectedFileEmitResult(state, ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile); } function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { @@ -77901,7 +80900,7 @@ var ts; return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected); } if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1); } if (ignoreSourceFile && ignoreSourceFile(affected)) { doneWithAffectedFile(state, affected); @@ -77931,8 +80930,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); if (state.affectedFilesPendingEmitIndex === undefined) { state.affectedFilesPendingEmitIndex = 0; } @@ -77959,7 +80964,7 @@ var ts; } var state = { fileInfos: fileInfos, - compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), + compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), @@ -77995,33 +81000,6 @@ var ts; } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function convertFromReusableCompilerOptions(options, toAbsolutePath) { - var result = {}; - var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertFromReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); - } - } - if (result.configFilePath) { - result.configFilePath = toAbsolutePath(result.configFilePath); - } - return result; - } - function convertFromReusableCompilerOptionValue(option, value, toAbsolutePath) { - if (option) { - if (option.type === "list") { - var values = value; - if (option.element.isFilePath && values.length) { - return values.map(toAbsolutePath); - } - } - else if (option.isFilePath) { - return toAbsolutePath(value); - } - } - return value; - } function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -78079,8 +81057,19 @@ var ts; if (nextDirectorySeparator === -1) { return false; } - if (dirPath.charCodeAt(0) !== 47 && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { @@ -78497,6 +81486,9 @@ var ts; if (!resolution.isInvalidated && isInvalidatedResolution(resolution, getResolutionWithResolvedFileName)) { resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -78632,8 +81624,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -78648,6 +81641,12 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); @@ -78710,43 +81709,21 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } function getAllModulePaths(files, importingFileName, importedFileName, getCanonicalFileName, host, redirectTargetsMap) { var redirects = redirectTargetsMap.get(importedFileName); var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -78763,7 +81740,30 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -78805,7 +81805,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -78814,24 +81814,30 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); - if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); + var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); + var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)); + if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) { return undefined; + } var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1); var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName); return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName; @@ -78998,11 +82004,17 @@ var ts; ? newLine + newLine : newLine; } + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; function createWatchStatusReporter(system, pretty) { return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -79011,7 +82023,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -79019,7 +82031,7 @@ var ts; ts.createWatchStatusReporter = createWatchStatusReporter; function parseConfigFileWithSystem(configFileName, optionsToExtend, system, reportDiagnostic) { var host = system; - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(ts.sys, reportDiagnostic, diagnostic); }; + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host); host.onUnRecoverableConfigFileDiagnostic = undefined; return result; @@ -79043,7 +82055,7 @@ var ts; } ts.getErrorSummaryText = getErrorSummaryText; function listFiles(program, writeFileName) { - if (program.getCompilerOptions().listFiles) { + if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) { ts.forEach(program.getSourceFiles(), function (file) { writeFileName(file.fileName); }); @@ -79051,17 +82063,22 @@ var ts; } ts.listFiles = listFiles; function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { + var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly; var diagnostics = program.getConfigFileParsingDiagnostics().slice(); var configFileParsingDiagnosticsLength = diagnostics.length; ts.addRange(diagnostics, program.getSyntacticDiagnostics(undefined, cancellationToken)); if (diagnostics.length === configFileParsingDiagnosticsLength) { ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken)); - ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); - if (diagnostics.length === configFileParsingDiagnosticsLength) { - ts.addRange(diagnostics, program.getSemanticDiagnostics(undefined, cancellationToken)); + if (!isListFilesOnly) { + ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); + if (diagnostics.length === configFileParsingDiagnosticsLength) { + ts.addRange(diagnostics, program.getSemanticDiagnostics(undefined, cancellationToken)); + } } } - var emitResult = program.emit(undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = isListFilesOnly + ? { emitSkipped: true, diagnostics: ts.emptyArray } + : program.emit(undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics; ts.addRange(diagnostics, emitDiagnostics); ts.sortAndDeduplicateDiagnostics(diagnostics).forEach(reportDiagnostic); @@ -79226,7 +82243,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -79266,7 +82283,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -79762,9 +82779,17 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts"); } + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -79916,18 +82941,21 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); if (permanentMarks.has(projPath)) return; if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -79951,10 +82979,8 @@ var ts; } function createStateBuildOrder(state) { var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); - if (ts.arrayIsEqualTo(state.buildOrder, buildOrder)) - return state.buildOrder; state.resolvedConfigFilePaths.clear(); - var currentProjects = ts.arrayToSet(buildOrder, function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); var noopOnDelete = { onDeleteValue: ts.noop }; ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete); @@ -79973,6 +82999,8 @@ var ts; function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -79980,6 +83008,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -80050,7 +83079,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -80374,6 +83403,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? state.currentInvalidatedProject : @@ -80426,8 +83457,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -80578,10 +83612,12 @@ var ts; refStatus.type === ts.UpToDateStatusType.ContainerOnly) { continue; } - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } if (refStatus.type !== ts.UpToDateStatusType.UpToDate) { @@ -80631,7 +83667,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -80771,33 +83807,34 @@ var ts; setupInitialBuild(state, cancellationToken); var reportQueue = true; var successfulProjects = 0; - var errorProjects = 0; while (true) { var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue); if (!invalidatedProject) break; reportQueue = false; invalidatedProject.done(cancellationToken); - if (state.diagnostics.has(invalidatedProject.projectPath)) { - errorProjects++; - } - else { + if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; - } } disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) + ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped + : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); }) + ? ts.ExitStatus.Success + : successfulProjects + ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated + : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -80933,8 +83970,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); watchConfigFile(state, resolved, resolvedPath); var cfg = parseConfigFile(state, resolved, resolvedPath); @@ -80963,6 +84000,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -80999,22 +84037,32 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -81043,7 +84091,9 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: @@ -81070,18 +84120,17 @@ var ts; }); return count; } - var reportDiagnostic = ts.createDiagnosticReporter(ts.sys); - function updateReportDiagnostic(options) { - if (shouldBePretty(options)) { - reportDiagnostic = ts.createDiagnosticReporter(ts.sys, /*pretty*/ true); - } + function updateReportDiagnostic(sys, existing, options) { + return shouldBePretty(sys, options) ? + ts.createDiagnosticReporter(sys, /*pretty*/ true) : + existing; } - function defaultIsPretty() { - return !!ts.sys.writeOutputIsTTY && ts.sys.writeOutputIsTTY(); + function defaultIsPretty(sys) { + return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY(); } - function shouldBePretty(options) { + function shouldBePretty(sys, options) { if (!options || typeof options.pretty === "undefined") { - return defaultIsPretty(); + return defaultIsPretty(sys); } return options.pretty; } @@ -81103,242 +84152,395 @@ var ts; ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) : ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; }); } - function executeCommandLine(args) { - if (args.length > 0 && args[0].charCodeAt(0) === 45 /* minus */) { - var firstOption = args[0].slice(args[0].charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); - if (firstOption === "build" || firstOption === "b") { - return performBuild(args.slice(1)); + function printVersion(sys) { + sys.write(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + sys.newLine); + } + function printHelp(sys, optionsList, syntaxPrefix) { + if (syntaxPrefix === void 0) { syntaxPrefix = ""; } + var output = []; + // We want to align our "syntax" and "examples" commands to a certain margin. + var syntaxLength = ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; + var examplesLength = ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; + var marginLength = Math.max(syntaxLength, examplesLength); + // Build up the syntactic skeleton. + var syntax = makePadding(marginLength - syntaxLength); + syntax += "tsc " + syntaxPrefix + "[" + ts.getDiagnosticText(ts.Diagnostics.options) + "] [" + ts.getDiagnosticText(ts.Diagnostics.file) + "...]"; + output.push(ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax)); + output.push(sys.newLine + sys.newLine); + // Build up the list of examples. + var padding = makePadding(marginLength); + output.push(ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine); + output.push(padding + "tsc --outFile file.js file.ts" + sys.newLine); + output.push(padding + "tsc @args.txt" + sys.newLine); + output.push(padding + "tsc --build tsconfig.json" + sys.newLine); + output.push(sys.newLine); + output.push(ts.getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine); + // We want our descriptions to align at the same column in our output, + // so we keep track of the longest option usage string. + marginLength = 0; + var usageColumn = []; // Things like "-d, --declaration" go in here. + var descriptionColumn = []; + var optionsDescriptionMap = ts.createMap(); // Map between option.description and list of option.type if it is a kind + for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) { + var option = optionsList_1[_i]; + // If an option lacks a description, + // it is not officially supported. + if (!option.description) { + continue; + } + var usageText_1 = " "; + if (option.shortName) { + usageText_1 += "-" + option.shortName; + usageText_1 += getParamType(option); + usageText_1 += ", "; + } + usageText_1 += "--" + option.name; + usageText_1 += getParamType(option); + usageColumn.push(usageText_1); + var description = void 0; + if (option.name === "lib") { + description = ts.getDiagnosticText(option.description); + var element = option.element; + var typeMap = element.type; + optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; })); + } + else { + description = ts.getDiagnosticText(option.description); } + descriptionColumn.push(description); + // Set the new margin for the description column if necessary. + marginLength = Math.max(usageText_1.length, marginLength); } - var commandLine = ts.parseCommandLine(args); + // Special case that can't fit in the loop. + var usageText = " @<" + ts.getDiagnosticText(ts.Diagnostics.file) + ">"; + usageColumn.push(usageText); + descriptionColumn.push(ts.getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); + marginLength = Math.max(usageText.length, marginLength); + // Print out each row, aligning all the descriptions on the same column. + for (var i = 0; i < usageColumn.length; i++) { + var usage = usageColumn[i]; + var description = descriptionColumn[i]; + var kindsList = optionsDescriptionMap.get(description); + output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine); + if (kindsList) { + output.push(makePadding(marginLength + 4)); + for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) { + var kind = kindsList_1[_a]; + output.push(kind + " "); + } + output.push(sys.newLine); + } + } + for (var _b = 0, output_1 = output; _b < output_1.length; _b++) { + var line = output_1[_b]; + sys.write(line); + } + return; + function getParamType(option) { + if (option.paramType !== undefined) { + return " " + ts.getDiagnosticText(option.paramType); + } + return ""; + } + function makePadding(paddingLength) { + return Array(paddingLength + 1).join(" "); + } + } + function executeCommandLineWorker(sys, cb, commandLine) { + var reportDiagnostic = ts.createDiagnosticReporter(sys); if (commandLine.options.build) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_build_must_be_the_first_command_line_argument)); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } // Configuration file name (if any) var configFileName; if (commandLine.options.locale) { - ts.validateLocaleAndSetLanguage(commandLine.options.locale, ts.sys, commandLine.errors); + ts.validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors); } // If there are any errors due to command line parsing and/or // setting up localization, report them and quit. if (commandLine.errors.length > 0) { commandLine.errors.forEach(reportDiagnostic); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (commandLine.options.init) { - writeConfigFile(commandLine.options, commandLine.fileNames); - return ts.sys.exit(ts.ExitStatus.Success); + writeConfigFile(sys, reportDiagnostic, commandLine.options, commandLine.fileNames); + return sys.exit(ts.ExitStatus.Success); } if (commandLine.options.version) { - ts.printVersion(); - return ts.sys.exit(ts.ExitStatus.Success); + printVersion(sys); + return sys.exit(ts.ExitStatus.Success); } if (commandLine.options.help || commandLine.options.all) { - ts.printVersion(); - ts.printHelp(getOptionsForHelp(commandLine)); - return ts.sys.exit(ts.ExitStatus.Success); + printVersion(sys); + printHelp(sys, getOptionsForHelp(commandLine)); + return sys.exit(ts.ExitStatus.Success); + } + if (commandLine.options.watch && commandLine.options.listFilesOnly) { + reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly")); + return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (commandLine.options.project) { if (commandLine.fileNames.length !== 0) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line)); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } var fileOrDirectory = ts.normalizePath(commandLine.options.project); - if (!fileOrDirectory /* current directory "." */ || ts.sys.directoryExists(fileOrDirectory)) { + if (!fileOrDirectory /* current directory "." */ || sys.directoryExists(fileOrDirectory)) { configFileName = ts.combinePaths(fileOrDirectory, "tsconfig.json"); - if (!ts.sys.fileExists(configFileName)) { + if (!sys.fileExists(configFileName)) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project)); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } } else { configFileName = fileOrDirectory; - if (!ts.sys.fileExists(configFileName)) { + if (!sys.fileExists(configFileName)) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project)); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } } } else if (commandLine.fileNames.length === 0) { - var searchPath = ts.normalizePath(ts.sys.getCurrentDirectory()); - configFileName = ts.findConfigFile(searchPath, ts.sys.fileExists); + var searchPath = ts.normalizePath(sys.getCurrentDirectory()); + configFileName = ts.findConfigFile(searchPath, sys.fileExists); } if (commandLine.fileNames.length === 0 && !configFileName) { - ts.printVersion(); - ts.printHelp(getOptionsForHelp(commandLine)); - return ts.sys.exit(ts.ExitStatus.Success); + printVersion(sys); + printHelp(sys, getOptionsForHelp(commandLine)); + return sys.exit(ts.ExitStatus.Success); } - var commandLineOptions = commandLine.options; + var currentDirectory = sys.getCurrentDirectory(); + var commandLineOptions = ts.convertToOptionsWithAbsolutePaths(commandLine.options, function (fileName) { return ts.getNormalizedAbsolutePath(fileName, currentDirectory); }); if (configFileName) { - var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, ts.sys, reportDiagnostic); // TODO: GH#18217 + var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, sys, reportDiagnostic); // TODO: GH#18217 if (commandLineOptions.showConfig) { if (configParseResult.errors.length !== 0) { - updateReportDiagnostic(configParseResult.options); + reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options); configParseResult.errors.forEach(reportDiagnostic); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } - // tslint:disable-next-line:no-null-keyword - ts.sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, ts.sys), null, 4) + ts.sys.newLine); - return ts.sys.exit(ts.ExitStatus.Success); + // eslint-disable-next-line no-null/no-null + sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine); + return sys.exit(ts.ExitStatus.Success); } - updateReportDiagnostic(configParseResult.options); + reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options); if (ts.isWatchSet(configParseResult.options)) { - reportWatchModeWithoutSysSupport(); - createWatchOfConfigFile(configParseResult, commandLineOptions); + if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic)) + return; + createWatchOfConfigFile(sys, reportDiagnostic, configParseResult, commandLineOptions); } else if (ts.isIncrementalCompilation(configParseResult.options)) { - performIncrementalCompilation(configParseResult); + performIncrementalCompilation(sys, reportDiagnostic, cb, configParseResult); } else { - performCompilation(configParseResult.fileNames, configParseResult.projectReferences, configParseResult.options, ts.getConfigFileParsingDiagnostics(configParseResult)); + performCompilation(sys, reportDiagnostic, cb, configParseResult); } } else { if (commandLineOptions.showConfig) { - // tslint:disable-next-line:no-null-keyword - ts.sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(ts.sys.getCurrentDirectory(), "tsconfig.json"), ts.sys), null, 4) + ts.sys.newLine); - return ts.sys.exit(ts.ExitStatus.Success); + // eslint-disable-next-line no-null/no-null + sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(currentDirectory, "tsconfig.json"), sys), null, 4) + sys.newLine); + return sys.exit(ts.ExitStatus.Success); } - updateReportDiagnostic(commandLineOptions); + reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, commandLineOptions); if (ts.isWatchSet(commandLineOptions)) { - reportWatchModeWithoutSysSupport(); - createWatchOfFilesAndCompilerOptions(commandLine.fileNames, commandLineOptions); + if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic)) + return; + createWatchOfFilesAndCompilerOptions(sys, reportDiagnostic, commandLine.fileNames, commandLineOptions); } else if (ts.isIncrementalCompilation(commandLineOptions)) { - performIncrementalCompilation(commandLine); + performIncrementalCompilation(sys, reportDiagnostic, cb, __assign(__assign({}, commandLine), { options: commandLineOptions })); } else { - performCompilation(commandLine.fileNames, /*references*/ undefined, commandLineOptions); + performCompilation(sys, reportDiagnostic, cb, __assign(__assign({}, commandLine), { options: commandLineOptions })); } } } + function isBuild(commandLineArgs) { + if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45 /* minus */) { + var firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 /* minus */ ? 2 : 1).toLowerCase(); + return firstOption === "build" || firstOption === "b"; + } + return false; + } + ts.isBuild = isBuild; + function executeCommandLine(system, cb, commandLineArgs) { + if (isBuild(commandLineArgs)) { + return performBuild(system, cb, commandLineArgs.slice(1)); + } + var commandLine = ts.parseCommandLine(commandLineArgs, function (path) { return system.readFile(path); }); + if (commandLine.options.generateCpuProfile && system.enableCPUProfiler) { + system.enableCPUProfiler(commandLine.options.generateCpuProfile, function () { return executeCommandLineWorker(system, cb, commandLine); }); + } + else { + executeCommandLineWorker(system, cb, commandLine); + } + } ts.executeCommandLine = executeCommandLine; - function reportWatchModeWithoutSysSupport() { - if (!ts.sys.watchFile || !ts.sys.watchDirectory) { + function reportWatchModeWithoutSysSupport(sys, reportDiagnostic) { + if (!sys.watchFile || !sys.watchDirectory) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch")); - ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return true; } + return false; } - function performBuild(args) { - var _a = ts.parseBuildCommand(args), buildOptions = _a.buildOptions, projects = _a.projects, errors = _a.errors; + function performBuildWorker(sys, cb, buildOptions, projects, errors) { // Update to pretty if host supports it - updateReportDiagnostic(buildOptions); + var reportDiagnostic = updateReportDiagnostic(sys, ts.createDiagnosticReporter(sys), buildOptions); if (buildOptions.locale) { - ts.validateLocaleAndSetLanguage(buildOptions.locale, ts.sys, errors); + ts.validateLocaleAndSetLanguage(buildOptions.locale, sys, errors); } if (errors.length > 0) { errors.forEach(reportDiagnostic); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (buildOptions.help) { - ts.printVersion(); - ts.printHelp(ts.buildOpts, "--build "); - return ts.sys.exit(ts.ExitStatus.Success); + printVersion(sys); + printHelp(sys, ts.buildOpts, "--build "); + return sys.exit(ts.ExitStatus.Success); } if (projects.length === 0) { - ts.printVersion(); - ts.printHelp(ts.buildOpts, "--build "); - return ts.sys.exit(ts.ExitStatus.Success); + printVersion(sys); + printHelp(sys, ts.buildOpts, "--build "); + return sys.exit(ts.ExitStatus.Success); } - if (!ts.sys.getModifiedTime || !ts.sys.setModifiedTime || (buildOptions.clean && !ts.sys.deleteFile)) { + if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--build")); - return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); + return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (buildOptions.watch) { - reportWatchModeWithoutSysSupport(); - var buildHost_1 = ts.createSolutionBuilderWithWatchHost(ts.sys, /*createProgram*/ undefined, reportDiagnostic, ts.createBuilderStatusReporter(ts.sys, shouldBePretty(buildOptions)), createWatchStatusReporter(buildOptions)); - updateCreateProgram(buildHost_1); - buildHost_1.afterProgramEmitAndDiagnostics = function (program) { return reportStatistics(program.getProgram()); }; + if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic)) + return; + var buildHost_1 = ts.createSolutionBuilderWithWatchHost(sys, + /*createProgram*/ undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createWatchStatusReporter(sys, buildOptions)); + if (cb && cb.onSolutionBuilderHostCreate) + cb.onSolutionBuilderHostCreate(buildHost_1); + updateCreateProgram(sys, buildHost_1); + buildHost_1.afterProgramEmitAndDiagnostics = function (program) { return reportStatistics(sys, program.getProgram()); }; var builder_1 = ts.createSolutionBuilderWithWatch(buildHost_1, projects, buildOptions); builder_1.build(); return; } - var buildHost = ts.createSolutionBuilderHost(ts.sys, /*createProgram*/ undefined, reportDiagnostic, ts.createBuilderStatusReporter(ts.sys, shouldBePretty(buildOptions)), createReportErrorSummary(buildOptions)); - updateCreateProgram(buildHost); - buildHost.afterProgramEmitAndDiagnostics = function (program) { return reportStatistics(program.getProgram()); }; + var buildHost = ts.createSolutionBuilderHost(sys, + /*createProgram*/ undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createReportErrorSummary(sys, buildOptions)); + if (cb && cb.onSolutionBuilderHostCreate) + cb.onSolutionBuilderHostCreate(buildHost); + updateCreateProgram(sys, buildHost); + buildHost.afterProgramEmitAndDiagnostics = function (program) { return reportStatistics(sys, program.getProgram()); }; var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions); - return ts.sys.exit(buildOptions.clean ? builder.clean() : builder.build()); + var exitStatus = buildOptions.clean ? builder.clean() : builder.build(); + if (cb && cb.onSolutionBuildComplete) + cb.onSolutionBuildComplete(builder.getAllParsedConfigs()); + return sys.exit(exitStatus); + } + function performBuild(sys, cb, args) { + var _a = ts.parseBuildCommand(args), buildOptions = _a.buildOptions, projects = _a.projects, errors = _a.errors; + if (buildOptions.generateCpuProfile && sys.enableCPUProfiler) { + sys.enableCPUProfiler(buildOptions.generateCpuProfile, function () { return performBuildWorker(sys, cb, buildOptions, projects, errors); }); + } + else { + performBuildWorker(sys, cb, buildOptions, projects, errors); + } } - function createReportErrorSummary(options) { - return shouldBePretty(options) ? - function (errorCount) { return ts.sys.write(ts.getErrorSummaryText(errorCount, ts.sys.newLine)); } : + function createReportErrorSummary(sys, options) { + return shouldBePretty(sys, options) ? + function (errorCount) { return sys.write(ts.getErrorSummaryText(errorCount, sys.newLine)); } : undefined; } - function performCompilation(rootNames, projectReferences, options, configFileParsingDiagnostics) { - var host = ts.createCompilerHost(options); + function performCompilation(sys, reportDiagnostic, cb, config) { + var fileNames = config.fileNames, options = config.options, projectReferences = config.projectReferences; + var host = ts.createCompilerHostWorker(options, /*setParentPos*/ undefined, sys); + if (cb && cb.onCompilerHostCreate) + cb.onCompilerHostCreate(host); var currentDirectory = host.getCurrentDirectory(); var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); }); - enableStatistics(options); + enableStatistics(sys, options); var programOptions = { - rootNames: rootNames, + rootNames: fileNames, options: options, projectReferences: projectReferences, host: host, - configFileParsingDiagnostics: configFileParsingDiagnostics + configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config) }; var program = ts.createProgram(programOptions); - var exitStatus = ts.emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, function (s) { return ts.sys.write(s + ts.sys.newLine); }, createReportErrorSummary(options)); - reportStatistics(program); - return ts.sys.exit(exitStatus); + var exitStatus = ts.emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, function (s) { return sys.write(s + sys.newLine); }, createReportErrorSummary(sys, options)); + reportStatistics(sys, program); + if (cb && cb.onCompilationComplete) + cb.onCompilationComplete(config); + return sys.exit(exitStatus); } - function performIncrementalCompilation(config) { + function performIncrementalCompilation(sys, reportDiagnostic, cb, config) { var options = config.options, fileNames = config.fileNames, projectReferences = config.projectReferences; - enableStatistics(options); - return ts.sys.exit(ts.performIncrementalCompilation({ + enableStatistics(sys, options); + var host = ts.createIncrementalCompilerHost(options, sys); + if (cb && cb.onCompilerHostCreate) + cb.onCompilerHostCreate(host); + var exitStatus = ts.performIncrementalCompilation({ + host: host, + system: sys, rootNames: fileNames, options: options, configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config), projectReferences: projectReferences, reportDiagnostic: reportDiagnostic, - reportErrorSummary: createReportErrorSummary(options), - afterProgramEmitAndDiagnostics: function (builderProgram) { return reportStatistics(builderProgram.getProgram()); } - })); + reportErrorSummary: createReportErrorSummary(sys, options), + afterProgramEmitAndDiagnostics: function (builderProgram) { return reportStatistics(sys, builderProgram.getProgram()); } + }); + if (cb && cb.onCompilationComplete) + cb.onCompilationComplete(config); + return sys.exit(exitStatus); } - function updateCreateProgram(host) { + function updateCreateProgram(sys, host) { var compileUsingBuilder = host.createProgram; host.createProgram = function (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) { ts.Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram)); if (options !== undefined) { - enableStatistics(options); + enableStatistics(sys, options); } return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences); }; } - function updateWatchCompilationHost(watchCompilerHost) { - updateCreateProgram(watchCompilerHost); + function updateWatchCompilationHost(sys, watchCompilerHost) { + updateCreateProgram(sys, watchCompilerHost); var emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate; // TODO: GH#18217 watchCompilerHost.afterProgramCreate = function (builderProgram) { emitFilesUsingBuilder(builderProgram); - reportStatistics(builderProgram.getProgram()); + reportStatistics(sys, builderProgram.getProgram()); }; } - function createWatchStatusReporter(options) { - return ts.createWatchStatusReporter(ts.sys, shouldBePretty(options)); + function createWatchStatusReporter(sys, options) { + return ts.createWatchStatusReporter(sys, shouldBePretty(sys, options)); } - function createWatchOfConfigFile(configParseResult, optionsToExtend) { - var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile(configParseResult.options.configFilePath, optionsToExtend, ts.sys, /*createProgram*/ undefined, reportDiagnostic, createWatchStatusReporter(configParseResult.options)); // TODO: GH#18217 - updateWatchCompilationHost(watchCompilerHost); + function createWatchOfConfigFile(sys, reportDiagnostic, configParseResult, optionsToExtend) { + var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile(configParseResult.options.configFilePath, optionsToExtend, sys, + /*createProgram*/ undefined, reportDiagnostic, createWatchStatusReporter(sys, configParseResult.options)); // TODO: GH#18217 + updateWatchCompilationHost(sys, watchCompilerHost); watchCompilerHost.configFileParsingResult = configParseResult; ts.createWatchProgram(watchCompilerHost); } - function createWatchOfFilesAndCompilerOptions(rootFiles, options) { - var watchCompilerHost = ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFiles, options, ts.sys, /*createProgram*/ undefined, reportDiagnostic, createWatchStatusReporter(options)); - updateWatchCompilationHost(watchCompilerHost); + function createWatchOfFilesAndCompilerOptions(sys, reportDiagnostic, rootFiles, options) { + var watchCompilerHost = ts.createWatchCompilerHostOfFilesAndCompilerOptions(rootFiles, options, sys, + /*createProgram*/ undefined, reportDiagnostic, createWatchStatusReporter(sys, options)); + updateWatchCompilationHost(sys, watchCompilerHost); ts.createWatchProgram(watchCompilerHost); } - function enableStatistics(compilerOptions) { - if (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics) { + function canReportDiagnostics(system, compilerOptions) { + return system === ts.sys && (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics); + } + function enableStatistics(sys, compilerOptions) { + if (canReportDiagnostics(sys, compilerOptions)) { ts.performance.enable(); } } - function reportStatistics(program) { + function reportStatistics(sys, program) { var statistics; var compilerOptions = program.getCompilerOptions(); - if (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics) { + if (canReportDiagnostics(sys, compilerOptions)) { statistics = []; - var memoryUsed = ts.sys.getMemoryUsage ? ts.sys.getMemoryUsage() : -1; + var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1; reportCountStatistic("Files", program.getSourceFiles().length); reportCountStatistic("Lines", countLines(program)); reportCountStatistic("Nodes", program.getNodeCount()); @@ -81389,7 +84591,7 @@ var ts; } for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) { var _c = statistics_2[_b], name = _c.name, value = _c.value; - ts.sys.write(padRight(name + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + ts.sys.newLine); + sys.write(padRight(name + ":", nameSize + 2) + padLeft(value.toString(), valueSize) + sys.newLine); } } function reportStatisticalValue(name, value) { @@ -81402,14 +84604,14 @@ var ts; reportStatisticalValue(name, (time / 1000).toFixed(2) + "s"); } } - function writeConfigFile(options, fileNames) { - var currentDirectory = ts.sys.getCurrentDirectory(); + function writeConfigFile(sys, reportDiagnostic, options, fileNames) { + var currentDirectory = sys.getCurrentDirectory(); var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json")); - if (ts.sys.fileExists(file)) { + if (sys.fileExists(file)) { reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file)); } else { - ts.sys.writeFile(file, ts.generateTSConfig(options, fileNames, ts.sys.newLine)); + sys.writeFile(file, ts.generateTSConfig(options, fileNames, sys.newLine)); reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file)); } return; @@ -81424,4 +84626,10 @@ if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnviron if (ts.sys.setBlocking) { ts.sys.setBlocking(); } -ts.executeCommandLine(ts.sys.args); +// This file actually uses arguments passed on commandline and executes it +ts.executeCommandLine(ts.sys, { + onCompilerHostCreate: ts.noop, + onCompilationComplete: ts.noop, + onSolutionBuilderHostCreate: ts.noop, + onSolutionBuildComplete: ts.noop +}, ts.sys.args); diff --git a/node_modules/typescript/lib/tsserver.js b/node_modules/typescript/lib/tsserver.js index be5166a94..0dcbf6ac9 100644 --- a/node_modules/typescript/lib/tsserver.js +++ b/node_modules/typescript/lib/tsserver.js @@ -92,9 +92,9 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".2"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -107,22 +107,32 @@ var ts; })(ts || (ts = {})); /* @internal */ (function (ts) { - ts.emptyArray = []; - /** Create a MapLike with good performance. */ - function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map.__ = undefined; - delete map.__; - return map; + /** + * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). + */ + function tryGetNativeMap() { + // Internet Explorer's Map doesn't support iteration, so don't use it. + // eslint-disable-next-line no-in-operator + return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined; } - /** Create a new map. If a template object is provided, the map will copy entries from it. */ + ts.tryGetNativeMap = tryGetNativeMap; +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + ts.emptyArray = []; + ts.Map = ts.tryGetNativeMap() || (function () { + // NOTE: createMapShim will be defined for typescriptServices.js but not for tsc.js, so we must test for it. + if (typeof ts.createMapShim === "function") { + return ts.createMapShim(); + } + throw new Error("TypeScript requires an environment that provides a compatible native Map implementation."); + })(); + /** Create a new map. */ function createMap() { - return new ts.MapCtr(); + return new ts.Map(); } ts.createMap = createMap; + /** Create a new map from an array of entries. */ function createMapFromEntries(entries) { var map = createMap(); for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { @@ -132,8 +142,9 @@ var ts; return map; } ts.createMapFromEntries = createMapFromEntries; + /** Create a new map from a template object is provided, the map will copy entries from it. */ function createMapFromTemplate(template) { - var map = new ts.MapCtr(); + var map = new ts.Map(); // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. for (var key in template) { @@ -144,147 +155,6 @@ var ts; return map; } ts.createMapFromTemplate = createMapFromTemplate; - // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name - ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); - // Keep the class inside a function so it doesn't get compiled if it's not used. - function shimMap() { - var MapIterator = /** @class */ (function () { - function MapIterator(currentEntry, selector) { - this.currentEntry = currentEntry; - this.selector = selector; - } - MapIterator.prototype.next = function () { - // Navigate to the next entry. - while (this.currentEntry) { - var skipNext = !!this.currentEntry.skipNext; - this.currentEntry = this.currentEntry.nextEntry; - if (!skipNext) { - break; - } - } - if (this.currentEntry) { - return { value: this.selector(this.currentEntry.key, this.currentEntry.value), done: false }; - } - else { - return { value: undefined, done: true }; - } - }; - return MapIterator; - }()); - return /** @class */ (function () { - function class_1() { - this.data = createDictionaryObject(); - this.size = 0; - // Create a first (stub) map entry that will not contain a key - // and value but serves as starting point for iterators. - this.firstEntry = {}; - // When the map is empty, the last entry is the same as the - // first one. - this.lastEntry = this.firstEntry; - } - class_1.prototype.get = function (key) { - var entry = this.data[key]; - return entry && entry.value; - }; - class_1.prototype.set = function (key, value) { - if (!this.has(key)) { - this.size++; - // Create a new entry that will be appended at the - // end of the linked list. - var newEntry = { - key: key, - value: value - }; - this.data[key] = newEntry; - // Adjust the references. - var previousLastEntry = this.lastEntry; - previousLastEntry.nextEntry = newEntry; - newEntry.previousEntry = previousLastEntry; - this.lastEntry = newEntry; - } - else { - this.data[key].value = value; - } - return this; - }; - class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator - return key in this.data; - }; - class_1.prototype.delete = function (key) { - if (this.has(key)) { - this.size--; - var entry = this.data[key]; - delete this.data[key]; - // Adjust the linked list references of the neighbor entries. - var previousEntry = entry.previousEntry; - previousEntry.nextEntry = entry.nextEntry; - if (entry.nextEntry) { - entry.nextEntry.previousEntry = previousEntry; - } - // When the deleted entry was the last one, we need to - // adjust the lastEntry reference. - if (this.lastEntry === entry) { - this.lastEntry = previousEntry; - } - // Adjust the forward reference of the deleted entry - // in case an iterator still references it. This allows us - // to throw away the entry, but when an active iterator - // (which points to the current entry) continues, it will - // navigate to the entry that originally came before the - // current one and skip it. - entry.previousEntry = undefined; - entry.nextEntry = previousEntry; - entry.skipNext = true; - return true; - } - return false; - }; - class_1.prototype.clear = function () { - this.data = createDictionaryObject(); - this.size = 0; - // Reset the linked list. Note that we must adjust the forward - // references of the deleted entries to ensure iterators stuck - // in the middle of the list don't continue with deleted entries, - // but can continue with new entries added after the clear() - // operation. - var firstEntry = this.firstEntry; - var currentEntry = firstEntry.nextEntry; - while (currentEntry) { - var nextEntry = currentEntry.nextEntry; - currentEntry.previousEntry = undefined; - currentEntry.nextEntry = firstEntry; - currentEntry.skipNext = true; - currentEntry = nextEntry; - } - firstEntry.nextEntry = undefined; - this.lastEntry = firstEntry; - }; - class_1.prototype.keys = function () { - return new MapIterator(this.firstEntry, function (key) { return key; }); - }; - class_1.prototype.values = function () { - return new MapIterator(this.firstEntry, function (_key, value) { return value; }); - }; - class_1.prototype.entries = function () { - return new MapIterator(this.firstEntry, function (key, value) { return [key, value]; }); - }; - class_1.prototype.forEach = function (action) { - var iterator = this.entries(); - while (true) { - var iterResult = iterator.next(); - if (iterResult.done) { - break; - } - var _a = iterResult.value, key = _a[0], value = _a[1]; - action(value, key); - } - }; - return class_1; - }()); - } - ts.shimMap = shimMap; function length(array) { return array ? array.length : 0; } @@ -306,6 +176,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -859,6 +744,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1399,6 +1285,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1458,7 +1350,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1492,7 +1384,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1844,20 +1736,6 @@ var ts; return str.indexOf(substring) !== -1; } ts.stringContains = stringContains; - function fileExtensionIs(path, extension) { - return path.length > extension.length && endsWith(path, extension); - } - ts.fileExtensionIs = fileExtensionIs; - function fileExtensionIsOneOf(path, extensions) { - for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { - var extension = extensions_1[_i]; - if (fileExtensionIs(path, extension)) { - return true; - } - } - return false; - } - ts.fileExtensionIsOneOf = fileExtensionIsOneOf; /** * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ @@ -1966,11 +1844,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2047,8 +1947,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2097,6 +1999,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2112,7 +2015,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2220,6 +2123,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2230,6 +2136,33 @@ var ts; ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); } : ts.noop; var isDebugInfoEnabled = false; + var extendedDebugModule; + function extendedDebug() { + enableDebugInfo(); + if (!extendedDebugModule) { + throw new Error("Debugging helpers could not be loaded."); + } + return extendedDebugModule; + } + function printControlFlowGraph(flowNode) { + return console.log(formatControlFlowGraph(flowNode)); + } + Debug.printControlFlowGraph = printControlFlowGraph; + function formatControlFlowGraph(flowNode) { + return extendedDebug().formatControlFlowGraph(flowNode); + } + Debug.formatControlFlowGraph = formatControlFlowGraph; + function attachFlowNodeDebugInfo(flowNode) { + if (isDebugInfoEnabled) { + if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line no-in-operator + Object.defineProperties(flowNode, { + __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, + __debugToString: { value: function () { return formatControlFlowGraph(this); } } + }); + } + } + } + Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo; /** * Injects debug information into frequently used types. */ @@ -2273,6 +2206,20 @@ var ts; }); } } + // attempt to load extended debugging information + try { + if (ts.sys && ts.sys.require) { + var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath())); + var result = ts.sys.require(basePath, "./compiler-debug"); + if (!result.error) { + result.module.init(ts); + extendedDebugModule = result.module; + } + } + } + catch (_a) { + // do nothing + } isDebugInfoEnabled = true; } Debug.enableDebugInfo = enableDebugInfo; @@ -2429,15 +2376,13 @@ var ts; try { // require() will throw an exception if the module is not installed // It may also return undefined if not installed properly - etwModule = require("@microsoft/typescript-etw"); // tslint:disable-line:no-implicit-dependencies + etwModule = require("@microsoft/typescript-etw"); } catch (e) { etwModule = undefined; } /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; - var args = typeof process === "undefined" ? [] : process.argv; - ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); })(ts || (ts = {})); /* @internal */ var ts; @@ -2839,360 +2784,366 @@ var ts; SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 297] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 298] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 299] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 300] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 301] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 302] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 303] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 304] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 305] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 306] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 307] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 308] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 309] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 310] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 311] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 312] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 313] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 314] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 315] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 316] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 317] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 318] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 319] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 320] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 313] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 301] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 313] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3202,20 +3153,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3225,23 +3177,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3280,7 +3232,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3322,6 +3277,7 @@ var ts; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; })(TokenFlags = ts.TokenFlags || (ts.TokenFlags = {})); + // NOTE: Ensure this is up-to-date with src/debug/debug.ts var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; @@ -3333,12 +3289,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3348,6 +3305,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3368,6 +3332,10 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped"; + /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3376,6 +3344,14 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + /* @internal */ + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + ContextFlags[ContextFlags["Completion"] = 4] = "Completion"; + })(ContextFlags = ts.ContextFlags || (ts.ContextFlags = {})); // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { @@ -3433,7 +3409,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3483,27 +3458,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3574,11 +3562,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3801,6 +3793,18 @@ var ts; SignatureKind[SignatureKind["Call"] = 0] = "Call"; SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + /* @internal */ + var SignatureFlags; + (function (SignatureFlags) { + SignatureFlags[SignatureFlags["None"] = 0] = "None"; + SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter"; + SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes"; + SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall"; + // We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us + // attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when + // instantiating the return type. + SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags"; + })(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {})); var IndexKind; (function (IndexKind) { IndexKind[IndexKind["String"] = 0] = "String"; @@ -4696,7 +4700,7 @@ var ts; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; /*@internal*/ - ts.sysLog = ts.noop; + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4801,6 +4805,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4817,12 +4847,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4834,6 +4866,8 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; @@ -4915,8 +4949,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4940,8 +4976,101 @@ var ts; bufferFrom: bufferFrom, base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); }, base64encode: function (input) { return bufferFrom(input).toString("base64"); }, + require: function (baseDir, moduleName) { + try { + var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem); + return { module: require(modulePath), modulePath: modulePath, error: undefined }; + } + catch (error) { + return { module: undefined, modulePath: undefined, error: error }; + } + } }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4994,6 +5123,7 @@ var ts; if (fsSupportsRecursive) { return watchDirectoryUsingFsWatch; } + // defer watchDirectoryRecursively as it depends on `ts.createMap()` which may not be usable yet. var watchDirectory = tscWatchDirectory === "RecursiveDirectoryUsingFsWatchFile" ? createWatchDirectoryUsing(fsWatchFile) : tscWatchDirectory === "RecursiveDirectoryUsingDynamicPriorityPolling" ? @@ -5413,16 +5543,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5434,14 +5554,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5455,371 +5568,1045 @@ var ts; ts.Debug.isDebugging = true; } })(ts || (ts = {})); -// -// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + /** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + */ + ts.directorySeparator = "/"; + var altDirectorySeparator = "\\"; + var urlSchemeSeparator = "://"; + var backslashRegExp = /\\/g; + //// Path Tests + /** + * Determines whether a charCode corresponds to `/` or `\`. + */ + function isAnyDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; } - // tslint:disable-next-line variable-name - ts.Diagnostics = { - Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), - Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), - _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), - A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), - Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), - An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), - Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), - A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), - A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), - Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), - A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), - An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), - An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), - An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), - An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), - An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), - An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), - An_index_signature_parameter_type_must_be_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_or_number_1023", "An index signature parameter type must be 'string' or 'number'."), - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), - Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), - _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), - _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), - _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), - super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), - Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), - Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), - Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), - _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), - _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), - _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), - _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), - _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), - A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), - Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), - A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), - A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), - A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), - A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), - A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), - A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), - A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), - An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), - The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), - A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), - The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), - Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), - Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), - An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), - Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), - _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), - _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), - A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), - Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), - _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), - Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), - Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), - An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), - A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), - An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), - _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), - Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), - Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), - Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), - with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), - delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), - Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), - A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), - Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), - Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), - Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), - An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), - Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), - Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), - Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), - Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), - Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), - Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), - Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), - case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), - Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), - Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), - Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), - Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), - Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), - Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), - Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), - Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), - Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), - String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), - Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), - or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), - Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), - Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), - File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), - const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), - const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), - let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), - Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), - Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), - An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), - A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), - Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), - A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), - extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), - extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), - Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), - implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), - Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), - Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), - Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), - Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), - Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), - Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), - A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), - An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), - Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), - Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), - A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), - A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), - An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), - Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), - An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), - Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), - Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), - Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), - Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), - Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), - Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), - Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), - All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), - A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), - Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), - Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), - Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), - An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), - _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), - Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), - Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), - Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), - Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), - A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), - An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), - An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), - _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), - Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), - An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), - A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), - A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), - A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), - A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), - A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), - Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), - Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), - Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), - with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), - await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), - The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), - Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), - Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), - Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), - A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), - An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), - A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), - Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), - Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), - Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323", "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'."), - Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), - Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), - String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), - Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), - _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), - A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), - A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), - A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), - unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), - unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), - unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), - An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), - An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), - infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), - Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), - Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), - A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), - An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), - This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), - use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), - Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), - use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), - Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), - An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), - A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), - A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), - readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), - A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), - Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), - Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), - Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), - Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), - Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), - Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), - File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), - Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), - Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), - A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), - An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), - Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), - Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), - Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), - Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), - Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), - Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), - Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), - Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), - Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), - Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), - Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), - Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), - Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), - Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), - Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), - Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), - Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), - Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), - this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), - this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), - this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), - this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), - super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), - super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: diag(2338, ts.DiagnosticCategory.Error, "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class."), - Property_0_does_not_exist_on_type_1: diag(2339, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."), - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), - Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), - Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), - Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), - Untyped_function_calls_may_not_accept_type_arguments: diag(2347, ts.DiagnosticCategory.Error, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."), - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, ts.DiagnosticCategory.Error, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"), - This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."), - Only_a_void_function_can_be_called_with_the_new_keyword: diag(2350, ts.DiagnosticCategory.Error, "Only_a_void_function_can_be_called_with_the_new_keyword_2350", "Only a void function can be called with the 'new' keyword."), - This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."), - Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, ts.DiagnosticCategory.Error, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."), - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), - This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), - An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), - Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), - Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), - This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), - Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), - A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), - A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."), - Parameter_0_cannot_be_referenced_in_its_initializer: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_be_referenced_in_its_initializer_2372", "Parameter '{0}' cannot be referenced in its initializer."), - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it."), - Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."), - Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."), - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties."), - Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), - A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), - A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), - Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), - Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."), - Overload_signatures_must_all_be_public_private_or_protected: diag(2385, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."), - Overload_signatures_must_all_be_optional_or_required: diag(2386, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_optional_or_required_2386", "Overload signatures must all be optional or required."), - Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."), - Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."), - Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."), - Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."), - Function_implementation_is_missing_or_not_immediately_following_the_declaration: diag(2391, ts.DiagnosticCategory.Error, "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", "Function implementation is missing or not immediately following the declaration."), - Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."), - Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."), - This_overload_signature_is_not_compatible_with_its_implementation_signature: diag(2394, ts.DiagnosticCategory.Error, "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394", "This overload signature is not compatible with its implementation signature."), + ts.isAnyDirectorySeparator = isAnyDirectorySeparator; + /** + * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.). + */ + function isUrl(path) { + return getEncodedRootLength(path) < 0; + } + ts.isUrl = isUrl; + /** + * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path + * like `c:`, `c:\` or `c:/`). + */ + function isRootedDiskPath(path) { + return getEncodedRootLength(path) > 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + /** + * Determines whether a path consists only of a path root. + */ + function isDiskPathRoot(path) { + var rootLength = getEncodedRootLength(path); + return rootLength > 0 && rootLength === path.length; + } + ts.isDiskPathRoot = isDiskPathRoot; + /** + * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.). + * + * ```ts + * // POSIX + * pathIsAbsolute("/path/to/file.ext") === true + * // DOS + * pathIsAbsolute("c:/path/to/file.ext") === true + * // URL + * pathIsAbsolute("file:///path/to/file.ext") === true + * // Non-absolute + * pathIsAbsolute("path/to/file.ext") === false + * pathIsAbsolute("./path/to/file.ext") === false + * ``` + */ + function pathIsAbsolute(path) { + return getEncodedRootLength(path) !== 0; + } + ts.pathIsAbsolute = pathIsAbsolute; + /** + * Determines whether a path starts with a relative path component (i.e. `.` or `..`). + */ + function pathIsRelative(path) { + return /^\.\.?($|[\\/])/.test(path); + } + ts.pathIsRelative = pathIsRelative; + function hasExtension(fileName) { + return ts.stringContains(getBaseFileName(fileName), "."); + } + ts.hasExtension = hasExtension; + function fileExtensionIs(path, extension) { + return path.length > extension.length && ts.endsWith(path, extension); + } + ts.fileExtensionIs = fileExtensionIs; + function fileExtensionIsOneOf(path, extensions) { + for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { + var extension = extensions_1[_i]; + if (fileExtensionIs(path, extension)) { + return true; + } + } + return false; + } + ts.fileExtensionIsOneOf = fileExtensionIsOneOf; + /** + * Determines whether a path has a trailing separator (`/` or `\\`). + */ + function hasTrailingDirectorySeparator(path) { + return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); + } + ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; + //// Path Parsing + function isVolumeCharacter(charCode) { + return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || + (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + } + function getFileUrlVolumeSeparatorEnd(url, start) { + var ch0 = url.charCodeAt(start); + if (ch0 === 58 /* colon */) + return start + 1; + if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + var ch2 = url.charCodeAt(start + 2); + if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + return start + 3; + } + return -1; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * If the root is part of a URL, the twos-complement of the root length is returned. + */ + function getEncodedRootLength(path) { + if (!path) + return 0; + var ch0 = path.charCodeAt(0); + // POSIX or UNC + if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (path.charCodeAt(1) !== ch0) + return 1; // POSIX: "/" (or non-normalized "\") + var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); + if (p1 < 0) + return path.length; // UNC: "//server" or "\\server" + return p1 + 1; // UNC: "//server/" or "\\server\" + } + // DOS + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + var ch2 = path.charCodeAt(2); + if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + return 3; // DOS: "c:/" or "c:\" + if (path.length === 2) + return 2; // DOS: "c:" (but not "c:d") + } + // URL + var schemeEnd = path.indexOf(urlSchemeSeparator); + if (schemeEnd !== -1) { + var authorityStart = schemeEnd + urlSchemeSeparator.length; + var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); + if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" + // For local "file" URLs, include the leading DOS volume (if present). + // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a + // special case interpreted as "the machine from which the URL is being interpreted". + var scheme = path.slice(0, schemeEnd); + var authority = path.slice(authorityStart, authorityEnd); + if (scheme === "file" && (authority === "" || authority === "localhost") && + isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { + var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); + if (volumeSeparatorEnd !== -1) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" + return ~(volumeSeparatorEnd + 1); + } + if (volumeSeparatorEnd === path.length) { + // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" + // but not "file:///c:d" or "file:///c%3ad" + return ~volumeSeparatorEnd; + } + } + } + return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" + } + return ~path.length; // URL: "file://server", "http://server" + } + // relative + return 0; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * + * For example: + * ```ts + * getRootLength("a") === 0 // "" + * getRootLength("/") === 1 // "/" + * getRootLength("c:") === 2 // "c:" + * getRootLength("c:d") === 0 // "" + * getRootLength("c:/") === 3 // "c:/" + * getRootLength("c:\\") === 3 // "c:\\" + * getRootLength("//server") === 7 // "//server" + * getRootLength("//server/share") === 8 // "//server/" + * getRootLength("\\\\server") === 7 // "\\\\server" + * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" + * getRootLength("file:///path") === 8 // "file:///" + * getRootLength("file:///c:") === 10 // "file:///c:" + * getRootLength("file:///c:d") === 8 // "file:///" + * getRootLength("file:///c:/path") === 11 // "file:///c:/" + * getRootLength("file://server") === 13 // "file://server" + * getRootLength("file://server/path") === 14 // "file://server/" + * getRootLength("http://server") === 13 // "http://server" + * getRootLength("http://server/path") === 14 // "http://server/" + * ``` + */ + function getRootLength(path) { + var rootLength = getEncodedRootLength(path); + return rootLength < 0 ? ~rootLength : rootLength; + } + ts.getRootLength = getRootLength; + function getDirectoryPath(path) { + path = normalizeSlashes(path); + // If the path provided is itself the root, then return it. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return path; + // return the leading portion of the path up to the last (non-terminal) directory separator + // but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function getBaseFileName(path, extensions, ignoreCase) { + path = normalizeSlashes(path); + // if the path provided is itself the root, then it has not file name. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return ""; + // return the trailing portion of the path starting after the last (non-terminal) directory + // separator but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); + var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; + return extension ? name.slice(0, name.length - extension.length) : name; + } + ts.getBaseFileName = getBaseFileName; + function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { + if (!ts.startsWith(extension, ".")) + extension = "." + extension; + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + var pathExtension = path.slice(path.length - extension.length); + if (stringEqualityComparer(pathExtension, extension)) { + return pathExtension; + } + } + } + function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { + if (typeof extensions === "string") { + return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || ""; + } + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer); + if (result) + return result; + } + return ""; + } + function getAnyExtensionFromPath(path, extensions, ignoreCase) { + // Retrieves any string from the final "." onwards from a base file name. + // Unlike extensionFromPath, which throws an exception on unrecognized extensions. + if (extensions) { + return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); + } + var baseFileName = getBaseFileName(path); + var extensionIndex = baseFileName.lastIndexOf("."); + if (extensionIndex >= 0) { + return baseFileName.substring(extensionIndex); + } + return ""; + } + ts.getAnyExtensionFromPath = getAnyExtensionFromPath; + function pathComponents(path, rootLength) { + var root = path.substring(0, rootLength); + var rest = path.substring(rootLength).split(ts.directorySeparator); + if (rest.length && !ts.lastOrUndefined(rest)) + rest.pop(); + return __spreadArrays([root], rest); + } + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is not normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * // POSIX + * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"] + * getPathComponents("/path/to/") === ["/", "path", "to"] + * getPathComponents("/") === ["/"] + * // DOS + * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"] + * getPathComponents("c:/path/to/") === ["c:/", "path", "to"] + * getPathComponents("c:/") === ["c:/"] + * getPathComponents("c:") === ["c:"] + * // URL + * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"] + * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"] + * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"] + * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"] + * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"] + * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"] + * getPathComponents("file://server/") === ["file://server/"] + * getPathComponents("file://server") === ["file://server"] + * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"] + * getPathComponents("file:///path/to/") === ["file:///", "path", "to"] + * getPathComponents("file:///") === ["file:///"] + * getPathComponents("file://") === ["file://"] + */ + function getPathComponents(path, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } + path = combinePaths(currentDirectory, path); + return pathComponents(path, getRootLength(path)); + } + ts.getPathComponents = getPathComponents; + //// Path Formatting + /** + * Formats a parsed path consisting of a root component (at index 0) and zero or more path + * segments (at indices > 0). + * + * ```ts + * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext" + * ``` + */ + function getPathFromPathComponents(pathComponents) { + if (pathComponents.length === 0) + return ""; + var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]); + return root + pathComponents.slice(1).join(ts.directorySeparator); + } + ts.getPathFromPathComponents = getPathFromPathComponents; + //// Path Normalization + /** + * Normalize path separators, converting `\` into `/`. + */ + function normalizeSlashes(path) { + return path.replace(backslashRegExp, ts.directorySeparator); + } + ts.normalizeSlashes = normalizeSlashes; + /** + * Reduce an array of path components to a more simplified path by navigating any + * `"."` or `".."` entries in the path. + */ + function reducePathComponents(components) { + if (!ts.some(components)) + return []; + var reduced = [components[0]]; + for (var i = 1; i < components.length; i++) { + var component = components[i]; + if (!component) + continue; + if (component === ".") + continue; + if (component === "..") { + if (reduced.length > 1) { + if (reduced[reduced.length - 1] !== "..") { + reduced.pop(); + continue; + } + } + else if (reduced[0]) + continue; + } + reduced.push(component); + } + return reduced; + } + ts.reducePathComponents = reducePathComponents; + /** + * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. + * + * ```ts + * // Non-rooted + * combinePaths("path", "to", "file.ext") === "path/to/file.ext" + * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext" + * // POSIX + * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext" + * combinePaths("/path", "/to", "file.ext") === "/to/file.ext" + * // DOS + * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext" + * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext" + * // URL + * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext" + * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext" + * ``` + */ + function combinePaths(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + if (path) + path = normalizeSlashes(path); + for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { + var relativePath = paths_1[_a]; + if (!relativePath) + continue; + relativePath = normalizeSlashes(relativePath); + if (!path || getRootLength(relativePath) !== 0) { + path = relativePath; + } + else { + path = ensureTrailingDirectorySeparator(path) + relativePath; + } + } + return path; + } + ts.combinePaths = combinePaths; + /** + * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any + * `.` and `..` path components are resolved. Trailing directory separators are preserved. + * + * ```ts + * resolvePath("/path", "to", "file.ext") === "path/to/file.ext" + * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/" + * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext" + * ``` + */ + function resolvePath(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path)); + } + ts.resolvePath = resolvePath; + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"] + */ + function getNormalizedPathComponents(path, currentDirectory) { + return reducePathComponents(getPathComponents(path, currentDirectory)); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function normalizePath(path) { + path = normalizeSlashes(path); + var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); + return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; + } + ts.normalizePath = normalizePath; + function getPathWithoutRoot(pathComponents) { + if (pathComponents.length === 0) + return ""; + return pathComponents.slice(1).join(ts.directorySeparator); + } + function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { + return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; + function normalizePathAndParts(path) { + path = normalizeSlashes(path); + var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; + } + else { + return { path: root, parts: parts }; + } + } + ts.normalizePathAndParts = normalizePathAndParts; + function removeTrailingDirectorySeparator(path) { + if (hasTrailingDirectorySeparator(path)) { + return path.substr(0, path.length - 1); + } + return path; + } + ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; + function ensureTrailingDirectorySeparator(path) { + if (!hasTrailingDirectorySeparator(path)) { + return path + ts.directorySeparator; + } + return path; + } + ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; + /** + * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed + * with `./` or `../`) so as not to be confused with an unprefixed module name. + * + * ```ts + * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext" + * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext" + * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext" + * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext" + * ``` + */ + function ensurePathIsNonModuleName(path) { + return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path; + } + ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; + function changeAnyExtension(path, ext, extensions, ignoreCase) { + var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); + return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; + } + ts.changeAnyExtension = changeAnyExtension; + //// Path Comparisons + // check path for these segments: '', '.'. '..' + var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + function comparePathsWorker(a, b, componentComparer) { + if (a === b) + return 0 /* EqualTo */; + if (a === undefined) + return -1 /* LessThan */; + if (b === undefined) + return 1 /* GreaterThan */; + // NOTE: Performance optimization - shortcut if the root segments differ as there would be no + // need to perform path reduction. + var aRoot = a.substring(0, getRootLength(a)); + var bRoot = b.substring(0, getRootLength(b)); + var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); + if (result !== 0 /* EqualTo */) { + return result; + } + // NOTE: Performance optimization - shortcut if there are no relative path segments in + // the non-root portion of the path + var aRest = a.substring(aRoot.length); + var bRest = b.substring(bRoot.length); + if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { + return componentComparer(aRest, bRest); + } + // The path contains a relative path segment. Normalize the paths and perform a slower component + // by component comparison. + var aComponents = reducePathComponents(getPathComponents(a)); + var bComponents = reducePathComponents(getPathComponents(b)); + var sharedLength = Math.min(aComponents.length, bComponents.length); + for (var i = 1; i < sharedLength; i++) { + var result_1 = componentComparer(aComponents[i], bComponents[i]); + if (result_1 !== 0 /* EqualTo */) { + return result_1; + } + } + return ts.compareValues(aComponents.length, bComponents.length); + } + /** + * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively. + */ + function comparePathsCaseSensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + } + ts.comparePathsCaseSensitive = comparePathsCaseSensitive; + /** + * Performs a case-insensitive comparison of two paths. + */ + function comparePathsCaseInsensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + } + ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; + function comparePaths(a, b, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + a = combinePaths(currentDirectory, a); + b = combinePaths(currentDirectory, b); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + } + ts.comparePaths = comparePaths; + function containsPath(parent, child, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + parent = combinePaths(currentDirectory, parent); + child = combinePaths(currentDirectory, child); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + if (parent === undefined || child === undefined) + return false; + if (parent === child) + return true; + var parentComponents = reducePathComponents(getPathComponents(parent)); + var childComponents = reducePathComponents(getPathComponents(child)); + if (childComponents.length < parentComponents.length) { + return false; + } + var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; + for (var i = 0; i < parentComponents.length; i++) { + var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; + if (!equalityComparer(parentComponents[i], childComponents[i])) { + return false; + } + } + return true; + } + ts.containsPath = containsPath; + /** + * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. + * Comparison is case-sensitive between the canonical paths. + * + * @deprecated Use `containsPath` if possible. + */ + function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { + var canonicalFileName = getCanonicalFileName(fileName); + var canonicalDirectoryName = getCanonicalFileName(directoryName); + return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); + } + ts.startsWithDirectory = startsWithDirectory; + //// Relative Paths + function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { + var fromComponents = reducePathComponents(getPathComponents(from)); + var toComponents = reducePathComponents(getPathComponents(to)); + var start; + for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { + var fromComponent = getCanonicalFileName(fromComponents[start]); + var toComponent = getCanonicalFileName(toComponents[start]); + var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; + if (!comparer(fromComponent, toComponent)) + break; + } + if (start === 0) { + return toComponents; + } + var components = toComponents.slice(start); + var relative = []; + for (; start < fromComponents.length; start++) { + relative.push(".."); + } + return __spreadArrays([""], relative, components); + } + ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; + function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { + ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); + var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; + var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; + var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathFromDirectory = getRelativePathFromDirectory; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + } + ts.convertToRelativePath = convertToRelativePath; + function getRelativePathFromFile(from, to, getCanonicalFileName) { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); + } + ts.getRelativePathFromFile = getRelativePathFromFile; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); + var firstComponent = pathComponents[0]; + if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) { + var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; + pathComponents[0] = prefix + firstComponent; + } + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } + ts.forEachAncestorDirectory = forEachAncestorDirectory; +})(ts || (ts = {})); +// +// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' +/* @internal */ +var ts; +(function (ts) { + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; + } + ts.Diagnostics = { + Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), + Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), + _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), + A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), + Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), + Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), + An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), + Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), + A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), + A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), + Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), + A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), + An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), + An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), + An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), + An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), + An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), + An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), + An_index_signature_parameter_type_must_be_either_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_either_string_or_number_1023", "An index signature parameter type must be either 'string' or 'number'."), + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), + Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), + _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), + _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), + _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), + super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), + Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), + Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), + Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), + _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), + _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), + _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), + _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), + _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), + A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), + Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), + A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), + A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), + A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), + A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), + A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), + A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), + A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), + An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), + A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), + Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), + An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), + _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), + _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), + A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), + Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), + _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), + _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), + Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), + Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), + An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), + A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), + An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), + _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), + Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), + Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), + Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), + with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), + delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), + A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), + Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), + Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), + Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), + An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), + Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), + Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), + Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), + Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), + Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), + Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), + Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), + Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), + case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), + Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), + Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), + Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), + Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), + Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), + Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), + Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), + Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), + Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), + String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), + Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), + or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), + Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), + Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), + Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), + File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), + const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), + const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), + let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), + Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), + Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), + An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), + A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), + Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), + A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), + extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), + extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), + Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), + implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), + Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), + Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), + Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), + Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), + Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), + Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), + A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), + An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), + Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), + Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), + A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), + A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), + An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), + Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), + An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), + Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), + Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), + Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), + Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), + Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), + Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), + Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), + All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), + A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), + Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), + Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), + Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), + An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), + _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), + Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), + Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), + Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), + Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), + A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), + An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), + An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), + _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), + Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), + An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), + A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), + A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), + A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), + _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), + A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), + A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), + Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), + with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), + await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), + The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), + Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), + Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), + Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), + A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), + An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd_1323", "Dynamic imports are only supported when the '--module' flag is set to 'esnext', 'commonjs', 'amd', 'system', or 'umd'."), + Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), + Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), + Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), + String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), + Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), + _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), + A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), + A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), + A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), + unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), + unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), + unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), + An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), + An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), + infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), + Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), + Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), + A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), + An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), + This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), + use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), + Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), + use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), + An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), + A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), + A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), + readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), + A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), + Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), + Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), + Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), + Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), + Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), + File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), + Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), + Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), + Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), + A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), + An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), + Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), + Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), + Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), + Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), + Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), + Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), + Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), + Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), + Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), + Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), + Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), + Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), + Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), + Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), + Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), + Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), + Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), + Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), + this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), + this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), + this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), + this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), + super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), + super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: diag(2338, ts.DiagnosticCategory.Error, "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class."), + Property_0_does_not_exist_on_type_1: diag(2339, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."), + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), + Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), + Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), + Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), + Untyped_function_calls_may_not_accept_type_arguments: diag(2347, ts.DiagnosticCategory.Error, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."), + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, ts.DiagnosticCategory.Error, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"), + This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."), + Only_a_void_function_can_be_called_with_the_new_keyword: diag(2350, ts.DiagnosticCategory.Error, "Only_a_void_function_can_be_called_with_the_new_keyword_2350", "Only a void function can be called with the 'new' keyword."), + This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."), + Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, ts.DiagnosticCategory.Error, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."), + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), + Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), + Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), + Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), + A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), + A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."), + Parameter_0_cannot_be_referenced_in_its_initializer: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_be_referenced_in_its_initializer_2372", "Parameter '{0}' cannot be referenced in its initializer."), + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it."), + Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."), + Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."), + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties."), + Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), + A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), + Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), + get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), + Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), + Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."), + Overload_signatures_must_all_be_public_private_or_protected: diag(2385, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."), + Overload_signatures_must_all_be_optional_or_required: diag(2386, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_optional_or_required_2386", "Overload signatures must all be optional or required."), + Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."), + Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."), + Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."), + Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."), + Function_implementation_is_missing_or_not_immediately_following_the_declaration: diag(2391, ts.DiagnosticCategory.Error, "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", "Function implementation is missing or not immediately following the declaration."), + Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."), + Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."), + This_overload_signature_is_not_compatible_with_its_implementation_signature: diag(2394, ts.DiagnosticCategory.Error, "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394", "This overload signature is not compatible with its implementation signature."), Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: diag(2395, ts.DiagnosticCategory.Error, "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", "Individual declarations in merged declaration '{0}' must be all exported or all local."), Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: diag(2396, ts.DiagnosticCategory.Error, "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters."), Declaration_name_conflicts_with_built_in_global_identifier_0: diag(2397, ts.DiagnosticCategory.Error, "Declaration_name_conflicts_with_built_in_global_identifier_0_2397", "Declaration name conflicts with built-in global identifier '{0}'."), @@ -5846,7 +6633,6 @@ var ts; Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2424, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property."), Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."), Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."), Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."), @@ -6016,6 +6802,11 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(2613, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(2614, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -6138,6 +6929,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -6224,6 +7023,11 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), + Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), + Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6234,6 +7038,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6259,6 +7064,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6446,6 +7252,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6464,9 +7271,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), - Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6505,9 +7314,12 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), + Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -6591,6 +7403,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6620,6 +7434,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6737,6 +7552,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6747,94 +7570,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7098,6 +7922,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7450,7 +8275,7 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, @@ -7460,8 +8285,8 @@ var ts; hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7471,6 +8296,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7485,6 +8311,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7933,7 +8768,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7997,7 +8832,7 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; @@ -8068,12 +8903,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -8082,19 +8917,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -8103,13 +8938,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -8117,28 +8952,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8199,10 +9034,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8260,7 +9095,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8276,20 +9111,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8302,15 +9137,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8322,10 +9157,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8334,10 +9177,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8352,22 +9195,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { @@ -8413,29 +9256,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8497,12 +9340,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8512,10 +9360,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8591,7 +9439,7 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } @@ -8607,13 +9455,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8623,17 +9471,17 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; + return token = 61 /* BacktickToken */; case 92 /* backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -8655,7 +9503,7 @@ var ts; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion)) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); if (char === 92 /* backslash */) { @@ -8736,7 +9584,7 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -8807,7 +9655,7 @@ var ts; ts.getDeclarationOfKind = getDeclarationOfKind; /** Create a new escaped identifier map. */ function createUnderscoreEscapedMap() { - return new ts.MapCtr(); + return new ts.Map(); } ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap; function hasEntries(map) { @@ -8849,6 +9697,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8861,13 +9711,6 @@ var ts; reportPrivateInBaseOfClassExpression: ts.noop, }; } - function toPath(fileName, basePath, getCanonicalFileName) { - var nonCanonicalizedPath = ts.isRootedDiskPath(fileName) - ? ts.normalizePath(fileName) - : ts.getNormalizedAbsolutePath(fileName, basePath); - return getCanonicalFileName(nonCanonicalizedPath); - } - ts.toPath = toPath; function changesAffectModuleResolution(oldOptions, newOptions) { return oldOptions.configFilePath !== newOptions.configFilePath || optionsHaveModuleResolutionChanges(oldOptions, newOptions); @@ -8936,7 +9779,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -9024,28 +9867,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -9053,11 +9896,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -9225,7 +10068,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 314 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9244,7 +10087,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9312,10 +10155,8 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings return "`" + rawText + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings return "}" + rawText + "${"; case 17 /* TemplateTail */: return "}" + rawText + "`"; @@ -9346,7 +10187,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9378,16 +10219,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9399,9 +10240,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9454,22 +10295,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9479,9 +10320,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 300 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9491,25 +10332,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9519,8 +10360,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9529,15 +10370,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9567,13 +10408,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9584,11 +10425,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9633,7 +10474,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9647,7 +10488,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9656,32 +10497,38 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + var start = ts.skipTrivia(sourceFile.text, node.pos); + var end = node.statements.length > 0 ? node.statements[0].pos : node.end; + return ts.createTextSpanFromBounds(start, end); } if (errorNode === undefined) { // If we don't have a better node, then just set the error on the first token of // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9723,16 +10570,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 93 /* ImportKeyword */ + && n.keywordToken === 95 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -9741,7 +10588,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9750,11 +10597,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -9770,48 +10617,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9820,40 +10667,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9878,23 +10725,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9904,26 +10751,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -9946,10 +10793,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9959,12 +10806,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9972,14 +10819,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9991,8 +10838,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -10003,13 +10850,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -10020,7 +10867,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -10028,17 +10875,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -10051,7 +10898,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -10092,14 +10939,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -10114,9 +10961,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10127,26 +10974,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -10156,9 +11003,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -10180,27 +11027,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10216,21 +11063,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -10239,8 +11086,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -10248,20 +11095,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -10269,10 +11116,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -10281,25 +11128,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10315,10 +11162,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10327,9 +11174,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10337,57 +11184,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10397,49 +11244,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10447,7 +11294,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10456,7 +11303,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10468,15 +11315,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10484,22 +11331,22 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; - function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + function isRequireCall(callExpression, requireStringLiteralLikeArgument) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { return false; } var arg = args[0]; - return !checkArgumentIsStringLiteralLike || ts.isStringLiteralLike(arg); + return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { @@ -10523,21 +11370,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { - if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { - name = node.parent.parent.name; - decl = node.parent.parent; - } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10547,13 +11398,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10567,14 +11419,20 @@ var ts; } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; function hasExpandoValueProperty(node, isPrototypeAssignment) { - return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + return ts.forEach(node.properties, function (p) { + return ts.isPropertyAssignment(p) && + ts.isIdentifier(p.name) && + p.name.escapedText === "value" && + p.initializer && + getExpandoInitializer(p.initializer, isPrototypeAssignment); + }); } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10600,11 +11458,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10621,14 +11479,16 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10636,8 +11496,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10656,19 +11516,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10683,10 +11544,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10701,60 +11565,129 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0], /*excludeThisKeyword*/ true); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + /** x.y OR x[0] */ + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + /** x[0] OR x['a'] OR x[Symbol.y] */ + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + /** Any series of property and element accesses. */ + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + /** Any series of property and element accesses, ending in a literal element access */ + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); + } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; - if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { - // exports.name = expr OR module.exports.name = expr + if ((id.escapedText === "exports" || + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") && + // ExportsProperty does not support binding with computed names + isBindableStaticAccessExpression(lhs)) { + // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... return 1 /* ExportsProperty */; } - // F.G...x = expr - return 5 /* Property */; + if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs) && lhs.expression.kind !== 103 /* ThisKeyword */)) { + // F.G...x = expr + return 5 /* Property */; + } } return 0 /* None */; } @@ -10772,7 +11705,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10781,7 +11715,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10790,14 +11724,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10807,12 +11741,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10821,11 +11755,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10833,19 +11767,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10859,7 +11793,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 312 /* JSDocTypedefTag */ || node.kind === 305 /* JSDocCallbackTag */ || node.kind === 306 /* JSDocEnumTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10869,7 +11803,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10878,18 +11812,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10900,7 +11834,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10915,11 +11849,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10930,12 +11864,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10946,7 +11880,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10969,7 +11903,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10994,7 +11928,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -11004,7 +11938,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -11017,31 +11951,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -11068,22 +12002,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -11100,33 +12034,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -11148,11 +12082,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -11175,8 +12110,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -11184,32 +12119,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -11225,22 +12160,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -11254,24 +12206,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11298,11 +12250,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -11310,7 +12262,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -11318,6 +12270,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11341,14 +12298,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11362,10 +12319,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11378,7 +12335,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11398,10 +12355,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11415,12 +12375,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11436,7 +12396,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11447,11 +12407,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11466,7 +12426,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11475,11 +12435,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11487,15 +12447,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11514,38 +12474,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11554,15 +12514,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11572,73 +12532,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11647,41 +12607,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11799,22 +12761,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11865,6 +12828,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11876,7 +12840,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11886,17 +12850,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11910,6 +12886,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11929,6 +12906,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11943,12 +12922,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -12012,7 +12991,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -12030,7 +13009,7 @@ var ts; */ function getExternalModuleNameFromPath(host, fileName, referencePath) { var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = ts.removeFileExtension(relativePath); @@ -12153,11 +13132,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -12168,10 +13147,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -12191,10 +13170,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -12240,7 +13219,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 298 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12480,7 +13459,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12488,29 +13467,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12523,14 +13502,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12538,8 +13517,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12549,9 +13528,32 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function getFirstIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + node = node.expression; + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + ts.getFirstIdentifier = getFirstIdentifier; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12567,21 +13569,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12879,8 +13881,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12957,35 +13959,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && skipParenthesesUp(parent.parent).kind === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -13064,21 +14066,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ - function forEachAncestorDirectory(directory, callback) { - while (true) { - var result = callback(directory); - if (result !== undefined) { - return result; - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - return undefined; - } - directory = parentPath; - } - } - ts.forEachAncestorDirectory = forEachAncestorDirectory; // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { return !!(getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isAbstractConstructorSymbol(type.symbol); @@ -13105,7 +14092,7 @@ var ts; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { - return !!forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); + return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { @@ -13149,32 +14136,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -13187,6 +14174,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13294,7 +14285,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13411,9 +14402,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } @@ -13421,7 +14412,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13451,14 +14442,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13522,7 +14513,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13604,30 +14596,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 205 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13639,6 +14631,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13651,41 +14654,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 306 /* JSDocEnumTag */: + case 309 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13708,8 +14716,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13887,7 +14895,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 298 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13907,10 +14915,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13955,198 +14962,230 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + var kind = node.kind; + return !!(node.flags & 32 /* OptionalChain */) && + (kind === 193 /* PropertyAccessExpression */ + || kind === 194 /* ElementAccessExpression */ + || kind === 195 /* CallExpression */); + } + ts.isOptionalChain = isOptionalChain; + /** + * Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`). + */ + /* @internal */ + function isExpressionOfOptionalChainRoot(node) { + return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node; + } + ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot; + function isNullishCoalesce(node) { + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + } + ts.isNullishCoalesce = isNullishCoalesce; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -14155,376 +15194,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 316 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14533,105 +15572,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 298 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 303 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 302 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 304 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 306 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 309 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 307 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 308 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 310 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 311 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 312 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 313 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 313 /* JSDocPropertyTag */ || node.kind === 307 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 299 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 305 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 300 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14642,7 +15681,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 314 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14652,7 +15691,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14661,7 +15700,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14714,17 +15753,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14737,7 +15776,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14746,23 +15785,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14777,13 +15816,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14792,14 +15831,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14814,29 +15853,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14846,11 +15885,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14859,12 +15898,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14879,8 +15918,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14891,8 +15930,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14900,15 +15939,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14917,9 +15956,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14940,8 +15979,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14953,8 +15992,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14963,26 +16002,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14990,12 +16029,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -15006,34 +16045,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -15046,13 +16085,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -15061,11 +16100,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -15082,15 +16121,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 317 /* CommaListExpression */: - case 316 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -15098,21 +16137,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 316 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 315 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -15120,21 +16164,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -15158,113 +16223,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 312 /* JSDocTypedefTag */ - || kind === 305 /* JSDocCallbackTag */ - || kind === 313 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 315 /* NotEmittedStatement */ - || kind === 319 /* EndOfDeclarationMarker */ - || kind === 318 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 311 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -15291,10 +16356,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -15304,83 +16369,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 313 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 298 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 301 /* FirstJSDocTagNode */ && node.kind <= 313 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; + } + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15408,12 +16478,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15449,7 +16519,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15467,7 +16537,12 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature(checker, flags) { + this.flags = flags; + if (ts.Debug.isDebugging) { + this.checker = checker; + } + } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15482,758 +16557,302 @@ var ts; function SourceMapSource(fileName, text, skipTrivia) { this.fileName = fileName; this.text = text; - this.skipTrivia = skipTrivia || (function (pos) { return pos; }); - } - ts.objectAllocator = { - getNodeConstructor: function () { return Node; }, - getTokenConstructor: function () { return Node; }, - getIdentifierConstructor: function () { return Node; }, - getSourceFileConstructor: function () { return Node; }, - getSymbolConstructor: function () { return Symbol; }, - getTypeConstructor: function () { return Type; }, - getSignatureConstructor: function () { return Signature; }, - getSourceMapSourceConstructor: function () { return SourceMapSource; }, - }; - function formatStringFromArgs(text, args, baseIndex) { - if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); - } - ts.formatStringFromArgs = formatStringFromArgs; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - ts.Debug.assertGreaterThanOrEqual(start, 0); - ts.Debug.assertGreaterThanOrEqual(length, 0); - if (file) { - ts.Debug.assertLessThanOrEqual(start, file.text.length); - ts.Debug.assertLessThanOrEqual(start + length, file.text.length); - } - var text = getLocaleSpecificMessage(message); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(_dummy, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return text; - } - ts.formatMessage = formatMessage; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function createCompilerDiagnosticFromMessageChain(chain) { - return { - file: undefined, - start: undefined, - length: undefined, - code: chain.code, - category: chain.category, - messageText: chain.next ? chain : chain.messageText, - }; - } - ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details === undefined || Array.isArray(details) ? details : [details] - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - var lastChain = headChain; - while (lastChain.next) { - lastChain = lastChain.next[0]; - } - lastChain.next = [tailChain]; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function getDiagnosticFilePath(diagnostic) { - return diagnostic.file ? diagnostic.file.path : undefined; - } - function compareDiagnostics(d1, d2) { - return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; - } - ts.compareDiagnostics = compareDiagnostics; - function compareDiagnosticsSkipRelatedInformation(d1, d2) { - return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || - ts.compareValues(d1.start, d2.start) || - ts.compareValues(d1.length, d2.length) || - ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; - } - ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; - function compareRelatedInformation(d1, d2) { - if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; - } - if (d1.relatedInformation && d2.relatedInformation) { - return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { - var d2i = d2.relatedInformation[index]; - return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; - } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; - } - function compareMessageText(t1, t2) { - if (typeof t1 === "string" && typeof t2 === "string") { - return ts.compareStringsCaseSensitive(t1, t2); - } - else if (typeof t1 === "string") { - return -1 /* LessThan */; - } - else if (typeof t2 === "string") { - return 1 /* GreaterThan */; - } - var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); - if (res) { - return res; - } - if (!t1.next && !t2.next) { - return 0 /* EqualTo */; - } - if (!t1.next) { - return -1 /* LessThan */; - } - if (!t2.next) { - return 1 /* GreaterThan */; - } - var len = Math.min(t1.next.length, t2.next.length); - for (var i = 0; i < len; i++) { - res = compareMessageText(t1.next[i], t2.next[i]); - if (res) { - return res; - } - } - if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; - } - else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; - } - return 0 /* EqualTo */; - } - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0 /* ES3 */; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; - function getEmitModuleResolutionKind(compilerOptions) { - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - } - return moduleResolution; - } - ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; - function hasJsonModuleEmitEnabled(options) { - switch (getEmitModuleKind(options)) { - case ts.ModuleKind.CommonJS: - case ts.ModuleKind.AMD: - case ts.ModuleKind.ES2015: - case ts.ModuleKind.ESNext: - return true; - default: - return false; - } - } - ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; - function unreachableCodeIsError(options) { - return options.allowUnreachableCode === false; - } - ts.unreachableCodeIsError = unreachableCodeIsError; - function unusedLabelIsError(options) { - return options.allowUnusedLabels === false; - } - ts.unusedLabelIsError = unusedLabelIsError; - function getAreDeclarationMapsEnabled(options) { - return !!(getEmitDeclarations(options) && options.declarationMap); - } - ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; - function getAllowSyntheticDefaultImports(compilerOptions) { - var moduleKind = getEmitModuleKind(compilerOptions); - return compilerOptions.allowSyntheticDefaultImports !== undefined - ? compilerOptions.allowSyntheticDefaultImports - : compilerOptions.esModuleInterop || - moduleKind === ts.ModuleKind.System; - } - ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; - function getEmitDeclarations(compilerOptions) { - return !!(compilerOptions.declaration || compilerOptions.composite); - } - ts.getEmitDeclarations = getEmitDeclarations; - function isIncrementalCompilation(options) { - return !!(options.incremental || options.composite); - } - ts.isIncrementalCompilation = isIncrementalCompilation; - function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; - } - ts.getStrictOptionValue = getStrictOptionValue; - function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; - function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; - function getCompilerOptionValue(options, option) { - return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; - } - ts.getCompilerOptionValue = getCompilerOptionValue; - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - // have already seen asterisk - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - /** - * Internally, we represent paths as strings with '/' as the directory separator. - * When we make system calls (eg: LanguageServiceHost.getDirectory()), - * we expect the host to correctly handle paths in our specified format. - */ - ts.directorySeparator = "/"; - var altDirectorySeparator = "\\"; - var urlSchemeSeparator = "://"; - var backslashRegExp = /\\/g; - /** - * Normalize path separators. - */ - function normalizeSlashes(path) { - return path.replace(backslashRegExp, ts.directorySeparator); - } - ts.normalizeSlashes = normalizeSlashes; - function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); - } - function getFileUrlVolumeSeparatorEnd(url, start) { - var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) - return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { - var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) - return start + 3; - } - return -1; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * If the root is part of a URL, the twos-complement of the root length is returned. - */ - function getEncodedRootLength(path) { - if (!path) - return 0; - var ch0 = path.charCodeAt(0); - // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { - if (path.charCodeAt(1) !== ch0) - return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); - if (p1 < 0) - return path.length; // UNC: "//server" or "\\server" - return p1 + 1; // UNC: "//server/" or "\\server\" - } - // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { - var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) - return 3; // DOS: "c:/" or "c:\" - if (path.length === 2) - return 2; // DOS: "c:" (but not "c:d") - } - // URL - var schemeEnd = path.indexOf(urlSchemeSeparator); - if (schemeEnd !== -1) { - var authorityStart = schemeEnd + urlSchemeSeparator.length; - var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); - if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" - // For local "file" URLs, include the leading DOS volume (if present). - // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a - // special case interpreted as "the machine from which the URL is being interpreted". - var scheme = path.slice(0, schemeEnd); - var authority = path.slice(authorityStart, authorityEnd); - if (scheme === "file" && (authority === "" || authority === "localhost") && - isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { - var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); - if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { - // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" - return ~(volumeSeparatorEnd + 1); - } - if (volumeSeparatorEnd === path.length) { - // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" - // but not "file:///c:d" or "file:///c%3ad" - return ~volumeSeparatorEnd; - } - } - } - return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" - } - return ~path.length; // URL: "file://server", "http://server" - } - // relative - return 0; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * - * For example: - * ```ts - * getRootLength("a") === 0 // "" - * getRootLength("/") === 1 // "/" - * getRootLength("c:") === 2 // "c:" - * getRootLength("c:d") === 0 // "" - * getRootLength("c:/") === 3 // "c:/" - * getRootLength("c:\\") === 3 // "c:\\" - * getRootLength("//server") === 7 // "//server" - * getRootLength("//server/share") === 8 // "//server/" - * getRootLength("\\\\server") === 7 // "\\\\server" - * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" - * getRootLength("file:///path") === 8 // "file:///" - * getRootLength("file:///c:") === 10 // "file:///c:" - * getRootLength("file:///c:d") === 8 // "file:///" - * getRootLength("file:///c:/path") === 11 // "file:///c:/" - * getRootLength("file://server") === 13 // "file://server" - * getRootLength("file://server/path") === 14 // "file://server/" - * getRootLength("http://server") === 13 // "http://server" - * getRootLength("http://server/path") === 14 // "http://server/" - * ``` - */ - function getRootLength(path) { - var rootLength = getEncodedRootLength(path); - return rootLength < 0 ? ~rootLength : rootLength; - } - ts.getRootLength = getRootLength; - // TODO(rbuckton): replace references with `resolvePath` - function normalizePath(path) { - return ts.resolvePath(path); - } - ts.normalizePath = normalizePath; - function normalizePathAndParts(path) { - path = normalizeSlashes(path); - var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); - if (parts.length) { - var joinedParts = root + parts.join(ts.directorySeparator); - return { path: ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; - } - else { - return { path: root, parts: parts }; - } - } - ts.normalizePathAndParts = normalizePathAndParts; - function getDirectoryPath(path) { - path = normalizeSlashes(path); - // If the path provided is itself the root, then return it. - var rootLength = getRootLength(path); - if (rootLength === path.length) - return path; - // return the leading portion of the path up to the last (non-terminal) directory separator - // but not including any trailing directory separator. - path = ts.removeTrailingDirectorySeparator(path); - return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { - var canonicalFileName = getCanonicalFileName(fileName); - var canonicalDirectoryName = getCanonicalFileName(directoryName); - return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); - } - ts.startsWithDirectory = startsWithDirectory; - function isUrl(path) { - return getEncodedRootLength(path) < 0; - } - ts.isUrl = isUrl; - function pathIsRelative(path) { - return /^\.\.?($|[\\/])/.test(path); - } - ts.pathIsRelative = pathIsRelative; - /** - * Determines whether a path is an absolute path (e.g. starts with `/`, or a dos path - * like `c:`, `c:\` or `c:/`). - */ - function isRootedDiskPath(path) { - return getEncodedRootLength(path) > 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - /** - * Determines whether a path consists only of a path root. - */ - function isDiskPathRoot(path) { - var rootLength = getEncodedRootLength(path); - return rootLength > 0 && rootLength === path.length; - } - ts.isDiskPathRoot = isDiskPathRoot; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - } - ts.convertToRelativePath = convertToRelativePath; - function pathComponents(path, rootLength) { - var root = path.substring(0, rootLength); - var rest = path.substring(rootLength).split(ts.directorySeparator); - if (rest.length && !ts.lastOrUndefined(rest)) - rest.pop(); - return __spreadArrays([root], rest); - } - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is not normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getPathComponents(path, currentDirectory) { - if (currentDirectory === void 0) { currentDirectory = ""; } - path = ts.combinePaths(currentDirectory, path); - var rootLength = getRootLength(path); - return pathComponents(path, rootLength); - } - ts.getPathComponents = getPathComponents; - /** - * Reduce an array of path components to a more simplified path by navigating any - * `"."` or `".."` entries in the path. - */ - function reducePathComponents(components) { - if (!ts.some(components)) - return []; - var reduced = [components[0]]; - for (var i = 1; i < components.length; i++) { - var component = components[i]; - if (!component) - continue; - if (component === ".") - continue; - if (component === "..") { - if (reduced.length > 1) { - if (reduced[reduced.length - 1] !== "..") { - reduced.pop(); - continue; - } - } - else if (reduced[0]) - continue; - } - reduced.push(component); - } - return reduced; - } - ts.reducePathComponents = reducePathComponents; - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getNormalizedPathComponents(path, currentDirectory) { - return reducePathComponents(getPathComponents(path, currentDirectory)); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - /** - * Formats a parsed path consisting of a root component (at index 0) and zero or more path - * segments (at indices > 0). - */ - function getPathFromPathComponents(pathComponents) { - if (pathComponents.length === 0) - return ""; - var root = pathComponents[0] && ts.ensureTrailingDirectorySeparator(pathComponents[0]); - return root + pathComponents.slice(1).join(ts.directorySeparator); + this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } - ts.getPathFromPathComponents = getPathFromPathComponents; - function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { - return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + // eslint-disable-next-line prefer-const + ts.objectAllocator = { + getNodeConstructor: function () { return Node; }, + getTokenConstructor: function () { return Node; }, + getIdentifierConstructor: function () { return Node; }, + getSourceFileConstructor: function () { return Node; }, + getSymbolConstructor: function () { return Symbol; }, + getTypeConstructor: function () { return Type; }, + getSignatureConstructor: function () { return Signature; }, + getSourceMapSourceConstructor: function () { return SourceMapSource; }, + }; + function formatStringFromArgs(text, args, baseIndex) { + if (baseIndex === void 0) { baseIndex = 0; } + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } - ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; - function getPathWithoutRoot(pathComponents) { - if (pathComponents.length === 0) - return ""; - return pathComponents.slice(1).join(ts.directorySeparator); + ts.formatStringFromArgs = formatStringFromArgs; + function getLocaleSpecificMessage(message) { + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; } -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { - var fromComponents = ts.reducePathComponents(ts.getPathComponents(from)); - var toComponents = ts.reducePathComponents(ts.getPathComponents(to)); - var start; - for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { - var fromComponent = getCanonicalFileName(fromComponents[start]); - var toComponent = getCanonicalFileName(toComponents[start]); - var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; - if (!comparer(fromComponent, toComponent)) - break; + ts.getLocaleSpecificMessage = getLocaleSpecificMessage; + function createFileDiagnostic(file, start, length, message) { + ts.Debug.assertGreaterThanOrEqual(start, 0); + ts.Debug.assertGreaterThanOrEqual(length, 0); + if (file) { + ts.Debug.assertLessThanOrEqual(start, file.text.length); + ts.Debug.assertLessThanOrEqual(start + length, file.text.length); } - if (start === 0) { - return toComponents; + var text = getLocaleSpecificMessage(message); + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); } - var components = toComponents.slice(start); - var relative = []; - for (; start < fromComponents.length; start++) { - relative.push(".."); + return { + file: file, + start: start, + length: length, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; + } + ts.createFileDiagnostic = createFileDiagnostic; + function formatMessage(_dummy, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return __spreadArrays([""], relative, components); + return text; } - ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; - function getRelativePathFromFile(from, to, getCanonicalFileName) { - return ensurePathIsNonModuleName(getRelativePathFromDirectory(ts.getDirectoryPath(from), to, getCanonicalFileName)); + ts.formatMessage = formatMessage; + function createCompilerDiagnostic(message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 1) { + text = formatStringFromArgs(text, arguments, 1); + } + return { + file: undefined, + start: undefined, + length: undefined, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; } - ts.getRelativePathFromFile = getRelativePathFromFile; - function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { - ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); - var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; - var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; - var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); - return ts.getPathFromPathComponents(pathComponents); + ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText, + }; } - ts.getRelativePathFromDirectory = getRelativePathFromDirectory; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); - var firstComponent = pathComponents[0]; - if (isAbsolutePathAnUrl && ts.isRootedDiskPath(firstComponent)) { - var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; - pathComponents[0] = prefix + firstComponent; + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; + function chainDiagnosticMessages(details, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return ts.getPathFromPathComponents(pathComponents); + return { + messageText: text, + category: message.category, + code: message.code, + next: details === undefined || Array.isArray(details) ? details : [details] + }; } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - /** - * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed - * with `./` or `../`) so as not to be confused with an unprefixed module name. - */ - function ensurePathIsNonModuleName(path) { - return ts.getRootLength(path) === 0 && !ts.pathIsRelative(path) ? "./" + path : path; + ts.chainDiagnosticMessages = chainDiagnosticMessages; + function concatenateDiagnosticMessageChains(headChain, tailChain) { + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next[0]; + } + lastChain.next = [tailChain]; } - ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; - function getBaseFileName(path, extensions, ignoreCase) { - path = ts.normalizeSlashes(path); - // if the path provided is itself the root, then it has not file name. - var rootLength = ts.getRootLength(path); - if (rootLength === path.length) - return ""; - // return the trailing portion of the path starting after the last (non-terminal) directory - // separator but not including any trailing directory separator. - path = removeTrailingDirectorySeparator(path); - var name = path.slice(Math.max(ts.getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); - var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; - return extension ? name.slice(0, name.length - extension.length) : name; + ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; + function getDiagnosticFilePath(diagnostic) { + return diagnostic.file ? diagnostic.file.path : undefined; } - ts.getBaseFileName = getBaseFileName; - /** - * Combines paths. If a path is absolute, it replaces any previous path. - */ - function combinePaths(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + function compareDiagnosticsSkipRelatedInformation(d1, d2) { + return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || + ts.compareValues(d1.start, d2.start) || + ts.compareValues(d1.length, d2.length) || + ts.compareValues(d1.code, d2.code) || + compareMessageText(d1.messageText, d2.messageText) || + 0 /* EqualTo */; + } + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; } - if (path) - path = ts.normalizeSlashes(path); - for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { - var relativePath = paths_1[_a]; - if (!relativePath) - continue; - relativePath = ts.normalizeSlashes(relativePath); - if (!path || ts.getRootLength(relativePath) !== 0) { - path = relativePath; - } - else { - path = ensureTrailingDirectorySeparator(path) + relativePath; - } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; } - return path; + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; } - ts.combinePaths = combinePaths; - /** - * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any - * `.` and `..` path components are resolved. - */ - function resolvePath(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareMessageText(t1, t2) { + if (typeof t1 === "string" && typeof t2 === "string") { + return ts.compareStringsCaseSensitive(t1, t2); } - var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); - var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); - return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; - } - ts.resolvePath = resolvePath; - /** - * Determines whether a path has a trailing separator (`/` or `\\`). - */ - function hasTrailingDirectorySeparator(path) { - if (path.length === 0) - return false; - var ch = path.charCodeAt(path.length - 1); - return ch === 47 /* slash */ || ch === 92 /* backslash */; - } - ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; - function removeTrailingDirectorySeparator(path) { - if (hasTrailingDirectorySeparator(path)) { - return path.substr(0, path.length - 1); + else if (typeof t1 === "string") { + return -1 /* LessThan */; } - return path; - } - ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; - function ensureTrailingDirectorySeparator(path) { - if (!hasTrailingDirectorySeparator(path)) { - return path + ts.directorySeparator; + else if (typeof t2 === "string") { + return 1 /* GreaterThan */; } - return path; - } - ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; - // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; - function comparePathsWorker(a, b, componentComparer) { - if (a === b) + var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); + if (res) { + return res; + } + if (!t1.next && !t2.next) { return 0 /* EqualTo */; - if (a === undefined) + } + if (!t1.next) { return -1 /* LessThan */; - if (b === undefined) - return 1 /* GreaterThan */; - // NOTE: Performance optimization - shortcut if the root segments differ as there would be no - // need to perform path reduction. - var aRoot = a.substring(0, ts.getRootLength(a)); - var bRoot = b.substring(0, ts.getRootLength(b)); - var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { - return result; } - // NOTE: Performance optimization - shortcut if there are no relative path segments in - // the non-root portion of the path - var aRest = a.substring(aRoot.length); - var bRest = b.substring(bRoot.length); - if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { - return componentComparer(aRest, bRest); + if (!t2.next) { + return 1 /* GreaterThan */; } - // The path contains a relative path segment. Normalize the paths and perform a slower component - // by component comparison. - var aComponents = ts.reducePathComponents(ts.getPathComponents(a)); - var bComponents = ts.reducePathComponents(ts.getPathComponents(b)); - var sharedLength = Math.min(aComponents.length, bComponents.length); - for (var i = 1; i < sharedLength; i++) { - var result_1 = componentComparer(aComponents[i], bComponents[i]); - if (result_1 !== 0 /* EqualTo */) { - return result_1; + var len = Math.min(t1.next.length, t2.next.length); + for (var i = 0; i < len; i++) { + res = compareMessageText(t1.next[i], t2.next[i]); + if (res) { + return res; } } - return ts.compareValues(aComponents.length, bComponents.length); + if (t1.next.length < t2.next.length) { + return -1 /* LessThan */; + } + else if (t1.next.length > t2.next.length) { + return 1 /* GreaterThan */; + } + return 0 /* EqualTo */; } - /** - * Performs a case-sensitive comparison of two paths. - */ - function comparePathsCaseSensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0 /* ES3 */; } - ts.comparePathsCaseSensitive = comparePathsCaseSensitive; - /** - * Performs a case-insensitive comparison of two paths. - */ - function comparePathsCaseInsensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } - ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; - function comparePaths(a, b, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - a = combinePaths(currentDirectory, a); - b = combinePaths(currentDirectory, b); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; + ts.getEmitModuleKind = getEmitModuleKind; + function getEmitModuleResolutionKind(compilerOptions) { + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; } - return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + return moduleResolution; } - ts.comparePaths = comparePaths; - function containsPath(parent, child, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - parent = combinePaths(currentDirectory, parent); - child = combinePaths(currentDirectory, child); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; - } - if (parent === undefined || child === undefined) - return false; - if (parent === child) - return true; - var parentComponents = ts.reducePathComponents(ts.getPathComponents(parent)); - var childComponents = ts.reducePathComponents(ts.getPathComponents(child)); - if (childComponents.length < parentComponents.length) { - return false; - } - var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; - for (var i = 0; i < parentComponents.length; i++) { - var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; - if (!equalityComparer(parentComponents[i], childComponents[i])) { + ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function hasJsonModuleEmitEnabled(options) { + switch (getEmitModuleKind(options)) { + case ts.ModuleKind.CommonJS: + case ts.ModuleKind.AMD: + case ts.ModuleKind.ES2015: + case ts.ModuleKind.ESNext: + return true; + default: return false; + } + } + ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; + function getAreDeclarationMapsEnabled(options) { + return !!(getEmitDeclarations(options) && options.declarationMap); + } + ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; + function getAllowSyntheticDefaultImports(compilerOptions) { + var moduleKind = getEmitModuleKind(compilerOptions); + return compilerOptions.allowSyntheticDefaultImports !== undefined + ? compilerOptions.allowSyntheticDefaultImports + : compilerOptions.esModuleInterop || + moduleKind === ts.ModuleKind.System; + } + ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; + function getEmitDeclarations(compilerOptions) { + return !!(compilerOptions.declaration || compilerOptions.composite); + } + ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; + function getStrictOptionValue(compilerOptions, flag) { + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; + } + ts.getStrictOptionValue = getStrictOptionValue; + function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; + function compilerOptionsAffectEmit(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; + function getCompilerOptionValue(options, option) { + return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; + } + ts.getCompilerOptionValue = getCompilerOptionValue; + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42 /* asterisk */) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + // have already seen asterisk + return false; + } } } return true; } - ts.containsPath = containsPath; - function isDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { function stripLeadingDirectorySeparator(s) { - return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; } function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); @@ -16252,10 +16871,6 @@ var ts; return "\\" + match; } var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; - function hasExtension(fileName) { - return ts.stringContains(getBaseFileName(fileName), "."); - } - ts.hasExtension = hasExtension; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; var filesMatcher = { @@ -16331,7 +16946,7 @@ var ts; } // getNormalizedPathComponents includes the separator for the root component. // We need to remove to create our regex correctly. - components[0] = removeTrailingDirectorySeparator(components[0]); + components[0] = ts.removeTrailingDirectorySeparator(components[0]); if (isImplicitGlob(lastComponent)) { components.push("**", "*"); } @@ -16393,7 +17008,7 @@ var ts; function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = ts.normalizePath(path); currentDirectory = ts.normalizePath(currentDirectory); - var absolutePath = combinePaths(currentDirectory, path); + var absolutePath = ts.combinePaths(currentDirectory, path); return { includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), @@ -16422,7 +17037,7 @@ var ts; var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; - visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth); + visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); } return ts.flatten(results); function visitDirectory(path, absolutePath, depth) { @@ -16432,8 +17047,8 @@ var ts; visited.set(canonicalPath, true); var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; var _loop_1 = function (current) { - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if (extensions && !ts.fileExtensionIsOneOf(name, extensions)) return "continue"; if (excludeRegex && excludeRegex.test(absoluteName)) @@ -16460,8 +17075,8 @@ var ts; } for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) { var current = _d[_c]; - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { visitDirectory(name, absoluteName, depth); @@ -16483,14 +17098,14 @@ var ts; var include = includes_1[_i]; // We also need to check the relative paths by converting them to absolute and normalizing // in case they escape the base path (e.g "..\somedirectory") - var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(combinePaths(path, include)); + var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include)); // Append the literal and canonical candidate base paths. includeBasePaths.push(getIncludeBasePath(absolute)); } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames)); var _loop_2 = function (includeBasePath) { - if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; @@ -16507,9 +17122,9 @@ var ts; var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes); if (wildcardOffset < 0) { // No "*" or "?" in the path - return !hasExtension(absolute) + return !ts.hasExtension(absolute) ? absolute - : removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); + : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); } return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); } @@ -16674,14 +17289,9 @@ var ts; } ts.removeExtension = removeExtension; function changeExtension(path, newExtension) { - return changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); + return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; - function changeAnyExtension(path, ext, extensions, ignoreCase) { - var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); - return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; - } - ts.changeAnyExtension = changeAnyExtension; function tryParsePattern(pattern) { // This should be verified outside of here and a proper error thrown. ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern)); @@ -16724,36 +17334,6 @@ var ts; return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); }); } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; - function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { - if (typeof extensions === "string") - extensions = [extensions]; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - if (!ts.startsWith(extension, ".")) - extension = "." + extension; - if (path.length >= extension.length && path.charAt(path.length - extension.length) === ".") { - var pathExtension = path.slice(path.length - extension.length); - if (stringEqualityComparer(pathExtension, extension)) { - return pathExtension; - } - } - } - return ""; - } - function getAnyExtensionFromPath(path, extensions, ignoreCase) { - // Retrieves any string from the final "." onwards from a base file name. - // Unlike extensionFromPath, which throws an exception on unrecognized extensions. - if (extensions) { - return getAnyExtensionFromPathWorker(path, extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); - } - var baseFileName = getBaseFileName(path); - var extensionIndex = baseFileName.lastIndexOf("."); - if (extensionIndex >= 0) { - return baseFileName.substring(extensionIndex); - } - return ""; - } - ts.getAnyExtensionFromPath = getAnyExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } @@ -16883,14 +17463,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16994,17 +17577,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -17053,19 +17634,19 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17073,9 +17654,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -17083,7 +17664,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17091,51 +17672,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -17147,345 +17728,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 303 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 301 /* JSDocTag */: - case 304 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17539,7 +18125,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17568,14 +18154,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17706,18 +18290,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17726,7 +18310,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17742,6 +18326,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17767,10 +18354,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17798,7 +18385,7 @@ var ts; function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17863,7 +18450,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17884,16 +18471,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17934,40 +18521,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -18082,20 +18669,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -18183,7 +18770,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -18213,7 +18800,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -18225,7 +18812,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -18246,9 +18833,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -18257,7 +18844,12 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var isReservedWord = scanner.isReservedWord(); + var msgArg = scanner.getTokenText(); + var defaultMessage = isReservedWord ? + ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : + ts.Diagnostics.Identifier_expected; + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -18288,7 +18880,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18309,20 +18901,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18335,16 +18927,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18364,7 +18956,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18380,7 +18972,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18450,7 +19042,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18467,8 +19059,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18498,14 +19090,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18524,9 +19116,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18546,7 +19138,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18621,7 +19213,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18722,20 +19314,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18744,8 +19336,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18754,58 +19346,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18826,7 +19418,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18893,7 +19485,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18931,6 +19523,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18951,7 +19546,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18962,7 +19557,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18993,13 +19588,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -19011,7 +19606,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -19071,24 +19666,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -19096,20 +19691,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -19117,7 +19712,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -19138,43 +19733,43 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); if (moduleSpecifier) { - var moduleTag = createNode(297 /* JSDocNamepathType */, moduleSpecifier.pos); + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); terminate: while (true) { switch (token()) { case 19 /* CloseBraceToken */: @@ -19193,25 +19788,25 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -19230,18 +19825,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -19250,12 +19845,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -19277,7 +19872,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -19299,16 +19894,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -19355,10 +19950,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19402,21 +19997,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 56 /* QuestionToken */) { + if (token() !== 57 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19424,17 +20019,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -19446,7 +20041,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19468,20 +20063,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19492,7 +20087,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19500,14 +20095,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19524,37 +20119,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19565,23 +20160,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19589,9 +20184,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19599,14 +20194,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19619,23 +20214,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19645,50 +20240,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19696,51 +20295,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19758,27 +20360,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19797,16 +20399,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19814,11 +20416,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19839,13 +20441,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19855,7 +20457,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19877,8 +20479,8 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19887,7 +20489,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19899,7 +20501,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19910,45 +20513,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19957,14 +20567,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19975,18 +20585,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -20005,9 +20615,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -20030,7 +20640,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -20075,7 +20685,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -20091,7 +20701,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -20120,15 +20730,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -20139,20 +20749,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -20177,8 +20787,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -20188,10 +20798,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -20201,12 +20811,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -20220,8 +20830,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -20245,30 +20855,30 @@ var ts; // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -20277,7 +20887,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -20287,11 +20897,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -20324,7 +20934,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -20337,23 +20947,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20363,7 +20973,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20376,7 +20986,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20387,8 +20997,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20413,20 +21023,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20434,7 +21044,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20463,16 +21073,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20493,51 +21103,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20547,7 +21157,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20571,7 +21181,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20588,10 +21198,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -20616,23 +21226,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20655,16 +21265,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20687,21 +21297,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20742,14 +21352,14 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20757,21 +21367,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a - // CallExpression. As such, we need to consume the rest of it here to be complete. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20823,11 +21434,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20839,7 +21450,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20848,8 +21459,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20858,15 +21469,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20877,11 +21488,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20911,7 +21522,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20919,7 +21530,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20940,16 +21551,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20957,23 +21568,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20987,10 +21598,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20998,7 +21609,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -21024,9 +21635,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -21039,7 +21650,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -21047,78 +21658,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -21127,48 +21770,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -21177,12 +21842,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -21199,21 +21864,23 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* ColonToken */: // foo: case 26 /* SemicolonToken */: // foo; - case 56 /* QuestionToken */: // foo? - case 33 /* EqualsEqualsToken */: // foo == - case 35 /* EqualsEqualsEqualsToken */: // foo === - case 34 /* ExclamationEqualsToken */: // foo != - case 36 /* ExclamationEqualsEqualsToken */: // foo !== - case 54 /* AmpersandAmpersandToken */: // foo && - case 55 /* BarBarToken */: // foo || - case 51 /* CaretToken */: // foo ^ - case 49 /* AmpersandToken */: // foo & - case 50 /* BarToken */: // foo | + case 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // these cases can't legally follow a type arg list. However, they're not legal @@ -21225,6 +21892,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -21237,11 +21905,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -21249,7 +21917,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -21257,14 +21925,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -21275,28 +21943,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21308,25 +21976,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -21334,24 +22002,24 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21370,10 +22038,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21381,7 +22049,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21393,26 +22061,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21422,7 +22090,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21455,25 +22123,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21485,8 +22153,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21495,12 +22163,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21508,23 +22176,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21542,7 +22210,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21550,8 +22218,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21559,39 +22227,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21606,29 +22274,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21641,8 +22309,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21652,13 +22320,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21670,11 +22338,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21683,12 +22351,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -21711,41 +22379,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21758,50 +22426,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -21824,63 +22493,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21889,52 +22559,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21943,7 +22632,7 @@ var ts; if (node.decorators || node.modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21966,24 +22655,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21991,14 +22680,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -22020,10 +22709,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22033,14 +22722,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -22056,7 +22745,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -22071,25 +22760,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -22101,25 +22790,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22134,17 +22823,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -22152,13 +22841,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -22175,7 +22864,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -22191,18 +22880,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -22220,10 +22909,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -22243,7 +22932,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -22262,7 +22951,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -22273,20 +22962,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -22300,27 +22989,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22346,7 +23045,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -22358,33 +23057,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22392,11 +23090,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22406,14 +23104,14 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22425,7 +23123,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22436,7 +23134,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22448,11 +23146,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22468,15 +23166,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22484,52 +23182,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22541,7 +23239,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22551,7 +23249,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22561,8 +23259,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22584,9 +23282,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22599,14 +23297,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22620,9 +23318,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22631,24 +23329,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22656,12 +23354,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22676,15 +23374,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22692,7 +23388,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22743,9 +23439,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22755,8 +23451,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22767,11 +23463,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22836,7 +23532,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22855,7 +23551,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -22906,7 +23602,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(298 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22942,14 +23638,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22957,7 +23653,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -23041,7 +23737,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -23066,7 +23762,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -23074,7 +23770,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -23083,7 +23779,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -23106,7 +23802,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(301 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -23134,15 +23830,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -23151,9 +23847,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -23169,8 +23865,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(313 /* JSDocPropertyTag */, start) : - createNode(307 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -23187,20 +23883,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -23212,7 +23908,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(308 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -23221,13 +23917,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(310 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(303 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -23249,20 +23945,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -23281,14 +23977,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(302 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -23300,7 +23996,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -23308,19 +24004,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(304 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(309 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(306 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -23329,7 +24025,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(312 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -23343,9 +24039,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 310 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -23358,7 +24054,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23377,7 +24073,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23391,22 +24087,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(305 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(300 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 308 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23448,10 +24144,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23464,13 +24160,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23479,7 +24175,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23515,13 +24211,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(311 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23554,13 +24250,13 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - if (token() !== 73 /* Identifier */) { + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { result.originalKeywordKind = token(); } result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -23689,7 +24385,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -24255,10 +24951,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24408,6 +25104,14 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", @@ -24472,6 +25176,15 @@ var ts; isCommandLineOnly: true, description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, + { + name: "listFilesOnly", + type: "boolean", + category: ts.Diagnostics.Command_line_Options, + affectsSemanticDiagnostics: true, + affectsEmit: true, + isCommandLineOnly: true, + description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing + }, // Basic { name: "target", @@ -25028,6 +25741,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -25123,6 +25842,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -25220,7 +25946,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25450,6 +26177,7 @@ var ts; return { buildOptions: buildOptions, projects: projects, errors: errors }; } ts.parseBuildCommand = parseBuildCommand; + /* @internal */ function getDiagnosticText(_message) { var _args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -25458,104 +26186,7 @@ var ts; var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } - /* @internal */ - function printVersion() { - ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); - } - ts.printVersion = printVersion; - /* @internal */ - function printHelp(optionsList, syntaxPrefix) { - if (syntaxPrefix === void 0) { syntaxPrefix = ""; } - var output = []; - // We want to align our "syntax" and "examples" commands to a certain margin. - var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; - var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; - var marginLength = Math.max(syntaxLength, examplesLength); - // Build up the syntactic skeleton. - var syntax = makePadding(marginLength - syntaxLength); - syntax += "tsc " + syntaxPrefix + "[" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + "...]"; - output.push(getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax)); - output.push(ts.sys.newLine + ts.sys.newLine); - // Build up the list of examples. - var padding = makePadding(marginLength); - output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine); - output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine); - output.push(padding + "tsc @args.txt" + ts.sys.newLine); - output.push(padding + "tsc --build tsconfig.json" + ts.sys.newLine); - output.push(ts.sys.newLine); - output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); - // We want our descriptions to align at the same column in our output, - // so we keep track of the longest option usage string. - marginLength = 0; - var usageColumn = []; // Things like "-d, --declaration" go in here. - var descriptionColumn = []; - var optionsDescriptionMap = ts.createMap(); // Map between option.description and list of option.type if it is a kind - for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) { - var option = optionsList_1[_i]; - // If an option lacks a description, - // it is not officially supported. - if (!option.description) { - continue; - } - var usageText_1 = " "; - if (option.shortName) { - usageText_1 += "-" + option.shortName; - usageText_1 += getParamType(option); - usageText_1 += ", "; - } - usageText_1 += "--" + option.name; - usageText_1 += getParamType(option); - usageColumn.push(usageText_1); - var description = void 0; - if (option.name === "lib") { - description = getDiagnosticText(option.description); - var element = option.element; - var typeMap = element.type; - optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; })); - } - else { - description = getDiagnosticText(option.description); - } - descriptionColumn.push(description); - // Set the new margin for the description column if necessary. - marginLength = Math.max(usageText_1.length, marginLength); - } - // Special case that can't fit in the loop. - var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; - usageColumn.push(usageText); - descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); - marginLength = Math.max(usageText.length, marginLength); - // Print out each row, aligning all the descriptions on the same column. - for (var i = 0; i < usageColumn.length; i++) { - var usage = usageColumn[i]; - var description = descriptionColumn[i]; - var kindsList = optionsDescriptionMap.get(description); - output.push(usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine); - if (kindsList) { - output.push(makePadding(marginLength + 4)); - for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) { - var kind = kindsList_1[_a]; - output.push(kind + " "); - } - output.push(ts.sys.newLine); - } - } - for (var _b = 0, output_1 = output; _b < output_1.length; _b++) { - var line = output_1[_b]; - ts.sys.write(line); - } - return; - function getParamType(option) { - if (option.paramType !== undefined) { - return " " + getDiagnosticText(option.paramType); - } - return ""; - } - function makePadding(paddingLength) { - return Array(paddingLength + 1).join(" "); - } - } - ts.printHelp = printHelp; + ts.getDiagnosticText = getDiagnosticText; /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ @@ -25720,7 +26351,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25776,15 +26407,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25802,13 +26433,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25825,7 +26456,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25874,7 +26505,7 @@ var ts; /** @internal */ function convertToTSConfig(configParseResult, configFileName, host) { var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); + var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs, host)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; @@ -25895,12 +26526,12 @@ var ts; return undefined; return specs; } - function matchesSpecs(path, includeSpecs, excludeSpecs) { + function matchesSpecs(path, includeSpecs, excludeSpecs, host) { if (!includeSpecs) return function (_) { return true; }; - var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); - var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); - var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames); if (includeRe) { if (excludeRe) { return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); }; @@ -26077,6 +26708,35 @@ var ts; } } ts.generateTSConfig = generateTSConfig; + /* @internal */ + function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) { + var result = {}; + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name in options) { + if (ts.hasProperty(options, name)) { + result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); + } + } + if (result.configFilePath) { + result.configFilePath = toAbsolutePath(result.configFilePath); + } + return result; + } + ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; + function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { + if (option) { + if (option.type === "list") { + var values = value; + if (option.element.isFilePath && values.length) { + return values.map(toAbsolutePath); + } + } + else if (option.isFilePath) { + return toAbsolutePath(value); + } + } + return value; + } /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -26107,8 +26767,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -26528,7 +27187,7 @@ var ts; } function normalizeNonListOptionValue(option, basePath, value) { if (option.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + value = ts.getNormalizedAbsolutePath(value, basePath); if (value === "") { value = "."; } @@ -26963,8 +27622,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -27223,7 +27883,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27687,7 +28347,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -28167,35 +28827,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -28214,9 +28906,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -28225,6 +28917,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -28249,7 +28971,11 @@ var ts; ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; })(ContainerFlags || (ContainerFlags = {})); - var flowNodeCreated = ts.identity; + function initFlowNode(node) { + ts.Debug.attachFlowNodeDebugInfo(node); + return node; + } + var flowNodeCreated = initFlowNode; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -28289,7 +29015,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -28313,6 +29039,9 @@ var ts; symbolCount = 0; skipTransformFlagAggregation = file.isDeclarationFile; Symbol = ts.objectAllocator.getSymbolConstructor(); + // Attach debugging information if necessary + ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); + ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { bind(file); file.symbolCount = symbolCount; @@ -28357,7 +29086,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -28384,7 +29113,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -28393,7 +29122,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28405,39 +29134,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 295 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 298 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -28537,7 +29269,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28572,7 +29304,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28596,7 +29328,7 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } @@ -28639,7 +29371,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28665,34 +29397,35 @@ var ts; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isIIFE) { - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; hasExplicitReturn = false; - flowNodeCreated = ts.identity; + flowNodeCreated = initFlowNode; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28709,7 +29442,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28736,8 +29469,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28769,80 +29502,90 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28853,30 +29596,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && - isNarrowableReference(expr.expression); + ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || + ts.isOptionalChain(expr); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -28887,7 +29629,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28901,17 +29643,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28920,11 +29662,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28933,20 +29675,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28961,31 +29697,35 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if ((expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -29000,47 +29740,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -29068,7 +29813,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -29100,15 +29845,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -29130,7 +29875,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -29150,7 +29895,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -29178,7 +29923,7 @@ var ts; // as possible antecedents of the start of the `catch` or `finally` blocks. // Don't bother intercepting the call if there's no finally or catch block that needs the information if (node.catchClause || node.finallyBlock) { - flowNodeCreated = function (node) { return (tryPriors.push(node), node); }; + flowNodeCreated = function (node) { return (tryPriors.push(node), initFlowNode(node)); }; } bind(node.tryBlock); flowNodeCreated = oldFlowNodeCreated; @@ -29242,7 +29987,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = initFlowNode({ flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }); addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -29260,7 +30005,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -29278,9 +30023,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all - // case clauses have unreachable end points (e.g. they all return). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -29308,7 +30054,7 @@ var ts; bind(clause); fallthroughFlow = currentFlow; if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { - errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + clause.fallthroughFlowNode = currentFlow; } } clauses.transformFlags = subtreeTransformFlags | 536870912 /* HasComputedFlags */; @@ -29334,6 +30080,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -29345,14 +30102,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -29363,10 +30120,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -29374,16 +30131,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29391,7 +30148,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29402,7 +30159,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29412,20 +30169,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29439,7 +30196,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29450,7 +30207,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29489,27 +30246,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.kind !== 306 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // an immediately invoked function expression (IIFE). Initialize the flowNode property to - // the current control flow (which includes evaluation of the IIFE arguments). - var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29518,54 +30350,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -29598,45 +30430,45 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 300 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -29663,11 +30495,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29737,7 +30569,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29749,7 +30581,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29781,10 +30613,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29812,7 +30644,7 @@ var ts; var host = ts.getJSDocHost(typeAlias); container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -29820,12 +30652,17 @@ var ts; // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); if (isTopLevel) { - bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; })); + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - container = file; + if (!ts.isExternalOrCommonJsModule(file)) { + container = undefined; + } + else { + container = file; + } break; case 4 /* ThisProperty */: container = declName.parent.expression; @@ -29839,11 +30676,13 @@ var ts; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + if (container) { + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -29861,11 +30700,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */) && - !(node.flags & 2097152 /* JSDoc */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29899,7 +30738,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -29910,7 +30749,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29951,8 +30790,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -29978,7 +30817,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -30047,7 +30886,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -30087,8 +30926,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -30109,7 +30948,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -30122,27 +30961,28 @@ var ts; break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -30170,76 +31010,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 307 /* JSDocClassTag */: + return bindJSDocClassTag(node); + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -30258,65 +31100,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 307 /* JSDocParameterTag */: - if (node.parent.kind === 300 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 299 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 313 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30424,8 +31266,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30435,7 +31276,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30454,41 +31295,53 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + setValueDeclaration(symbol, node); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } - if (constructorSymbol) { + if (constructorSymbol && constructorSymbol.valueDeclaration) { // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -30501,11 +31354,21 @@ var ts; ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30518,11 +31381,14 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + if (namespaceSymbol) { + // Ensure the namespace symbol becomes class-like + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } /** @@ -30538,32 +31404,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30572,9 +31444,9 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; @@ -30591,6 +31463,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30601,20 +31476,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30643,7 +31545,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30660,7 +31562,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30672,7 +31574,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30683,7 +31585,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { + if (node.kind === 244 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -30746,10 +31648,10 @@ var ts; } } function bindParameter(node) { - if (node.kind === 307 /* JSDocParameterTag */ && container.kind !== 300 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30768,9 +31670,9 @@ var ts; } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); @@ -30783,9 +31685,9 @@ var ts; } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30796,8 +31698,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30823,7 +31725,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -30851,11 +31753,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30869,7 +31771,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30899,12 +31801,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30916,7 +31818,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30953,58 +31855,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -31015,6 +31917,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -31026,7 +31931,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31049,17 +31954,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -31102,8 +32010,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31143,11 +32051,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -31338,9 +32246,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31350,9 +32261,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31440,43 +32354,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31484,11 +32398,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31505,103 +32419,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31614,26 +32528,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31651,67 +32565,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31730,7 +32644,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31803,7 +32717,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31886,7 +32800,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -32040,6 +32954,7 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 7] = "ResolvedTypeArguments"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var CheckMode; (function (CheckMode) { @@ -32050,11 +32965,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); var AccessFlags; (function (AccessFlags) { AccessFlags[AccessFlags["None"] = 0] = "None"; @@ -32157,11 +33067,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -32243,8 +33151,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -32310,9 +33221,9 @@ var ts; }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (nodeIn) { + getContextualType: function (nodeIn, contextFlags) { var node = ts.getParseTreeNode(nodeIn, ts.isExpression); - return node ? getContextualType(node) : undefined; + return node ? getContextualType(node, contextFlags) : undefined; }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); @@ -32361,7 +33272,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -32377,6 +33288,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -32395,6 +33309,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -32423,7 +33338,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -32487,6 +33402,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -32516,6 +33432,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -32539,11 +33456,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var iterationTypesCache = ts.createMap(); // cache for common IterationTypes instances var noIterationTypes = { @@ -32636,6 +33553,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32648,13 +33568,13 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -32690,10 +33610,10 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { - return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; + return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText; } } } @@ -32703,7 +33623,7 @@ var ts; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); if (_jsxFactoryEntity) { - _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).escapedText; + _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText; } } else if (compilerOptions.reactNamespace) { @@ -32747,7 +33667,7 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32832,7 +33752,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32961,7 +33885,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32971,7 +33895,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -33020,7 +33944,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -33064,7 +33988,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -33078,17 +34002,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -33111,22 +34035,22 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -33147,16 +34071,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -33177,14 +34101,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -33230,12 +34154,12 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 298 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -33252,13 +34176,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -33273,14 +34197,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -33304,7 +34228,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -33318,12 +34242,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -33340,9 +34264,9 @@ var ts; } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! @@ -33361,7 +34285,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -33369,9 +34293,9 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -33389,9 +34313,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -33399,24 +34323,24 @@ var ts; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -33429,7 +34353,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -33438,7 +34362,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33453,25 +34377,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33491,7 +34415,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33564,7 +34488,7 @@ var ts; } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); @@ -33587,10 +34511,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33603,12 +34527,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33620,7 +34544,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 154 /* TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -33675,10 +34599,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33766,11 +34690,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 244 /* EnumDeclaration */); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33802,13 +34730,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33818,7 +34746,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33883,7 +34811,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33895,7 +34828,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33949,9 +34882,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33986,7 +34920,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -34006,34 +34945,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -34113,17 +35074,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 249 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -34139,17 +35100,17 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { - var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); + if (name.kind === 75 /* Identifier */) { + var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); if (!symbol) { return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -34201,7 +35162,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -34240,6 +35201,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -34251,9 +35226,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -34284,7 +35256,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -34355,7 +35327,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -34364,9 +35336,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -34374,15 +35350,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34456,7 +35433,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34593,7 +35570,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34602,7 +35580,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34610,7 +35599,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34618,20 +35607,29 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { @@ -34644,7 +35642,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34722,25 +35720,55 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals + // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would + // trigger resolving late-bound names, which we may already be in the process of doing while we're here! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } @@ -34777,12 +35805,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34799,7 +35827,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34835,7 +35863,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34850,10 +35878,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34970,14 +35998,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -35020,14 +36048,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -35036,7 +36064,7 @@ var ts; // Type Reference or TypeAlias entity = Identifier meaning = 788968 /* Type */; } - var firstIdentifier = getFirstIdentifier(entityName); + var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { @@ -35076,15 +36104,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -35107,14 +36135,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -35145,6 +36176,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -35155,7 +36189,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -35183,26 +36218,26 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -35222,7 +36257,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -35243,31 +36278,31 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -35281,10 +36316,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -35292,6 +36333,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -35302,12 +36344,6 @@ var ts; ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -35315,7 +36351,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -35379,17 +36415,14 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 111551 /* Value */); @@ -35406,24 +36439,7 @@ var ts; } } else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -35436,15 +36452,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35457,12 +36503,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35475,7 +36521,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35483,7 +36529,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35497,12 +36543,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35597,11 +36643,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35648,7 +36694,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35659,25 +36705,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35688,20 +36738,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35742,7 +36802,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35755,7 +36815,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35766,7 +36826,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35774,23 +36834,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -35810,9 +36873,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 307 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35822,15 +36885,14 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35840,22 +36902,22 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); + var firstIdentifier = ts.getFirstIdentifier(accessExpression); var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); @@ -35863,6 +36925,9 @@ var ts; } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35895,6 +36960,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35975,7 +37047,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -36067,16 +37139,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -36109,6 +37197,9 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -36154,9 +37245,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -36165,6 +37253,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -36192,12 +37283,1104 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + ts.forEachEntry(symbolTable, function (symbol, name) { + var baseName = ts.unescapeLeadingUnderscores(name); + void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` + }); + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && + symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && + symbol.escapedName !== "export=" /* ExportEquals */; + var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); + if (symbol.flags & 16 /* Function */ || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */) + && !isConstMergedWithNSPrintableAsSignatureMerge) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + if (ts.some(symbol.declarations, ts.isParameterDeclaration)) + return; + ts.Debug.assertDefined(deferredPrivates); + getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol); // Call to cache unique name for symbol + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function getNamespaceMembersForSerialization(symbol) { + return !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + } + function isTypeOnlyNamespace(symbol) { + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = getNamespaceMembersForSerialization(symbol); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s); + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + includePrivateSymbol(target || s); + var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName; + return ts.createExportSpecifier(name === targetName ? undefined : targetName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), + // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned + // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag + // In such cases, the `target` refers to the module itself already + ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + case 193 /* PropertyAccessExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + // If the target resolves and resolves to a thing defined in this file, emit as an alias, otherwise emit as a const + if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = ts.getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (symbol) { + input = getNameCandidateWorker(symbol, input); + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getNameCandidateWorker(symbol, localName) { + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; + } + if (localName === "default" /* Default */) { + localName = "_default"; + } + else if (localName === "export=" /* ExportEquals */) { + localName = "_exports"; + } + localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); + return localName; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + localName = getNameCandidateWorker(symbol, localName); + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -36242,8 +38425,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -36251,11 +38434,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -36293,9 +38476,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -36308,17 +38491,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -36335,28 +38521,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -36364,53 +38550,54 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -36419,14 +38606,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { + else if (node.parent.kind === 261 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -36443,9 +38633,11 @@ var ts; if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); + var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36505,6 +38697,8 @@ var ts; return !!target.immediateBaseConstraint; case 6 /* JSDocTypeReference */: return !!getSymbolLinks(target).resolvedJSDocType; + case 7 /* ResolvedTypeArguments */: + return !!target.resolvedTypeArguments; } return ts.Debug.assertNever(propertyName); } @@ -36520,12 +38714,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36558,7 +38752,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36610,7 +38804,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36625,23 +38819,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36659,11 +38853,11 @@ var ts; return parentType; } // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36731,30 +38925,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -36773,8 +38967,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36787,11 +38981,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36858,12 +39052,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36881,6 +39077,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36906,9 +39105,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -37001,9 +39200,9 @@ var ts; var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -37078,7 +39277,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -37101,7 +39300,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -37140,7 +39339,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -37196,22 +39395,26 @@ var ts; // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -37252,12 +39455,15 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -37266,7 +39472,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -37293,33 +39499,43 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { @@ -37329,25 +39545,21 @@ var ts; } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + } } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -37355,19 +39567,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -37379,8 +39582,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -37447,7 +39651,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37528,40 +39732,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: - case 305 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37569,7 +39783,8 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); + ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37578,9 +39793,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37599,19 +39815,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37704,24 +39920,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37759,14 +39969,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37774,7 +39991,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37810,8 +40027,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37832,9 +40049,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37850,7 +40073,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37892,10 +40115,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37903,18 +40126,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37928,10 +40152,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37955,7 +40179,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -38027,23 +40251,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -38069,7 +40293,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -38085,14 +40309,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -38147,9 +40371,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -38243,7 +40470,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -38259,9 +40487,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -38302,6 +40530,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -38312,7 +40555,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -38342,7 +40585,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -38405,12 +40648,12 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } - function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { - var sig = new Signature(checker); + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) { + var sig = new Signature(checker, flags); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; @@ -38418,15 +40661,13 @@ var ts; sig.resolvedReturnType = resolvedReturnType; sig.resolvedTypePredicate = resolvedTypePredicate; sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasLiteralTypes = hasLiteralTypes; sig.target = undefined; sig.mapper = undefined; return sig; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; return result; @@ -38438,13 +40679,22 @@ var ts; result.mapper = undefined; return result; } + function getOptionalCallSignature(signature) { + return signatureIsOptionalCall(signature) ? signature : + (signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature))); + } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.flags |= 4 /* IsOptionalCall */; + return result; + } function getExpandedParameters(sig) { - if (sig.hasRestParameter) { + if (signatureHasRestParameter(sig)) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38464,7 +40714,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38561,7 +40811,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38573,8 +40823,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38628,11 +40878,9 @@ var ts; var params = combineUnionParameters(left, right); var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter); var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); - var hasRestParam = left.hasRestParameter || right.hasRestParameter; - var hasLiteralTypes = left.hasLiteralTypes || right.hasLiteralTypes; var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, hasRestParam, hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 3 /* PropagatingFlags */); result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); return result; } @@ -38699,7 +40947,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38722,19 +40970,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38742,7 +40990,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38798,14 +41046,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38948,8 +41200,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38973,8 +41225,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -39190,11 +41442,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; if (t.flags & 63176704 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). @@ -39204,6 +41456,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -39216,8 +41471,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -39303,8 +41558,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39652,10 +41907,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39689,13 +41944,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; - } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39741,7 +41993,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var hasLiteralTypes = false; + var flags = 0 /* None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -39771,8 +42023,8 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { - hasLiteralTypes = true; + if (type && type.kind === 186 /* LiteralType */) { + flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -39785,22 +42037,24 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); - var hasRestLikeParameter = ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters); + if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { + flags |= 1 /* HasRestParameter */; + } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, - /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, hasRestLikeParameter, hasLiteralTypes); + /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); } return links.resolvedSignature; } @@ -39852,13 +42106,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39901,9 +42155,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39932,13 +42183,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39948,8 +42196,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signatureIsOptionalCall(signature)) { + type = addOptionalTypeMarker(type); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39974,7 +42224,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39984,12 +42234,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -40004,7 +42254,7 @@ var ts; return tryGetRestTypeOfSignature(signature) || anyType; } function tryGetRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType; return restType && getIndexTypeOfType(restType, 1 /* Number */); @@ -40079,7 +42329,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -40093,7 +42343,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -40127,13 +42377,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -40158,7 +42408,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -40182,7 +42432,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -40215,8 +42465,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -40231,7 +42481,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -40240,16 +42490,50 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; + return type; + } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; return type; } + function getTypeArguments(type) { + var _a, _b; + if (!type.resolvedTypeArguments) { + if (!pushTypeResolution(type, 7 /* ResolvedTypeArguments */)) { + return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; + } + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + if (popTypeResolution()) { + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + else { + type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray; + error(type.node || currentNode, type.target.symbol + ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves + : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol)); + } + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -40259,13 +42543,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -40273,10 +42557,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -40297,27 +42584,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -40335,13 +42622,15 @@ var ts; return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -40350,56 +42639,44 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSDocValueReference(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value, but resolve it as a type anyway. + * Note: If the value is imported from commonjs, it should really be an alias, + * but this function's special-case code fakes alias resolution as well. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + function getTypeFromJSDocValueReference(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType; + if (symbol.valueDeclaration) { + var decl = ts.getRootDeclaration(symbol.valueDeclaration); + var isRequireAlias = false; + if (ts.isVariableDeclaration(decl) && decl.initializer) { + var expr = decl.initializer; + // skip past entity names, eg `require("x").a.b.c` + while (ts.isPropertyAccessExpression(expr)) { + expr = expr.expression; } + isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol; } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); + var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol; + if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) { + typeType = getTypeReferenceType(node, valueType.symbol); } } + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } function getSubstitutionType(typeVariable, substitute) { if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === typeVariable) { @@ -40417,7 +42694,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -40426,9 +42703,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 298 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40439,7 +42716,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40476,10 +42753,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40491,7 +42768,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40549,9 +42826,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40670,15 +42947,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40715,7 +43032,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40749,27 +43066,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; - var elementTypes = ts.map(node.elementTypes, function (n) { - var type = getTypeFromTypeNode(n); - return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40818,8 +43121,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40848,8 +43151,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40934,10 +43237,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40956,14 +43259,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -41030,8 +43329,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -41306,21 +43605,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - // tslint:disable no-unnecessary-type-assertion - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -41356,7 +43656,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -41367,13 +43667,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41504,13 +43804,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41635,7 +43932,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41847,7 +44144,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41870,11 +44167,11 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { var errorMessage = targetMeaning === 111551 /* Value */ @@ -41886,16 +44183,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; if (meaning === 111551 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41919,7 +44216,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 137 /* ReadonlyKeyword */) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -42108,12 +44409,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -42126,89 +44441,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -42297,20 +44612,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -42330,7 +44632,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 3 /* PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -42364,17 +44666,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -42390,7 +44692,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -42403,13 +44705,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -42417,9 +44720,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 184 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -42428,7 +44731,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -42437,12 +44740,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42496,7 +44799,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42592,15 +44895,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42664,35 +44970,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42712,7 +45018,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -42724,7 +45030,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42827,23 +45133,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -43015,7 +45321,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -43024,9 +45330,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -43168,11 +45474,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -43207,20 +45513,20 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` */ function isAnySignature(s) { return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 && - s.hasRestParameter && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && + signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && isTypeAny(getReturnTypeOfSignature(s)); } /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -43244,8 +45550,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -43278,11 +45584,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is - compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -43293,15 +45599,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol)) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol)) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43322,6 +45630,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -43334,7 +45645,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -43343,7 +45654,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -43389,12 +45702,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -43405,7 +45718,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43482,9 +45795,9 @@ var ts; return true; } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, relation)); + var related = relation.get(getRelationKey(source, target, /*isIntersectionConstituent*/ false, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43516,9 +45829,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43561,8 +45879,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43575,6 +46016,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43593,8 +46036,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43716,14 +46159,14 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); var isIntersectionConstituent = !!isApparentIntersectionConstituent; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { @@ -43761,15 +46204,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -43779,21 +46222,30 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43813,6 +46265,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43849,7 +46302,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43864,6 +46317,11 @@ var ts; // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43892,9 +46350,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -44030,14 +46488,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { + function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); if (related) { return related; } @@ -44116,17 +46574,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -44136,25 +46583,25 @@ var ts; if (overflow) { return 0 /* False */; } - var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var id = getRelationKey(source, target, isIntersectionConstituent, relation); + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -44185,14 +46632,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -44200,7 +46659,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -44240,7 +46699,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. @@ -44330,7 +46789,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44341,7 +46800,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44350,25 +46809,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44377,13 +46836,23 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44392,14 +46861,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44413,7 +46882,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44432,7 +46901,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -44459,7 +46928,7 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); @@ -44474,7 +46943,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44505,7 +46974,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44533,7 +47002,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44609,11 +47078,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44629,8 +47098,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44643,9 +47112,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -44770,7 +47239,7 @@ var ts; var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44810,8 +47279,8 @@ var ts; if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44821,8 +47290,8 @@ var ts; else { reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44834,7 +47303,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44859,8 +47328,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44874,10 +47344,12 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { @@ -44942,14 +47414,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44963,7 +47436,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44972,10 +47445,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44988,11 +47461,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -45058,7 +47543,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -45190,7 +47675,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -45222,7 +47707,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -45248,8 +47733,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -45258,7 +47746,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -45281,17 +47769,18 @@ var ts; * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. * For other cases, the types ids are used. */ - function getRelationKey(source, target, relation) { + function getRelationKey(source, target, isIntersectionConstituent, relation) { if (relation === identityRelation && source.id > target.id) { var temp = source; source = target; target = temp; } + var intersection = isIntersectionConstituent ? "&" : ""; if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { var typeParameters = []; - return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + intersection; } - return source.id + "," + target.id; + return source.id + "," + target.id + intersection; } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. @@ -45487,20 +47976,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45539,7 +48030,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45547,7 +48038,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45631,7 +48122,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45646,8 +48137,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45712,6 +48203,23 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function isNotOptionalTypeMarker(type) { + return type !== optionalType; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function getOptionalExpressionType(exprType, expression) { + return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) : + ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : + exprType; + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45741,8 +48249,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45894,7 +48402,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45931,7 +48439,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45961,12 +48469,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -45981,23 +48489,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -46011,7 +48519,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -46053,8 +48561,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -46123,6 +48630,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -46132,7 +48645,7 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); @@ -46201,10 +48714,10 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames); @@ -46340,10 +48853,7 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; - inferFromTypes(source, target); - priority = savePriority; + inferWithPriority(source, target, 1 /* NakedTypeVariable */); return; } source = getUnionType(sources); @@ -46430,9 +48940,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -46442,10 +48953,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - var savePriority = priority; - priority |= 32 /* LiteralKeyof */; - inferFromTypes(empty, target.type); - priority = savePriority; + inferWithPriority(empty, target.type, 32 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -46497,6 +49005,12 @@ var ts; } } } + function inferWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromTypes(source, target); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -46562,6 +49076,18 @@ var ts; } return undefined; } + function getSingleTypeVariableFromIntersectionTypes(types) { + var typeVariable; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var type = types_13[_i]; + var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + if (!t || typeVariable && t !== typeVariable) { + return undefined; + } + typeVariable = t; + } + return typeVariable; + } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; if (targetFlags & 1048576 /* Union */) { @@ -46591,6 +49117,16 @@ var ts; } } } + if (typeVariableCount === 0) { + // If every target is an intersection of types containing a single naked type variable, + // make a lower priority inference to that type variable. This handles inferring from + // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. + var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); + if (intersectionTypeVariable) { + inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + } + return; + } // If the target has a single naked type variable and no inference circularities were // encountered above (meaning we explored the types fully), create a union of the source // types from which no inferences have been made so far and infer from that union to the @@ -46622,15 +49158,12 @@ var ts; // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferFromTypes(source, t); + inferWithPriority(source, t, 1 /* NakedTypeVariable */); } } - priority = savePriority; } } function inferToMappedType(source, target, constraintType) { @@ -46651,14 +49184,12 @@ var ts; if (inference && !inference.isFixed) { var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); if (inferredType) { - var savePriority = priority; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - priority |= ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? - 4 /* PartialHomomorphicMappedType */ : 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? + 4 /* PartialHomomorphicMappedType */ : + 2 /* HomomorphicMappedType */); } } return true; @@ -46666,10 +49197,7 @@ var ts; if (constraintType.flags & 262144 /* TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - var savePriority = priority; - priority |= 8 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; + inferWithPriority(getIndexType(source), constraintType, 8 /* MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -46711,6 +49239,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer // from S to T and from X to Y. @@ -46740,10 +49273,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46783,7 +49316,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46953,7 +49486,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46974,7 +49507,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -46984,16 +49517,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -47004,24 +49537,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -47029,8 +49562,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -47042,6 +49575,15 @@ var ts; } return false; } + function optionalChainContainsReference(source, target) { + while (ts.isOptionalChain(source)) { + source = source.expression; + if (isMatchingReference(source, target)) { + return true; + } + } + return false; + } // Return true if target is a property access xxx.yyy, source is a property access xxx.zzz, the declared // type of xxx is a union type, and yyy is a property that is possibly a discriminant. We consider a property // a possible discriminant if its type differs in the constituents of containing union type, and if every @@ -47054,7 +49596,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -47085,7 +49627,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -47113,14 +49655,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -47162,8 +49704,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -47268,15 +49810,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -47293,21 +49835,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -47315,7 +49857,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -47333,37 +49875,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -47373,13 +49910,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -47401,8 +49938,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -47485,8 +50022,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47538,8 +50074,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47562,33 +50098,94 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = void 0; + if (node.parent.kind === 225 /* ExpressionStatement */) { + funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); + } + else if (node.expression.kind !== 101 /* SuperKeyword */) { + if (ts.isOptionalChain(node)) { + funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); + } + else { + funcType = checkNonNullExpression(node.expression); + } + } + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + } + function getTypePredicateArgument(predicate, callExpression) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + return callExpression.arguments[predicate.parameterIndex]; + } + var invokedExpression = ts.skipParentheses(callExpression.expression); + return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined; } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47596,6 +50193,82 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isFalseExpression(expr) { + var node = ts.skipParentheses(expr); + return node.kind === 90 /* FalseKeyword */ || node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && predicate.kind === 3 /* AssertsIdentifier */) { + var predicateArgument = flow.node.arguments[predicate.parameterIndex]; + if (predicateArgument && isFalseExpression(predicateArgument)) { + return false; + } + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47607,6 +50280,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47615,7 +50289,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47637,16 +50311,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47658,13 +50323,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47676,14 +50341,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47710,11 +50373,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47726,7 +50389,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47736,11 +50399,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47749,11 +50435,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47762,27 +50448,63 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 90 /* FalseKeyword */) { + return unreachableNeverType; + } + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47790,7 +50512,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47825,7 +50547,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47840,14 +50562,27 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); - } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (containsMatchingReferenceDiscriminant(reference, expr)) { - type = declaredType; + else { + if (strictNullChecks) { + if (optionalChainContainsReference(expr, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + } + else if (expr.kind === 203 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + } + } + if (isMatchingReferenceDiscriminant(expr, type)) { + type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + } + else if (containsMatchingReferenceDiscriminant(reference, expr)) { + type = declaredType; + } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } } return createFlowType(type, isIncomplete(flowType)); } @@ -47857,7 +50592,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47917,25 +50652,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47982,6 +50724,9 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } + if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { + type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } if (isMatchingReferenceDiscriminant(expr, declaredType)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } @@ -48009,19 +50754,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -48030,6 +50775,14 @@ var ts; if (isMatchingReference(reference, right_1)) { return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); } + if (strictNullChecks) { + if (optionalChainContainsReference(left_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + } + else if (optionalChainContainsReference(right_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + } + } if (isMatchingReferenceDiscriminant(left_1, declaredType)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } @@ -48040,9 +50793,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -48053,15 +50806,24 @@ var ts; } return type; } + function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { + // We are in a branch of obj?.foo === value or obj?.foo !== value. We remove undefined and null from + // the type of obj if (a) the operator is === and the type of value doesn't include undefined or (b) the + // operator is !== and the type of value is undefined. + var effectiveTrue = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */ ? assumeTrue : !assumeTrue; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var valueNonNullish = !(getTypeFacts(getTypeOfExpression(value)) & (doubleEquals ? 262144 /* EQUndefinedOrNull */ : 65536 /* EQUndefined */)); + return effectiveTrue === valueNonNullish ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeByEquality(type, operator, value, assumeTrue) { if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -48074,7 +50836,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -48086,7 +50848,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -48099,9 +50861,15 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + assumeTrue = !assumeTrue; + } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { + if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the // narrowed type of 'y' to its declared type. if (containsMatchingReference(reference, target)) { @@ -48109,9 +50877,6 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { - assumeTrue = !assumeTrue; - } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } @@ -48144,6 +50909,10 @@ var ts; return type; } } + function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { + var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify // values with unit types, except for the case where @@ -48276,6 +51045,9 @@ var ts; function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { + if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the // narrowed type of 'y' to its declared type. We do this because preceding 'x.y' // references might reference a different 'y' property. However, we make an exception @@ -48336,38 +51108,29 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' - if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { - return type; - } - if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) { + var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } - if (containsMatchingReference(reference, predicateArgument)) { - return declaredType; - } - } - } - else { - var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { - var possibleReference = ts.skipParentheses(invokedExpression.expression); - if (isMatchingReference(reference, possibleReference)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && + !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (containsMatchingReference(reference, possibleReference)) { + if (containsMatchingReference(reference, predicateArgument)) { return declaredType; } } @@ -48377,27 +51140,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isExpressionOfOptionalChainRoot(expr) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -48405,7 +51185,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -48426,9 +51206,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -48447,10 +51227,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -48465,7 +51245,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -48473,10 +51253,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48513,7 +51293,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -48534,7 +51314,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48546,14 +51326,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48602,7 +51382,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48611,8 +51391,8 @@ var ts; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48620,11 +51400,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48658,7 +51438,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48681,7 +51461,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48699,8 +51479,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48718,7 +51498,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48726,9 +51506,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48739,7 +51519,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48807,37 +51587,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 158 /* Constructor */: + case 161 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48876,10 +51656,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48887,12 +51665,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48921,9 +51697,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48933,16 +51722,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48950,7 +51739,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -48975,7 +51764,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48989,15 +51778,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -49010,14 +51799,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -49025,7 +51814,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -49094,7 +51883,7 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -49108,7 +51897,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -49129,7 +51918,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; @@ -49144,7 +51933,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -49152,21 +51941,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -49174,14 +51963,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -49189,7 +51978,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -49216,7 +52005,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -49230,9 +52019,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -49296,9 +52085,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -49413,22 +52202,26 @@ var ts; return undefined; } // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. - function getContextualTypeForArgument(callTarget, arg) { + function getContextualTypeForArgument(callTarget, arg, contextFlags) { var args = getEffectiveCallArguments(callTarget); var argIndex = args.indexOf(arg); // -1 for e.g. the expression of a CallExpression, or the tag of a TaggedTemplateExpression - return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); + return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags); } - function getContextualTypeForArgumentAtIndex(callTarget, argIndex) { + function getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags) { // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } + if (contextFlags && contextFlags & 4 /* Completion */ && signature.target) { + var baseSignature = getBaseSignature(signature.target); + return intersectTypes(getTypeAtPosition(signature, argIndex), getTypeAtPosition(baseSignature, argIndex)); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -49437,7 +52230,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -49446,7 +52239,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -49455,7 +52249,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -49483,7 +52277,7 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); @@ -49494,8 +52288,11 @@ var ts; if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49517,12 +52314,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49566,7 +52364,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49655,25 +52453,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 279 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 271 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -49682,7 +52480,7 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { @@ -49750,7 +52548,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49759,58 +52557,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: - return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* NewExpression */: + return getContextualTypeForArgument(parent, node, contextFlags); + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49965,7 +52763,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49979,7 +52777,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -49993,8 +52791,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -50024,8 +52822,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -50037,7 +52835,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -50062,12 +52860,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -50109,9 +52907,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -50199,7 +52997,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -50214,13 +53012,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -50243,8 +53041,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -50269,7 +53067,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -50295,7 +53093,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -50355,7 +53153,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -50403,7 +53207,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -50448,7 +53252,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -50471,7 +53275,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -50890,7 +53694,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50985,32 +53789,43 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); } - function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + function checkNonNullExpression(node) { + return checkNonNullType(checkExpression(node), node); + } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; + } + function reportObjectPossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); } - function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); + } + function checkNonNullTypeWithReporter(type, node, reportError) { if (strictNullChecks && type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? - (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : - (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : - (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); + reportError(node, kind); var t = getNonNullableType(type); return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } + function checkNonNullType(type, node) { + return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError); + } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); if (nonNullType !== errorType && nonNullType.flags & 16384 /* Void */) { @@ -51019,20 +53834,24 @@ var ts; return nonNullType; } function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + } + function checkPropertyAccessChain(node) { + var leftType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(leftType, node.expression); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType); } function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -51046,6 +53865,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -51073,9 +53893,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -51091,7 +53911,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -51101,11 +53921,11 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -51136,9 +53956,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -51149,22 +53969,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -51204,7 +54024,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -51337,16 +54157,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -51363,13 +54183,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -51386,13 +54206,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -51406,28 +54226,22 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + } + function checkElementAccessChain(node) { + var exprType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(exprType, node.expression); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType); + } + function checkElementAccessExpression(node, exprType) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -51482,13 +54296,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51507,7 +54321,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51515,8 +54329,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51537,7 +54351,7 @@ var ts; lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless // of the cutoff position; see GH#1133 - if (signature.hasLiteralTypes) { + if (signatureHasLiteralTypes(signature)) { specializedIndex++; spliceIndex = specializedIndex; // The cutoff index always needs to be greater than or equal to the specialized signature index @@ -51548,11 +54362,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51566,9 +54380,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -51583,7 +54397,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51598,7 +54412,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51691,7 +54505,7 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51721,7 +54535,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51734,7 +54548,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51758,7 +54572,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51838,12 +54652,24 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + var thisArgumentType = void 0; + if (thisArgumentNode) { + thisArgumentType = checkExpression(thisArgumentNode); + if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { + thisArgumentType = getNonNullableType(thisArgumentType); + } + else if (ts.isOptionalChain(thisArgumentNode.parent)) { + thisArgumentType = removeOptionalTypeMarker(thisArgumentType); + } + } + else { + thisArgumentType = voidType; + } var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -51856,7 +54682,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51897,15 +54723,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51915,17 +54741,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51940,7 +54766,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51955,30 +54781,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 152 /* Parameter */: + case 155 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51992,17 +54818,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -52040,8 +54866,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -52070,7 +54896,7 @@ var ts; if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(getFirstIdentifier(paramDecl.name)) : undefined); + related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); } } if (min < argCount && argCount < max) { @@ -52110,8 +54936,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -52126,22 +54952,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -52190,7 +55016,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -52243,7 +55069,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -52261,7 +55087,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -52395,35 +55221,35 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { - var symbols = ts.mapDefined(candidates, function (_a) { - var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; - return hasRestParameter ? - i < parameters.length - 1 ? parameters[i] : ts.last(parameters) : - i < parameters.length ? parameters[i] : undefined; - }); + var _loop_15 = function (i) { + var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? + i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : + i < s.parameters.length ? s.parameters[i] : undefined; }); ts.Debug.assert(symbols.length !== 0); parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } - var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); - var hasRestParameter = restParameterSymbols.length !== 0; - if (hasRestParameter) { + var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); + var flags = 0 /* None */; + if (restParameterSymbols.length !== 0) { var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); + flags |= 1 /* HasRestParameter */; + } + if (candidates.some(signatureHasLiteralTypes)) { + flags |= 2 /* HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. thisParameter, parameters, /*resolvedReturnType*/ getIntersectionType(candidates.map(getReturnTypeOfSignature)), - /*typePredicate*/ undefined, minArgumentCount, hasRestParameter, - /*hasLiteralTypes*/ candidates.some(function (c) { return c.hasLiteralTypes; })); + /*typePredicate*/ undefined, minArgumentCount, flags); } function getNumNonRestParameters(signature) { var numParams = signature.parameters.length; - return signature.hasRestParameter ? numParams - 1 : numParams; + return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); @@ -52484,7 +55310,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -52499,12 +55325,22 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var isOptional; + var funcType = checkExpression(node.expression); + if (ts.isCallChain(node)) { + var nonOptionalType = getOptionalExpressionType(funcType, node.expression); + isOptional = nonOptionalType !== funcType; + funcType = nonOptionalType; + } + else { + isOptional = false; + } + funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52570,7 +55406,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52633,7 +55469,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52641,7 +55477,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52726,8 +55562,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var constituent = types_14[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var constituent = types_17[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52818,23 +55654,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52871,7 +55707,7 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); @@ -52880,15 +55716,13 @@ var ts; // file would probably be preferable. var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, - /*hasRestparameter*/ false, - /*hasLiteralTypes*/ false); + /*returnTypePredicate*/ undefined, 1, 0 /* None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -52911,7 +55745,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52921,22 +55755,22 @@ var ts; function isPotentiallyUncalledDecorator(decorator, signatures) { return signatures.length && ts.every(signatures, function (signature) { return signature.minArgumentCount === 0 && - !signature.hasRestParameter && + !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52987,57 +55821,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -53052,15 +55881,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -53080,18 +55909,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -53129,7 +55968,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -53177,19 +56016,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -53204,20 +56044,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -53253,10 +56093,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -53267,7 +56107,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -53281,7 +56121,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -53296,7 +56136,7 @@ var ts; return type; } function getParameterNameAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return signature.parameters[pos].escapedName; } @@ -53313,17 +56153,17 @@ var ts; return tryGetTypeAtPosition(signature, pos) || anyType; } function tryGetTypeAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return getTypeOfParameter(signature.parameters[pos]); } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // We want to return the value undefined for an out of bounds parameter position, // so we need to check bounds here before calling getIndexedAccessType (which // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -53352,16 +56192,16 @@ var ts; } function getParameterCount(signature) { var length = signature.parameters.length; - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; } function getMinArgumentCount(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { var minLength = restType.target.minLength; @@ -53373,14 +56213,14 @@ var ts; return signature.minArgumentCount; } function hasEffectiveRestParameter(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return !isTupleType(restType) || restType.target.hasRestElement; } return false; } function getEffectiveRestType(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType; } @@ -53397,7 +56237,7 @@ var ts; return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType; } function inferFromAnnotatedParameters(signature, context, inferenceContext) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -53430,7 +56270,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter)); } } - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53438,7 +56278,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53453,7 +56293,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -53467,7 +56307,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); @@ -53522,7 +56362,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53705,10 +56545,11 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); @@ -53728,13 +56569,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53774,11 +56609,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53804,10 +56639,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53837,7 +56672,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53848,7 +56683,7 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); returnOnlyType.objectFlags |= 1048576 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; @@ -53857,7 +56692,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53911,7 +56746,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53924,7 +56759,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -54005,11 +56840,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -54022,31 +56857,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -54068,14 +56907,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -54102,14 +56941,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -54117,32 +56956,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54156,7 +56995,7 @@ var ts; var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54177,8 +57016,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -54267,7 +57106,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -54280,9 +57119,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -54325,8 +57164,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -54344,7 +57183,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -54360,7 +57199,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -54376,24 +57215,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - if (checkReferenceExpression(target, error)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -54409,53 +57251,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -54467,15 +57309,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -54483,28 +57337,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54531,17 +57385,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54549,8 +57403,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54583,24 +57437,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54609,25 +57463,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54654,6 +57512,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54671,7 +57532,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54686,15 +57547,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54707,7 +57568,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54741,17 +57602,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; + } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54759,12 +57626,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54773,6 +57640,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54791,7 +57669,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54862,7 +57740,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -54901,12 +57779,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54928,10 +57806,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54983,7 +57861,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54994,7 +57872,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -55006,8 +57884,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -55137,11 +58015,22 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var isOptional = void 0; + var funcType = void 0; + if (ts.isCallChain(expr)) { + funcType = checkExpression(expr.expression); + var nonOptionalType = getOptionalExpressionType(funcType, expr.expression); + isOptional = funcType !== nonOptionalType; + funcType = checkNonNullType(nonOptionalType, expr.expression); + } + else { + isOptional = false; + funcType = checkNonNullExpression(expr.expression); + } var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -55187,18 +58076,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 258 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // We allow reexporting const enums + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -55216,20 +58105,20 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -55240,82 +58129,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -55352,7 +58241,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -55363,10 +58252,10 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -55390,18 +58279,20 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { if (typePredicate.parameterIndex >= 0) { - if (signature.hasRestParameter && typePredicate.parameterIndex === signature.parameters.length - 1) { + if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -55422,13 +58313,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -55442,11 +58333,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -55455,13 +58346,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -55491,10 +58382,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55524,7 +58415,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -55534,7 +58425,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { @@ -55549,16 +58440,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: addName(names, name, memberName, 8 /* Method */); break; } @@ -55621,7 +58512,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55629,7 +58520,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55646,7 +58537,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -55666,7 +58557,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55674,7 +58565,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55701,7 +58592,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55726,7 +58617,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55754,9 +58645,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55781,9 +58672,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55791,13 +58682,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55815,7 +58706,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55863,19 +58754,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55911,16 +58799,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55941,7 +58829,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -55992,7 +58880,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -56003,16 +58891,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -56102,7 +58990,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -56141,8 +59029,8 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -56153,10 +59041,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -56217,8 +59105,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -56287,41 +59175,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -56355,7 +59244,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -56551,7 +59440,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -56570,7 +59459,7 @@ var ts; return; } // Verify there is no local declaration that could collide with the promise constructor. - var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); @@ -56590,24 +59479,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56627,8 +59516,8 @@ var ts; function markEntityNameOrEntityExpressionAsReference(typeName) { if (!typeName) return; - var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var rootName = ts.getFirstIdentifier(typeName); + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56653,29 +59542,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var typeNode = types_16[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -56721,14 +59610,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56737,23 +59626,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56816,7 +59705,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 149 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56849,9 +59738,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56864,7 +59753,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56880,7 +59769,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56893,7 +59782,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56919,7 +59808,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56935,42 +59824,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56990,11 +59879,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -57003,7 +59892,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -57011,8 +59900,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -57039,7 +59928,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -57074,7 +59963,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -57124,7 +60013,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -57142,7 +60031,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -57163,7 +60052,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -57175,24 +60064,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -57209,7 +60098,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -57222,21 +60111,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -57246,7 +60135,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -57261,7 +60150,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -57287,7 +60176,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57302,7 +60191,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57337,7 +60226,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -57349,17 +60238,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -57389,18 +60278,18 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -57414,26 +60303,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -57470,7 +60359,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -57496,10 +60385,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -57508,7 +60397,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57518,8 +60407,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57556,13 +60445,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57585,12 +60517,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57624,14 +60556,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -57639,7 +60571,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57663,7 +60595,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -57677,7 +60609,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -57685,7 +60617,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -58038,7 +60970,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -58050,7 +60982,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58129,7 +61061,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -58140,7 +61072,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58176,11 +61108,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -58244,11 +61176,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -58341,12 +61275,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -58364,7 +61298,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -58372,7 +61306,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -58393,19 +61327,16 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -58422,6 +61353,9 @@ var ts; } } ts.forEach(clause.statements, checkSourceElement); + if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) { + error(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } }); if (node.caseBlock.locals) { registerForUnusedIdentifiersCheck(node.caseBlock); @@ -58434,7 +61368,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58541,8 +61475,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58619,7 +61553,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58719,7 +61653,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58732,11 +61666,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58774,12 +61709,9 @@ var ts; } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify - // that all instantiated base constructor signatures return the same type. We can simply compare the type - // references (as opposed to checking the structure of the types) because elsewhere we have already checked - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58822,7 +61754,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58841,7 +61773,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58867,7 +61799,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58918,7 +61850,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 210 /* ClassExpression */) { + if (derivedClassDecl.kind === 213 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -58933,17 +61865,55 @@ var ts; // either base or derived property is private - not override, skip it continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment + continue; + } + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; + } + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } + } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + // method is overridden with method or property -- correct case + continue; + } + else { + ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } else if (base.flags & 98304 /* Accessor */) { @@ -58989,12 +61959,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -59009,7 +61982,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -59033,7 +62006,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -59096,7 +62069,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -59128,7 +62101,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -59138,66 +62111,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 50 /* BarToken */: return left | right; - case 49 /* AmpersandToken */: return left & right; - case 47 /* GreaterThanGreaterThanToken */: return left >> right; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 46 /* LessThanLessThanToken */: return left << right; - case 51 /* CaretToken */: return left ^ right; - case 40 /* AsteriskToken */: return left * right; - case 42 /* SlashToken */: return left / right; - case 38 /* PlusToken */: return left + right; - case 39 /* MinusToken */: return left - right; - case 43 /* PercentToken */: return left % right; - case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -59222,10 +62194,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -59259,7 +62231,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -59282,9 +62254,9 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -59307,7 +62279,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -59346,7 +62318,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -59396,23 +62368,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -59423,12 +62395,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -59447,19 +62419,22 @@ var ts; break; } } - function getFirstIdentifier(node) { + function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -59473,9 +62448,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -59505,20 +62480,21 @@ var ts; // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). + symbol = getMergedSymbol(symbol.exportSymbol || symbol); var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 258 /* ExportSpecifier */ + && node.kind === 261 /* ExportSpecifier */ && !(target.flags & 111551 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59543,7 +62519,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59567,12 +62543,12 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name - var moduleName = getFirstIdentifier(node.moduleReference); + var moduleName = ts.getFirstIdentifier(node.moduleReference); if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } @@ -59583,7 +62559,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59603,10 +62579,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59623,7 +62599,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59639,7 +62615,7 @@ var ts; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { @@ -59656,8 +62632,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59670,7 +62646,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -59690,10 +62666,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59719,9 +62695,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59771,159 +62747,162 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 307 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 299 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -60018,23 +62997,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -60063,7 +63042,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -60149,7 +63128,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -60164,26 +63143,26 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -60192,7 +63171,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -60234,17 +63213,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -60252,16 +63231,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -60289,13 +63268,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -60321,7 +63300,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -60331,7 +63310,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -60339,7 +63318,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -60349,7 +63328,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -60367,7 +63346,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -60383,10 +63362,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 307 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 311 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -60396,19 +63375,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -60418,22 +63397,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -60447,12 +63426,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -60462,11 +63441,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -60478,14 +63457,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -60496,7 +63475,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -60513,21 +63492,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -60539,7 +63518,7 @@ var ts; resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60595,27 +63574,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60654,17 +63633,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60716,7 +63694,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60772,7 +63750,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -60800,7 +63778,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60831,7 +63809,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60872,26 +63850,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60992,15 +63969,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -61085,7 +64062,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -61104,7 +64081,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61112,7 +64089,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61236,12 +64213,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -61254,10 +64231,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -61269,7 +64255,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -61320,7 +64306,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -61348,12 +64334,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -61486,7 +64472,7 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; @@ -61495,7 +64481,7 @@ var ts; var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61542,14 +64528,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -61566,23 +64552,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61596,11 +64582,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61609,7 +64595,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61619,10 +64605,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61631,18 +64617,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61655,52 +64641,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 126 /* DeclareKeyword */: + case 129 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61712,14 +64698,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61727,7 +64713,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61742,13 +64728,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61769,38 +64755,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61812,10 +64798,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61844,7 +64830,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61930,15 +64916,15 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); } - if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -61962,11 +64948,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61996,7 +64988,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -62009,7 +65001,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -62025,14 +65017,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -62043,21 +65035,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -62075,7 +65067,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -62086,21 +65078,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { - // tslint:disable no-unnecessary-type-assertion + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -62115,10 +65107,10 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -62126,13 +65118,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -62169,7 +65161,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -62179,7 +65171,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -62193,14 +65185,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -62211,7 +65203,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -62226,20 +65218,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -62249,7 +65241,7 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 4194304 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */)) { if (languageVersion < 1 /* ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -62264,11 +65256,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 159 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -62290,23 +65282,23 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -62316,13 +65308,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -62331,9 +65323,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -62346,10 +65338,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -62372,17 +65364,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -62393,11 +65385,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -62405,8 +65397,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -62421,13 +65413,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -62450,13 +65442,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -62469,7 +65461,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -62486,8 +65478,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -62499,11 +65491,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -62516,7 +65508,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62533,8 +65525,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62561,15 +65553,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62587,12 +65579,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -62650,7 +65642,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62658,7 +65650,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62666,11 +65658,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62687,13 +65679,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62702,7 +65694,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62711,10 +65703,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -62725,7 +65717,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62747,20 +65739,39 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62796,7 +65807,7 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd); } if (node.typeArguments) { return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); @@ -62820,14 +65831,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62835,21 +65846,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62859,7 +65869,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62868,6 +65877,18 @@ var ts; case 2 /* Next */: return "nextType"; } } + function signatureHasRestParameter(s) { + return !!(s.flags & 1 /* HasRestParameter */); + } + ts.signatureHasRestParameter = signatureHasRestParameter; + function signatureHasLiteralTypes(s) { + return !!(s.flags & 2 /* HasLiteralTypes */); + } + ts.signatureHasLiteralTypes = signatureHasLiteralTypes; + function signatureIsOptionalCall(s) { + return !!(s.flags & 4 /* IsOptionalCall */); + } + ts.signatureIsOptionalCall = signatureIsOptionalCall; })(ts || (ts = {})); var ts; (function (ts) { @@ -62930,6 +65951,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62977,7 +65999,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -63058,23 +66080,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -63085,44 +66107,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -63141,7 +66163,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -63154,7 +66176,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -63170,7 +66192,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -63194,7 +66216,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63207,7 +66229,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -63227,12 +66249,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -63242,8 +66264,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -63251,7 +66273,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -63268,7 +66290,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63281,6 +66303,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -63296,7 +66350,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -63316,7 +66370,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63339,7 +66393,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63360,7 +66414,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -63368,7 +66422,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -63376,7 +66430,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -63416,21 +66470,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -63444,7 +66508,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -63452,7 +66516,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -63460,7 +66524,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -63472,7 +66536,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -63484,7 +66548,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -63496,7 +66560,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -63508,7 +66572,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -63520,7 +66584,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63532,7 +66596,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63540,7 +66604,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63559,7 +66623,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63577,7 +66641,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63589,7 +66653,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63607,7 +66671,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63619,12 +66683,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63634,7 +66698,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63648,7 +66712,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63666,7 +66730,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63679,7 +66743,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63691,7 +66755,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63703,7 +66767,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63722,7 +66786,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63736,7 +66800,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63750,7 +66814,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63758,6 +66822,9 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + if (ts.isOptionalChain(node)) { + return updatePropertyAccessChain(node, expression, node.questionDotToken, name); + } // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63766,22 +66833,64 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + if (ts.isOptionalChain(node)) { + return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression); + } return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63789,6 +66898,9 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + if (ts.isOptionalChain(node)) { + return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray); + } return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63796,8 +66908,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63813,7 +66945,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63836,7 +66968,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63850,7 +66982,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63862,7 +66994,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63886,12 +67018,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63908,7 +67040,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63920,7 +67052,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63932,7 +67064,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63944,7 +67076,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63956,7 +67088,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63969,7 +67101,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63982,7 +67114,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63999,11 +67131,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -64019,7 +67151,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -64043,11 +67175,9 @@ var ts; rawTextScanner.setText("`" + rawText + "`"); break; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; case 17 /* TemplateTail */: @@ -64118,9 +67248,9 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -64132,7 +67262,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64144,7 +67274,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64165,11 +67295,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -64183,7 +67313,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -64197,7 +67327,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -64209,7 +67339,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -64223,7 +67353,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -64237,12 +67367,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -64256,7 +67386,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -64271,11 +67401,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -64291,7 +67421,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -64307,7 +67437,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -64321,7 +67451,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64335,7 +67465,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -64353,7 +67483,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -64369,10 +67499,10 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; - node.expression = expression; + node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression; node.statement = asEmbeddedStatement(statement); return node; } @@ -64387,7 +67517,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -64399,7 +67529,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -64411,7 +67541,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -64423,7 +67553,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64437,7 +67567,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -64451,7 +67581,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -64465,7 +67595,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -64477,7 +67607,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -64493,11 +67623,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -64514,7 +67644,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -64527,7 +67657,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -64553,7 +67683,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64575,7 +67705,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64597,7 +67727,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64617,7 +67747,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64636,8 +67766,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64655,7 +67785,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64667,7 +67797,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64679,7 +67809,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64691,7 +67821,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64709,7 +67839,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64727,7 +67857,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64741,7 +67871,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64753,7 +67883,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64765,7 +67895,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64779,11 +67909,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64796,7 +67926,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64813,8 +67943,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64826,7 +67961,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64841,7 +67976,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64855,14 +67990,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(310 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64870,7 +68005,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(308 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64878,14 +68013,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(309 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64895,7 +68030,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(298 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64909,7 +68044,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64925,7 +68060,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64941,7 +68076,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64957,7 +68092,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64969,7 +68104,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64991,11 +68126,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -65007,7 +68142,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -65021,7 +68156,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -65033,7 +68168,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -65045,7 +68180,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -65059,7 +68194,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -65073,7 +68208,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -65085,7 +68220,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -65098,7 +68233,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -65113,7 +68248,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -65128,7 +68263,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -65142,7 +68277,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -65155,7 +68290,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -65176,7 +68311,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -65260,7 +68395,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(315 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -65272,7 +68407,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(319 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65284,7 +68419,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65299,7 +68434,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(316 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -65315,7 +68450,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 317 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -65325,7 +68460,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(317 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -65336,9 +68471,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -65369,7 +68520,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -65451,8 +68602,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -65501,10 +68655,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -65522,14 +68676,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -65575,8 +68729,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65619,43 +68773,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65675,7 +68833,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65719,7 +68880,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65784,7 +68945,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -66260,7 +69420,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -66272,20 +69432,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -66300,7 +69460,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -66312,7 +69472,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66325,7 +69485,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66382,14 +69542,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66667,8 +69827,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66715,7 +69875,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66749,10 +69909,10 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66764,7 +69924,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66801,7 +69961,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66836,10 +69996,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66852,25 +70012,23 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { return ts.createParen(condition); } return condition; @@ -66902,8 +70060,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66919,9 +70077,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66944,7 +70102,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66982,7 +70140,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66993,29 +70151,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -67023,9 +70181,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -67051,28 +70209,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 316 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -67081,15 +70239,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 317 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -67102,13 +70260,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -67133,7 +70291,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -67141,11 +70299,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 316 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -67163,7 +70321,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -67282,10 +70440,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -67404,7 +70562,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -67416,11 +70574,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -67452,12 +70610,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -67469,7 +70627,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -67481,7 +70639,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -67493,7 +70651,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -67516,13 +70674,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -67562,11 +70720,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67690,7 +70848,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict) - statements = ts.ensureUseStrict(statements); // tslint:disable-line no-unnecessary-qualifier + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; @@ -67725,278 +70883,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 161 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -68038,58 +71205,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 315 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68098,12 +71265,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68111,7 +71278,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68119,50 +71286,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -68170,123 +71337,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68295,7 +71462,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68303,140 +71470,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -68509,7 +71676,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -68582,19 +71749,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68797,12 +71965,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68814,6 +71981,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -69182,7 +72350,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -69229,7 +72397,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -69242,13 +72410,13 @@ var ts; hasImportDefault = true; } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -69278,13 +72446,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -69292,7 +72460,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -69312,7 +72480,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -69410,7 +72578,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -69440,42 +72608,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); - } - ts.getInitializedProperties = getInitializedProperties; - /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.isStaticInitializedProperty = isStaticInitializedProperty; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -70001,8 +73155,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -70028,14 +73182,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -70086,16 +73240,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -70107,7 +73261,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -70150,10 +73304,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -70174,13 +73328,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -70200,11 +73354,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -70228,19 +73382,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -70250,7 +73404,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -70267,67 +73421,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70337,7 +73495,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70347,35 +73505,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -70385,35 +73543,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70451,7 +73609,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -70480,7 +73638,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70823,12 +73981,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70981,7 +74139,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? ts.createVoidZero() @@ -71082,13 +74240,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -71104,10 +74262,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -71117,7 +74275,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -71128,12 +74286,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -71150,15 +74308,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -71195,7 +74353,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -71240,69 +74398,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -71313,15 +74471,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var typeNode = types_20[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -71401,12 +74559,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -71422,7 +74580,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.getMutableClone(node); @@ -71430,7 +74588,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -71514,7 +74672,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -71977,12 +75135,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -72107,7 +75265,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -72153,13 +75311,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -72200,7 +75358,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -72413,7 +75571,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -72421,7 +75579,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72431,17 +75589,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -72500,11 +75658,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -72542,9 +75700,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -72566,9 +75724,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -72672,7 +75831,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72683,11 +75844,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72699,20 +75860,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72742,7 +75903,7 @@ var ts; // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { (pendingExpressions || (pendingExpressions = [])).push(expr); } @@ -72755,7 +75916,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72771,9 +75932,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72791,9 +75952,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72805,7 +75966,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72846,8 +76007,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72860,7 +76021,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72904,7 +76065,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72921,7 +76082,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72958,19 +76119,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72990,7 +76161,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -73108,34 +76279,34 @@ var ts; return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73144,27 +76315,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -73365,7 +76536,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -73456,17 +76627,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73514,23 +76685,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73550,11 +76721,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73622,7 +76793,7 @@ var ts; function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -73694,7 +76865,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; @@ -73716,62 +76887,62 @@ var ts; return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return doOutsideOfTopLevel(visitConstructorDeclaration, node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73805,7 +76976,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73817,7 +76988,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73826,7 +76997,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73860,7 +77031,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -74157,7 +77328,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); @@ -74226,17 +77397,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -74284,23 +77455,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -74320,11 +77491,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -74347,8 +77518,7 @@ var ts; }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getUnscopedHelperName("__assign"), @@ -74423,7 +77593,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -74442,6 +77612,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -74454,10 +77625,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -74492,13 +77796,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74508,13 +77812,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -74589,7 +77893,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -74683,7 +77987,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74989,7 +78293,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74997,9 +78301,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -75202,13 +78506,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -75221,72 +78525,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -75297,28 +78601,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -75409,14 +78713,14 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -75427,7 +78731,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75685,7 +78989,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75823,11 +79127,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75835,7 +79139,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75990,10 +79294,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -76017,7 +79321,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -76033,7 +79337,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -76054,25 +79358,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -76101,20 +79405,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -76140,12 +79444,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -76302,7 +79616,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -76346,7 +79660,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -76414,9 +79728,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -76435,9 +79749,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -76472,7 +79786,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -76646,14 +79960,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76841,7 +80155,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76896,7 +80210,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76962,11 +80276,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76991,11 +80305,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -77146,7 +80460,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -77208,7 +80522,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -77246,7 +80560,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -77257,7 +80571,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -77270,7 +80584,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -77284,7 +80598,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -77305,10 +80619,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -77394,20 +80708,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -77514,7 +80828,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77567,7 +80881,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -77691,10 +81005,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -77712,7 +81026,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77724,10 +81038,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -78015,13 +81329,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -78053,7 +81365,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -78063,14 +81375,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -78111,10 +81423,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -78127,9 +81439,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -78196,19 +81508,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -78263,15 +81575,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -78290,9 +81602,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -78349,7 +81661,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -78624,13 +81936,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -78643,24 +81955,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -78681,21 +81993,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -78708,9 +82020,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78909,23 +82221,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78938,7 +82250,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78950,7 +82262,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -79037,7 +82349,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -79326,35 +82638,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79784,7 +83096,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79797,7 +83109,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79970,11 +83282,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80109,7 +83420,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -81026,12 +84337,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -81359,23 +84670,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -81402,24 +84713,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -81897,7 +85208,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81952,10 +85263,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82137,8 +85448,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82154,7 +85465,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -82216,12 +85527,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -82242,7 +85553,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -82310,15 +85621,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -82394,13 +85705,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -82622,7 +85933,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -82647,7 +85958,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -82716,28 +86027,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82787,15 +86098,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82971,7 +86282,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -83035,7 +86346,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -83097,10 +86408,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -83280,43 +86591,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -83563,7 +86874,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -83579,8 +86890,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -83596,7 +86907,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -83646,7 +86957,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -83680,14 +86991,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -83773,22 +87084,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83815,7 +87126,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83854,8 +87165,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -83879,10 +87190,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83989,7 +87300,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84018,7 +87329,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84065,7 +87376,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84074,8 +87385,8 @@ var ts; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -84084,7 +87395,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84109,7 +87420,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.hasModifier(node, 32 /* Static */)) { @@ -84148,26 +87459,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84175,7 +87486,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84189,7 +87500,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84214,30 +87525,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84245,7 +87556,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84258,13 +87569,20 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -84273,39 +87591,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -84320,9 +87638,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -84357,11 +87675,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -84371,7 +87686,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -84435,7 +87750,6 @@ var ts; var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -84518,20 +87832,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -84544,18 +87867,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; - var statements_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(126 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -84592,12 +87915,20 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -84684,11 +88015,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -84696,7 +88027,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -84709,7 +88040,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -84734,19 +88065,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84754,12 +88085,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -84770,26 +88101,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84870,7 +88201,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84890,7 +88221,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84917,7 +88248,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84966,11 +88297,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84980,13 +88311,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -85013,7 +88337,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -85034,75 +88358,65 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 215 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - var isPrivate = ts.hasModifier(input, 8 /* Private */); - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(ts.updateGetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 160 /* SetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - return cleanup(ts.updateSetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 155 /* PropertyDeclaration */: + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } + case 158 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -85110,13 +88424,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 154 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 179 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -85128,13 +88442,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -85163,7 +88477,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -85173,7 +88487,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -85182,13 +88496,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -85198,7 +88512,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -85223,10 +88537,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -85247,14 +88561,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -85269,7 +88583,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -85302,17 +88616,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -85321,7 +88635,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -85348,7 +88662,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -85359,7 +88673,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -85389,7 +88703,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -85399,16 +88713,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -85419,10 +88733,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -85441,7 +88755,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -85462,7 +88776,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -85512,7 +88826,7 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -85533,43 +88847,15 @@ var ts; } return accessorType; } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; - } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -85594,7 +88880,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -85603,52 +88889,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -85777,7 +89063,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(320 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -86062,15 +89348,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -86080,22 +89366,21 @@ var ts; if (!onlyBuildInfo) { 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); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -86118,7 +89403,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -86126,14 +89411,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -86143,9 +89428,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -86186,7 +89469,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -86203,43 +89486,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -86255,11 +89568,11 @@ var ts; return jsFilePath; if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -86267,7 +89580,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -86281,7 +89594,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -86377,17 +89690,20 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle) + return; + if (!declarationFilePath) { + if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly) + emitSkipped = true; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -86419,7 +89735,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -86427,7 +89743,7 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -86438,7 +89754,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -86450,8 +89766,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -86492,7 +89808,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -86599,10 +89915,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -86614,7 +89931,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -86760,6 +90077,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -86788,9 +90107,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86959,8 +90278,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86972,7 +90290,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86988,6 +90306,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86997,21 +90317,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -87026,12 +90357,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -87045,10 +90376,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -87068,279 +90402,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 304 /* JSDocClassTag */: - case 301 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -87358,83 +90692,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -87447,8 +90781,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -87474,7 +90811,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -87574,7 +90911,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -87607,7 +90944,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87643,7 +90980,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -87705,7 +91042,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87746,11 +91083,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87882,18 +91225,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87973,66 +91315,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -88072,22 +91405,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -88112,9 +91445,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ - && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) - || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -88127,7 +91460,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -88155,7 +91488,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -88232,7 +91565,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88240,8 +91573,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -88251,14 +91584,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -88267,14 +91600,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -88286,25 +91619,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -88312,7 +91645,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -88321,12 +91654,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -88354,12 +91687,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88367,7 +91700,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88377,17 +91710,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -88396,13 +91729,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -88427,7 +91760,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -88599,7 +91932,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -88607,7 +91940,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88628,17 +91961,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88647,12 +91980,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -88667,9 +92000,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -88680,42 +92013,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -88735,7 +92068,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88813,7 +92146,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88824,13 +92157,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88842,12 +92175,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88858,7 +92191,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88928,7 +92261,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 310 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88962,7 +92295,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88981,7 +92314,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 299 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -89115,8 +92448,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { - var directive = types_18[_d]; + for (var _d = 0, types_21 = types; _d < types_21.length; _d++) { + var directive = types_21[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -89296,7 +92629,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -89334,8 +92667,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -89742,6 +93074,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -89759,7 +93094,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89824,81 +93159,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89907,12 +93242,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -90092,25 +93427,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -90153,11 +93488,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 315 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -90181,7 +93517,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -90211,6 +93547,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -90424,6 +93761,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -90438,7 +93776,7 @@ var ts; else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -90451,12 +93789,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -91380,6 +94719,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -91484,15 +94825,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -91574,11 +94917,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structuralIsReused; - structuralIsReused = tryReuseStructureFromOldProgram(); + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -91586,20 +94931,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -91612,7 +94973,7 @@ var ts; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -91648,8 +95009,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -91665,12 +95026,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91707,7 +95069,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -91734,9 +95098,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91940,6 +95309,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -92030,7 +95405,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -92067,28 +95442,26 @@ var ts; for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = getModuleNames(newSourceFile); - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); - // ensure that module resolution results are still correct - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); + // ensure that module resolution results are still correct + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -92102,11 +95475,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; var filePath = newSourceFile.path; addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); + if (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -92126,7 +95507,8 @@ var ts; function getEmitHost(writeFileCallback) { return __assign(__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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, 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) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, 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)) @@ -92191,15 +95573,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -92231,7 +95613,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -92306,15 +95689,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -92373,22 +95757,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -92396,41 +95780,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -92443,51 +95827,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -92504,24 +95889,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -92596,8 +95981,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -92627,7 +96012,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -92678,7 +96063,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -92759,24 +96144,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, diagnostic], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([diagnostic], args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -92799,15 +96178,36 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (!source && + host.realpath && + options.preserveSymlinks && + ts.isDeclarationFileName(fileName) && + ts.stringContains(fileName, ts.nodeModulesPathPart)) { + // use host's cached realpath + var realPath = host.realpath(fileName); + if (realPath !== fileName) + source = getSourceOfProjectReferenceRedirect(realPath); + } + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92816,34 +96216,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92861,14 +96262,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92899,7 +96293,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92922,8 +96316,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92938,8 +96342,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92978,6 +96382,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -93012,9 +96445,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -93030,10 +96471,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -93045,7 +96492,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -93055,8 +96502,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -93064,14 +96510,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -93089,20 +96535,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { + if (!refFile) { return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, message], args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -93142,14 +96588,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -93168,12 +96622,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; 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) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -93230,9 +96687,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -93270,14 +96724,12 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -93393,8 +96845,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -93459,8 +96911,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -93487,7 +96972,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -93562,7 +97047,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -93621,6 +97106,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -93666,9 +97157,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -93718,9 +97206,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93966,7 +97454,10 @@ var ts; } } else { - var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); var firstDts_1 = emitOutput_1.outputFiles && programOfThisState.getCompilerOptions().declarationMap ? emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : @@ -94078,6 +97569,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -94181,6 +97673,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -94194,8 +97691,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -94218,7 +97714,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -94264,16 +97761,17 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } + state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit; return state; } function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -94318,7 +97816,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -94395,13 +97894,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -94420,7 +97924,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -94445,7 +97949,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -94463,15 +97967,40 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { return; } + if (!isChangedSignagure(state, affectedFile.path)) + return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } + } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first @@ -94539,7 +98068,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, isEmitResult) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -94549,8 +98078,8 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); - if (isEmitResult) { - (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; @@ -94563,15 +98092,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); return { result: result, affected: affected }; } /** * Returns the result with affected file */ - function toAffectedFileEmitResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, /*isEmitResult*/ true); + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -94601,7 +98130,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -94794,11 +98323,12 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } @@ -94806,10 +98336,11 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94825,7 +98356,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94881,7 +98412,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94913,7 +98444,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94925,8 +98456,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94959,7 +98496,7 @@ var ts; } var state = { fileInfos: fileInfos, - compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), + compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), @@ -94995,33 +98532,6 @@ var ts; } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function convertFromReusableCompilerOptions(options, toAbsolutePath) { - var result = {}; - var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertFromReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); - } - } - if (result.configFilePath) { - result.configFilePath = toAbsolutePath(result.configFilePath); - } - return result; - } - function convertFromReusableCompilerOptionValue(option, value, toAbsolutePath) { - if (option) { - if (option.type === "list") { - var values = value; - if (option.element.isFilePath && values.length) { - return values.map(toAbsolutePath); - } - } - else if (option.isFilePath) { - return toAbsolutePath(value); - } - } - return value; - } function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -95088,15 +98598,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -95342,7 +98864,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -95553,6 +99075,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -95738,8 +99264,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -95755,13 +99282,19 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) @@ -95820,38 +99353,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95862,7 +99369,9 @@ var ts; var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95879,7 +99388,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95921,7 +99454,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95930,28 +99463,34 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); + var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) + var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)); + if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) { return undefined; + } // If the module was found in @types, get the actual Node package name var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1); var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName); @@ -96142,6 +99681,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96149,7 +99697,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -96158,7 +99706,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -96167,7 +99715,7 @@ var ts; /** Parses config file using System interface */ function parseConfigFileWithSystem(configFileName, optionsToExtend, system, reportDiagnostic) { var host = system; - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(ts.sys, reportDiagnostic, diagnostic); }; + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; @@ -96191,7 +99739,7 @@ var ts; } ts.getErrorSummaryText = getErrorSummaryText; function listFiles(program, writeFileName) { - if (program.getCompilerOptions().listFiles) { + if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) { ts.forEach(program.getSourceFiles(), function (file) { writeFileName(file.fileName); }); @@ -96202,6 +99750,7 @@ var ts; * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { + var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly; // First get and report any syntactic errors. var diagnostics = program.getConfigFileParsingDiagnostics().slice(); var configFileParsingDiagnosticsLength = diagnostics.length; @@ -96210,13 +99759,17 @@ var ts; // semantic errors. if (diagnostics.length === configFileParsingDiagnosticsLength) { ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken)); - ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); - if (diagnostics.length === configFileParsingDiagnosticsLength) { - ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + if (!isListFilesOnly) { + ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); + if (diagnostics.length === configFileParsingDiagnosticsLength) { + ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + } } } // Emit and report any errors we ran into. - var emitResult = program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = isListFilesOnly + ? { emitSkipped: true, diagnostics: ts.emptyArray } + : program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics; ts.addRange(diagnostics, emitDiagnostics); ts.sortAndDeduplicateDiagnostics(diagnostics).forEach(reportDiagnostic); @@ -96365,7 +99918,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -96399,7 +99954,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -96448,7 +100003,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -97006,12 +100561,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -97167,11 +100732,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -97180,8 +100748,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -97205,11 +100772,9 @@ var ts; } function createStateBuildOrder(state) { var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); - if (ts.arrayIsEqualTo(state.buildOrder, buildOrder)) - return state.buildOrder; // Clear all to ResolvedConfigFilePaths cache to start fresh state.resolvedConfigFilePaths.clear(); - var currentProjects = ts.arrayToSet(buildOrder, function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); var noopOnDelete = { onDeleteValue: ts.noop }; // Config file cache ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); @@ -97230,6 +100795,8 @@ var ts; function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -97237,6 +100804,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -97308,7 +100876,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -97648,6 +101216,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -97704,8 +101274,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97876,10 +101449,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97938,7 +101513,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -98086,33 +101661,34 @@ var ts; setupInitialBuild(state, cancellationToken); var reportQueue = true; var successfulProjects = 0; - var errorProjects = 0; while (true) { var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue); if (!invalidatedProject) break; reportQueue = false; invalidatedProject.done(cancellationToken); - if (state.diagnostics.has(invalidatedProject.projectPath)) { - errorProjects++; - } - else { + if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; - } } disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) + ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped + : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); }) + ? ts.ExitStatus.Success + : successfulProjects + ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated + : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -98255,8 +101831,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -98288,6 +101864,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -98324,23 +101901,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -98373,13 +101960,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -98425,6 +102015,15 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ + var PackageJsonDependencyGroup; + (function (PackageJsonDependencyGroup) { + PackageJsonDependencyGroup[PackageJsonDependencyGroup["Dependencies"] = 1] = "Dependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["DevDependencies"] = 2] = "DevDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["PeerDependencies"] = 4] = "PeerDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["OptionalDependencies"] = 8] = "OptionalDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["All"] = 15] = "All"; + })(PackageJsonDependencyGroup = ts.PackageJsonDependencyGroup || (ts.PackageJsonDependencyGroup = {})); + /* @internal */ ts.emptyOptions = {}; var HighlightSpanKind; (function (HighlightSpanKind) { @@ -98439,6 +102038,12 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = ts.SemicolonPreference || (ts.SemicolonPreference = {})); function getDefaultFormatCodeSettings(newLineCharacter) { return { indentSize: 4, @@ -98460,6 +102065,7 @@ var ts; insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, + semicolons: SemicolonPreference.Ignore, }; } ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; @@ -98689,37 +102295,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 278 /* CatchClause */: + case 271 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 154 /* TypeParameter */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 172 /* TypeLiteral */: return 2 /* Type */; - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 282 /* EnumMember */: + case 244 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -98729,26 +102335,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 247 /* EnumDeclaration */: + case 256 /* NamedImports */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 258 /* ExportAssignment */ || node.parent.kind === 263 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -98780,11 +102386,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 152 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 252 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -98796,27 +102402,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 152 /* QualifiedName */) { + while (root.parent && root.parent.kind === 152 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 168 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 193 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 193 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 215 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 277 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 244 /* ClassDeclaration */ && root.parent.parent.token === 112 /* ImplementsKeyword */) || + (decl.kind === 245 /* InterfaceDeclaration */ && root.parent.parent.token === 89 /* ExtendsKeyword */); } return false; } @@ -98825,17 +102431,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return true; - case 184 /* ImportType */: + case 187 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -98862,7 +102468,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 237 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -98878,11 +102484,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 73 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 73 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -98894,40 +102500,40 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 248 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 73 /* Identifier */ && + return node.kind === 75 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 282 /* EnumMember */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 248 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 186 /* LiteralType */: + return node.parent.parent.kind === 184 /* IndexedAccessType */; default: return false; } @@ -98951,17 +102557,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return node; } } @@ -98969,48 +102575,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: + case 245 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 246 /* TypeAliasDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 247 /* EnumDeclaration */: return "enum" /* enumElement */; + case 241 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 162 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 163 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 279 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 166 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 165 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 164 /* CallSignature */: return "call" /* callSignatureElement */; + case 161 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 154 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 282 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 155 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -99037,7 +102648,7 @@ var ts; return "" /* unknown */; } } - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -99053,12 +102664,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 155 /* Parameter */; default: return false; } @@ -99123,42 +102734,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 172 /* TypeLiteral */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 250 /* CaseBlock */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 196 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 195 /* CallExpression */: + case 199 /* ParenthesizedExpression */: + case 181 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 201 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -99168,65 +102779,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 191 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 194 /* ElementAccessExpression */: + case 153 /* ComputedPropertyName */: + case 174 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 110 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 203 /* TypeOfExpression */: + case 202 /* DeleteExpression */: + case 204 /* VoidExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -99358,7 +102969,7 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - return ts.firstDefined(n.getChildren(), function (child) { + return ts.firstDefined(n.getChildren(sourceFile), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -99405,7 +103016,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 288 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -99471,21 +103082,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 267 /* JsxClosingElement */) { return true; } return false; @@ -99507,7 +103118,7 @@ var ts; if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 28 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -99534,6 +103145,12 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; + function removeOptionality(type, isOptionalExpression, isOptionalChain) { + return isOptionalExpression ? type.getNonNullableType() : + isOptionalChain ? type.getNonOptionalType() : + type; + } + ts.removeOptionality = removeOptionality; function isPossiblyTypeArgumentPosition(token, sourceFile, checker) { var info = getPossibleTypeArgumentsInfo(token, sourceFile); return info !== undefined && (ts.isPartOfTypeNode(info.called) || @@ -99543,6 +103160,9 @@ var ts; ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; function getPossibleGenericSignatures(called, typeArgumentCount, checker) { var type = checker.getTypeAtLocation(called); + if (ts.isOptionalChain(called.parent)) { + type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true); + } var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; }); } @@ -99559,9 +103179,12 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); + if (token && token.kind === 28 /* QuestionDotToken */) { + token = findPrecedingToken(token.getFullStart(), sourceFile); + } if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { @@ -99569,13 +103192,13 @@ var ts; } remainingLessThanTokens--; break; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: remainingLessThanTokens++; break; case 19 /* CloseBraceToken */: @@ -99603,20 +103226,22 @@ var ts; case 27 /* CommaToken */: nTypeArguments++; break; - case 37 /* EqualsGreaterThanToken */: - case 73 /* Identifier */: + case 38 /* EqualsGreaterThanToken */: + // falls through + case 75 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 105 /* TypeOfKeyword */: - case 87 /* ExtendsKeyword */: - case 130 /* KeyOfKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + // falls through + case 107 /* TypeOfKeyword */: + case 89 /* ExtendsKeyword */: + case 133 /* KeyOfKeyword */: case 24 /* DotToken */: - case 50 /* BarToken */: - case 56 /* QuestionToken */: - case 57 /* ColonToken */: + case 51 /* BarToken */: + case 57 /* QuestionToken */: + case 58 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -99665,16 +103290,16 @@ var ts; result.push("abstract" /* abstractModifier */); if (flags & 1 /* Export */) result.push("export" /* exportedModifier */); - if (node.flags & 4194304 /* Ambient */) + if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 168 /* TypeReference */ || node.kind === 195 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 244 /* ClassDeclaration */ || node.kind === 245 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -99694,7 +103319,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 72 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 74 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -99704,9 +103329,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: return true; } return false; @@ -99719,18 +103344,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 191 /* ArrayLiteralExpression */ || + node.kind === 192 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 208 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 60 /* EqualsToken */) { + node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 231 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -99738,7 +103363,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 279 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -99782,23 +103407,23 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 121 /* AnyKeyword */, - 147 /* BigIntKeyword */, - 124 /* BooleanKeyword */, - 88 /* FalseKeyword */, - 130 /* KeyOfKeyword */, - 133 /* NeverKeyword */, - 97 /* NullKeyword */, - 136 /* NumberKeyword */, - 137 /* ObjectKeyword */, - 134 /* ReadonlyKeyword */, - 139 /* StringKeyword */, - 140 /* SymbolKeyword */, - 103 /* TrueKeyword */, - 107 /* VoidKeyword */, - 142 /* UndefinedKeyword */, - 143 /* UniqueKeyword */, - 144 /* UnknownKeyword */, + 124 /* AnyKeyword */, + 150 /* BigIntKeyword */, + 127 /* BooleanKeyword */, + 90 /* FalseKeyword */, + 133 /* KeyOfKeyword */, + 136 /* NeverKeyword */, + 99 /* NullKeyword */, + 139 /* NumberKeyword */, + 140 /* ObjectKeyword */, + 137 /* ReadonlyKeyword */, + 142 /* StringKeyword */, + 143 /* SymbolKeyword */, + 105 /* TrueKeyword */, + 109 /* VoidKeyword */, + 145 /* UndefinedKeyword */, + 146 /* UniqueKeyword */, + 147 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -99834,7 +103459,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 153 /* ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.getTextOfIdentifierOrLiteral(name); @@ -99910,7 +103535,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 73 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 75 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -99994,12 +103619,31 @@ var ts; return a.fileName === b.fileName && textSpansEqual(a.textSpan, b.textSpan); } ts.documentSpansEqual = documentSpansEqual; + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ + function forEachUnique(array, callback) { + if (array) { + for (var i = 0; i < array.length; i++) { + if (array.indexOf(array[i]) === i) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + } + return undefined; + } + ts.forEachUnique = forEachUnique; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 155 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -100040,6 +103684,8 @@ var ts; getColumn: function () { return 0; }, getLine: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingWhitespace: function () { return false; }, + hasTrailingComment: function () { return false; }, rawWrite: ts.notImplemented, getIndent: function () { return indent; }, increaseIndent: function () { indent++; }, @@ -100461,15 +104107,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 272 /* CaseClause */: + case 275 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100497,10 +104143,10 @@ var ts; ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: return true; default: return false; @@ -100511,8 +104157,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: return true; default: return false; @@ -100533,7 +104179,6 @@ var ts; var notAccessible = function () { typeIsAccessible = false; }; var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { trackSymbol: function (symbol, declaration, meaning) { - // TODO: GH#18217 typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; }, reportInaccessibleThisError: notAccessible, @@ -100551,28 +104196,90 @@ var ts; return typeIsAccessible ? res : undefined; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; - function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; - } - ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; + function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { + return kind === 164 /* CallSignature */ + || kind === 165 /* ConstructSignature */ + || kind === 166 /* IndexSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */; + } + ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; + function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { + return kind === 243 /* FunctionDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; + } + ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; + function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { + return kind === 248 /* ModuleDeclaration */; + } + ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; + function syntaxRequiresTrailingSemicolonOrASI(kind) { + return kind === 224 /* VariableStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 227 /* DoStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 233 /* BreakStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 158 /* PropertyDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 258 /* ExportAssignment */; + } + ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; + ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); + function isASICandidate(node, sourceFile) { + var lastToken = node.getLastToken(sourceFile); + if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + return false; + } + if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { + if (lastToken && lastToken.kind === 27 /* CommaToken */) { + return false; + } + } + else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isModuleBlock(lastChild)) { + return false; + } + } + else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isFunctionBlock(lastChild)) { + return false; + } + } + else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) { + return false; + } + // See comment in parser’s `parseDoStatement` + if (node.kind === 227 /* DoStatement */) { + return true; + } + var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); + var nextToken = ts.findNextToken(node, topNode, sourceFile); + if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + return true; + } + var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line; + return startLine !== endLine; + } + ts.isASICandidate = isASICandidate; function probablyUsesSemicolons(sourceFile) { var withSemicolon = 0; var withoutSemicolon = 0; var nStatementsToObserve = 5; ts.forEachChild(sourceFile, function visit(node) { - if (syntaxUsuallyHasTrailingSemicolon(node.kind)) { + if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { withSemicolon++; @@ -100595,6 +104302,150 @@ var ts; return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; } ts.probablyUsesSemicolons = probablyUsesSemicolons; + function tryGetDirectories(host, directoryName) { + return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; + } + ts.tryGetDirectories = tryGetDirectories; + function tryReadDirectory(host, path, extensions, exclude, include) { + return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || ts.emptyArray; + } + ts.tryReadDirectory = tryReadDirectory; + function tryFileExists(host, path) { + return tryIOAndConsumeErrors(host, host.fileExists, path); + } + ts.tryFileExists = tryFileExists; + function tryDirectoryExists(host, path) { + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; + } + ts.tryDirectoryExists = tryDirectoryExists; + function tryAndIgnoreErrors(cb) { + try { + return cb(); + } + catch (_a) { + return undefined; + } + } + ts.tryAndIgnoreErrors = tryAndIgnoreErrors; + function tryIOAndConsumeErrors(host, toApply) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + return tryAndIgnoreErrors(function () { return toApply && toApply.apply(host, args); }); + } + ts.tryIOAndConsumeErrors = tryIOAndConsumeErrors; + function findPackageJsons(startDirectory, host, stopDirectory) { + var paths = []; + ts.forEachAncestorDirectory(startDirectory, function (ancestor) { + if (ancestor === stopDirectory) { + return true; + } + var currentConfigPath = ts.combinePaths(ancestor, "package.json"); + if (tryFileExists(host, currentConfigPath)) { + paths.push(currentConfigPath); + } + }); + return paths; + } + ts.findPackageJsons = findPackageJsons; + function findPackageJson(directory, host) { + var packageJson; + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (ancestor === "node_modules") + return true; + packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); + if (packageJson) { + return true; // break out + } + }); + return packageJson; + } + ts.findPackageJson = findPackageJson; + function getPackageJsonsVisibleToFile(fileName, host) { + if (!host.fileExists) { + return []; + } + var packageJsons = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(fileName), function (ancestor) { + var packageJsonFileName = ts.combinePaths(ancestor, "package.json"); + if (host.fileExists(packageJsonFileName)) { + var info = createPackageJsonInfo(packageJsonFileName, host); + if (info) { + packageJsons.push(info); + } + } + }); + return packageJsons; + } + ts.getPackageJsonsVisibleToFile = getPackageJsonsVisibleToFile; + function createPackageJsonInfo(fileName, host) { + if (!host.readFile) { + return undefined; + } + var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]; + var stringContent = host.readFile(fileName); + var content = stringContent && tryParseJson(stringContent); + if (!content) { + return undefined; + } + var info = {}; + for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) { + var key = dependencyKeys_1[_i]; + var dependencies = content[key]; + if (!dependencies) { + continue; + } + var dependencyMap = ts.createMap(); + for (var packageName in dependencies) { + dependencyMap.set(packageName, dependencies[packageName]); + } + info[key] = dependencyMap; + } + var dependencyGroups = [ + [1 /* Dependencies */, info.dependencies], + [2 /* DevDependencies */, info.devDependencies], + [8 /* OptionalDependencies */, info.optionalDependencies], + [4 /* PeerDependencies */, info.peerDependencies], + ]; + return __assign(__assign({}, info), { fileName: fileName, + get: get, + has: function (dependencyName, inGroups) { + return !!get(dependencyName, inGroups); + } }); + function get(dependencyName, inGroups) { + if (inGroups === void 0) { inGroups = 15 /* All */; } + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; + if (deps && (inGroups & group_1)) { + var dep = deps.get(dependencyName); + if (dep !== undefined) { + return dep; + } + } + } + } + } + ts.createPackageJsonInfo = createPackageJsonInfo; + function tryParseJson(text) { + try { + return JSON.parse(text); + } + catch (_a) { + return undefined; + } + } + function consumesNodeCoreModules(sourceFile) { + return ts.some(sourceFile.imports, function (_a) { + var text = _a.text; + return ts.JsTyping.nodeCoreModules.has(text); + }); + } + ts.consumesNodeCoreModules = consumesNodeCoreModules; + function isInsideNodeModules(fileOrDirectory) { + return ts.contains(ts.getPathComponents(fileOrDirectory), "node_modules"); + } + ts.isInsideNodeModules = isInsideNodeModules; })(ts || (ts = {})); var ts; (function (ts) { @@ -100676,36 +104527,36 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; - case 28 /* LessThanToken */: - if (lastNonTriviaToken === 73 /* Identifier */) { + case 29 /* LessThanToken */: + if (lastNonTriviaToken === 75 /* Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 121 /* AnyKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: + case 124 /* AnyKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 73 /* Identifier */; + token = 75 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -100744,14 +104595,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 73 /* Identifier */; + token = 75 /* Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 73 /* Identifier */; + token = 75 /* Identifier */; } } } @@ -100765,19 +104616,19 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 73 /* Identifier */, + 75 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 101 /* ThisKeyword */, - 44 /* PlusPlusToken */, - 45 /* MinusMinusToken */, + 103 /* ThisKeyword */, + 45 /* PlusPlusToken */, + 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 103 /* TrueKeyword */, - 88 /* FalseKeyword */, + 105 /* TrueKeyword */, + 90 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -100889,10 +104740,10 @@ var ts; return true; } switch (keyword2) { - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 125 /* ConstructorKeyword */: - case 117 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 128 /* ConstructorKeyword */: + case 119 /* StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -100925,43 +104776,44 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 49 /* AmpersandToken */: - case 51 /* CaretToken */: - case 50 /* BarToken */: - case 54 /* AmpersandAmpersandToken */: - case 55 /* BarBarToken */: - case 71 /* BarEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 60 /* EqualsToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 50 /* AmpersandToken */: + case 52 /* CaretToken */: + case 51 /* BarToken */: + case 55 /* AmpersandAmpersandToken */: + case 56 /* BarBarToken */: + case 73 /* BarEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: + case 60 /* QuestionQuestionToken */: return true; default: return false; @@ -100969,12 +104821,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: return true; default: return false; @@ -100987,7 +104839,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 72 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 74 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -101006,7 +104858,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 73 /* Identifier */: + case 75 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -101031,10 +104883,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -101061,8 +104913,10 @@ var ts; }); return { spans: spans, endOfLineState: 0 /* None */ }; function pushClassification(start, end, type) { + var length = end - start; + ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); spans.push(start); - spans.push(end - start); + spans.push(length); spans.push(type); } } @@ -101252,18 +105106,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 307 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 308 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -101304,6 +105158,7 @@ var ts; // defined in `ts.commentPragmas` would be excessive, but we can avoid // some obvious false positives (e.g. in XML-like doc comments) by // checking the element name. + // eslint-disable-next-line no-in-operator if (!match[3] || !(match[3] in ts.commentPragmas)) { return false; } @@ -101413,22 +105268,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -101445,7 +105300,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* GreaterThanToken */) { + if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -101455,19 +105310,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 60 /* EqualsToken */) { + if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 241 /* VariableDeclaration */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 155 /* Parameter */ || + parent.kind === 271 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 208 /* BinaryExpression */ || + parent.kind === 206 /* PrefixUnaryExpression */ || + parent.kind === 207 /* PostfixUnaryExpression */ || + parent.kind === 209 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -101480,8 +105335,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 271 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -101494,35 +105348,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 73 /* Identifier */) { + else if (tokenKind === 75 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 155 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -101645,11 +105499,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -101657,9 +105511,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 187 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 177 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -101669,7 +105523,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -101686,7 +105540,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -101699,8 +105553,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -101709,9 +105563,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 263 /* ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); @@ -101739,7 +105593,7 @@ var ts; var candidates = []; checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); var types = ts.flatMap(candidates, function (candidate) { - if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) + if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length) return; var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); @@ -101755,11 +105609,8 @@ var ts; if (!type) return ts.emptyArray; type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; + return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : + type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; @@ -101849,10 +105700,10 @@ var ts; var absolutePath = ts.resolvePath(scriptPath, fragment); var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (!tryDirectoryExists(host, baseDirectory)) + if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { /** * Multiple file entries might map to the same truncated name once we remove extensions @@ -101875,7 +105726,7 @@ var ts; }); } // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); + var directories = ts.tryGetDirectories(host, baseDirectory); if (directories) { for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var directory = directories_1[_b]; @@ -101886,7 +105737,7 @@ var ts; } } // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); + var packageJsonPath = ts.findPackageJson(baseDirectory, host); if (packageJsonPath) { var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; @@ -101964,7 +105815,7 @@ var ts; if (!foundGlobal) { ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); - if (tryDirectoryExists(host, nodeModules)) { + if (ts.tryDirectoryExists(host, nodeModules)) { getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); @@ -102014,12 +105865,12 @@ var ts; // that encodes the suffix, but we would have to escape the character "?" which readDirectory // doesn't support. For now, this is safer but slower var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = ts.mapDefined(tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); }); - var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { var name = trimPrefixAndSuffix(dir); return name === undefined ? undefined : directoryResult(name); }); @@ -102071,22 +105922,22 @@ var ts; if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { var root = typeRoots_1[_i]; getCompletionEntriesFromDirectories(root); } // Also get all @types typings installed in visible node_modules directories - for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + for (var _a = 0, _b = ts.findPackageJsons(scriptPath, host); _a < _b.length; _a++) { var packageJson = _b[_a]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); getCompletionEntriesFromDirectories(typesDir); } return result; function getCompletionEntriesFromDirectories(directory) { - if (!tryDirectoryExists(host, directory)) + if (!ts.tryDirectoryExists(host, directory)) return; - for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.tryGetDirectories(host, directory); _i < _a.length; _i++) { var typeDirectoryName = _a[_i]; var packageName = ts.unmangleScopedPackageName(typeDirectoryName); if (options.types && !ts.contains(options.types, packageName)) @@ -102107,34 +105958,11 @@ var ts; } } } - function findPackageJsons(directory, host) { - var paths = []; - ts.forEachAncestorDirectory(directory, function (ancestor) { - var currentConfigPath = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (!currentConfigPath) { - return true; // break out - } - paths.push(currentConfigPath); - }); - return paths; - } - function findPackageJson(directory, host) { - var packageJson; - ts.forEachAncestorDirectory(directory, function (ancestor) { - if (ancestor === "node_modules") - return true; - packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (packageJson) { - return true; // break out - } - }); - return packageJson; - } function enumerateNodeModulesVisibleToScript(host, scriptPath) { if (!host.readFile || !host.fileExists) return ts.emptyArray; var result = []; - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.findPackageJsons(scriptPath, host); _i < _a.length; _i++) { var packageJson = _a[_i]; var contents = ts.readJson(packageJson, host); // Cast to assert that readFile is defined // Provide completions for all non @types dependencies @@ -102183,33 +106011,6 @@ var ts; */ var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*" with type any // And at `
` (with a closing `>`), the completion list will contain "div". var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 30 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -102382,14 +106242,25 @@ var ts; function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; var replacementSpan; - if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; + var insertQuestionDot = origin && originIsNullableMember(origin); + var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; + if (origin && originIsThisType(origin)) { + insertText = needsConvertPropertyAccess + ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]" + : "this" + (insertQuestionDot ? "?." : ".") + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. - else if ((origin && originIsSymbolMember(origin) || needsConvertPropertyAccess) && propertyAccessToConvert) { - insertText = needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); + else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { + insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name; + if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { + insertText = "?." + insertText; + } + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + if (!dot) { + return undefined; + } // If the text after the '.' starts with this name, write over it. Else, add new text. var end = ts.startsWith(name, propertyAccessToConvert.name.text) ? propertyAccessToConvert.name.end : dot.end; replacementSpan = ts.createTextSpanFromBounds(dot.getStart(sourceFile), end); @@ -102402,6 +106273,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -102496,9 +106374,9 @@ var ts; } return entries; } - function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { + function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) { var compilerOptions = program.getCompilerOptions(); - var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { return { type: "none" }; } @@ -102538,7 +106416,7 @@ var ts; return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); } // Compute all the completion symbols again. - var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); switch (symbolCompletion.type) { case "request": { var request = symbolCompletion.request; @@ -102594,8 +106472,8 @@ var ts; var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } - function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { - var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) { + var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); return completion.type === "symbol" ? completion.symbol : undefined; } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; @@ -102628,34 +106506,34 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return checker.getContextualType(parent); - case 75 /* CaseKeyword */: + case 77 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 264 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side - ? checker.getTypeAtLocation(parent.left) - : checker.getContextualType(previousToken); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -102665,9 +106543,9 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 288 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 @@ -102716,11 +106594,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 313 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 316 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -102756,6 +106634,7 @@ var ts; var node = currentToken; var propertyAccessToConvert; var isRightOfDot = false; + var isRightOfQuestionDot = false; var isRightOfOpenTag = false; var isStartingCloseTag = false; var isJsxInitializer = false; @@ -102767,10 +106646,11 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */) { - isRightOfDot = true; + if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -102782,14 +106662,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 187 /* ImportType */: + case 218 /* MetaProperty */: node = parent; break; default: @@ -102802,56 +106682,56 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 193 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + case 31 /* GreaterThanToken */: + if (currentToken.parent.kind === 264 /* JsxElement */ || currentToken.parent.kind === 266 /* JsxOpeningElement */) { location = currentToken; } break; - case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + case 43 /* SlashToken */: + if (currentToken.parent.kind === 265 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: - if (contextToken.kind === 42 /* SlashToken */) { + case 267 /* JsxClosingElement */: + if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: - if (contextToken.kind === 28 /* LessThanToken */) { + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: + case 266 /* JsxOpeningElement */: + if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: switch (previousToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: isJsxInitializer = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 60 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 62 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -102863,10 +106743,12 @@ var ts; var completionKind = 5 /* None */; var isNewIdentifierLocation = false; var keywordFilters = 0 /* None */; + // This also gets mutated in nested-functions after the return var symbols = []; var symbolToOriginInfoMap = []; var symbolToSortTextMap = []; - if (isRightOfDot) { + var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { @@ -102916,11 +106798,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 312 /* JSDocTypedefTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 315 /* JSDocTypedefTag */: return true; default: return false; @@ -102964,24 +106846,54 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 288 /* SourceFile */ && d.kind !== 248 /* ModuleDeclaration */ && d.kind !== 247 /* EnumDeclaration */; })) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + var canCorrectToQuestionDot = isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 96 /* NewKeyword */ || node.keywordToken === 93 /* ImportKeyword */)) { - var completion = (node.keywordToken === 96 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 98 /* NewKeyword */ || node.keywordToken === 95 /* ImportKeyword */)) { + var completion = (node.keywordToken === 98 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + var type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + var canCorrectToQuestionDot = isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait, insertQuestionDot) { isNewIdentifierLocation = !!type.getStringIndexType(); + if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { + isNewIdentifierLocation = true; + } + var propertyAccess = node.kind === 187 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -102993,13 +106905,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { - addPropertySymbol(symbol); + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { + addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); + } + } + } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true, insertQuestionDot); + } } } } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait, insertQuestionDot) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -103013,15 +106936,32 @@ var ts; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) + ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } + : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addSymbolOriginInfo(symbol); symbols.push(symbol); } + function addSymbolOriginInfo(symbol) { + if (preferences.includeCompletionsWithInsertText) { + if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + } + else if (insertQuestionDot) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + } + } + } + function getNullableSymbolOriginInfoKind(kind) { + return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -103054,6 +106994,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -103107,19 +107048,38 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 288 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ }; + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; } } } if (shouldOfferImportCompletions()) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && ts.isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target); + var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); + if (!detailsEntryId && importSuggestionsCache) { + importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); + } + autoImportSuggestions.forEach(function (_a) { + var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; + if (detailsEntryId) { + if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { + return; + } + } + else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { + return; + } + var symbolId = ts.getSymbolId(symbol); + symbols.push(symbol); + symbolToOriginInfoMap[symbolId] = origin; + symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; + }); } filterGlobalCompletion(symbols); } @@ -103141,10 +107101,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 210 /* TemplateExpression */: + case 274 /* JsxExpression */: + case 222 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -103189,28 +107149,28 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 107 /* TypeOfKeyword */ && + (contextToken.parent.kind === 171 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + case 58 /* ColonToken */: + return parentKind === 158 /* PropertyDeclaration */ || + parentKind === 157 /* PropertySignature */ || + parentKind === 155 /* Parameter */ || + parentKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; - case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; - case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; - case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + case 62 /* EqualsToken */: + return parentKind === 246 /* TypeAliasDeclaration */; + case 122 /* AsKeyword */: + return parentKind === 216 /* AsExpression */; + case 29 /* LessThanToken */: + return parentKind === 168 /* TypeReference */ || + parentKind === 198 /* TypeAssertionExpression */; + case 89 /* ExtendsKeyword */: + return parentKind === 154 /* TypeParameter */; } } return false; @@ -103224,10 +107184,71 @@ var ts; ts.addToSeen(seenModules, ts.getSymbolId(sym)) && typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); } - function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { - var tokenTextLowerCase = tokenText.toLowerCase(); + /** + * Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates" + * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but + * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, + * if and only if the the first can be imported (it may be excluded due to package.json filtering in + * `codefix.forEachExternalModuleToImportFrom`). + * + * Example. Imagine a chain of node_modules re-exporting one original symbol: + * + * ```js + * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js + * +-----------------------+ +--------------------------+ +--------------------------+ + * | | | | | | + * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | + * | | | | | | + * +-----------------------+ +--------------------------+ +--------------------------+ + * ``` + * + * Also imagine three buckets, which we’ll reference soon: + * + * ```md + * | | | | | | + * | **Bucket A** | | **Bucket B** | | **Bucket C** | + * | Symbols to | | Aliases to symbols | | Symbols to return | + * | definitely | | in Buckets A or C | | if nothing better | + * | return | | (don’t return these) | | comes along | + * |__________________| |______________________| |___________________| + * ``` + * + * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it + * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not + * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we + * may not be sure whether or not it should go in the list. So, we’ll take the following steps: + * + * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is + * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B + * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. + * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. + * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' + * should never be returned in the final list, so put it in Bucket B. + * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so + * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. + * Put this symbol in Bucket A. + * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t + * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move + * everything from Bucket C to Bucket A. + */ + function getSymbolsFromOtherSourceFileExports(target, host) { + var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); + if (cached) { + log("getSymbolsFromOtherSourceFileExports: Using cached list"); + return cached; + } + var startTime = ts.timestamp(); + log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); var seenResolvedModules = ts.createMap(); - ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + /** Bucket B */ + var aliasesToAlreadyIncludedSymbols = ts.createMap(); + /** Bucket C */ + var aliasesToReturnIfOriginalsAreMissing = ts.createMap(); + /** Bucket A */ + var results = []; + /** Ids present in `results` for faster lookup */ + var resultSymbolIds = ts.createMap(); + ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; @@ -103237,41 +107258,75 @@ var ts; if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { return; } + // Don't add another completion for `export =` of a symbol that's already global. + // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. if (resolvedModuleSymbol !== moduleSymbol && - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { - symbols.push(resolvedModuleSymbol); - symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator && !ts.findAncestor(d, ts.isGlobalScopeAugmentation); })) { + pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true); } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; - // Don't add a completion for a re-export, only for the original. - // The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details. - // This is just to avoid adding duplicate completion entries. - // - // If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols. - if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol - || ts.some(symbol.declarations, function (d) { - // If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion. - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - return ts.isExportSpecifier(d) && (d.propertyName ? ts.isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier); - })) { + // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. + if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { continue; } - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + var symbolId = ts.getSymbolId(symbol).toString(); + // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. + var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; + // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { + // Walk the export chain back one module (step 1 or 2 in diagrammed example). + // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. + var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); + if (!nearestExportSymbol) + continue; + var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); + var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); + if (!symbolHasBeenSeen) { + aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol }); + aliasesToAlreadyIncludedSymbols.set(symbolId, true); + } + else { + // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here + // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. + ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); + } } - var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; - if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { - symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin; + else { + // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.delete(symbolId); + pushSymbol(symbol, moduleSymbol); } } }); + // By this point, any potential duplicates that were actually duplicates have been + // removed, so the rest need to be added. (Step 4 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { + var alias = _a.alias, moduleSymbol = _a.moduleSymbol; + return pushSymbol(alias, moduleSymbol); + }); + log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); + return results; + function pushSymbol(symbol, moduleSymbol, skipFilter) { + if (skipFilter === void 0) { skipFilter = false; } + var isDefaultExport = symbol.escapedName === "default" /* Default */; + if (isDefaultExport) { + symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + } + ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); + var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; + results.push({ + symbol: symbol, + symbolName: getSymbolName(symbol, origin, target), + origin: origin, + skipFilter: skipFilter, + }); + } + } + function getNearestExportSymbol(fromSymbol) { + return findAlias(typeChecker, fromSymbol, function (alias) { + return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); + }); } /** * True if you could remove some characters in `a` to get `b`. @@ -103318,12 +107373,12 @@ var ts; if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 266 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 267 /* JsxClosingElement */ || contextToken.parent.kind === 265 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 264 /* JsxElement */; } } return false; @@ -103334,40 +107389,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 195 /* CallExpression */ // func( a, | + || containingNodeKind === 161 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 196 /* NewExpression */ // new C(a, | + || containingNodeKind === 191 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 208 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 169 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 195 /* CallExpression */ // func( | + || containingNodeKind === 161 /* Constructor */ // constructor( | + || containingNodeKind === 196 /* NewExpression */ // new C(a| + || containingNodeKind === 199 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 181 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 131 /* ModuleKeyword */: // module | - case 132 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 191 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 166 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 153 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 134 /* ModuleKeyword */: // module | + case 135 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 248 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | - case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 244 /* ClassDeclaration */; // class A{ | + case 62 /* EqualsToken */: + return containingNodeKind === 241 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 208 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 210 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 220 /* TemplateSpan */; // `aa ${10} dd ${| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -103394,8 +107449,8 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { - var typeForObject = typeChecker.getContextualType(objectLikeContainer); + if (objectLikeContainer.kind === 192 /* ObjectLiteralExpression */) { + var typeForObject = typeChecker.getContextualType(objectLikeContainer, 4 /* Completion */); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = ts.hasIndexSignature(typeForObject); @@ -103403,7 +107458,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 188 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -103414,12 +107469,12 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 231 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 155 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 160 /* MethodDeclaration */ || rootDeclaration.parent.kind === 163 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -103436,6 +107491,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -103461,7 +107517,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 256 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -103484,7 +107540,7 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) @@ -103492,7 +107548,7 @@ var ts; var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 75 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -103527,9 +107583,9 @@ var ts; return parent; } break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 73 /* Identifier */: + case 75 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -103579,23 +107635,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 30 /* GreaterThanToken */: // End of a type argument list - case 29 /* LessThanSlashToken */: - case 42 /* SlashToken */: - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { - if (contextToken.kind === 30 /* GreaterThanToken */) { + case 31 /* GreaterThanToken */: // End of a type argument list + case 30 /* LessThanSlashToken */: + case 43 /* SlashToken */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 272 /* JsxAttributes */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 265 /* JsxSelfClosingElement */ || parent.kind === 266 /* JsxOpeningElement */)) { + if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) break; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103607,7 +107663,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 271 /* JsxAttribute */) || (parent.kind === 273 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103617,8 +107673,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 274 /* JsxExpression */ && + parent.parent && parent.parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103626,7 +107682,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 273 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103646,64 +107702,64 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 241 /* VariableDeclaration */ || + containingNodeKind === 242 /* VariableDeclarationList */ || + containingNodeKind === 224 /* VariableStatement */ || + containingNodeKind === 247 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| - case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [.| + case 58 /* ColonToken */: + return containingNodeKind === 190 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 278 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | - case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 247 /* EnumDeclaration */; // enum a { | + case 29 /* LessThanToken */: + return containingNodeKind === 244 /* ClassDeclaration */ || // class A< | + containingNodeKind === 213 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 245 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 246 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 119 /* StaticKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + return containingNodeKind === 155 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 189 /* ArrayBindingPattern */); // var [...z| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 155 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 122 /* AsKeyword */: + return containingNodeKind === 257 /* ImportSpecifier */ || + containingNodeKind === 261 /* ExportSpecifier */ || + containingNodeKind === 255 /* NamespaceImport */; + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 111 /* InterfaceKeyword */: - case 91 /* FunctionKeyword */: - case 106 /* VarKeyword */: - case 93 /* ImportKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 118 /* YieldKeyword */: - case 141 /* TypeKeyword */: // type htm| + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 113 /* InterfaceKeyword */: + case 93 /* FunctionKeyword */: + case 108 /* VarKeyword */: + case 95 /* ImportKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 120 /* YieldKeyword */: + case 144 /* TypeKeyword */: // type htm| return true; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -103724,22 +107780,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 119 /* AbstractKeyword */: - case 77 /* ClassKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 91 /* FunctionKeyword */: - case 111 /* InterfaceKeyword */: - case 112 /* LetKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 117 /* StaticKeyword */: - case 106 /* VarKeyword */: - case 118 /* YieldKeyword */: + case 121 /* AbstractKeyword */: + case 79 /* ClassKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 93 /* FunctionKeyword */: + case 113 /* InterfaceKeyword */: + case 114 /* LetKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 119 /* StaticKeyword */: + case 108 /* VarKeyword */: + case 120 /* YieldKeyword */: return true; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -103749,7 +107805,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 161 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -103768,16 +107824,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 279 /* PropertyAssignment */ && + m.kind !== 280 /* ShorthandPropertyAssignment */ && + m.kind !== 190 /* BindingElement */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */ && + m.kind !== 281 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103785,9 +107843,12 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 73 /* Identifier */) { + if (m.propertyName.kind === 75 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -103800,7 +107861,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -103812,10 +107906,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 158 /* PropertyDeclaration */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -103849,17 +107943,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 271 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -103870,7 +107970,7 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.startsWithQuote(name) + || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; @@ -103899,7 +107999,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 76 /* FirstKeyword */; i <= 151 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -103925,9 +108025,11 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 126 /* DeclareKeyword */ - || kind === 131 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 142 /* UndefinedKeyword */; + || kind === 129 /* DeclareKeyword */ + || kind === 134 /* ModuleKeyword */ + || kind === 144 /* TypeKeyword */ + || kind === 135 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 145 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -103937,7 +108039,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 78 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 80 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -103947,55 +108049,55 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 121 /* AnyKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 146 /* GlobalKeyword */: - case 110 /* ImplementsKeyword */: - case 128 /* InferKeyword */: - case 111 /* InterfaceKeyword */: - case 129 /* IsKeyword */: - case 130 /* KeyOfKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 133 /* NeverKeyword */: - case 136 /* NumberKeyword */: - case 137 /* ObjectKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: - case 139 /* StringKeyword */: - case 140 /* SymbolKeyword */: - case 141 /* TypeKeyword */: - case 143 /* UniqueKeyword */: - case 144 /* UnknownKeyword */: + case 121 /* AbstractKeyword */: + case 124 /* AnyKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 149 /* GlobalKeyword */: + case 112 /* ImplementsKeyword */: + case 131 /* InferKeyword */: + case 113 /* InterfaceKeyword */: + case 132 /* IsKeyword */: + case 133 /* KeyOfKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 136 /* NeverKeyword */: + case 139 /* NumberKeyword */: + case 140 /* ObjectKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: + case 142 /* StringKeyword */: + case 143 /* SymbolKeyword */: + case 144 /* TypeKeyword */: + case 146 /* UniqueKeyword */: + case 147 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 134 /* ReadonlyKeyword */; + return kind === 137 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 125 /* ConstructorKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 122 /* AsyncKeyword */: + case 121 /* AbstractKeyword */: + case 128 /* ConstructorKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 125 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 122 /* AsyncKeyword */ - || kind === 123 /* AwaitKeyword */ + return kind === 125 /* AsyncKeyword */ + || kind === 126 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -104033,7 +108135,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 314 /* SyntaxList */: + case 317 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -104041,7 +108143,7 @@ var ts; return cls; } break; - case 73 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } + case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return ts.findAncestor(location, ts.isObjectTypeDeclaration); } @@ -104067,7 +108169,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -104087,11 +108189,11 @@ var ts; return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -104100,6 +108202,14 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } + function findAlias(typeChecker, symbol, predicate) { + var currentAlias = symbol; + while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { + if (predicate(currentAlias)) { + return currentAlias; + } + } + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -104152,40 +108262,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 92 /* IfKeyword */: - case 84 /* ElseKeyword */: + case 94 /* IfKeyword */: + case 86 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 98 /* ReturnKeyword */: + case 100 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 104 /* TryKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: - var tryStatement = node.kind === 76 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 106 /* TryKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: + var tryStatement = node.kind === 78 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 75 /* CaseKeyword */: - case 81 /* DefaultKeyword */: + case 77 /* CaseKeyword */: + case 83 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 74 /* BreakKeyword */: - case 79 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 81 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 90 /* ForKeyword */: - case 108 /* WhileKeyword */: - case 83 /* DoKeyword */: + case 92 /* ForKeyword */: + case 110 /* WhileKeyword */: + case 85 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 125 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [125 /* ConstructorKeyword */]); - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [127 /* GetKeyword */, 138 /* SetKeyword */]); - case 123 /* AwaitKeyword */: + case 128 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [128 /* ConstructorKeyword */]); + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [130 /* GetKeyword */, 141 /* SetKeyword */]); + case 126 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 118 /* YieldKeyword */: + case 120 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -104228,7 +108338,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 288 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -104260,16 +108370,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 236 /* SwitchStatement */: + if (statement.kind === 232 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -104285,11 +108395,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 222 /* Block */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArrays(declaration.members, [declaration]); @@ -104297,14 +108407,14 @@ var ts; else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 172 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. @@ -104335,12 +108445,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 92 /* ForKeyword */, 110 /* WhileKeyword */, 85 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 227 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 110 /* WhileKeyword */)) { break; } } @@ -104348,7 +108458,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */, 79 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */, 81 /* ContinueKeyword */); } }); return keywords; @@ -104357,13 +108467,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -104371,13 +108481,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 100 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 102 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 75 /* CaseKeyword */, 81 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 77 /* CaseKeyword */, 83 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */); } }); }); @@ -104385,13 +108495,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 104 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 106 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 76 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 78 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 89 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 91 /* FinallyKeyword */); } return keywords; } @@ -104402,13 +108512,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -104420,11 +108530,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -104436,13 +108546,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 122 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 125 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 123 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 126 /* AwaitKeyword */); } }); }); @@ -104457,7 +108567,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 118 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 120 /* YieldKeyword */); } }); }); @@ -104476,7 +108586,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 84 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 86 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -104511,10 +108621,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 92 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 94 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 84 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 86 /* ElseKeyword */)) { break; } } @@ -104730,12 +108840,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 241 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { directImports.push(name); break; } @@ -104744,22 +108854,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 73 /* Identifier */: // for 'const x = require("y"); + case 75 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 255 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -104769,7 +108879,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 187 /* ImportType */: directImports.push(direct); break; default: @@ -104786,7 +108896,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 288 /* SourceFile */ || sourceFileLike.kind === 248 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -104841,17 +108951,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 252 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 73 /* Identifier */) { + if (decl.kind === 75 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 187 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -104866,17 +108976,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 259 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -104926,7 +109036,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 261 /* ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -104955,7 +109065,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 285 /* SourceFile */) { + if (searchSourceFile.kind === 288 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -105003,7 +109113,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 288 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -105018,15 +109128,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -105050,7 +109160,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 193 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -105184,13 +109294,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -105223,21 +109333,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 288 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 249 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 248 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 263 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -105286,7 +109396,7 @@ var ts; if (ts.isInJSFile(node)) { var binaryExpression = ts.isBinaryExpression(node.parent) ? node.parent : - ts.isPropertyAccessExpression(node.parent) && + ts.isAccessExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && node.parent.parent.left === node.parent ? node.parent.parent : @@ -105330,7 +109440,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 81 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 83 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -105339,7 +109449,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -105347,27 +109457,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -105411,18 +109521,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 99 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -105511,7 +109621,7 @@ var ts; return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 83 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -105566,13 +109676,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 213 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105601,7 +109711,7 @@ var ts; function getTextSpan(node, sourceFile, endNode) { var start = node.getStart(sourceFile); var end = (endNode || node).getEnd(); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { ts.Debug.assert(endNode === undefined); start += 1; end -= 1; @@ -105616,7 +109726,7 @@ var ts; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 81 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 83 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -105624,49 +109734,49 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 4194304 /* Ambient */)) + if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 208 /* BinaryExpression */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 83 /* DefaultKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 261 /* ExportSpecifier */: + case 254 /* ImportClause */: // default import + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 245 /* InterfaceDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 271 /* JsxAttribute */: + case 248 /* ModuleDeclaration */: + case 251 /* NamespaceExportDeclaration */: + case 255 /* NamespaceImport */: + case 155 /* Parameter */: + case 280 /* ShorthandPropertyAssignment */: + case 246 /* TypeAliasDeclaration */: + case 154 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: + case 159 /* MethodSignature */: + case 157 /* PropertySignature */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -105826,10 +109936,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -105846,11 +109956,9 @@ var ts; var sourceFile = decl.getSourceFile(); if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` - var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) - ? decl.left.expression - : ts.isExportAssignment(decl) - ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 88 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } @@ -105859,21 +109967,21 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 134 /* ReadonlyKeyword */ + return node.kind === 137 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 134 /* ReadonlyKeyword */; + && node.parent.operator === 137 /* ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 134 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 137 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 134 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 137 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -105889,7 +109997,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -105906,7 +110014,7 @@ var ts; // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 81 /* DefaultKeyword */) { + else if (node && node.kind === 83 /* DefaultKeyword */) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } @@ -105934,9 +110042,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: return 1 /* Constructor */; - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -106172,7 +110280,7 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 200 /* FunctionExpression */ || valueDeclaration.kind === 213 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -106182,7 +110290,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 244 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -106211,7 +110319,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -106319,8 +110427,9 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.text.length === searchSymbolName.length; + case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && @@ -106328,7 +110437,7 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 81 /* DefaultKeyword */: + case 83 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -106394,7 +110503,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 73 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 75 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -106450,12 +110559,14 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 81 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 81 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 83 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 83 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol); - var exportInfo = ts.Debug.assertDefined(FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker)); - searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); + var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); + if (exportInfo) { + searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); + } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { @@ -106514,7 +110625,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -106530,7 +110641,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 81 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 83 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -106557,7 +110668,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 101 /* ThisKeyword */) { + if (node.kind === 103 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -106576,18 +110687,18 @@ var ts; if (constructorSymbol) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 128 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 161 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 160 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 103 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -106608,10 +110719,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 161 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 101 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -106635,10 +110746,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 73 /* Identifier */) { + if (refNode.kind !== 75 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 280 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -106658,7 +110769,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 222 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -106686,13 +110797,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 191 /* ArrayLiteralExpression */: return true; default: return false; @@ -106745,13 +110856,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -106760,7 +110871,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 99 /* SuperKeyword */) { + if (node.kind !== 101 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -106772,41 +110883,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 75 /* Identifier */ && node.parent.kind === 155 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 288 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -106814,19 +110925,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 288 /* SourceFile */: + return container.kind === 288 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -106945,7 +111056,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 190 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -106995,11 +111106,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -107049,12 +111159,12 @@ var ts; /* @internal */ var ts; (function (ts) { - function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, _preferences, sourceMapper) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences, sourceMapper) { var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); - return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, function (changeTracker) { updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); @@ -107302,9 +111412,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); + return node.kind === 101 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -107312,7 +111422,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -107465,31 +111575,32 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 73 /* Identifier */) { + if (node.kind !== 75 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 257 /* ImportSpecifier */: + return declaration.parent.kind === 256 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { // There are cases when you extend a function by adding properties to it afterwards, - // we want to strip those extra properties - var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return !ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration; }) || undefined; + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 128 /* ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -107504,8 +111615,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -107558,9 +111673,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return true; default: return false; @@ -107662,7 +111777,7 @@ var ts; // The property length will have two declarations of property length coming // from Array - Array and Array var documentationComment = []; - forEachUnique(declarations, function (declaration) { + ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var comment = _a[_i].comment; if (comment === undefined) @@ -107678,11 +111793,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return [declaration]; - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -107691,7 +111806,7 @@ var ts; function getJsDocTagsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once. var tags = []; - forEachUnique(declarations, function (declaration) { + ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { var tag = _a[_i]; tags.push({ name: tag.tagName.text, text: getCommentText(tag) }); @@ -107703,16 +111818,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return withNode(tag.class); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -107728,24 +111843,6 @@ var ts; return comment === undefined ? s : s + " " + comment; } } - /** - * Iterates through 'array' by index and performs the callback on each element of array until the callback - * returns a truthy value, then returns that value. - * If no such value is found, the callback is applied to each element of array and undefined is returned. - */ - function forEachUnique(array, callback) { - if (array) { - for (var i = 0; i < array.length; i++) { - if (array.indexOf(array[i]) === i) { - var result = callback(array[i], i); - if (result) { - return result; - } - } - } - } - return undefined; - } function getJSDocTagNameCompletions() { return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { @@ -107889,7 +111986,7 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 73 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 75 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -107899,23 +111996,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 159 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 157 /* PropertySignature */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 246 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -107923,14 +112020,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 288 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 248 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 208 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -107949,14 +112046,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 199 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 213 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -108018,9 +112115,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -108030,7 +112127,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 153 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -108047,7 +112144,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 153 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -108091,6 +112188,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -108105,6 +112203,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -108115,13 +112218,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -108147,7 +112252,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -108172,28 +112277,56 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isPropertyNameLiteral(entityName)) { + var name = ts.getNameOrArgument(entityName); + var nameText = ts.getElementOrPropertyAccessName(entityName); + entityName = entityName.expression; + if (nameText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -108203,46 +112336,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 159 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -108254,90 +112389,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 280 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 281 /* SpreadAssignment */: + var expression = node.expression; + // Use the expression as the name of the SpreadAssignment, otherwise show as . + ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); + break; + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: + case 241 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + addNodeWithRecursiveChild(node, node.body); + break; + case 247 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 261 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 166 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 246 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && ts.getElementOrPropertyAccessName(assignmentTarget) !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else if (ts.isBindableStaticAccessExpression(assignmentTarget)) { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, ts.getNameOrArgument(assignmentTarget)); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -108360,8 +112573,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -108375,7 +112588,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -108384,7 +112597,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -108392,7 +112605,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -108405,12 +112711,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -108426,7 +112732,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 248 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -108456,43 +112762,46 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 248 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); if (declName && ts.isPropertyName(declName)) { - return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 + var propertyName = ts.getPropertyNameForPropertyNameNode(declName); + return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 248 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text + : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -108500,24 +112809,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 164 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -108527,28 +112839,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 246 /* TypeAliasDeclaration */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -108558,21 +112870,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -108585,18 +112891,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108627,7 +112933,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -108641,13 +112947,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 153 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 288 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 241 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -108655,14 +112961,14 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -108679,7 +112985,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -108700,14 +113010,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -108721,8 +113041,8 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, _preferences) { - var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext }); + function organizeImports(sourceFile, formatContext, host, program, preferences) { + var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); var coalesceAndOrganizeImports = function (importGroup) { return coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); @@ -109050,7 +113370,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 93 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 95 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -109167,7 +113487,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -109175,23 +113495,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 227 /* DoStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 278 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - return spanForNode(ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -109199,24 +113519,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 250 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -109258,7 +113578,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 201 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -109793,10 +114113,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 126 /* DeclareKeyword */) { + if (token === 129 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 131 /* ModuleKeyword */) { + if (token === 134 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -109814,7 +114134,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 93 /* ImportKeyword */) { + if (token === 95 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -109830,9 +114150,9 @@ var ts; return true; } else { - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -109840,7 +114160,7 @@ var ts; return true; } } - else if (token === 60 /* EqualsToken */) { + else if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -109863,7 +114183,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -109873,13 +114193,13 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 120 /* AsKeyword */) { + if (token === 122 /* AsKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -109897,7 +114217,7 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 86 /* ExportKeyword */) { + if (token === 88 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); if (token === 18 /* OpenBraceToken */) { @@ -109909,7 +114229,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -109919,9 +114239,9 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -109929,11 +114249,11 @@ var ts; } } } - else if (token === 93 /* ImportKeyword */) { + else if (token === 95 /* ImportKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 60 /* EqualsToken */) { + if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -109946,7 +114266,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 135 /* RequireKeyword */) { + if (token === 138 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -109961,7 +114281,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 73 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 75 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -110095,14 +114415,14 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 81 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 83 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 153 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -110149,7 +114469,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { // Exclude the quotes start += 1; width -= 2; @@ -110158,9 +114478,10 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -110200,7 +114521,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -110312,14 +114633,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 134 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 56 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 137 /* ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 154 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -110327,7 +114648,7 @@ var ts; // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; })), closeBraceToken, ]; @@ -110339,7 +114660,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -110352,14 +114673,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } return node.getChildren(); @@ -110426,7 +114747,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(314 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(317 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -110435,14 +114756,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 266 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 267 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -110535,7 +114856,7 @@ var ts; var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -110594,7 +114915,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -110647,10 +114968,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 197 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 210 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -110717,17 +115038,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 199 /* ParenthesizedExpression */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -110798,11 +115119,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -110851,7 +115172,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -110916,8 +115237,8 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(); - var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(28 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(29 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { @@ -110950,7 +115271,7 @@ var ts; var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(30 /* GreaterThanToken */)], parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -111026,6 +115347,10 @@ var ts; if (!sourceFile) return undefined; var program = host.getProgram(); + // If this is source file of project reference source (instead of redirect) there is no generated position + if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) { + return undefined; + } var options = program.getCompilerOptions(); var outPath = options.outFile || options.out; var declarationPath = outPath ? @@ -111163,7 +115488,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -111173,7 +115498,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -111206,11 +115531,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -111227,12 +115552,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 255 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -111290,13 +115615,13 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ - case 97 /* NullKeyword */: - case 73 /* Identifier */: // identifier includes undefined + // falls through + case 99 /* NullKeyword */: + case 75 /* Identifier */: // identifier includes undefined return true; default: return false; @@ -111319,7 +115644,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -111356,7 +115681,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 101 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 103 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -111407,11 +115732,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + return location.kind === 75 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 271 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -111438,13 +115763,13 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 101 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 103 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 101 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(101 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 103 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(103 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { @@ -111454,7 +115779,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 193 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -111474,7 +115799,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 196 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 101 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -111492,7 +115817,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -111509,14 +115834,14 @@ var ts; case "parameter" /* parameterElement */: case "local var" /* localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -111529,29 +115854,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 128 /* ConstructorKeyword */ && location.parent.kind === 161 /* Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration - var locationIsSymbolDeclaration = ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { + return declaration === (location.kind === 128 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 161 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 161 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 164 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -111561,7 +115886,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -111569,7 +115894,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(77 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(79 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -111577,37 +115902,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(111 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(113 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(78 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(80 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(85 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(87 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 248 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 75 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 135 /* NamespaceKeyword */ : 134 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -111626,7 +115951,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 154 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111634,21 +115959,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + if (declaration.kind === 165 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 164 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 246 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -111660,11 +115985,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 282 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -111690,32 +116015,32 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 251 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(135 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 258 /* ExportAssignment */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 83 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 261 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(93 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(95 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 252 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(135 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(138 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -111724,7 +116049,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -111738,7 +116063,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(101 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(103 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -111749,7 +116074,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -111787,10 +116112,10 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 288 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 208 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -111833,7 +116158,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(94 /* InKeyword */)); + displayParts.push(ts.keywordPart(96 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -111843,7 +116168,7 @@ var ts; var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(56 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -111878,7 +116203,7 @@ var ts; if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(38 /* PlusToken */)); + displayParts.push(ts.operatorPart(39 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); @@ -111903,16 +116228,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 200 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 241 /* VariableDeclaration */ && declaration.kind !== 243 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 288 /* SourceFile */ || parent.kind === 249 /* ModuleBlock */) { return false; } } @@ -112157,7 +116482,9 @@ var ts; var res = cb({ advance: advance, readTokenInfo: readTokenInfo, + readEOFTokenRange: readEOFTokenRange, isOnToken: isOnToken, + isOnEOF: isOnEOF, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, @@ -112197,11 +116524,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 32 /* GreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -112209,12 +116536,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 271 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 73 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 75 /* Identifier */; } } return false; @@ -112230,23 +116557,18 @@ var ts; container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 42 /* SlashToken */ || t === 65 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -112263,11 +116585,7 @@ var ts; scanner.scan(); } var currentToken = getNextToken(n, expectedScanAction); - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var token = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); // consume trailing trivia if (trailingTrivia) { trailingTrivia = undefined; @@ -112277,11 +116595,7 @@ var ts; if (!ts.isTrivia(currentToken)) { break; } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var trivia = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); if (!trailingTrivia) { trailingTrivia = []; } @@ -112300,7 +116614,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -112334,11 +116648,19 @@ var ts; } return token; } + function readEOFTokenRange() { + ts.Debug.assert(isOnEOF()); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } + function isOnEOF() { + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + return current === 1 /* EndOfFileToken */; + } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, // then kind needs to be fixed. This might happen in cases @@ -112370,10 +116692,16 @@ var ts; formatting.anyContext = ts.emptyArray; var RuleAction; (function (RuleAction) { - RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; - RuleAction[RuleAction["Space"] = 2] = "Space"; - RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; - RuleAction[RuleAction["Delete"] = 8] = "Delete"; + RuleAction[RuleAction["StopProcessingSpaceActions"] = 1] = "StopProcessingSpaceActions"; + RuleAction[RuleAction["StopProcessingTokenActions"] = 2] = "StopProcessingTokenActions"; + RuleAction[RuleAction["InsertSpace"] = 4] = "InsertSpace"; + RuleAction[RuleAction["InsertNewLine"] = 8] = "InsertNewLine"; + RuleAction[RuleAction["DeleteSpace"] = 16] = "DeleteSpace"; + RuleAction[RuleAction["DeleteToken"] = 32] = "DeleteToken"; + RuleAction[RuleAction["InsertTrailingSemicolon"] = 64] = "InsertTrailingSemicolon"; + RuleAction[RuleAction["StopAction"] = 3] = "StopAction"; + RuleAction[RuleAction["ModifySpaceAction"] = 28] = "ModifySpaceAction"; + RuleAction[RuleAction["ModifyTokenAction"] = 96] = "ModifyTokenAction"; })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); var RuleFlags; (function (RuleFlags) { @@ -112389,8 +116717,10 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { - allTokens.push(token); + for (var token = 0 /* FirstToken */; token <= 151 /* LastToken */; token++) { + if (token !== 1 /* EndOfFileToken */) { + allTokens.push(token); + } } function anyTokenExcept() { var tokens = []; @@ -112401,256 +116731,259 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; - var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArrays(allTokens, [1 /* EndOfFileToken */])); + var keywords = tokenRangeFromRange(76 /* FirstKeyword */, 151 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 74 /* LastBinaryOperator */); + var binaryKeywordOperators = [96 /* InKeyword */, 97 /* InstanceOfKeyword */, 151 /* OfKeyword */, 122 /* AsKeyword */, 132 /* IsKeyword */]; + var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 75 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostincrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; - var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; + var unaryPreincrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostincrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; + var unaryPredecrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostdecrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArrays([73 /* Identifier */], ts.typeKeywords); + var typeNames = __spreadArrays([75 /* Identifier */], ts.typeKeywords); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([73 /* Identifier */, 3 /* MultiLineCommentTrivia */, 77 /* ClassKeyword */, 86 /* ExportKeyword */, 93 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([75 /* Identifier */, 3 /* MultiLineCommentTrivia */, 79 /* ClassKeyword */, 88 /* ExportKeyword */, 95 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 83 /* DoKeyword */, 104 /* TryKeyword */, 89 /* FinallyKeyword */, 84 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 85 /* DoKeyword */, 106 /* TryKeyword */, 91 /* FinallyKeyword */, 86 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* Ignore */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* Ignore */), - rule("NotSpaceBeforeColon", anyToken, 57 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), - rule("SpaceAfterColon", 57 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeQuestionMark", anyToken, 56 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBetweenImportParenInImportType", 93 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 95 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPreincrementOperator", 44 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPredecrementOperator", 45 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 44 /* PlusPlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 38 /* PlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 38 /* PlusToken */, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 45 /* MinusMinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 39 /* MinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 39 /* MinusToken */, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 84 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 108 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 86 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 110 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 91 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, 73 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 91 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 93 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 75 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 93 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [127 /* GetKeyword */, 138 /* SetKeyword */], 73 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 118 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [118 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 98 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [106 /* VarKeyword */, 102 /* ThrowKeyword */, 96 /* NewKeyword */, 82 /* DeleteKeyword */, 98 /* ReturnKeyword */, 105 /* TypeOfKeyword */, 123 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [112 /* LetKeyword */, 78 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [130 /* GetKeyword */, 141 /* SetKeyword */], 75 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 120 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [120 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 100 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterCertainKeywords", [108 /* VarKeyword */, 104 /* ThrowKeyword */, 98 /* NewKeyword */, 84 /* DeleteKeyword */, 100 /* ReturnKeyword */, 107 /* TypeOfKeyword */, 126 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [114 /* LetKeyword */, 80 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 107 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 109 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 122 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 122 /* AsyncKeyword */, 91 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 125 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 125 /* AsyncKeyword */, 93 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [73 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 73 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 42 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 42 /* SlashToken */, 30 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 60 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 60 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 75 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [131 /* ModuleKeyword */, 135 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [134 /* ModuleKeyword */, 138 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 119 /* AbstractKeyword */, - 77 /* ClassKeyword */, - 126 /* DeclareKeyword */, - 81 /* DefaultKeyword */, - 85 /* EnumKeyword */, - 86 /* ExportKeyword */, - 87 /* ExtendsKeyword */, - 127 /* GetKeyword */, - 110 /* ImplementsKeyword */, - 93 /* ImportKeyword */, - 111 /* InterfaceKeyword */, - 131 /* ModuleKeyword */, - 132 /* NamespaceKeyword */, - 114 /* PrivateKeyword */, - 116 /* PublicKeyword */, - 115 /* ProtectedKeyword */, - 134 /* ReadonlyKeyword */, - 138 /* SetKeyword */, - 117 /* StaticKeyword */, - 141 /* TypeKeyword */, - 145 /* FromKeyword */, - 130 /* KeyOfKeyword */, - 128 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [87 /* ExtendsKeyword */, 110 /* ImplementsKeyword */, 145 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + 121 /* AbstractKeyword */, + 79 /* ClassKeyword */, + 129 /* DeclareKeyword */, + 83 /* DefaultKeyword */, + 87 /* EnumKeyword */, + 88 /* ExportKeyword */, + 89 /* ExtendsKeyword */, + 130 /* GetKeyword */, + 112 /* ImplementsKeyword */, + 95 /* ImportKeyword */, + 113 /* InterfaceKeyword */, + 134 /* ModuleKeyword */, + 135 /* NamespaceKeyword */, + 116 /* PrivateKeyword */, + 118 /* PublicKeyword */, + 117 /* ProtectedKeyword */, + 137 /* ReadonlyKeyword */, + 141 /* SetKeyword */, + 119 /* StaticKeyword */, + 144 /* TypeKeyword */, + 148 /* FromKeyword */, + 133 /* KeyOfKeyword */, + 131 /* InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [89 /* ExtendsKeyword */, 112 /* ImplementsKeyword */, 148 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 73 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 75 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterOpenAngularBracket", 28 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 30 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterCloseAngularBracket", 30 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 30 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 73 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 75 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 119 /* AbstractKeyword */, - 73 /* Identifier */, - 86 /* ExportKeyword */, - 81 /* DefaultKeyword */, - 77 /* ClassKeyword */, - 117 /* StaticKeyword */, - 116 /* PublicKeyword */, - 114 /* PrivateKeyword */, - 115 /* ProtectedKeyword */, - 127 /* GetKeyword */, - 138 /* SetKeyword */, + 121 /* AbstractKeyword */, + 75 /* Identifier */, + 88 /* ExportKeyword */, + 83 /* DefaultKeyword */, + 79 /* ClassKeyword */, + 119 /* StaticKeyword */, + 118 /* PublicKeyword */, + 116 /* PrivateKeyword */, + 117 /* ProtectedKeyword */, + 130 /* GetKeyword */, + 141 /* SetKeyword */, 22 /* OpenBracketToken */, - 40 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 96 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 28 /* LessThanToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + 41 /* AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 98 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), + rule("SpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), - rule("NoSpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), - rule("SpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(122 /* AsyncKeyword */, 75 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(125 /* AsyncKeyword */, 77 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 90 /* ForKeyword */, 123 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 92 /* ForKeyword */, 126 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 83 /* DoKeyword */, 84 /* ElseKeyword */, 75 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 85 /* DoKeyword */, 86 /* ElseKeyword */, 77 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [106 /* TryKeyword */, 91 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } @@ -112690,6 +117023,9 @@ var ts; /// /// Contexts /// + function optionEquals(optionName, optionValue) { + return function (context) { return context.options && context.options[optionName] === optionValue; }; + } function isOptionEnabled(optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; } @@ -112706,45 +117042,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 229 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 179 /* ConditionalType */: + case 216 /* AsExpression */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 167 /* TypePredicate */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 190 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 252 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 241 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 155 /* Parameter */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: - return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 154 /* TypeParameter */: + return context.currentTokenSpan.kind === 96 /* InKeyword */ || context.nextTokenSpan.kind === 96 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 231 /* ForOfStatement */: + return context.currentTokenSpan.kind === 151 /* OfKeyword */ || context.nextTokenSpan.kind === 151 /* OfKeyword */; } return false; } @@ -112756,22 +117097,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 158 /* PropertyDeclaration */ || + contextKind === 157 /* PropertySignature */ || + contextKind === 155 /* Parameter */ || + contextKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 209 /* ConditionalExpression */ || + context.contextNode.kind === 179 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 188 /* ObjectBindingPattern */ || + context.contextNode.kind === 185 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -112797,31 +117138,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 192 /* ObjectLiteralExpression */: + case 249 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 164 /* CallSignature */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 201 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 245 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -112830,40 +117174,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 243 /* FunctionDeclaration */ || context.contextNode.kind === 200 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 172 /* TypeLiteral */: + case 248 /* ModuleDeclaration */: + case 259 /* ExportDeclaration */: + case 260 /* NamedExports */: + case 253 /* ImportDeclaration */: + case 256 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 278 /* CatchClause */: + case 249 /* ModuleBlock */: + case 236 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 222 /* Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 201 /* ArrowFunction */ && blockParent.kind !== 200 /* FunctionExpression */) { return true; } } @@ -112872,31 +117216,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 235 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 278 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 192 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 195 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 196 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -112908,28 +117253,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 201 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 187 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 264 /* JsxElement */ && context.contextNode.kind !== 268 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 274 /* JsxExpression */ || context.contextNode.kind === 273 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 271 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 271 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 265 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -112944,45 +117289,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 242 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 248 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 172 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 165 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { + if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 198 /* TypeAssertionExpression */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -112993,16 +117338,78 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 198 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 109 /* VoidKeyword */ && context.currentTokenParent.kind === 204 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 211 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 217 /* NonNullExpression */; + } + function isSemicolonDeletionContext(context) { + var nextTokenKind = context.nextTokenSpan.kind; + var nextTokenStart = context.nextTokenSpan.pos; + if (ts.isTrivia(nextTokenKind)) { + var nextRealToken = context.nextTokenParent === context.currentTokenParent + ? ts.findNextToken(context.currentTokenParent, ts.findAncestor(context.currentTokenParent, function (a) { return !a.parent; }), context.sourceFile) + : context.nextTokenParent.getFirstToken(context.sourceFile); + if (!nextRealToken) { + return true; + } + nextTokenKind = nextRealToken.kind; + nextTokenStart = nextRealToken.getStart(context.sourceFile); + } + var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; + var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; + if (startLine === endLine) { + return nextTokenKind === 19 /* CloseBraceToken */ + || nextTokenKind === 1 /* EndOfFileToken */; + } + if (nextTokenKind === 221 /* SemicolonClassElement */ || + nextTokenKind === 26 /* SemicolonToken */) { + return false; + } + if (context.contextNode.kind === 245 /* InterfaceDeclaration */ || + context.contextNode.kind === 246 /* TypeAliasDeclaration */) { + // Can’t remove semicolon after `foo`; it would parse as a method declaration: + // + // interface I { + // foo; + // (): void + // } + return !ts.isPropertySignature(context.currentTokenParent) + || !!context.currentTokenParent.type + || nextTokenKind !== 20 /* OpenParenToken */; + } + if (ts.isPropertyDeclaration(context.currentTokenParent)) { + return !context.currentTokenParent.initializer; + } + return context.currentTokenParent.kind !== 229 /* ForStatement */ + && context.currentTokenParent.kind !== 223 /* EmptyStatement */ + && context.currentTokenParent.kind !== 221 /* SemicolonClassElement */ + && nextTokenKind !== 22 /* OpenBracketToken */ + && nextTokenKind !== 20 /* OpenParenToken */ + && nextTokenKind !== 39 /* PlusToken */ + && nextTokenKind !== 40 /* MinusToken */ + && nextTokenKind !== 43 /* SlashToken */ + && nextTokenKind !== 13 /* RegularExpressionLiteral */ + && nextTokenKind !== 27 /* CommaToken */ + && nextTokenKind !== 210 /* TemplateExpression */ + && nextTokenKind !== 15 /* TemplateHead */ + && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* DotToken */; + } + function isSemicolonInsertionContext(context) { + var contextAncestor = ts.findAncestor(context.currentTokenParent, function (ancestor) { + if (ancestor.end !== context.currentTokenSpan.end) { + return "quit"; + } + return ts.syntaxMayBeASICandidate(ancestor.kind); + }); + return !!contextAncestor && ts.isASICandidate(contextAncestor, context.sourceFile); } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -113012,7 +117419,7 @@ var ts; var formatting; (function (formatting) { function getFormatContext(options) { - return { options: options, getRule: getRulesMap() }; + return { options: options, getRules: getRulesMap() }; } formatting.getFormatContext = getFormatContext; var rulesMapCache; @@ -113022,11 +117429,45 @@ var ts; } return rulesMapCache; } + /** + * For a given rule action, gets a mask of other rule actions that + * cannot be applied at the same position. + */ + function getRuleActionExclusion(ruleAction) { + var mask = 0; + if (ruleAction & 1 /* StopProcessingSpaceActions */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 2 /* StopProcessingTokenActions */) { + mask |= 96 /* ModifyTokenAction */; + } + if (ruleAction & 28 /* ModifySpaceAction */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 96 /* ModifyTokenAction */) { + mask |= 96 /* ModifyTokenAction */; + } + return mask; + } function createRulesMap(rules) { var map = buildMap(rules); return function (context) { var bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)]; - return bucket && ts.find(bucket, function (rule) { return ts.every(rule.context, function (c) { return c(context); }); }); + if (bucket) { + var rules_1 = []; + var ruleActionMask = 0; + for (var _i = 0, bucket_1 = bucket; _i < bucket_1.length; _i++) { + var rule = bucket_1[_i]; + var acceptRuleActions = ~getRuleActionExclusion(ruleActionMask); + if (rule.action & acceptRuleActions && ts.every(rule.context, function (c) { return c(context); })) { + rules_1.push(rule); + ruleActionMask |= rule.action; + } + } + if (rules_1.length) { + return rules_1; + } + } }; } function buildMap(rules) { @@ -113034,8 +117475,8 @@ var ts; var map = new Array(mapRowLength * mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(map.length); - for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) { - var rule = rules_1[_i]; + for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) { + var rule = rules_2[_i]; var specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific; for (var _a = 0, _b = rule.leftTokenRange.tokens; _a < _b.length; _a++) { var left = _b[_a]; @@ -113053,16 +117494,16 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 151 /* LastKeyword */ && column <= 151 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 151 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = maskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; + RulesPosition[RulesPosition["StopRulesAny"] = maskBitSize * 1] = "StopRulesAny"; RulesPosition[RulesPosition["ContextRulesSpecific"] = maskBitSize * 2] = "ContextRulesSpecific"; RulesPosition[RulesPosition["ContextRulesAny"] = maskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = maskBitSize * 4] = "NoContextRulesSpecific"; @@ -113084,11 +117525,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action & 3 /* StopAction */ ? + specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -113113,6 +117554,16 @@ var ts; (function (ts) { var formatting; (function (formatting) { + function createTextRangeWithKind(pos, end, kind) { + var textRangeWithKind = { pos: pos, end: end, kind: kind }; + if (ts.Debug.isDebugging) { + Object.defineProperty(textRangeWithKind, "__debugKind", { + get: function () { return ts.Debug.formatSyntaxKind(kind); }, + }); + } + return textRangeWithKind; + } + formatting.createTextRangeWithKind = createTextRangeWithKind; var Constants; (function (Constants) { Constants[Constants["Unknown"] = -1] = "Unknown"; @@ -113236,17 +117687,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 249 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 288 /* SourceFile */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -113381,7 +117832,7 @@ var ts; return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) { - var options = _a.options, getRule = _a.getRule; + var options = _a.options, getRules = _a.getRules; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); var previousRange; @@ -113471,19 +117922,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: return 79 /* ClassKeyword */; + case 245 /* InterfaceDeclaration */: return 113 /* InterfaceKeyword */; + case 243 /* FunctionDeclaration */: return 93 /* FunctionKeyword */; + case 247 /* EnumDeclaration */: return 247 /* EnumDeclaration */; + case 162 /* GetAccessor */: return 130 /* GetKeyword */; + case 163 /* SetAccessor */: return 141 /* SetKeyword */; + case 160 /* MethodDeclaration */: if (node.asteriskToken) { - return 40 /* AsteriskToken */; + return 41 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -113533,22 +117984,22 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 84 /* ElseKeyword */: - case 108 /* WhileKeyword */: - case 58 /* AtToken */: + case 86 /* ElseKeyword */: + case 110 /* WhileKeyword */: + case 59 /* AtToken */: return false; - case 42 /* SlashToken */: - case 30 /* GreaterThanToken */: + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 185 /* MappedType */) { return false; } break; @@ -113595,6 +118046,12 @@ var ts; } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } + if (!node.parent && formattingScanner.isOnEOF()) { + var token = formattingScanner.readEOFTokenRange(); + if (token.end <= node.end && previousRange) { + processPair(token, sourceFile.getLineAndCharacterOfPosition(token.pos).line, node, previousRange, previousRangeStartLine, previousParent, contextNode, nodeDynamicIndentation); + } + } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; @@ -113640,7 +118097,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 156 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 11 /* JsxText */) { @@ -113648,7 +118105,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 191 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -113816,35 +118273,39 @@ var ts; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = getRule(formattingContext); - var trimTrailingWhitespaces; + var rules = getRules(formattingContext); + var trimTrailingWhitespaces = false; var lineAction = 0 /* None */; - if (rule) { - lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - switch (lineAction) { - case 2 /* LineRemoved */: - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); - } - break; - case 1 /* LineAdded */: - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); - } - break; - default: - ts.Debug.assert(lineAction === 0 /* None */); - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & 8 /* Delete */) && rule.flags !== 1 /* CanDeleteNewLines */; + if (rules) { + // Apply rules in reverse order so that higher priority rules (which are first in the array) + // win in a conflict with lower priority rules. + ts.forEachRight(rules, function (rule) { + lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + switch (lineAction) { + case 2 /* LineRemoved */: + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + } + break; + case 1 /* LineAdded */: + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + } + break; + default: + ts.Debug.assert(lineAction === 0 /* None */); + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + }); } else { - trimTrailingWhitespaces = true; + trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -113981,20 +118442,28 @@ var ts; edits.push(ts.createTextChangeFromStartLength(start, len, newText)); } } + function recordInsert(start, text) { + if (text) { + edits.push(ts.createTextChangeFromStartLength(start, 0, text)); + } + } function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* Ignore */: + case 1 /* StopProcessingSpaceActions */: // no action required return 0 /* None */; - case 8 /* Delete */: + case 16 /* DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } break; - case 4 /* NewLine */: + case 32 /* DeleteToken */: + recordDelete(previousRange.pos, previousRange.end - previousRange.pos); + break; + case 8 /* InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines @@ -114008,7 +118477,7 @@ var ts; return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; } break; - case 2 /* Space */: + case 4 /* InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { return 0 /* None */; @@ -114018,6 +118487,9 @@ var ts; recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } + break; + case 64 /* InsertTrailingSemicolon */: + recordInsert(previousRange.end, ";"); } return 0 /* None */; } @@ -114031,8 +118503,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -114041,6 +118512,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -114066,34 +118538,34 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 201 /* ArrowFunction */: if (node.typeParameters === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.parameters === list) { return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.arguments === list) { return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 168 /* TypeReference */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -114102,8 +118574,8 @@ var ts; switch (kind) { case 20 /* OpenParenToken */: return 21 /* CloseParenToken */; - case 28 /* LessThanToken */: - return 30 /* GreaterThanToken */; + case 29 /* LessThanToken */: + return 31 /* GreaterThanToken */; case 18 /* OpenBraceToken */: return 19 /* CloseBraceToken */; } @@ -114191,7 +118663,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -114210,7 +118683,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 208 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -114364,7 +118837,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 288 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -114412,8 +118885,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); + if (parent.kind === 226 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 86 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -114425,7 +118898,10 @@ var ts; if (ts.isCallOrNewExpression(parent)) { if (!parent.arguments) return false; - var currentNode = ts.Debug.assertDefined(ts.find(parent.arguments, function (arg) { return arg.pos === child.pos; })); + var currentNode = ts.find(parent.arguments, function (arg) { return arg.pos === child.pos; }); + // If it's not one of the arguments, don't look past this + if (!currentNode) + return false; var currentIndex = parent.arguments.indexOf(currentNode); if (currentIndex === 0) return false; // Can't look at previous node if first @@ -114447,40 +118923,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -114503,7 +118979,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 242 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114576,83 +119052,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 225 /* ExpressionStatement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 191 /* ArrayLiteralExpression */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 185 /* MappedType */: + case 174 /* TupleType */: + case 250 /* CaseBlock */: + case 276 /* DefaultClause */: + case 275 /* CaseClause */: + case 199 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 224 /* VariableStatement */: + case 258 /* ExportAssignment */: + case 234 /* ReturnStatement */: + case 209 /* ConditionalExpression */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: + case 265 /* JsxSelfClosingElement */: + case 274 /* JsxExpression */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 155 /* Parameter */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 181 /* ParenthesizedType */: + case 197 /* TaggedTemplateExpression */: + case 205 /* AwaitExpression */: + case 260 /* NamedExports */: + case 256 /* NamedImports */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 158 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 241 /* VariableDeclaration */: + case 279 /* PropertyAssignment */: + case 208 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 192 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 208 /* BinaryExpression */) { + return true; + } + break; + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return childKind !== 222 /* Block */; + case 259 /* ExportDeclaration */: + return childKind !== 260 /* NamedExports */; + case 253 /* ImportDeclaration */: + return childKind !== 254 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 256 /* NamedImports */); + case 264 /* JsxElement */: + return childKind !== 267 /* JsxClosingElement */; + case 268 /* JsxFragment */: + return childKind !== 270 /* JsxClosingFragment */; + case 178 /* IntersectionType */: + case 177 /* UnionType */: + if (childKind === 172 /* TypeLiteral */) { return false; } // falls through @@ -114663,11 +119143,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: + return parent.kind !== 222 /* Block */; default: return false; } @@ -114809,7 +119289,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 192 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -114840,6 +119320,18 @@ var ts; cb(tracker); return tracker.getChanges(); }; + ChangeTracker.prototype.pushRaw = function (sourceFile, change) { + ts.Debug.assertEqual(sourceFile.fileName, change.fileName); + for (var _i = 0, _a = change.textChanges; _i < _a.length; _i++) { + var c = _a[_i]; + this.changes.push({ + kind: ChangeKind.Text, + sourceFile: sourceFile, + text: c.newText, + range: ts.createTextRangeFromSpan(c.span), + }); + } + }; ChangeTracker.prototype.deleteRange = function (sourceFile, range) { this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); }; @@ -114968,15 +119460,16 @@ var ts; endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) - return; // Function missing parentheses, give up + return false; // Function missing parentheses, give up // If no `)`, is an arrow function `x => x`, so use the end of the first parameter endNode = ts.first(node.parameters); } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 241 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); + return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; @@ -115091,18 +119584,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 155 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -115111,12 +119604,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + if (node.kind === 201 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(91 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(93 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -115125,14 +119618,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 222 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(100 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 200 /* FunctionExpression */ ? 93 /* FunctionKeyword */ : 79 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -115383,29 +119876,34 @@ var ts; var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + noIndent + (options.suffix || ""); } + function getFormatCodeSettingsForWriting(_a, sourceFile) { + var options = _a.options; + var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore; + var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile); + return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore }); + } /** Note: this may mutate `nodeIn`. */ function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) { var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta; var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text; if (validate) validate(node, text); - var formatOptions = formatContext.options; + var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile); var initialIndentation = indentation !== undefined ? indentation : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos); if (delta === undefined) { - delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatContext.options, nodeIn) ? (formatOptions.indentSize || 0) : 0; + delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } var file = { text: text, getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); } }; - var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, formatContext); + var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, __assign(__assign({}, formatContext), { options: formatOptions })); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ function getNonformattedText(node, sourceFile, newLineCharacter) { - var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); - var writer = createWriter(newLineCharacter, omitTrailingSemicolon); + var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -115440,9 +119938,9 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - function createWriter(newLine, omitTrailingSemicolon) { + function createWriter(newLine) { var lastNonTriviaPosition = 0; - var writer = omitTrailingSemicolon ? ts.getTrailingSemicolonOmittingWriter(ts.createTextWriter(newLine)) : ts.createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var onEmitNode = function (hint, node, printCallback) { if (node) { setPos(node, lastNonTriviaPosition); @@ -115593,6 +120091,8 @@ var ts; getColumn: getColumn, getIndent: getIndent, isAtStartOfLine: isAtStartOfLine, + hasTrailingComment: function () { return writer.hasTrailingComment(); }, + hasTrailingWhitespace: function () { return writer.hasTrailingWhitespace(); }, clear: clear }; } @@ -115657,14 +120157,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 153 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 152 /* Parameter */: { + case 155 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -115679,14 +120179,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 189 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -115694,13 +120194,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -115709,7 +120209,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -115756,13 +120256,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 253 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 278 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -115773,14 +120273,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -115941,10 +120441,10 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) - : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(147 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(147 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -115982,7 +120482,7 @@ var ts; errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -115996,27 +120496,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -116030,7 +120541,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -116043,64 +120554,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = function (identifier) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return "continue"; + } + var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); + var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); + var variableStatement = ts.getAncestor(declaration, 224 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; - }); - if (isUsedElsewhere) { - return; + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - return declaration.initializer; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); + }); + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { - return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 243 /* FunctionDeclaration */ || + ancestor.parent.kind === 200 /* FunctionExpression */ || + ancestor.parent.kind === 201 /* ArrowFunction */ || + ancestor.parent.kind === 160 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -116163,16 +120756,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || fixedNodes.tryAdd(initializer)) { - changeTracker.insertModifierBefore(sourceFile, 78 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 80 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 75 /* Identifier */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -116186,8 +120779,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 75 /* Identifier */: + case 208 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -116207,6 +120800,42 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addMissingDeclareProperty"; + var errorCodes = [ + ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Prefix_with_declare, fixId, ts.Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var fixedNodes = new ts.NodeSet(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start, fixedNodes); }); + }, + }); + function makeChange(changeTracker, sourceFile, pos, fixedNodes) { + var token = ts.getTokenAtPosition(sourceFile, pos); + if (!ts.isIdentifier(token)) { + return; + } + var declaration = token.parent; + if (declaration.kind === 158 /* PropertyDeclaration */ && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, 129 /* DeclareKeyword */, declaration); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -116328,33 +120957,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 241 /* VariableDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 158 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -116376,7 +121005,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 299 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -116416,8 +121045,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -116467,20 +121096,20 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; + var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; var token = ts.getTokenAtPosition(sourceFile, start); var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, formatContext, preferences); }); var name = declaration && ts.getNameOfDeclaration(declaration); return !name || changes.length === 0 ? undefined : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, formatContext, preferences); }); }, }); @@ -116520,8 +121149,8 @@ var ts; } return errorCode; } - function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 73 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 101 /* ThisKeyword */) { + function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, formatContext, preferences) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 103 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -116531,7 +121160,7 @@ var ts; case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location - annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); + annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken, formatContext, preferences); return parent; } if (ts.isPropertyAccessExpression(parent)) { @@ -116548,7 +121177,7 @@ var ts; case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { var symbol = program.getTypeChecker().getSymbolAtLocation(token); if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { - annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); + annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken, formatContext, preferences); return symbol.valueDeclaration; } return undefined; @@ -116562,14 +121191,14 @@ var ts; // Parameter declarations case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); return containingFunction; } // falls through case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: if (markSeen(containingFunction)) { var param = ts.cast(parent, ts.isParameter); - annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken); + annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken, formatContext, preferences); return param; } return undefined; @@ -116577,14 +121206,14 @@ var ts; case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { - annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); + annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host, formatContext, preferences); return containingFunction; } return undefined; // Set Accessor declarations case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); return containingFunction; } return undefined; @@ -116599,22 +121228,17 @@ var ts; return ts.Debug.fail(String(errorCode)); } } - function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { + function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken, formatContext, preferences) { if (ts.isIdentifier(declaration.name)) { - annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); + annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host, formatContext, preferences); } } - function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { + function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken, formatContext, preferences) { if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116625,7 +121249,7 @@ var ts; for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { - annotate(changes, sourceFile, declaration, type, program, host); + annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences); } } if (needParens) @@ -116633,14 +121257,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -116657,7 +121278,7 @@ var ts; ts.createJSDocThisTag(ts.createJSDocTypeExpression(typeNode)), ]); } - function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { + function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken, formatContext, preferences) { var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); @@ -116668,14 +121289,14 @@ var ts; annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); } else { - annotate(changes, sourceFile, param, type, program, host); + annotate(changes, sourceFile, param, type, program, host, formatContext, preferences); } } } - function annotate(changes, sourceFile, declaration, type, program, host) { + function annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 157 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -116684,11 +121305,32 @@ var ts; var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); addJSDocTags(changes, sourceFile, parent, [typeTag]); } - else { + else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences)) { changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); } } } + function tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences) { + var _a; + if (ts.isLiteralImportTypeNode(typeNode) && typeNode.qualifier && type.symbol) { + // Replace 'import("./a").SomeType' with 'SomeType' and an actual import if possible + var moduleSymbol = (_a = ts.find(type.symbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) === null || _a === void 0 ? void 0 : _a.getSourceFile().symbol; + // Symbol for the left-most thing after the dot + if (moduleSymbol) { + var symbol = ts.getFirstIdentifier(typeNode.qualifier).symbol; + var action = codefix.getImportCompletionAction(symbol, moduleSymbol, sourceFile, symbol.name, host, program, formatContext, declaration.pos, preferences); + if (action.codeAction.changes.length && changes.tryInsertTypeAnnotation(sourceFile, declaration, ts.createTypeReferenceNode(typeNode.qualifier, typeNode.typeArguments))) { + for (var _i = 0, _b = action.codeAction.changes; _i < _b.length; _i++) { + var change = _b[_i]; + var file = sourceFile.fileName === change.fileName ? sourceFile : ts.Debug.assertDefined(program.getSourceFile(change.fileName)); + changes.pushRaw(file, change); + } + return true; + } + } + } + return false; + } function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { var signature = parameterInferences.length && parameterInferences[0].declaration.parent; if (!signature) { @@ -116716,13 +121358,13 @@ var ts; return !!merged; }); }); var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var jsDocNode = parent.kind === 201 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 158 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -116732,14 +121374,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 307 /* JSDocParameterTag */: { + case 310 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 308 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -116751,25 +121393,31 @@ var ts; } function inferTypeForVariableFromUsage(token, program, cancellationToken) { var references = getReferences(token, program, cancellationToken); - var checker = program.getTypeChecker(); - var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); - return InferFromReference.unifyFromContext(types, checker); + return inferTypeFromReferences(program, references, cancellationToken).single(); + } + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); + case 161 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 128 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -116778,54 +121426,109 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + var builtinConstructors = { + string: function () { return checker.getStringType(); }, + number: function () { return checker.getNumberType(); }, + Array: function (t) { return checker.createArrayType(t); }, + Promise: function (t) { return checker.createPromiseType(t); }, + }; + var builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function createEmptyUsage() { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + function combineUsages(usages) { + var combinedProperties = ts.createUnderscoreEscapedMap(); + for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { + var u = usages_1[_i]; + if (u.properties) { + u.properties.forEach(function (p, name) { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name).push(p); + }); + } } - return inferFromContext(usageContext, checker); + var properties = ts.createUnderscoreEscapedMap(); + combinedProperties.forEach(function (ps, name) { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(function (u) { return u.isNumber; }), + isString: usages.some(function (u) { return u.isString; }), + isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), + candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), + properties: properties, + calls: ts.flatMap(usages, function (u) { return u.calls; }), + constructs: ts.flatMap(usages, function (u) { return u.constructs; }), + numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), + stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), + candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), + inferredTypes: undefined, + }; } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function single() { + return combineTypes(inferTypesFromReferencesSingle(references)); + } + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = createEmptyUsage(); + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = __spreadArrays(usageContext.constructContexts || [], usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return declaration.parameters.map(function (parameter, parameterIndex) { var types = []; var isRest = ts.isRestParameter(parameter); var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.argumentTypes.length <= parameterIndex) { isOptional = ts.isInJSFile(declaration); types.push(checker.getUndefinedType()); } else if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = combineTypes(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -116833,242 +121536,255 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = createEmptyUsage(); + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return combineTypes(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = createEmptyUsage(); for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferTypes(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 225 /* ExpressionStatement */: + addCandidateType(usage, checker.getVoidType()); break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 207 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 206 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 208 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); + break; + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 193 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 194 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 158 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - usageContext.isNumber = true; + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + usage.isNumber = true; break; - case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + case 39 /* PlusToken */: + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: // MultiplicativeOperator - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + // falls through + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: // ShiftOperator - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // falls through + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator - case 49 /* AmpersandToken */: - case 50 /* BarToken */: - case 51 /* CaretToken */: + // falls through + case 50 /* AmpersandToken */: + case 51 /* BarToken */: + case 52 /* CaretToken */: // CompoundAssignmentOperator - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 71 /* BarEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: + // falls through + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 73 /* BarEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator - case 39 /* MinusToken */: + // falls through + case 40 /* MinusToken */: // RelationalOperator - case 28 /* LessThanToken */: - case 31 /* LessThanEqualsToken */: - case 30 /* GreaterThanToken */: - case 32 /* GreaterThanEqualsToken */: + // falls through + case 29 /* LessThanToken */: + case 32 /* LessThanEqualsToken */: + case 31 /* GreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; - case 61 /* PlusEqualsToken */: - case 38 /* PlusToken */: + case 63 /* PlusEqualsToken */: + case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; + } + else if (otherOperandType.flags & 1 /* Any */) { + // do nothing, maybe we'll learn something elsewhere } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators - case 60 /* EqualsToken */: - case 33 /* EqualsEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + case 62 /* EqualsToken */: + case 34 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 94 /* InKeyword */: + case 96 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; - // LogicalOperator - case 55 /* BarBarToken */: + // LogicalOperator Or NullishCoalescing + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 241 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: // nothing to infer here break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], - returnType: {} + return_: createEmptyUsage() }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.return_); + if (parent.kind === 195 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || createEmptyUsage(); + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = createEmptyUsage(); + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -117077,17 +121793,19 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { - if (fallback === void 0) { fallback = checker.getAnyType(); } + function combineFromUsage(usage) { + return combineTypes(inferTypes(usage)); + } + function combineTypes(inferences) { if (!inferences.length) - return fallback; + return checker.getAnyType(); // 1. string or number individually override string | number // 2. non-any, non-void overrides any or void // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types @@ -117110,12 +121828,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function combineAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -117151,109 +121868,173 @@ var ts; }); return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); } - function inferFromContext(usageContext, checker) { + function inferTypes(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); - if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types_1 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); - types_1.push(checker.createPromiseType(types_1.length ? checker.getUnionType(types_1, 2 /* Subtype */) : checker.getAnyType())); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); - } - if (usageContext.numberIndexContext) { - types.push(checker.createArrayType(recur(usageContext.numberIndexContext))); - } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_1 = ts.createUnderscoreEscapedMap(); - var callSignatures = []; - var constructSignatures = []; - var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { - var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); - members_1.set(name, symbol); - }); - } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); - } - } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); - } - } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); - } - types.push(checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); + } + if (usage.properties && usage.properties.size + || usage.calls && usage.calls.length + || usage.constructs && usage.constructs.length + || usage.stringIndex) { + types.push(inferStructuralType(usage)); } + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + types.push.apply(types, inferNamedTypesFromProperties(usage)); return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + function inferStructuralType(usage) { + var members = ts.createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach(function (u, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); } + var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + } + function inferNamedTypesFromProperties(usage) { + if (!usage.properties || !usage.properties.size) + return []; + var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); + if (0 < types.length && types.length < 3) { + return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); + } + return []; + } + function allPropertiesAreAssignableToUsage(type, usage) { + if (!usage.properties) + return false; + return !ts.forEachEntry(usage.properties, function (propUsage, name) { + var source = checker.getTypeOfPropertyOfType(type, name); + if (!source) { + return true; + } + if (propUsage.calls) { + var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type, usage) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + return type; + } + var generic = type.target; + var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) + return type; var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + usage.properties.forEach(function (propUsage, name) { + var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); + ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName](combineTypes(types)); + } + function inferTypeParameters(genericType, usageType, typeParameter) { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); + } + else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + var genericArgs = checker.getTypeArguments(genericType); + var usageArgs = checker.getTypeArguments(usageType); + var types = []; + if (genericArgs && usageArgs) { + for (var i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); } } } + return types; } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } - return undefined; + return []; } - function getSignatureFromCallContext(callContext, checker) { + function inferFromSignatures(genericSig, usageSig, typeParameter) { + var types = []; + for (var i = 0; i < genericSig.parameters.length; i++) { + var genericParam = genericSig.parameters[i]; + var usageParam = usageSig.parameters[i]; + var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); + } + var genericReturn = checker.getReturnTypeOfSignature(genericSig); + var usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; + } + function getFunctionFromCalls(calls) { + return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + function getSignatureFromCalls(calls) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); + var _loop_12 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); + if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { + symbol.flags |= 16777216 /* Optional */; + } parameters.push(symbol); + }; + for (var i = 0; i < length; i++) { + _loop_12(i); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -117282,12 +122063,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -117319,7 +122100,7 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(117 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(119 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -117342,7 +122123,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 225 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -117350,27 +122131,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 201 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 222 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -117391,17 +122172,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 200 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 73 /* Identifier */) { + if (node.name.kind !== 75 /* Identifier */) { return undefined; } var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(precedingNode, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 88 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -117412,7 +122193,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 88 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -117475,12 +122256,12 @@ var ts; return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 122 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 125 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_13 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -117492,7 +122273,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_13(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -117786,10 +122567,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 73 /* Identifier */: // identifier includes undefined + case 75 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -117811,8 +122592,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -117924,6 +122705,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -118015,10 +122797,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -118064,29 +122846,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 60 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 62 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 195 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -118126,8 +122908,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -118135,11 +122917,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -118178,18 +122960,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); + case 160 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(88 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -118218,12 +123001,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -118236,7 +123017,7 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(86 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(88 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -118245,14 +123026,14 @@ var ts; } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(86 /* ExportKeyword */), ts.createToken(78 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(88 /* ExportKeyword */), ts.createToken(80 /* ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported) { - var modifiers = [ts.createToken(86 /* ExportKeyword */)]; + var modifiers = [ts.createToken(88 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -118260,10 +123041,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -118281,18 +123062,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 188 /* ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 189 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -118303,10 +123086,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -118328,7 +123111,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` var idName = namedBindingsNames.get(propertyName); if (idName === undefined) { idName = makeUniqueName(propertyName, identifiers); @@ -118375,11 +123158,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -118454,8 +123237,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -118482,7 +123267,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118580,7 +123365,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118593,7 +123378,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118601,14 +123386,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -118649,11 +123434,11 @@ var ts; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function codeFixActionToCodeAction(_a) { @@ -118719,21 +123504,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 253 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 256 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 253 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 255 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -118744,22 +123529,35 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 253 /* ImportDeclaration */ || i.kind === 252 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); + var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); - // Sort to keep the shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + // Sort by presence in package.json, then shortest paths first + return ts.sort(choicesForEachExportingModule, function (a, b) { + var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); + var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); + if (allowsImportingA && !allowsImportingB) { + return -1; + } + if (allowsImportingB && !allowsImportingA) { + return 1; + } + return a.moduleSpecifier.length - b.moduleSpecifier.length; + }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -118767,9 +123565,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 253 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 263 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -118826,7 +123624,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -118839,22 +123637,23 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default" /* Default */); - var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host); + var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, host) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); function addSymbol(moduleSymbol, exportedSymbol, importKind) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { @@ -118913,7 +123712,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -118929,7 +123728,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -118963,12 +123762,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -118986,7 +123785,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -119026,12 +123825,34 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(checker, from, allSourceFiles, cb) { - forEachExternalModule(checker, allSourceFiles, function (module, sourceFile) { - if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { - cb(module); + function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) { + var filteredCount = 0; + var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host); + var allSourceFiles = program.getSourceFiles(); + var globalTypingsCache = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); + forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) { + if (sourceFile === undefined) { + if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } + } + else if (sourceFile && + sourceFile !== from && + isImportablePath(from.fileName, sourceFile.fileName, ts.hostGetCanonicalFileName(host), globalTypingsCache)) { + if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } } }); + if (host.log) { + host.log("forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); + } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; function forEachExternalModule(checker, allSourceFiles, cb) { @@ -119050,10 +123871,13 @@ var ts; * Don't include something from a `node_modules` that isn't actually reachable by a global import. * A relative import to node_modules is usually a bad idea. */ - function isImportablePath(fromPath, toPath) { + function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); - return toNodeModules === undefined || ts.startsWith(fromPath, ts.getDirectoryPath(toNodeModules)); + var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); + return toNodeModulesParent === undefined + || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) + || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); @@ -119086,6 +123910,110 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; + function createAutoImportFilter(fromFile, program, host) { + var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host); + var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */; + // Mix in `getProbablySymlinks` from Program when host doesn't have it + // in order for non-Project hosts to have a symlinks cache. + var moduleSpecifierResolutionHost = { + directoryExists: ts.maybeBind(host, host.directoryExists), + fileExists: ts.maybeBind(host, host.fileExists), + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + readFile: ts.maybeBind(host, host.readFile), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks, + getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), + }; + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName, dependencyGroups) || packageJson.has(ts.getTypesPackageName(packageName), dependencyGroups)) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + /** + * Use for a specific module specifier that has already been resolved. + * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve + * the best module specifier for a given module _and_ determine if it’s importable. + */ + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -119129,12 +124057,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -119237,7 +124165,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -119264,7 +124192,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_14(info); } }); })); @@ -119325,7 +124253,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 213 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -119351,7 +124279,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 208 /* BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); @@ -119361,7 +124289,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; } - return typeNode || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return typeNode || ts.createKeywordTypeNode(124 /* AnyKeyword */); } function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); }); @@ -119370,7 +124298,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -119394,7 +124322,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(139 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(142 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -119414,7 +124342,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 160 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119622,7 +124550,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 101 /* ThisKeyword */) + if (token.kind !== 103 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -119661,7 +124589,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 128 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -119705,6 +124633,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -119732,14 +124697,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 87 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 89 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(110 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(112 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 87 /* ExtendsKeyword */ && - heritageClauses[1].token === 110 /* ImplementsKeyword */) { + heritageClauses[0].token === 89 /* ExtendsKeyword */ && + heritageClauses[1].token === 112 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* CommaToken */)); @@ -119826,7 +124791,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 28 /* LessThanToken */) { + if (token.kind === 29 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -119846,7 +124811,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -119878,7 +124843,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 128 /* InferKeyword */) + if (token.kind === 131 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -119887,7 +124852,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 28 /* LessThanToken */) { + else if (token.kind === 29 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -119897,7 +124862,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -119908,23 +124873,23 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(144 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(147 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 93 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 95 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 155 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -119935,7 +124900,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -119944,7 +124909,7 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -119953,14 +124918,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 155 /* Parameter */: + case 154 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return true; } } @@ -120007,26 +124972,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); - ts.Debug.assert(index !== -1); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 75 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -120062,11 +125027,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -120077,15 +125042,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -120127,7 +125092,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -120151,7 +125116,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 292 /* JSDocNullableType */) { + if (typeNode.kind === 295 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -120171,7 +125136,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 295 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -120188,22 +125153,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 216 /* AsExpression */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 162 /* GetAccessor */: + case 166 /* IndexSignature */: + case 185 /* MappedType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 198 /* TypeAssertionExpression */: + case 241 /* VariableDeclaration */: return true; default: return false; @@ -120232,12 +125197,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -120257,14 +125225,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 93 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -120279,11 +125247,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 73 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 75 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 122 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 125 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -120391,17 +125359,17 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 4194304 /* Ambient */); + var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); switch (declaration.kind) { - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 158 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: { + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: { var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var orderedAccessors = allAccessors.secondAccessor @@ -120414,7 +125382,7 @@ var ts; /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); } else { - ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration); + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); var parameter = ts.getSetAccessorValueParameter(accessor); var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; out(ts.createSetAccessor( @@ -120423,8 +125391,8 @@ var ts; } break; } - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 160 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -120437,7 +125405,7 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; @@ -120453,7 +125421,7 @@ var ts; outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); } else { - ts.Debug.assert(declarations.length === signatures.length); + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); } } @@ -120467,14 +125435,14 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 160 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(57 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -120488,15 +125456,14 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(41 /* AsteriskToken */) : undefined, methodName, /*questionToken*/ undefined, /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); @@ -120513,8 +125480,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(121 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(124 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -120531,22 +125498,22 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - if (sig.hasRestParameter) { + if (ts.signatureHasRestParameter(sig)) { someSigHasRestParameter = true; } - if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!ts.signatureHasRestParameter(sig) || ts.signatureHasRestParameter(maxArgsSignature))) { maxArgsSignature = sig; } } - var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + var maxNonRestArgs = maxArgsSignature.parameters.length - (ts.signatureHasRestParameter(maxArgsSignature) ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { - var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(121 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(124 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -120557,7 +125524,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -120568,10 +125535,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(116 /* PublicKeyword */); + return ts.createToken(118 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(115 /* ProtectedKeyword */); + return ts.createToken(117 /* ProtectedKeyword */); } return undefined; } @@ -120643,7 +125610,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 195 /* CallExpression */ : 196 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -120754,7 +125721,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties); } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -120762,7 +125729,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(145 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); @@ -120883,6 +125850,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120904,8 +125904,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 95 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 187 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -120957,7 +125957,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(137 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); @@ -120988,7 +125988,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 123 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 126 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -120999,7 +125999,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 96 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 98 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -121010,6 +126010,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -121026,8 +126060,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -121047,16 +126081,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -121065,7 +126099,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + ts.Debug.assert(!wasDefault, "Can't have a default flag here"); return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } default: @@ -121079,40 +126113,40 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 83 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 88 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(83 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -121126,27 +126160,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 251 /* ImportClause */: { + case 254 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 255 /* NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; @@ -121167,11 +126201,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 257 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.createIdentifier(parent.name.text); @@ -121184,7 +126218,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 261 /* ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -121193,7 +126227,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -121217,13 +126251,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 255 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 255 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -121240,7 +126274,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 255 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -121261,7 +126295,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -121300,7 +126334,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -121319,7 +126353,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -121440,6 +126474,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -121531,6 +126566,9 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -121583,20 +126621,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 158 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 155 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 161 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 160 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -121614,13 +126652,13 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 4194304 /* Ambient */) { + if (nodeToCheck.flags & 8388608 /* Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -121639,7 +126677,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 241 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! @@ -121651,13 +126689,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 192 /* CallExpression */) { + if (node.parent.kind === 195 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -121672,8 +126710,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -121685,20 +126723,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 222 /* Block */: + if (node.parent && node.parent.kind === 239 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -121710,19 +126748,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 182 /* ThisType */: + case 103 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -121731,20 +126769,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 233 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -121798,7 +126836,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 152 /* Parameter */) { + if (current.kind === 155 /* Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -121809,7 +126847,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 288 /* SourceFile */) { return scopes; } } @@ -121899,32 +126937,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 244 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 246 /* ModuleBlock */ + return scope.kind === 249 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -121990,20 +127028,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(114 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(116 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(122 /* AsyncKeyword */)); + modifiers.push(ts.createToken(125 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(122 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(125 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -122020,7 +127058,7 @@ var ts; var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.createYield(ts.createToken(40 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(41 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -122028,8 +127066,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -122097,7 +127135,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -122144,9 +127182,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 142 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 145 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(142 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); } } /** @@ -122154,6 +127192,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -122164,16 +127203,17 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(114 /* PrivateKeyword */)); + modifiers.push(ts.createToken(116 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } - modifiers.push(ts.createToken(134 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(137 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -122202,7 +127242,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 225 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.createVariableStatement( @@ -122221,7 +127261,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 225 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -122235,6 +127275,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -122308,7 +127405,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 234 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -122371,11 +127468,11 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { - var member = members_2[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -122413,11 +127510,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -122486,7 +127583,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 243 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -122539,7 +127636,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -122549,7 +127646,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -122571,7 +127668,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -122589,7 +127686,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -122802,30 +127899,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 282 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 253 /* ImportDeclaration */ && + parent.kind !== 257 /* ImportSpecifier */; + case 212 /* SpreadElement */: + case 188 /* ObjectBindingPattern */: + case 190 /* BindingElement */: return false; - case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + case 75 /* Identifier */: + return parent.kind !== 190 /* BindingElement */ && + parent.kind !== 257 /* ImportSpecifier */ && + parent.kind !== 261 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 222 /* Block */: + case 288 /* SourceFile */: + case 249 /* ModuleBlock */: + case 275 /* CaseClause */: return true; default: return false; @@ -122841,6 +127938,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -122850,22 +127948,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -122880,14 +127990,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; } - function isStatementAndHasJSDoc(n) { - return ts.isStatement(n) && ts.hasJSDocNodes(n); + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function rangeContainsSkipTrivia(r1, node, file) { return ts.rangeContainsStartEnd(r1, ts.skipTrivia(file.text, node.pos), node.end); @@ -122935,15 +128067,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(312 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(315 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -122951,10 +128094,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(311 /* JSDocTemplateTag */); + var template = ts.createNode(314 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(154 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -123004,10 +128147,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 116 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 118 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 114 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 116 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -123045,7 +128188,7 @@ var ts; return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { - var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(117 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(119 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -123068,7 +128211,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 155 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -123114,24 +128257,22 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration, declaration.parent) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 101 /* ThisKeyword */ && + node.expression.kind === 103 /* ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 103 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -123156,7 +128297,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -123213,11 +128354,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -123270,10 +128411,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -123295,25 +128436,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 253 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 255 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -123341,20 +128482,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 253 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 252 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -123396,7 +128537,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -123424,19 +128565,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -123445,7 +128586,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 255 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -123457,7 +128598,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 256 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -123470,14 +128611,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -123551,7 +128692,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -123604,13 +128745,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -123622,7 +128763,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123632,18 +128773,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -123653,11 +128794,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 188 /* ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.createObjectBindingPattern(newElements) : undefined; @@ -123709,18 +128850,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -123728,17 +128869,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -123748,13 +128889,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -123762,9 +128903,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -123795,28 +128936,28 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(88 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { @@ -123824,26 +128965,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 225 /* ExpressionStatement */: + return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 60 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 62 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -123966,7 +129107,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -124105,15 +129246,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -124123,7 +129264,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -124142,14 +129283,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -124191,11 +129332,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 161 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -124203,8 +129344,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -124214,7 +129355,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 81 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 83 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -124329,7 +129470,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(56 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); ts.suppressLeadingAndTrailingTrivia(propertySignature); copyComments(parameterDeclaration.name, propertySignature.name); @@ -124375,15 +129516,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 83 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -124394,30 +129535,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 83 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: - var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + case 161 /* Constructor */: + var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 128 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 213 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -124429,10 +129570,10 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 73 /* Identifier */ ? new IdentifierObject(73 /* Identifier */, pos, end) : + kind === 75 /* Identifier */ ? new IdentifierObject(75 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 12679168 /* ContextFlags */; + node.flags = parent.flags & 25358336 /* ContextFlags */; return node; } var NodeObject = /** @class */ (function () { @@ -124446,7 +129587,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -124503,8 +129644,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 313 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 292 /* FirstJSDocNode */ || kid.kind > 316 /* LastJSDocNode */; }); + return child.kind < 152 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -124515,7 +129656,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 152 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -124561,7 +129702,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 73 /* Identifier */) { + if (token === 75 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -124573,7 +129714,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(314 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(317 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -124696,7 +129837,9 @@ var ts; var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { - return _super.call(this, pos, end) || this; + var _this = _super.call(this, pos, end) || this; + _this.kind = 75 /* Identifier */; + return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { get: function () { @@ -124707,7 +129850,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 73 /* Identifier */; + IdentifierObject.prototype.kind = 75 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -124743,9 +129886,15 @@ var ts; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; }; + TypeObject.prototype.isNullableType = function () { + return this.checker.isNullableType(this); + }; TypeObject.prototype.getNonNullableType = function () { return this.checker.getNonNullableType(this); }; + TypeObject.prototype.getNonOptionalType = function () { + return this.checker.getNonOptionalType(this); + }; TypeObject.prototype.getConstraint = function () { return this.checker.getBaseConstraintOfType(this); }; @@ -124779,11 +129928,25 @@ var ts; TypeObject.prototype.isClass = function () { return !!(ts.getObjectFlags(this) & 1 /* Class */); }; + Object.defineProperty(TypeObject.prototype, "typeArguments", { + /** + * This polyfills `referenceType.typeArguments` for API consumers + */ + get: function () { + if (ts.getObjectFlags(this) & 4 /* Reference */) { + return this.checker.getTypeArguments(this); + } + return undefined; + }, + enumerable: true, + configurable: true + }); return TypeObject; }()); var SignatureObject = /** @class */ (function () { - function SignatureObject(checker) { + function SignatureObject(checker, flags) { this.checker = checker; + this.flags = flags; } SignatureObject.prototype.getDeclaration = function () { return this.declaration; @@ -124821,13 +129984,12 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var declaration = declarations_4[_i]; + ts.forEachUnique(declarations, function (declaration) { var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); - } + }); } return doc; } @@ -124850,7 +130012,9 @@ var ts; var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - return _super.call(this, kind, pos, end) || this; + var _this = _super.call(this, kind, pos, end) || this; + _this.kind = 288 /* SourceFile */; + return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -124908,10 +130072,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -124931,31 +130095,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 172 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -124966,19 +130130,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -124990,7 +130154,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -124999,7 +130163,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -125196,7 +130360,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -125316,10 +130480,10 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; }, getCurrentDirectory: function () { return currentDirectory; }, getProgram: getProgram, - fileExists: host.fileExists && (function (f) { return host.fileExists(f); }), - readFile: host.readFile && (function (f, encoding) { return host.readFile(f, encoding); }), - getDocumentPositionMapper: host.getDocumentPositionMapper && (function (generatedFileName, sourceFileName) { return host.getDocumentPositionMapper(generatedFileName, sourceFileName); }), - getSourceFileLike: host.getSourceFileLike && (function (f) { return host.getSourceFileLike(f); }), + fileExists: ts.maybeBind(host, host.fileExists), + readFile: ts.maybeBind(host, host.readFile), + getDocumentPositionMapper: ts.maybeBind(host, host.getDocumentPositionMapper), + getSourceFileLike: ts.maybeBind(host, host.getSourceFileLike), log: log }); function getValidSourceFile(fileName) { @@ -125415,6 +130579,12 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }; } + if (host.setResolvedProjectReferenceCallbacks) { + compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); }; + } + if (host.useSourceOfProjectReferenceRedirect) { + compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); }; + } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -125575,7 +130745,7 @@ var ts; } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }); + return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host); } function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); @@ -125619,15 +130789,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 99 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 101 /* SuperKeyword */: return true; default: return false; @@ -125700,12 +130870,11 @@ var ts; var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } - function getEmitOutput(fileName, emitOnlyDtsFiles) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function getEmitOutput(fileName, emitOnlyDtsFiles, forceDtsEmit) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); - return ts.getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers); + return ts.getFileEmitOutput(program, sourceFile, !!emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit); } // Signature help /** @@ -125729,16 +130898,16 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: case 10 /* StringLiteral */: - case 88 /* FalseKeyword */: - case 103 /* TrueKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 73 /* Identifier */: + case 90 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 75 /* Identifier */: break; // Cant create the text span default: @@ -125754,7 +130923,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 248 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -125819,7 +130988,7 @@ var ts; _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, + _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -125943,7 +131112,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -126206,7 +131375,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 263 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -126222,14 +131391,15 @@ var ts; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 153 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 192 /* ObjectLiteralExpression */ || node.parent.parent.kind === 272 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -126271,7 +131441,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -126318,7 +131488,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 4194304 /* Ambient */) { + if (tokenAtLocation.flags & 8388608 /* Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -126351,114 +131521,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 190 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 156 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -126476,19 +131646,19 @@ var ts; return spanInOpenParenToken(node); case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 57 /* ColonToken */: + case 58 /* ColonToken */: return spanInColonToken(node); - case 30 /* GreaterThanToken */: - case 28 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return spanInWhileKeyword(node); - case 84 /* ElseKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + case 86 /* ElseKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 151 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -126500,14 +131670,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + if ((node.kind === 75 /* Identifier */ || + node.kind === 212 /* SpreadElement */ || + node.kind === 279 /* PropertyAssignment */ || + node.kind === 280 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 208 /* BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -126516,7 +131686,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 60 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -126529,22 +131699,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 156 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -126553,21 +131723,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -126575,7 +131745,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -126605,7 +131775,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 230 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -126617,7 +131787,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 231 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -126658,7 +131828,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 244 /* ClassDeclaration */ && functionDeclaration.kind !== 161 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -126681,26 +131851,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 230 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 242 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -126725,21 +131895,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 190 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 189 /* ArrayBindingPattern */ && node.kind !== 188 /* ObjectBindingPattern */); + var elements = node.kind === 191 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -126747,18 +131917,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 208 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -126766,25 +131936,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -126792,7 +131962,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -126808,7 +131978,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -126823,12 +131993,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 227 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 195 /* CallExpression */ || + node.parent.kind === 196 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 199 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -126837,21 +132007,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 199 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -126861,20 +132031,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 279 /* PropertyAssignment */ || + node.parent.kind === 155 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 198 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 227 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -126882,7 +132052,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 231 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -126927,10 +132097,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -126952,9 +132121,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -127025,6 +132196,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -127053,6 +132225,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -127064,6 +132237,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -127207,13 +132381,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -127221,13 +132395,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -127685,8 +132860,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; @@ -127705,7 +132879,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -128267,9 +133440,10 @@ var ts; WatchType["MissingSourceMapFile"] = "Missing source map file"; WatchType["NoopConfigFileForInferredRoot"] = "Noop Config file for the inferred project root"; WatchType["MissingGeneratedFile"] = "Missing generated file"; + WatchType["PackageJsonFile"] = "package.json file for import suggestions"; })(WatchType = ts.WatchType || (ts.WatchType = {})); })(ts || (ts = {})); -// tslint:disable no-unnecessary-qualifier +/* eslint-disable @typescript-eslint/no-unnecessary-qualifier */ /** * Declaration module describing the TypeScript Server protocol */ @@ -128418,6 +133592,12 @@ var ts; IndentStyle["Block"] = "Block"; IndentStyle["Smart"] = "Smart"; })(IndentStyle = protocol.IndentStyle || (protocol.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = protocol.SemicolonPreference || (protocol.SemicolonPreference = {})); var JsxEmit; (function (JsxEmit) { JsxEmit["None"] = "None"; @@ -128843,20 +134023,43 @@ var ts; case 1: return this.containingProjects[0]; default: - // if this file belongs to multiple projects, the first configured project should be - // the default project; if no configured projects, the first external project should - // be the default project; otherwise the first inferred project should be the default. + // If this file belongs to multiple projects, below is the order in which default project is used + // - for open script info, its default configured project during opening is default if info is part of it + // - first configured project of which script info is not a source of project reference redirect + // - first configured project + // - first external project + // - first inferred project var firstExternalProject = void 0; - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var project = _a[_i]; + var firstConfiguredProject = void 0; + var firstNonSourceOfProjectReferenceRedirect = void 0; + var defaultConfiguredProject = void 0; + for (var index = 0; index < this.containingProjects.length; index++) { + var project = this.containingProjects[index]; if (project.projectKind === server.ProjectKind.Configured) { - return project; + if (!project.isSourceOfProjectReferenceRedirect(this.fileName)) { + // If we havent found default configuredProject and + // its not the last one, find it and use that one if there + if (defaultConfiguredProject === undefined && + index !== this.containingProjects.length - 1) { + defaultConfiguredProject = project.projectService.findDefaultConfiguredProject(this) || false; + } + if (defaultConfiguredProject === project) + return project; + if (!firstNonSourceOfProjectReferenceRedirect) + firstNonSourceOfProjectReferenceRedirect = project; + } + if (!firstConfiguredProject) + firstConfiguredProject = project; } else if (project.projectKind === server.ProjectKind.External && !firstExternalProject) { firstExternalProject = project; } } - return firstExternalProject || this.containingProjects[0]; + return defaultConfiguredProject || + firstNonSourceOfProjectReferenceRedirect || + firstConfiguredProject || + firstExternalProject || + this.containingProjects[0]; } }; ScriptInfo.prototype.registerFileUpdate = function () { @@ -128919,7 +134122,7 @@ var ts; ScriptInfo.prototype.markContainingProjectsAsDirty = function () { for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { var p = _a[_i]; - p.markAsDirty(); + p.markFileAsDirty(this.path); } }; ScriptInfo.prototype.isOrphan = function () { @@ -129155,7 +134358,7 @@ var ts; var Project = /** @class */ (function () { /*@internal*/ function Project( - /*@internal*/ projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, directoryStructureHost, currentDirectory) { + /*@internal*/ projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, directoryStructureHost, currentDirectory, customRealpath) { var _this = this; this.projectName = projectName; this.projectKind = projectKind; @@ -129199,6 +134402,8 @@ var ts; /*@internal*/ this.typingFiles = server.emptyArray; /*@internal*/ + this.importSuggestionsCache = ts.Completions.createImportSuggestionsForFileCache(); + /*@internal*/ this.globalCacheResolutionModuleName = ts.JsTyping.nonRelativeModuleNameForTypingCache; this.directoryStructureHost = directoryStructureHost; this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory || ""); @@ -129223,7 +134428,7 @@ var ts; this.trace = function (s) { return host.trace(s); }; } if (host.realpath) { - this.realpath = function (path) { return host.realpath(path); }; + this.realpath = customRealpath || (function (path) { return host.realpath(path); }); } // Use the current directory as resolution root only if the project created using current directory string this.resolutionCache = ts.createResolutionCache(this, currentDirectory && this.currentDirectory, /*logChangesWhenResolvingModule*/ true); @@ -129233,7 +134438,12 @@ var ts; } this.markAsDirty(); this.projectService.pendingEnsureProjectForOpenFiles = true; + this.packageJsonCache = server.createPackageJsonCache(this); } + /*@internal*/ + Project.prototype.getResolvedProjectReferenceToRedirect = function (_fileName) { + return undefined; + }; Project.prototype.isNonTsProject = function () { server.updateProjectIfDirty(this); return allFilesAreJsOrDts(this); @@ -129259,6 +134469,10 @@ var ts; Project.prototype.installPackage = function (options) { return this.typingsCache.installPackage(__assign(__assign({}, options), { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); }; + /*@internal*/ + Project.prototype.getGlobalTypingsCacheLocation = function () { + return this.getGlobalCache(); + }; Object.defineProperty(Project.prototype, "typingsCache", { get: function () { return this.projectService.typingsCache; @@ -129266,6 +134480,10 @@ var ts; enumerable: true, configurable: true }); + /*@internal*/ + Project.prototype.getProbableSymlinks = function (files) { + return this.symlinks || (this.symlinks = ts.discoverProbableSymlinks(files, this.getCanonicalFileName, this.getCurrentDirectory())); + }; // Method of LanguageServiceHost Project.prototype.getCompilationSettings = function () { return this.compilerOptions; @@ -129347,6 +134565,10 @@ var ts; return this.projectService.host.writeFile(fileName, content); }; Project.prototype.fileExists = function (file) { + return this.fileExistsWithCache(file); + }; + /* @internal */ + Project.prototype.fileExistsWithCache = function (file) { // As an optimization, don't hit the disks for files we already know don't exist // (because we're watching for their creation). var path = this.toPath(file); @@ -129443,8 +134665,11 @@ var ts; Project.prototype.getSourceFileLike = function (fileName) { return this.projectService.getSourceFileLike(fileName, this); }; + /*@internal*/ Project.prototype.shouldEmitFile = function (scriptInfo) { - return scriptInfo && !scriptInfo.isDynamicOrHasMixedContent(); + return scriptInfo && + !scriptInfo.isDynamicOrHasMixedContent() && + !this.program.isSourceOfProjectReferenceRedirect(scriptInfo.path); }; Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { var _this = this; @@ -129570,6 +134795,10 @@ var ts; ts.clearMap(this.missingFilesMap, ts.closeFileWatcher); this.missingFilesMap = undefined; } + if (this.packageJsonFilesMap) { + ts.clearMap(this.packageJsonFilesMap, ts.closeFileWatcher); + this.packageJsonFilesMap = undefined; + } this.clearGeneratedFileWatch(); // signal language service to release source files acquired from document registry this.languageService.dispose(); @@ -129726,6 +134955,13 @@ var ts; Project.prototype.registerFileUpdate = function (fileName) { (this.updatedFileNames || (this.updatedFileNames = ts.createMap())).set(fileName, true); }; + /*@internal*/ + Project.prototype.markFileAsDirty = function (changedFile) { + this.markAsDirty(); + if (!this.importSuggestionsCache.isEmpty()) { + (this.dirtyFilesForSuggestions || (this.dirtyFilesForSuggestions = ts.createMap())).set(changedFile, true); + } + }; Project.prototype.markAsDirty = function () { if (!this.dirty) { this.projectStateVersion++; @@ -129861,6 +135097,27 @@ var ts; this.resolutionCache.updateTypeRootsWatch(); } } + if (!this.importSuggestionsCache.isEmpty()) { + if (this.hasAddedorRemovedFiles || oldProgram && !oldProgram.structureIsReused) { + this.importSuggestionsCache.clear(); + } + else if (this.dirtyFilesForSuggestions && oldProgram && this.program) { + ts.forEachKey(this.dirtyFilesForSuggestions, function (fileName) { + var oldSourceFile = oldProgram.getSourceFile(fileName); + var sourceFile = _this.program.getSourceFile(fileName); + if (_this.sourceFileHasChangedOwnImportSuggestions(oldSourceFile, sourceFile)) { + _this.importSuggestionsCache.clear(); + return true; + } + }); + } + } + if (this.dirtyFilesForSuggestions) { + this.dirtyFilesForSuggestions.clear(); + } + if (this.hasAddedorRemovedFiles) { + this.symlinks = undefined; + } var oldExternalFiles = this.externalFiles || server.emptyArray; this.externalFiles = this.getExternalFiles(); ts.enumerateInsertsAndDeletes(this.externalFiles, oldExternalFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), @@ -129881,6 +135138,54 @@ var ts; } return hasNewProgram; }; + /*@internal*/ + Project.prototype.sourceFileHasChangedOwnImportSuggestions = function (oldSourceFile, newSourceFile) { + if (!oldSourceFile && !newSourceFile) { + return false; + } + // Probably shouldn’t get this far, but on the off chance the file was added or removed, + // we can’t reliably tell anything about it. + if (!oldSourceFile || !newSourceFile) { + return true; + } + ts.Debug.assertEqual(oldSourceFile.fileName, newSourceFile.fileName); + // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. + // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. + if (this.getTypeAcquisition().enable && ts.consumesNodeCoreModules(oldSourceFile) !== ts.consumesNodeCoreModules(newSourceFile)) { + return true; + } + // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. + // Changes elsewhere in the file can change the *type* of an export in a module augmentation, + // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. + if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || + !this.ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { + return true; + } + return false; + }; + /*@internal*/ + Project.prototype.ambientModuleDeclarationsAreEqual = function (oldSourceFile, newSourceFile) { + if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { + return false; + } + var oldFileStatementIndex = -1; + var newFileStatementIndex = -1; + var _loop_1 = function (ambientModuleName) { + var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; + oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); + newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); + if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { + return { value: false }; + } + }; + for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { + var ambientModuleName = _a[_i]; + var state_1 = _loop_1(ambientModuleName); + if (typeof state_1 === "object") + return state_1.value; + } + return true; + }; Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { var scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName); if (scriptInfoToDetach) { @@ -130057,6 +135362,10 @@ var ts; ts.orderedRemoveItem(this.rootFiles, info); this.rootFilesMap.delete(info.path); }; + /*@internal*/ + Project.prototype.isSourceOfProjectReferenceRedirect = function (fileName) { + return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName); + }; Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { @@ -130067,7 +135376,7 @@ var ts; // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.globalPlugins) { - var _loop_1 = function (globalPluginName) { + var _loop_2 = function (globalPluginName) { // Skip empty names from odd commandline parses if (!globalPluginName) return "continue"; @@ -130082,7 +135391,7 @@ var ts; // Enable global plugins with synthetic configuration entries for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { var globalPluginName = _a[_i]; - _loop_1(globalPluginName); + _loop_2(globalPluginName); } } }; @@ -130127,6 +135436,7 @@ var ts; var newLS = pluginModule.create(info); for (var _i = 0, _a = Object.keys(this.languageService); _i < _a.length; _i++) { var k = _a[_i]; + // eslint-disable-next-line no-in-operator if (!(k in newLS)) { this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); newLS[k] = this.languageService[k]; @@ -130152,6 +135462,61 @@ var ts; Project.prototype.refreshDiagnostics = function () { this.projectService.sendProjectsUpdatedInBackgroundEvent(); }; + /*@internal*/ + Project.prototype.getPackageJsonsVisibleToFile = function (fileName, rootDir) { + var packageJsonCache = this.packageJsonCache; + var watchPackageJsonFile = this.watchPackageJsonFile.bind(this); + var toPath = this.toPath.bind(this); + var rootPath = rootDir && toPath(rootDir); + var filePath = toPath(fileName); + var result = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(filePath), function processDirectory(directory) { + switch (packageJsonCache.directoryHasPackageJson(directory)) { + // Sync and check same directory again + case 1 /* Maybe */: + packageJsonCache.searchDirectoryAndAncestors(directory); + return processDirectory(directory); + // Check package.json + case -1 /* True */: + var packageJsonFileName = ts.combinePaths(directory, "package.json"); + watchPackageJsonFile(packageJsonFileName); + result.push(ts.Debug.assertDefined(packageJsonCache.getInDirectory(directory))); + } + if (rootPath && rootPath === toPath(directory)) { + return true; + } + }); + return result; + }; + /*@internal*/ + Project.prototype.onAddPackageJson = function (path) { + this.packageJsonCache.addOrUpdate(path); + this.watchPackageJsonFile(path); + }; + /*@internal*/ + Project.prototype.getImportSuggestionsCache = function () { + return this.importSuggestionsCache; + }; + Project.prototype.watchPackageJsonFile = function (path) { + var _this = this; + var watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = ts.createMap()); + if (!watchers.has(path)) { + watchers.set(path, this.projectService.watchFactory.watchFile(this.projectService.host, path, function (fileName, eventKind) { + var path = _this.toPath(fileName); + switch (eventKind) { + case ts.FileWatcherEventKind.Created: + return ts.Debug.fail(); + case ts.FileWatcherEventKind.Changed: + _this.packageJsonCache.addOrUpdate(path); + break; + case ts.FileWatcherEventKind.Deleted: + _this.packageJsonCache.delete(path); + watchers.get(path).close(); + watchers.delete(path); + } + }, ts.PollingInterval.Low, "package.json file for import suggestions" /* PackageJsonFile */)); + } + }; return Project; }()); server.Project = Project; @@ -130283,7 +135648,7 @@ var ts; /*hasExplicitListOfFiles*/ false, /*lastFileExceededProgramSize*/ undefined, /*compilerOptions*/ {}, - /*compileOnSaveEnabled*/ false, cachedDirectoryStructureHost, ts.getDirectoryPath(configFileName)) || this; + /*compileOnSaveEnabled*/ false, cachedDirectoryStructureHost, ts.getDirectoryPath(configFileName), projectService.host.realpath && (function (s) { return _this.getRealpath(s); })) || this; /*@internal*/ _this.canConfigFileJsonReportNoInputFiles = false; /** Ref count to the project when opened from external project */ @@ -130291,9 +135656,138 @@ var ts; _this.isInitialLoadPending = ts.returnTrue; /*@internal*/ _this.sendLoadingProjectFinish = false; + /* @internal */ + _this.useSourceOfProjectReferenceRedirect = function () { return !!_this.languageServiceEnabled && + !_this.getCompilerOptions().disableSourceOfProjectReferenceRedirect; }; _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); return _this; } + /* @internal */ + ConfiguredProject.prototype.setResolvedProjectReferenceCallbacks = function (projectReferenceCallbacks) { + this.projectReferenceCallbacks = projectReferenceCallbacks; + }; + ConfiguredProject.prototype.fileExistsIfProjectReferenceDts = function (file) { + var source = this.projectReferenceCallbacks.getSourceOfProjectReferenceRedirect(file); + return source !== undefined ? + ts.isString(source) ? _super.prototype.fileExists.call(this, source) : true : + undefined; + }; + /** + * This implementation of fileExists checks if the file being requested is + * .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that file exists on host + */ + ConfiguredProject.prototype.fileExists = function (file) { + if (_super.prototype.fileExists.call(this, file)) + return true; + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) + return false; + if (!ts.isDeclarationFileName(file)) + return false; + // Project references go to source file instead of .d.ts file + return this.fileOrDirectoryExistsUsingSource(file, /*isFile*/ true); + }; + ConfiguredProject.prototype.directoryExistsIfProjectReferenceDeclDir = function (dir) { + var dirPath = this.toPath(dir); + var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + return ts.forEachKey(this.mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator); }); + }; + /** + * This implementation of directoryExists checks if the directory being requested is + * directory of .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that directory exists on host + */ + ConfiguredProject.prototype.directoryExists = function (path) { + var _this = this; + if (_super.prototype.directoryExists.call(this, path)) { + this.handleDirectoryCouldBeSymlink(path); + return true; + } + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) + return false; + if (!this.mapOfDeclarationDirectories) { + this.mapOfDeclarationDirectories = ts.createMap(); + this.projectReferenceCallbacks.forEachResolvedProjectReference(function (ref) { + if (!ref) + return; + var out = ref.commandLine.options.outFile || ref.commandLine.options.out; + if (out) { + _this.mapOfDeclarationDirectories.set(ts.getDirectoryPath(_this.toPath(out)), true); + } + else { + // Set declaration's in different locations only, if they are next to source the directory present doesnt change + var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir; + if (declarationDir) { + _this.mapOfDeclarationDirectories.set(_this.toPath(declarationDir), true); + } + } + }); + } + return this.fileOrDirectoryExistsUsingSource(path, /*isFile*/ false); + }; + ConfiguredProject.prototype.realpathIfSymlinkedProjectReferenceDts = function (s) { + return this.symlinkedFiles && this.symlinkedFiles.get(this.toPath(s)); + }; + ConfiguredProject.prototype.getRealpath = function (s) { + return this.realpathIfSymlinkedProjectReferenceDts(s) || + this.projectService.host.realpath(s); + }; + ConfiguredProject.prototype.handleDirectoryCouldBeSymlink = function (directory) { + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) + return; + // Because we already watch node_modules, handle symlinks in there + if (!this.realpath || !ts.stringContains(directory, ts.nodeModulesPathPart)) + return; + if (!this.symlinkedDirectories) + this.symlinkedDirectories = ts.createMap(); + var directoryPath = ts.ensureTrailingDirectorySeparator(this.toPath(directory)); + if (this.symlinkedDirectories.has(directoryPath)) + return; + var real = this.projectService.host.realpath(directory); + var realPath; + if (real === directory || + (realPath = ts.ensureTrailingDirectorySeparator(this.toPath(real))) === directoryPath) { + // not symlinked + this.symlinkedDirectories.set(directoryPath, false); + return; + } + this.symlinkedDirectories.set(directoryPath, { + real: ts.ensureTrailingDirectorySeparator(real), + realPath: realPath + }); + }; + ConfiguredProject.prototype.fileOrDirectoryExistsUsingSource = function (fileOrDirectory, isFile) { + var _this = this; + var fileOrDirectoryExistsUsingSource = isFile ? + function (file) { return _this.fileExistsIfProjectReferenceDts(file); } : + function (dir) { return _this.directoryExistsIfProjectReferenceDeclDir(dir); }; + // Check current directory or file + var result = fileOrDirectoryExistsUsingSource(fileOrDirectory); + if (result !== undefined) + return result; + if (!this.symlinkedDirectories) + return false; + var fileOrDirectoryPath = this.toPath(fileOrDirectory); + if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart)) + return false; + if (isFile && this.symlinkedFiles && this.symlinkedFiles.has(fileOrDirectoryPath)) + return true; + // If it contains node_modules check if its one of the symlinked path we know of + return ts.firstDefinedIterator(this.symlinkedDirectories.entries(), function (_a) { + var directoryPath = _a[0], symlinkedDirectory = _a[1]; + if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath)) + return undefined; + var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath)); + if (isFile && result) { + if (!_this.symlinkedFiles) + _this.symlinkedFiles = ts.createMap(); + // Store the real path for the file' + var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, _this.currentDirectory); + _this.symlinkedFiles.set(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + } + return result; + }) || false; + }; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph * @returns: true if set of files in the project stays the same and false - otherwise. @@ -130302,6 +135796,10 @@ var ts; this.isInitialLoadPending = ts.returnFalse; var reloadLevel = this.pendingReload; this.pendingReload = ts.ConfigFileProgramReloadLevel.None; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; + this.symlinkedDirectories = undefined; + this.symlinkedFiles = undefined; var result; switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: @@ -130339,6 +135837,11 @@ var ts; return program && program.forEachResolvedProjectReference(cb); }; /*@internal*/ + ConfiguredProject.prototype.getResolvedProjectReferenceToRedirect = function (fileName) { + var program = this.getCurrentProgram(); + return program && program.getResolvedProjectReferenceToRedirect(fileName); + }; + /*@internal*/ ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { @@ -130405,6 +135908,10 @@ var ts; this.stopWatchingWildCards(); this.projectErrors = undefined; this.configFileSpecs = undefined; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; + this.symlinkedDirectories = undefined; + this.symlinkedFiles = undefined; _super.prototype.close.call(this); }; /* @internal */ @@ -130498,7 +136005,6 @@ var ts; server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; /*@internal*/ server.maxFileSize = 4 * 1024 * 1024; - // tslint:disable variable-name server.ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; server.ProjectLoadingStartEvent = "projectLoadingStart"; server.ProjectLoadingFinishEvent = "projectLoadingFinish"; @@ -131155,7 +136661,7 @@ var ts; var _this = this; return this.watchFactory.watchDirectory(this.host, directory, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); - project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + var fsResult = project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); // don't trigger callback on open, existing files if (project.fileIsOpen(fileOrDirectoryPath)) { return; @@ -131163,6 +136669,11 @@ var ts; if (ts.isPathIgnored(fileOrDirectoryPath)) return; var configFilename = project.getConfigFilePath(); + if (ts.getBaseFileName(fileOrDirectoryPath) === "package.json" && !ts.isInsideNodeModules(fileOrDirectoryPath) && + (fsResult && fsResult.fileExists || !fsResult && _this.host.fileExists(fileOrDirectoryPath))) { + _this.logger.info("Project: " + configFilename + " Detected new package.json: " + fileOrDirectory); + project.onAddPackageJson(fileOrDirectoryPath); + } // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, project.getCompilationSettings(), _this.hostConfiguration.extraFileExtensions)) { @@ -131266,7 +136777,7 @@ var ts; } project.updateGraph(); if (!this.useSingleInferredProject && !project.projectRootPath) { - var _loop_2 = function (inferredProject) { + var _loop_3 = function (inferredProject) { if (inferredProject === project || inferredProject.isOrphan()) { return "continue"; } @@ -131287,7 +136798,7 @@ var ts; // Note that we need to create a copy of the array since the list of project can change for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var inferredProject = _a[_i]; - _loop_2(inferredProject); + _loop_3(inferredProject); } } return project; @@ -131604,6 +137115,14 @@ var ts; } while (anySearchPathOk || isSearchPathInProjectRoot()); return undefined; }; + /*@internal*/ + ProjectService.prototype.findDefaultConfiguredProject = function (info) { + if (!info.isScriptOpen()) + return undefined; + var configFileName = this.getConfigFileNameForFile(info); + return configFileName && + this.findConfiguredProjectByProjectName(configFileName); + }; /** * This function tries to search for a tsconfig.json for the given file. * This is different from the method the compiler uses because @@ -131806,6 +137325,11 @@ var ts; if (parsedCommandLine.errors.length) { configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); } + this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + rootNames: parsedCommandLine.fileNames, + options: parsedCommandLine.options, + projectReferences: parsedCommandLine.projectReferences + }, /*replacer*/ undefined, " ")); ts.Debug.assert(!!parsedCommandLine.fileNames); var compilerOptions = parsedCommandLine.options; // Update the project @@ -131832,7 +137356,7 @@ var ts; } 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 + this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); }; ProjectService.prototype.updateNonInferredProjectFiles = function (project, files, propertyReader) { var projectRootFilesMap = project.getRootFilesMap(); @@ -131845,7 +137369,7 @@ var ts; var scriptInfo = void 0; var path = void 0; // Use the project's fileExists so that it can use caching instead of reaching to disk for the query - if (!isDynamic && !project.fileExists(newRootFile)) { + if (!isDynamic && !project.fileExistsWithCache(newRootFile)) { path = server.normalizedPathToPath(normalizedPath, this.currentDirectory, this.toCanonicalFileName); var existingValue = projectRootFilesMap.get(path); if (server.isScriptInfo(existingValue)) { @@ -131877,7 +137401,7 @@ var ts; projectRootFilesMap.forEach(function (value, path) { if (!newRootScriptInfoMap.has(path)) { if (server.isScriptInfo(value)) { - project.removeFile(value, project.fileExists(path), /*detachFromProject*/ true); + project.removeFile(value, project.fileExistsWithCache(path), /*detachFromProject*/ true); } else { projectRootFilesMap.delete(path); @@ -132056,7 +137580,7 @@ var ts; return projects; function combineProjects(toAddInfo) { if (toAddInfo !== info) { - var _loop_3 = function (project) { + var _loop_4 = function (project) { // Add the projects only if they can use symLink targets and not already in the list if (project.languageServiceEnabled && !project.isOrphan() && @@ -132073,7 +137597,7 @@ var ts; }; for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; - _loop_3(project); + _loop_4(project); } } } @@ -132538,7 +138062,9 @@ var ts; }; /*@internal*/ ProjectService.prototype.getOriginalLocationEnsuringConfiguredProject = function (project, location) { - var originalLocation = project.getSourceMapper().tryGetSourcePosition(location); + var originalLocation = project.isSourceOfProjectReferenceRedirect(location.fileName) ? + location : + project.getSourceMapper().tryGetSourcePosition(location); if (!originalLocation) return undefined; var fileName = originalLocation.fileName; @@ -132549,7 +138075,9 @@ var ts; if (!configFileName) return undefined; var configuredProject = this.findConfiguredProjectByProjectName(configFileName) || - this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + " for location: " + location.fileName); + this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + if (configuredProject === project) + return originalLocation; updateProjectIfDirty(configuredProject); // Keep this configured project as referenced from project addOriginalConfiguredProject(configuredProject); @@ -132770,13 +138298,13 @@ var ts; return result; }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { + var _loop_5 = function (proj) { var knownProject = ts.find(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName(); }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_4(proj); + _loop_5(proj); } }; /* @internal */ @@ -132919,7 +138447,7 @@ var ts; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); var excludedFiles = []; - var _loop_5 = function (name) { + var _loop_6 = function (name) { var rule = this_2.safelist[name]; for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { var root = normalizedNames_1[_i]; @@ -132937,7 +138465,7 @@ var ts; } } if (rule.exclude) { - var _loop_7 = function (exclude) { + var _loop_8 = function (exclude) { var processedRule = root.replace(rule.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -132964,7 +138492,7 @@ var ts; }; for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) { var exclude = _d[_c]; - _loop_7(exclude); + _loop_8(exclude); } } else { @@ -132980,11 +138508,11 @@ var ts; var this_2 = this; for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) { var name = _a[_i]; - _loop_5(name); + _loop_6(name); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); var filesToKeep = []; - var _loop_6 = function (i) { + var _loop_7 = function (i) { if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { excludedFiles.push(normalizedNames[i]); } @@ -133022,7 +138550,7 @@ var ts; }; var this_3 = this; for (var i = 0; i < proj.rootFiles.length; i++) { - _loop_6(i); + _loop_7(i); } proj.rootFiles = filesToKeep; return excludedFiles; @@ -133180,6 +138708,55 @@ var ts; } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + var server; + (function (server) { + function createPackageJsonCache(project) { + var packageJsons = ts.createMap(); + var directoriesWithoutPackageJson = ts.createMap(); + return { + addOrUpdate: addOrUpdate, + delete: function (fileName) { + packageJsons.delete(fileName); + directoriesWithoutPackageJson.set(ts.getDirectoryPath(fileName), true); + }, + getInDirectory: function (directory) { + return packageJsons.get(ts.combinePaths(directory, "package.json")); + }, + directoryHasPackageJson: directoryHasPackageJson, + searchDirectoryAndAncestors: function (directory) { + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (directoryHasPackageJson(ancestor) !== 1 /* Maybe */) { + return true; + } + var packageJsonFileName = project.toPath(ts.combinePaths(ancestor, "package.json")); + if (ts.tryFileExists(project, packageJsonFileName)) { + addOrUpdate(packageJsonFileName); + } + else { + directoriesWithoutPackageJson.set(ancestor, true); + } + }); + }, + }; + function addOrUpdate(fileName) { + var packageJsonInfo = ts.createPackageJsonInfo(fileName, project); + if (packageJsonInfo) { + packageJsons.set(fileName, packageJsonInfo); + directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName)); + } + } + function directoryHasPackageJson(directory) { + return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : + directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : + 1 /* Maybe */; + } + } + server.createPackageJsonCache = createPackageJsonCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); var ts; (function (ts) { var server; @@ -133274,7 +138851,7 @@ var ts; function allEditsBeforePos(edits, pos) { return edits.every(function (edit) { return ts.textSpanEnd(edit.span) < pos; }); } - server.CommandNames = server.protocol.CommandTypes; // tslint:disable-line variable-name + server.CommandNames = server.protocol.CommandTypes; function formatMessage(msg, logger, byteLength, newLine) { var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); @@ -133430,7 +139007,7 @@ var ts; var outputs = []; combineProjectOutputWorker(projects, defaultProject, initialLocation, function (_a, getMappedLocation) { var project = _a.project, location = _a.location; - var _loop_8 = function (outputReferencedSymbol) { + var _loop_9 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? outputReferencedSymbol.definition : __assign(__assign({}, outputReferencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); @@ -133449,7 +139026,7 @@ var ts; }; for (var _i = 0, _b = project.getLanguageService().findReferences(location.fileName, location.pos) || server.emptyArray; _i < _b.length; _i++) { var outputReferencedSymbol = _b[_i]; - _loop_8(outputReferencedSymbol); + _loop_9(outputReferencedSymbol); } }, function () { return getDefinitionLocation(defaultProject, initialLocation); }); return outputs.filter(function (o) { return o.references.length !== 0; }); @@ -133483,7 +139060,7 @@ var ts; projectService.forEachEnabledProject(function (project) { if (!ts.addToSeen(seenProjects, project.projectName)) return; - var definition = getDefinitionInProject(memGetDefinition_1(), defaultProject, project); + var definition = mapDefinitionInProject(memGetDefinition_1(), defaultProject, project); if (definition) { toDo = callbackProjectAndLocation({ project: project, location: definition }, projectService, toDo, seenProjects, cb); } @@ -133493,15 +139070,41 @@ var ts; toDo = callbackProjectAndLocation(ts.Debug.assertDefined(toDo.pop()), projectService, toDo, seenProjects, cb); } } - function getDefinitionInProject(definition, definingProject, project) { - if (!definition || project.containsFile(server.toNormalizedPath(definition.fileName))) + function mapDefinitionInProject(definition, definingProject, project) { + // If the definition is actually from the project, definition is correct as is + if (!definition || + project.containsFile(server.toNormalizedPath(definition.fileName)) && + !isLocationProjectReferenceRedirect(project, definition)) { return definition; - var mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); + } + var mappedDefinition = definingProject.isSourceOfProjectReferenceRedirect(definition.fileName) ? + definition : + definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); return mappedDefinition && project.containsFile(server.toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined; } + function isLocationProjectReferenceRedirect(project, location) { + if (!location) + return false; + var program = project.getLanguageService().getProgram(); + if (!program) + return false; + var sourceFile = program.getSourceFile(location.fileName); + // It is possible that location is attached to project but + // the program actually includes its redirect instead. + // This happens when rootFile in project is one of the file from referenced project + // Thus root is attached but program doesnt have the actual .ts file but .d.ts + // If this is not the file we were actually looking, return rest of the toDo + return !!sourceFile && + sourceFile.resolvedPath !== sourceFile.path && + sourceFile.resolvedPath !== project.toPath(location.fileName); + } function callbackProjectAndLocation(projectAndLocation, projectService, toDo, seenProjects, cb) { - if (projectAndLocation.project.getCancellationToken().isCancellationRequested()) + var project = projectAndLocation.project, location = projectAndLocation.location; + if (project.getCancellationToken().isCancellationRequested()) return undefined; // Skip rest of toDo if cancelled + // If this is not the file we were actually looking, return rest of the toDo + if (isLocationProjectReferenceRedirect(project, location)) + return toDo; cb(projectAndLocation, function (project, location) { seenProjects.set(projectAndLocation.project.projectName, true); var originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(project, location); @@ -133515,14 +139118,14 @@ var ts; } var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo); if (symlinkedProjectsMap) { - symlinkedProjectsMap.forEach(function (symlinkedProjects) { + symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) { for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) { var symlinkedProject = symlinkedProjects_2[_i]; - addToTodo({ project: symlinkedProject, location: originalLocation }, toDo, seenProjects); + addToTodo({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } }, toDo, seenProjects); } }); } - return originalLocation; + return originalLocation === location ? undefined : originalLocation; }); return toDo; } @@ -134031,7 +139634,7 @@ var ts; msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; } } - catch (_b) { } // tslint:disable-line no-empty + catch (_b) { } // eslint-disable-line no-empty } if (err.ProgramFiles) { msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; @@ -134307,7 +139910,9 @@ var ts; }; Session.prototype.getEmitOutput = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEmitOutput(file); + return project.shouldEmitFile(project.getScriptInfo(file)) ? + project.getLanguageService().getEmitOutput(file) : + { emitSkipped: true, outputFiles: [] }; }; Session.prototype.mapDefinitionInfo = function (definitions, project) { var _this = this; @@ -134843,11 +140448,11 @@ var ts; return helpItems; } }; - Session.prototype.createCheckList = function (fileNames, defaultProject) { + Session.prototype.createCheckList = function (fileNames) { var _this = this; return ts.mapDefined(fileNames, function (uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); - var project = defaultProject || _this.projectService.tryGetDefaultProjectForFile(fileName); + var project = _this.projectService.tryGetDefaultProjectForFile(fileName); return project && { fileName: fileName, project: project }; }); }; @@ -136143,7 +141748,6 @@ var ts; }()); })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); -// tslint:disable no-unnecessary-type-assertion (TODO: tslint can't find node types) var ts; (function (ts) { var server; @@ -136281,7 +141885,7 @@ var ts; Logger.prototype.write = function (s) { if (this.fd >= 0) { var buf = sys.bufferFrom(s); - // tslint:disable-next-line no-null-keyword + // eslint-disable-next-line no-null/no-null fs.writeSync(this.fd, buf, 0, buf.length, /*position*/ null); // TODO: GH#18217 } if (this.traceToConsole) { @@ -136527,6 +142131,7 @@ var ts; // so we defer until the next tick. // // Construction should finish before the next tick fires, so we do not need to do this recursively. + // eslint-disable-next-line no-restricted-globals setImmediate(function () { return _this.event(body, eventName); }); } }; @@ -136720,7 +142325,7 @@ var ts; // stat due to inconsistencies of fs.watch // and efficiency of stat on modern filesystems function startWatchTimer() { - // tslint:disable-next-line:ban + // eslint-disable-next-line no-restricted-globals setInterval(function () { var count = 0; var nextToCheck = nextFileToCheck; @@ -136889,10 +142494,12 @@ var ts; close: function () { return pollingWatchedFileSet.removeFile(watchedFile); } }; }; + /* eslint-disable no-restricted-globals */ sys.setTimeout = setTimeout; sys.clearTimeout = clearTimeout; sys.setImmediate = setImmediate; sys.clearImmediate = clearImmediate; + /* eslint-enable no-restricted-globals */ if (typeof global !== "undefined" && global.gc) { sys.gc = function () { return global.gc(); }; } @@ -136912,14 +142519,11 @@ var ts; catch (e) { cancellationToken = server.nullCancellationToken; } - var eventPort; - { - var str = server.findArgument("--eventPort"); - var v = str === undefined ? undefined : parseInt(str); - if (v !== undefined && !isNaN(v)) { - eventPort = v; - } + function parseEventPort(eventPortStr) { + var eventPort = eventPortStr === undefined ? undefined : parseInt(eventPortStr); + return eventPort !== undefined && !isNaN(eventPort) ? eventPort : undefined; } + var eventPort = parseEventPort(server.findArgument("--eventPort")); var localeStr = server.findArgument("--locale"); if (localeStr) { ts.validateLocaleAndSetLanguage(localeStr, sys); @@ -136955,7 +142559,6 @@ var ts; ioSession.logError(err, "unknown"); }); // See https://github.com/Microsoft/TypeScript/issues/11348 - // tslint:disable-next-line no-unnecessary-type-assertion-2 process.noAsar = true; // Start listening ioSession.listen(); diff --git a/node_modules/typescript/lib/tsserverlibrary.d.ts b/node_modules/typescript/lib/tsserverlibrary.d.ts index 5869f3641..6fbc32952 100644 --- a/node_modules/typescript/lib/tsserverlibrary.d.ts +++ b/node_modules/typescript/lib/tsserverlibrary.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.6"; + const versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ const version: string; } @@ -73,7 +73,7 @@ declare namespace ts { end: number; } export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | 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 KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.BigIntKeyword | 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 | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; export enum SyntaxKind { Unknown = 0, @@ -104,329 +104,335 @@ declare namespace ts { DotDotDotToken = 25, SemicolonToken = 26, CommaToken = 27, - LessThanToken = 28, - LessThanSlashToken = 29, - GreaterThanToken = 30, - LessThanEqualsToken = 31, - GreaterThanEqualsToken = 32, - EqualsEqualsToken = 33, - ExclamationEqualsToken = 34, - EqualsEqualsEqualsToken = 35, - ExclamationEqualsEqualsToken = 36, - EqualsGreaterThanToken = 37, - PlusToken = 38, - MinusToken = 39, - AsteriskToken = 40, - AsteriskAsteriskToken = 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 = 57, - AtToken = 58, + QuestionDotToken = 28, + LessThanToken = 29, + LessThanSlashToken = 30, + GreaterThanToken = 31, + LessThanEqualsToken = 32, + GreaterThanEqualsToken = 33, + EqualsEqualsToken = 34, + ExclamationEqualsToken = 35, + EqualsEqualsEqualsToken = 36, + ExclamationEqualsEqualsToken = 37, + EqualsGreaterThanToken = 38, + PlusToken = 39, + MinusToken = 40, + AsteriskToken = 41, + AsteriskAsteriskToken = 42, + SlashToken = 43, + PercentToken = 44, + PlusPlusToken = 45, + MinusMinusToken = 46, + LessThanLessThanToken = 47, + GreaterThanGreaterThanToken = 48, + GreaterThanGreaterThanGreaterThanToken = 49, + AmpersandToken = 50, + BarToken = 51, + CaretToken = 52, + ExclamationToken = 53, + TildeToken = 54, + AmpersandAmpersandToken = 55, + BarBarToken = 56, + QuestionToken = 57, + ColonToken = 58, + AtToken = 59, + QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 59, - EqualsToken = 60, - PlusEqualsToken = 61, - MinusEqualsToken = 62, - AsteriskEqualsToken = 63, - AsteriskAsteriskEqualsToken = 64, - SlashEqualsToken = 65, - PercentEqualsToken = 66, - LessThanLessThanEqualsToken = 67, - GreaterThanGreaterThanEqualsToken = 68, - GreaterThanGreaterThanGreaterThanEqualsToken = 69, - AmpersandEqualsToken = 70, - BarEqualsToken = 71, - CaretEqualsToken = 72, - Identifier = 73, - BreakKeyword = 74, - CaseKeyword = 75, - CatchKeyword = 76, - ClassKeyword = 77, - ConstKeyword = 78, - ContinueKeyword = 79, - DebuggerKeyword = 80, - DefaultKeyword = 81, - DeleteKeyword = 82, - DoKeyword = 83, - ElseKeyword = 84, - EnumKeyword = 85, - ExportKeyword = 86, - ExtendsKeyword = 87, - FalseKeyword = 88, - FinallyKeyword = 89, - ForKeyword = 90, - FunctionKeyword = 91, - IfKeyword = 92, - ImportKeyword = 93, - InKeyword = 94, - InstanceOfKeyword = 95, - NewKeyword = 96, - NullKeyword = 97, - ReturnKeyword = 98, - SuperKeyword = 99, - SwitchKeyword = 100, - ThisKeyword = 101, - ThrowKeyword = 102, - TrueKeyword = 103, - TryKeyword = 104, - TypeOfKeyword = 105, - VarKeyword = 106, - VoidKeyword = 107, - WhileKeyword = 108, - WithKeyword = 109, - ImplementsKeyword = 110, - InterfaceKeyword = 111, - LetKeyword = 112, - PackageKeyword = 113, - PrivateKeyword = 114, - ProtectedKeyword = 115, - PublicKeyword = 116, - StaticKeyword = 117, - YieldKeyword = 118, - AbstractKeyword = 119, - AsKeyword = 120, - AnyKeyword = 121, - AsyncKeyword = 122, - AwaitKeyword = 123, - BooleanKeyword = 124, - ConstructorKeyword = 125, - DeclareKeyword = 126, - GetKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocNamepathType = 297, - JSDocComment = 298, - JSDocTypeLiteral = 299, - JSDocSignature = 300, - JSDocTag = 301, - JSDocAugmentsTag = 302, - JSDocAuthorTag = 303, - JSDocClassTag = 304, - JSDocCallbackTag = 305, - JSDocEnumTag = 306, - JSDocParameterTag = 307, - JSDocReturnTag = 308, - JSDocThisTag = 309, - JSDocTypeTag = 310, - JSDocTemplateTag = 311, - JSDocTypedefTag = 312, - JSDocPropertyTag = 313, - SyntaxList = 314, - NotEmittedStatement = 315, - PartiallyEmittedExpression = 316, - CommaListExpression = 317, - MergeDeclarationMarker = 318, - EndOfDeclarationMarker = 319, - Count = 320, - FirstAssignment = 60, - LastAssignment = 72, - FirstCompoundAssignment = 61, - LastCompoundAssignment = 72, - FirstReservedWord = 74, - LastReservedWord = 109, - FirstKeyword = 74, - LastKeyword = 148, - FirstFutureReservedWord = 110, - LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + BacktickToken = 61, + EqualsToken = 62, + PlusEqualsToken = 63, + MinusEqualsToken = 64, + AsteriskEqualsToken = 65, + AsteriskAsteriskEqualsToken = 66, + SlashEqualsToken = 67, + PercentEqualsToken = 68, + LessThanLessThanEqualsToken = 69, + GreaterThanGreaterThanEqualsToken = 70, + GreaterThanGreaterThanGreaterThanEqualsToken = 71, + AmpersandEqualsToken = 72, + BarEqualsToken = 73, + CaretEqualsToken = 74, + Identifier = 75, + BreakKeyword = 76, + CaseKeyword = 77, + CatchKeyword = 78, + ClassKeyword = 79, + ConstKeyword = 80, + ContinueKeyword = 81, + DebuggerKeyword = 82, + DefaultKeyword = 83, + DeleteKeyword = 84, + DoKeyword = 85, + ElseKeyword = 86, + EnumKeyword = 87, + ExportKeyword = 88, + ExtendsKeyword = 89, + FalseKeyword = 90, + FinallyKeyword = 91, + ForKeyword = 92, + FunctionKeyword = 93, + IfKeyword = 94, + ImportKeyword = 95, + InKeyword = 96, + InstanceOfKeyword = 97, + NewKeyword = 98, + NullKeyword = 99, + ReturnKeyword = 100, + SuperKeyword = 101, + SwitchKeyword = 102, + ThisKeyword = 103, + ThrowKeyword = 104, + TrueKeyword = 105, + TryKeyword = 106, + TypeOfKeyword = 107, + VarKeyword = 108, + VoidKeyword = 109, + WhileKeyword = 110, + WithKeyword = 111, + ImplementsKeyword = 112, + InterfaceKeyword = 113, + LetKeyword = 114, + PackageKeyword = 115, + PrivateKeyword = 116, + ProtectedKeyword = 117, + PublicKeyword = 118, + StaticKeyword = 119, + YieldKeyword = 120, + AbstractKeyword = 121, + AsKeyword = 122, + AssertsKeyword = 123, + AnyKeyword = 124, + AsyncKeyword = 125, + AwaitKeyword = 126, + BooleanKeyword = 127, + ConstructorKeyword = 128, + DeclareKeyword = 129, + GetKeyword = 130, + InferKeyword = 131, + IsKeyword = 132, + KeyOfKeyword = 133, + ModuleKeyword = 134, + NamespaceKeyword = 135, + NeverKeyword = 136, + ReadonlyKeyword = 137, + RequireKeyword = 138, + NumberKeyword = 139, + ObjectKeyword = 140, + SetKeyword = 141, + StringKeyword = 142, + SymbolKeyword = 143, + TypeKeyword = 144, + UndefinedKeyword = 145, + UniqueKeyword = 146, + UnknownKeyword = 147, + FromKeyword = 148, + GlobalKeyword = 149, + BigIntKeyword = 150, + OfKeyword = 151, + QualifiedName = 152, + ComputedPropertyName = 153, + TypeParameter = 154, + Parameter = 155, + Decorator = 156, + PropertySignature = 157, + PropertyDeclaration = 158, + MethodSignature = 159, + MethodDeclaration = 160, + Constructor = 161, + GetAccessor = 162, + SetAccessor = 163, + CallSignature = 164, + ConstructSignature = 165, + IndexSignature = 166, + TypePredicate = 167, + TypeReference = 168, + FunctionType = 169, + ConstructorType = 170, + TypeQuery = 171, + TypeLiteral = 172, + ArrayType = 173, + TupleType = 174, + OptionalType = 175, + RestType = 176, + UnionType = 177, + IntersectionType = 178, + ConditionalType = 179, + InferType = 180, + ParenthesizedType = 181, + ThisType = 182, + TypeOperator = 183, + IndexedAccessType = 184, + MappedType = 185, + LiteralType = 186, + ImportType = 187, + ObjectBindingPattern = 188, + ArrayBindingPattern = 189, + BindingElement = 190, + ArrayLiteralExpression = 191, + ObjectLiteralExpression = 192, + PropertyAccessExpression = 193, + ElementAccessExpression = 194, + CallExpression = 195, + NewExpression = 196, + TaggedTemplateExpression = 197, + TypeAssertionExpression = 198, + ParenthesizedExpression = 199, + FunctionExpression = 200, + ArrowFunction = 201, + DeleteExpression = 202, + TypeOfExpression = 203, + VoidExpression = 204, + AwaitExpression = 205, + PrefixUnaryExpression = 206, + PostfixUnaryExpression = 207, + BinaryExpression = 208, + ConditionalExpression = 209, + TemplateExpression = 210, + YieldExpression = 211, + SpreadElement = 212, + ClassExpression = 213, + OmittedExpression = 214, + ExpressionWithTypeArguments = 215, + AsExpression = 216, + NonNullExpression = 217, + MetaProperty = 218, + SyntheticExpression = 219, + TemplateSpan = 220, + SemicolonClassElement = 221, + Block = 222, + EmptyStatement = 223, + VariableStatement = 224, + ExpressionStatement = 225, + IfStatement = 226, + DoStatement = 227, + WhileStatement = 228, + ForStatement = 229, + ForInStatement = 230, + ForOfStatement = 231, + ContinueStatement = 232, + BreakStatement = 233, + ReturnStatement = 234, + WithStatement = 235, + SwitchStatement = 236, + LabeledStatement = 237, + ThrowStatement = 238, + TryStatement = 239, + DebuggerStatement = 240, + VariableDeclaration = 241, + VariableDeclarationList = 242, + FunctionDeclaration = 243, + ClassDeclaration = 244, + InterfaceDeclaration = 245, + TypeAliasDeclaration = 246, + EnumDeclaration = 247, + ModuleDeclaration = 248, + ModuleBlock = 249, + CaseBlock = 250, + NamespaceExportDeclaration = 251, + ImportEqualsDeclaration = 252, + ImportDeclaration = 253, + ImportClause = 254, + NamespaceImport = 255, + NamedImports = 256, + ImportSpecifier = 257, + ExportAssignment = 258, + ExportDeclaration = 259, + NamedExports = 260, + ExportSpecifier = 261, + MissingDeclaration = 262, + ExternalModuleReference = 263, + JsxElement = 264, + JsxSelfClosingElement = 265, + JsxOpeningElement = 266, + JsxClosingElement = 267, + JsxFragment = 268, + JsxOpeningFragment = 269, + JsxClosingFragment = 270, + JsxAttribute = 271, + JsxAttributes = 272, + JsxSpreadAttribute = 273, + JsxExpression = 274, + CaseClause = 275, + DefaultClause = 276, + HeritageClause = 277, + CatchClause = 278, + PropertyAssignment = 279, + ShorthandPropertyAssignment = 280, + SpreadAssignment = 281, + EnumMember = 282, + UnparsedPrologue = 283, + UnparsedPrepend = 284, + UnparsedText = 285, + UnparsedInternalText = 286, + UnparsedSyntheticReference = 287, + SourceFile = 288, + Bundle = 289, + UnparsedSource = 290, + InputFiles = 291, + JSDocTypeExpression = 292, + JSDocAllType = 293, + JSDocUnknownType = 294, + JSDocNullableType = 295, + JSDocNonNullableType = 296, + JSDocOptionalType = 297, + JSDocFunctionType = 298, + JSDocVariadicType = 299, + JSDocNamepathType = 300, + JSDocComment = 301, + JSDocTypeLiteral = 302, + JSDocSignature = 303, + JSDocTag = 304, + JSDocAugmentsTag = 305, + JSDocAuthorTag = 306, + JSDocClassTag = 307, + JSDocCallbackTag = 308, + JSDocEnumTag = 309, + JSDocParameterTag = 310, + JSDocReturnTag = 311, + JSDocThisTag = 312, + JSDocTypeTag = 313, + JSDocTemplateTag = 314, + JSDocTypedefTag = 315, + JSDocPropertyTag = 316, + SyntaxList = 317, + NotEmittedStatement = 318, + PartiallyEmittedExpression = 319, + CommaListExpression = 320, + MergeDeclarationMarker = 321, + EndOfDeclarationMarker = 322, + SyntheticReferenceExpression = 323, + Count = 324, + FirstAssignment = 62, + LastAssignment = 74, + FirstCompoundAssignment = 63, + LastCompoundAssignment = 74, + FirstReservedWord = 76, + LastReservedWord = 111, + FirstKeyword = 76, + LastKeyword = 151, + FirstFutureReservedWord = 112, + LastFutureReservedWord = 120, + FirstTypeNode = 167, + LastTypeNode = 187, FirstPunctuation = 18, - LastPunctuation = 72, + LastPunctuation = 74, FirstToken = 0, - LastToken = 148, + LastToken = 151, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, LastLiteralToken = 14, FirstTemplateToken = 14, LastTemplateToken = 17, - FirstBinaryOperator = 28, - LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 313, - FirstJSDocTagNode = 301, - LastJSDocTagNode = 313, + FirstBinaryOperator = 29, + LastBinaryOperator = 74, + FirstStatement = 224, + LastStatement = 240, + FirstNode = 152, + FirstJSDocNode = 292, + LastJSDocNode = 316, + FirstJSDocTagNode = 304, + LastJSDocTagNode = 316, } export enum NodeFlags { None = 0, @@ -435,27 +441,28 @@ declare namespace ts { NestedNamespace = 4, Synthesized = 8, Namespace = 16, - ExportContext = 32, - ContainsThis = 64, - HasImplicitReturn = 128, - HasExplicitReturn = 256, - GlobalAugmentation = 512, - HasAsyncFunctions = 1024, - DisallowInContext = 2048, - YieldContext = 4096, - DecoratorContext = 8192, - AwaitContext = 16384, - ThisNodeHasError = 32768, - JavaScriptFile = 65536, - ThisNodeOrAnySubNodesHasError = 131072, - HasAggregatedChildData = 262144, - JSDoc = 2097152, - JsonFile = 16777216, + OptionalChain = 32, + ExportContext = 64, + ContainsThis = 128, + HasImplicitReturn = 256, + HasExplicitReturn = 512, + GlobalAugmentation = 1024, + HasAsyncFunctions = 2048, + DisallowInContext = 4096, + YieldContext = 8192, + DecoratorContext = 16384, + AwaitContext = 32768, + ThisNodeHasError = 65536, + JavaScriptFile = 131072, + ThisNodeOrAnySubNodesHasError = 262144, + HasAggregatedChildData = 524288, + JSDoc = 4194304, + JsonFile = 33554432, BlockScoped = 3, - ReachabilityCheckFlags = 384, - ReachabilityAndEmitFlags = 1408, - ContextFlags = 12679168, - TypeExcludesFlags = 20480, + ReachabilityCheckFlags = 768, + ReachabilityAndEmitFlags = 2816, + ContextFlags = 25358336, + TypeExcludesFlags = 40960, } export enum ModifierFlags { None = 0, @@ -505,8 +512,10 @@ declare namespace ts { export interface Token extends Node { kind: TKind; } + export type DotToken = Token; export type DotDotDotToken = Token; export type QuestionToken = Token; + export type QuestionDotToken = Token; export type ExclamationToken = Token; export type ColonToken = Token; export type EqualsToken = Token; @@ -517,6 +526,7 @@ declare namespace ts { export type AwaitKeywordToken = Token; export type PlusToken = Token; export type MinusToken = Token; + export type AssertsToken = Token; export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; export type ModifiersArray = NodeArray; export interface Identifier extends PrimaryExpression, Declaration { @@ -539,7 +549,7 @@ declare namespace ts { } export type EntityName = Identifier | QualifiedName; export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; + export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; export interface Declaration extends Node { _declarationBrand: any; } @@ -770,8 +780,9 @@ declare namespace ts { export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; + assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; - type: TypeNode; + type?: TypeNode; } export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; @@ -842,7 +853,7 @@ declare namespace ts { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - export interface StringLiteral extends LiteralExpression { + export interface StringLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.StringLiteral; } export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; @@ -943,7 +954,7 @@ declare namespace ts { export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - export type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator; export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; export type BinaryOperatorToken = Token; export interface BinaryExpression extends Expression, Declaration { @@ -1006,7 +1017,7 @@ declare namespace ts { export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } - export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode { + export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode, Declaration { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } export enum TokenFlags { @@ -1017,7 +1028,7 @@ declare namespace ts { BinarySpecifier = 128, OctalSpecifier = 256, } - export interface NumericLiteral extends LiteralExpression { + export interface NumericLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.NumericLiteral; } export interface BigIntLiteral extends LiteralExpression { @@ -1077,8 +1088,12 @@ declare namespace ts { export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; name: Identifier; } + export interface PropertyAccessChain extends PropertyAccessExpression { + _optionalChainBrand: any; + } export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } @@ -1090,8 +1105,12 @@ declare namespace ts { export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; argumentExpression: Expression; } + export interface ElementAccessChain extends ElementAccessExpression { + _optionalChainBrand: any; + } export interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } @@ -1099,9 +1118,14 @@ declare namespace ts { export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; typeArguments?: NodeArray; arguments: NodeArray; } + export interface CallChain extends CallExpression { + _optionalChainBrand: any; + } + export type OptionalChain = PropertyAccessChain | ElementAccessChain | CallChain; export interface SuperCall extends CallExpression { expression: SuperExpression; } @@ -1635,8 +1659,8 @@ declare namespace ts { } export interface JSDocSignature extends JSDocType, Declaration { kind: SyntaxKind.JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly JSDocTemplateTag[]; + parameters: readonly JSDocParameterTag[]; type: JSDocReturnTag | undefined; } export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { @@ -1655,7 +1679,7 @@ declare namespace ts { } export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: ReadonlyArray; + jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } @@ -1669,13 +1693,19 @@ declare namespace ts { FalseCondition = 64, SwitchClause = 128, ArrayMutation = 256, - Referenced = 512, - Shared = 1024, - PreFinally = 2048, - AfterFinally = 4096, + Call = 512, + Referenced = 1024, + Shared = 2048, + PreFinally = 4096, + AfterFinally = 8192, Label = 12, Condition = 96 } + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { + flags: FlowFlags; + id?: number; + } export interface FlowLock { locked?: boolean; } @@ -1686,13 +1716,8 @@ declare namespace ts { antecedent: FlowNode; lock: FlowLock; } - export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - export interface FlowNodeBase { - flags: FlowFlags; - id?: number; - } export interface FlowStart extends FlowNodeBase { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + node?: FunctionExpression | ArrowFunction | MethodDeclaration; } export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; @@ -1701,8 +1726,12 @@ declare namespace ts { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } + export interface FlowCall extends FlowNodeBase { + node: CallExpression; + antecedent: FlowNode; + } export interface FlowCondition extends FlowNodeBase { - expression: Expression; + node: Expression; antecedent: FlowNode; } export interface FlowSwitchClause extends FlowNodeBase { @@ -1730,11 +1759,11 @@ declare namespace ts { endOfFileToken: Token; fileName: string; text: string; - amdDependencies: ReadonlyArray; + amdDependencies: readonly AmdDependency[]; moduleName?: string; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray; - libReferenceDirectives: ReadonlyArray; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly FileReference[]; + libReferenceDirectives: readonly FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1750,8 +1779,8 @@ declare namespace ts { } export interface Bundle extends Node { kind: SyntaxKind.Bundle; - prepends: ReadonlyArray; - sourceFiles: ReadonlyArray; + prepends: readonly (InputFiles | UnparsedSource)[]; + sourceFiles: readonly SourceFile[]; } export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; @@ -1768,16 +1797,16 @@ declare namespace ts { kind: SyntaxKind.UnparsedSource; fileName: string; text: string; - prologues: ReadonlyArray; - helpers: ReadonlyArray | undefined; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray | undefined; - libReferenceDirectives: ReadonlyArray; + prologues: readonly UnparsedPrologue[]; + helpers: readonly UnscopedEmitHelper[] | undefined; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly string[] | undefined; + libReferenceDirectives: readonly FileReference[]; hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; - syntheticReferences?: ReadonlyArray; - texts: ReadonlyArray; + syntheticReferences?: readonly UnparsedSyntheticReference[]; + texts: readonly UnparsedSourceText[]; } export type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; export type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; @@ -1795,7 +1824,7 @@ declare namespace ts { kind: SyntaxKind.UnparsedPrepend; data: string; parent: UnparsedSource; - texts: ReadonlyArray; + texts: readonly UnparsedTextLike[]; } export interface UnparsedTextLike extends UnparsedSection { kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; @@ -1827,7 +1856,7 @@ declare namespace ts { } export interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. @@ -1844,7 +1873,7 @@ declare namespace ts { export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; + export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; export class OperationCanceledException { } export interface CancellationToken { @@ -1856,11 +1885,11 @@ declare namespace ts { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): ReadonlyArray; + getRootFileNames(): readonly string[]; /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1872,26 +1901,35 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** The first time this is called, it will return global diagnostics (no location). */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getRelationCacheSizes(): { + assignable: number; + identity: number; + subtype: number; + }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; + getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } export interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; - references?: ReadonlyArray; + references?: readonly (ResolvedProjectReference | undefined)[]; } export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; export interface CustomTransformer { @@ -1925,12 +1963,15 @@ declare namespace ts { Success = 0, DiagnosticsPresent_OutputsSkipped = 1, DiagnosticsPresent_OutputsGenerated = 2, - InvalidProject_OutputsSkipped = 3 + InvalidProject_OutputsSkipped = 3, + ProjectReferenceCycle_OutputsSkipped = 4, + /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ + ProjectReferenceCycle_OutputsSkupped = 4 } export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; emittedFiles?: string[]; } export interface TypeChecker { @@ -1939,7 +1980,7 @@ declare namespace ts { getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; + getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1947,6 +1988,7 @@ declare namespace ts { getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; + getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -1993,7 +2035,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): ReadonlyArray; + getRootSymbols(symbol: Symbol): readonly Symbol[]; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -2088,21 +2130,39 @@ declare namespace ts { } export enum TypePredicateKind { This = 0, - Identifier = 1 + Identifier = 1, + AssertsThis = 2, + AssertsIdentifier = 3 } export interface TypePredicateBase { kind: TypePredicateKind; - type: Type; + type: Type | undefined; } export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; + parameterName: undefined; + parameterIndex: undefined; + type: Type; } export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; + type: Type; } - export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + export interface AssertsThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsThis; + parameterName: undefined; + parameterIndex: undefined; + type: Type | undefined; + } + export interface AssertsIdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsIdentifier; + parameterName: string; + parameterIndex: number; + type: Type | undefined; + } + export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2278,7 +2338,7 @@ declare namespace ts { symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: ReadonlyArray; + aliasTypeArguments?: readonly Type[]; } export interface LiteralType extends Type { value: string | number | PseudoBigInt; @@ -2330,7 +2390,7 @@ declare namespace ts { localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - export type BaseType = ObjectType | IntersectionType; + export type BaseType = ObjectType | IntersectionType | TypeVariable; export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -2350,7 +2410,9 @@ declare namespace ts { */ export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: ReadonlyArray; + node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; + } + export interface DeferredTypeReference extends TypeReference { } export interface GenericType extends InterfaceType, TypeReference { } @@ -2420,8 +2482,8 @@ declare namespace ts { } export interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly TypeParameter[]; + parameters: readonly Symbol[]; } export enum IndexKind { String = 0, @@ -2529,6 +2591,7 @@ declare namespace ts { emitDeclarationOnly?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + disableSourceOfProjectReferenceRedirect?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; @@ -2595,9 +2658,14 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; + useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } export interface TypeAcquisition { + /** + * @deprecated typingOptions.enableAutoDiscovery + * Use typeAcquisition.enable instead. + */ enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; @@ -2664,7 +2732,7 @@ declare namespace ts { options: CompilerOptions; typeAcquisition?: TypeAcquisition; fileNames: string[]; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; @@ -2679,12 +2747,12 @@ declare namespace ts { wildcardDirectories: MapLike; } export interface CreateProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; oldProgram?: Program; - configFileParsingDiagnostics?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; } export interface ModuleResolutionHost { fileExists(fileName: string): boolean; @@ -2765,7 +2833,7 @@ declare namespace ts { } export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: ReadonlyArray; + readonly failedLookupLocations: readonly string[]; } export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; @@ -2778,7 +2846,7 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; + readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files @@ -3016,6 +3084,11 @@ declare namespace ts { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } + export interface ModuleSpecifierResolutionHost extends GetEffectiveTypeRootsHost { + useCaseSensitiveFileNames?(): boolean; + fileExists?(path: string): boolean; + readFile?(path: string): string | undefined; + } export interface TextSpan { start: number; length: number; @@ -3098,6 +3171,7 @@ declare namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ @@ -3144,7 +3218,7 @@ declare namespace ts { getExecutingFilePath(): string; getCurrentDirectory(): string; getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; @@ -3192,6 +3266,7 @@ declare namespace ts { scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanQuestionToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; @@ -3229,7 +3304,7 @@ declare namespace ts { } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; + function sortAndDeduplicateDiagnostics(diagnostics: readonly T[]): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3258,7 +3333,7 @@ declare namespace ts { * This function will then merge those changes into a single change range valid between V1 and * Vn. */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; @@ -3330,7 +3405,7 @@ declare namespace ts { * * For binding patterns, parameter tags are matched by position. */ - function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the JSDoc type parameter tags for the node if present. * @@ -3341,7 +3416,7 @@ declare namespace ts { * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ - function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; /** * Return true if the node has JSDoc parameter tags. * @@ -3383,14 +3458,14 @@ declare namespace ts { */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ - function getJSDocTags(node: Node): ReadonlyArray; + function getJSDocTags(node: Node): readonly JSDocTag[]; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ - function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ - function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; } declare namespace ts { @@ -3444,8 +3519,13 @@ declare namespace ts { function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; + function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessExpression(node: Node): node is ElementAccessExpression; + function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallExpression(node: Node): node is CallExpression; + function isCallChain(node: Node): node is CallChain; + function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain; + function isNullishCoalesce(node: Node): boolean; function isNewExpression(node: Node): node is NewExpression; function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression; function isTypeAssertion(node: Node): node is TypeAssertion; @@ -3543,7 +3623,7 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; - function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; + function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType; @@ -3643,7 +3723,7 @@ declare namespace ts { export {}; } declare namespace ts { - export function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; + export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine; export type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics @@ -3697,7 +3777,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3705,7 +3785,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; export interface ParsedTsconfig { raw: any; options?: CompilerOptions; @@ -3771,7 +3851,7 @@ declare namespace ts { function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { - function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; + function createNodeArray(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; function createLiteral(value: number | PseudoBigInt): NumericLiteral; @@ -3809,62 +3889,64 @@ declare namespace ts { function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function createParameter(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + function createParameter(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createPropertySignature(modifiers: ReadonlyArray | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function updatePropertySignature(node: PropertySignature, modifiers: ReadonlyArray | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function createProperty(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function createMethodSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createProperty(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function createMethodSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; - function createMethod(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function createConstructor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function createGetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function createSetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createMethod(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; - function createConstructSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; + function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; - function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray | undefined): TypeReferenceNode; + function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; - function createFunctionTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): FunctionTypeNode; + function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; - function createConstructorTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructorTypeNode; + function createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; + function createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; - function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode; function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; function createRestTypeNode(type: TypeNode): RestTypeNode; function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; - function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; + function createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; - function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; + function createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray): IntersectionTypeNode; - function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray): UnionOrIntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: readonly TypeNode[]): UnionOrIntersectionTypeNode; function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; @@ -3877,36 +3959,42 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; - function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ReadonlyArray): ArrayBindingPattern; + function createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; - function createArrayLiteral(elements?: ReadonlyArray, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; - function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; + function createArrayLiteral(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier): PropertyAccessChain; + function updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier): PropertyAccessChain; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; - function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; + function createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; + function updateElementAccessChain(node: ElementAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, argumentExpression: Expression): ElementAccessChain; + function createCall(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; + function createCallChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallChain; + function updateCallChain(node: CallChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallChain; + function createNew(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; /** @deprecated */ function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; /** @deprecated */ function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; - function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3924,8 +4012,8 @@ declare namespace ts { /** @deprecated */ function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; function createTemplateHead(text: string, rawText?: string): TemplateHead; function createTemplateMiddle(text: string, rawText?: string): TemplateMiddle; function createTemplateTail(text: string, rawText?: string): TemplateTail; @@ -3935,11 +4023,11 @@ declare namespace ts { function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3949,10 +4037,10 @@ declare namespace ts { function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; - function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function updateBlock(node: Block, statements: ReadonlyArray): Block; - function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; + function createBlock(statements: readonly Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: readonly Statement[]): Block; + function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; function createExpressionStatement(expression: Expression): ExpressionStatement; function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; @@ -3991,76 +4079,76 @@ declare namespace ts { function createDebuggerStatement(): DebuggerStatement; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - function createVariableDeclarationList(declarations: ReadonlyArray, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; - function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function createEnumDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, members: ReadonlyArray): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, members: ReadonlyArray): EnumDeclaration; - function createModuleDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; - function createModuleBlock(statements: ReadonlyArray): ModuleBlock; - function updateModuleBlock(node: ModuleBlock, statements: ReadonlyArray): ModuleBlock; - function createCaseBlock(clauses: ReadonlyArray): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: ReadonlyArray): CaseBlock; + function createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; + function createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + function createModuleBlock(statements: readonly Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; + function createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ReadonlyArray): NamedImports; - function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; + function createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; - function createNamedExports(elements: ReadonlyArray): NamedExports; - function updateNamedExports(node: NamedExports, elements: ReadonlyArray): NamedExports; + function createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + function createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; - function createJsxElement(openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; + function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxFragment(openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function createJsxOpeningFragment(): JsxOpeningFragment; function createJsxJsxClosingFragment(): JsxClosingFragment; - function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxAttributes(properties: ReadonlyArray): JsxAttributes; - function updateJsxAttributes(node: JsxAttributes, properties: ReadonlyArray): JsxAttributes; + function createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; - function createCaseClause(expression: Expression, statements: ReadonlyArray): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: ReadonlyArray): CaseClause; - function createDefaultClause(statements: ReadonlyArray): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; - function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; + function createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; + function createDefaultClause(statements: readonly Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; + function createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; @@ -4071,7 +4159,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4093,20 +4181,20 @@ declare namespace ts { */ function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createCommaList(elements: ReadonlyArray): CommaListExpression; - function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; + function createCommaList(elements: readonly Expression[]): CommaListExpression; + function updateCommaList(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; + function createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; - function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + function updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -4118,6 +4206,7 @@ declare namespace ts { function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createNullishCoalesce(left: Expression, right: Expression): BinaryExpression; function createLogicalNot(operand: Expression): PrefixUnaryExpression; function createVoidZero(): VoidExpression; function createExportDefault(expression: Expression): ExportAssignment; @@ -4174,7 +4263,7 @@ declare namespace ts { /** * Sets the constant value to emit for an expression. */ - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): PropertyAccessExpression | ElementAccessExpression; + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): ElementAccessExpression | PropertyAccessExpression; /** * Adds an EmitHelper to a node. */ @@ -4279,23 +4368,25 @@ declare namespace ts { function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } declare namespace ts { + function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined; + function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[]; function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } declare namespace ts { export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; export function resolveTripleslashReference(moduleName: string, containingFile: string): string; export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; export interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; getNewLine(): string; } - export function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; + export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - export function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; + export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; - export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4321,7 +4412,7 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - export function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; + export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program; /** @deprecated */ export interface ResolveProjectReferencePathHost { fileExists(fileName: string): boolean; } @@ -4383,31 +4474,31 @@ declare namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Get the diagnostics for compiler options */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics that dont belong to any file */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics from config file parsing */ - getConfigFileParsingDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Get the syntax diagnostics, for all source files if source file is not supplied */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the declaration diagnostics, for all source files if source file is not supplied */ - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** * Get all the dependencies of the file */ - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + getAllDependencies(sourceFile: SourceFile): readonly string[]; /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -4416,7 +4507,7 @@ declare namespace ts { * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -4442,7 +4533,7 @@ declare namespace ts { * Gets the semantic diagnostics from the program for the next affected file and caches it * Returns undefined if the iteration is complete */ - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; } /** * The builder that can handle the changes in program and iterate through changed file to emit the files @@ -4459,19 +4550,19 @@ declare namespace ts { /** * Create the builder to manage semantic diagnostics and cache them */ - function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ - function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ - function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram; + function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram; } declare namespace ts { interface ReadBuildProgramHost { @@ -4482,21 +4573,21 @@ declare namespace ts { function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram | undefined; function createIncrementalCompilerHost(options: CompilerOptions, system?: System): CompilerHost; interface IncrementalProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - configFileParsingDiagnostics?: ReadonlyArray; - projectReferences?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; createProgram?: CreateProgram; } function createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: IncrementalProgramOptions): T; - type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; + type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ - type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + type CreateProgram = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T; /** Host that has watch functionality used in --watch mode */ interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ - onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; + onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number): void; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4532,7 +4623,7 @@ declare namespace ts { /** If provided, used in resolutions as well as handling directory structure */ getDirectories?(path: string): string[]; /** If provided, used to cache and handle directory structure modifications */ - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; /** Symbol links resolution */ realpath?(path: string): string; /** If provided would be used to write log about compilation */ @@ -4557,7 +4648,7 @@ declare namespace ts { /** Compiler options */ options: CompilerOptions; /** Project References */ - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; } /** * Host to create watch with config file @@ -4571,7 +4662,7 @@ declare namespace ts { * Used to generate source file names from the config file and its include, exclude, files rules * and also to cache the directory stucture */ - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; } interface Watch { /** Synchronize with host and get updated program */ @@ -4595,7 +4686,7 @@ declare namespace ts { * Create the watch compiler host for either configFile or fileNames and its options */ function createWatchCompilerHost(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray): WatchCompilerHostOfFilesAndCompilerOptions; + function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions; /** * Creates the watch from the host for root files and compiler options */ @@ -4648,8 +4739,8 @@ declare namespace ts { function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter; function createSolutionBuilderHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost; function createSolutionBuilderWithWatchHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost; - function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilder(host: SolutionBuilderHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; enum InvalidatedProjectKind { Build = 0, UpdateBundle = 1, @@ -4674,14 +4765,14 @@ declare namespace ts { getBuilderProgram(): T | undefined; getProgram(): Program | undefined; getSourceFile(fileName: string): SourceFile | undefined; - getSourceFiles(): ReadonlyArray; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSourceFiles(): readonly SourceFile[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getAllDependencies(sourceFile: SourceFile): readonly string[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } interface UpdateBundleProject extends InvalidatedProjectBase { @@ -4744,7 +4835,7 @@ declare namespace ts.server { readonly kind: EventBeginInstallTypes | EventEndInstallTypes; readonly eventId: number; readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; + readonly packagesToInstall: readonly string[]; } interface BeginInstallTypes extends InstallTypes { readonly kind: EventBeginInstallTypes; @@ -4797,8 +4888,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): ReadonlyArray; - getConstructSignatures(): ReadonlyArray; + getCallSignatures(): readonly Signature[]; + getConstructSignatures(): readonly Signature[]; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4815,6 +4906,9 @@ declare namespace ts { isClassOrInterface(): this is InterfaceType; isClass(): this is InterfaceType; } + interface TypeReference { + typeArguments?: readonly Type[]; + } interface Signature { getDeclaration(): SignatureDeclaration; getTypeParameters(): TypeParameter[] | undefined; @@ -4826,7 +4920,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): ReadonlyArray; + getLineStarts(): readonly number[]; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -4875,7 +4969,7 @@ declare namespace ts { fileName: Path; packageName: string; } - interface LanguageServiceHost extends GetEffectiveTypeRootsHost { + interface LanguageServiceHost extends ModuleSpecifierResolutionHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; getProjectVersion?(): string; @@ -4883,7 +4977,7 @@ declare namespace ts { getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getProjectReferences?(): ReadonlyArray | undefined; + getProjectReferences?(): readonly ProjectReference[] | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4891,8 +4985,7 @@ declare namespace ts { log?(s: string): void; trace?(s: string): void; error?(s: string): void; - useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; @@ -4937,17 +5030,17 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined; getSmartSelectionRange(fileName: string, position: number): SelectionRange; - getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; - getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | undefined; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4967,7 +5060,7 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[]; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -4980,9 +5073,9 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; - getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; + organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput; getProgram(): Program | undefined; dispose(): void; } @@ -5105,7 +5198,7 @@ declare namespace ts { } interface FileTextChanges { fileName: string; - textChanges: TextChange[]; + textChanges: readonly TextChange[]; isNewFile?: boolean; } interface CodeAction { @@ -5130,8 +5223,8 @@ declare namespace ts { fixAllDescription?: string; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray; + changes: readonly FileTextChanges[]; + commands?: readonly CodeActionCommand[]; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -5252,6 +5345,11 @@ declare namespace ts { Block = 1, Smart = 2 } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -5304,6 +5402,7 @@ declare namespace ts { readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; readonly insertSpaceBeforeTypeAnnotation?: boolean; readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: SemicolonPreference; } function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { @@ -5313,7 +5412,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions?: ReadonlyArray; + definitions?: readonly DefinitionInfo[]; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -6346,7 +6445,7 @@ declare namespace ts.server.protocol { scope: OrganizeImportsScope; } interface OrganizeImportsResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } interface GetEditsForFileRenameRequest extends Request { command: CommandTypes.GetEditsForFileRename; @@ -6358,7 +6457,7 @@ declare namespace ts.server.protocol { readonly newFilePath: string; } interface GetEditsForFileRenameResponse extends Response { - body: ReadonlyArray; + body: readonly FileCodeEdits[]; } /** * Request for the available codefixes at a specific position. @@ -6405,7 +6504,7 @@ declare namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes: ReadonlyArray; + errorCodes: readonly number[]; } interface GetCombinedCodeFixRequestArgs { scope: GetCombinedCodeFixScope; @@ -6522,7 +6621,7 @@ declare namespace ts.server.protocol { interface FileSpanWithContext extends FileSpan, TextSpanWithContext { } interface DefinitionInfoAndBoundSpan { - definitions: ReadonlyArray; + definitions: readonly FileSpanWithContext[]; textSpan: TextSpan; } /** @@ -6531,9 +6630,11 @@ declare namespace ts.server.protocol { interface DefinitionResponse extends Response { body?: FileSpanWithContext[]; } - interface DefinitionInfoAndBoundSpanReponse extends Response { + interface DefinitionInfoAndBoundSpanResponse extends Response { body?: DefinitionInfoAndBoundSpan; } + /** @deprecated Use `DefinitionInfoAndBoundSpanResponse` instead. */ + type DefinitionInfoAndBoundSpanReponse = DefinitionInfoAndBoundSpanResponse; /** * Definition response message. Gives text range for definition. */ @@ -6660,7 +6761,7 @@ declare namespace ts.server.protocol { /** * The file locations referencing the symbol. */ - refs: ReadonlyArray; + refs: readonly ReferencesResponseItem[]; /** * The name of the symbol. */ @@ -6764,7 +6865,7 @@ declare namespace ts.server.protocol { /** * An array of span groups (one per file) that refer to the item to be renamed. */ - locs: ReadonlyArray; + locs: readonly SpanGroup[]; } /** * Rename response message. @@ -7243,8 +7344,8 @@ declare namespace ts.server.protocol { commands?: {}[]; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray<{}>; + changes: readonly FileCodeEdits[]; + commands?: readonly {}[]; } interface CodeFixAction extends CodeAction { /** Short name to identify the fix, for use by telemetry. */ @@ -7451,7 +7552,7 @@ declare namespace ts.server.protocol { readonly isGlobalCompletion: boolean; readonly isMemberCompletion: boolean; readonly isNewIdentifierLocation: boolean; - readonly entries: ReadonlyArray; + readonly entries: readonly CompletionEntry[]; } interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; @@ -8130,7 +8231,7 @@ declare namespace ts.server.protocol { /** * list of packages to install */ - packages: ReadonlyArray; + packages: readonly string[]; } interface BeginInstallTypesEventBody extends InstallTypesEventBody { } @@ -8151,6 +8252,11 @@ declare namespace ts.server.protocol { Block = "Block", Smart = "Smart" } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorSettings { baseIndentSize?: number; indentSize?: number; @@ -8176,6 +8282,7 @@ declare namespace ts.server.protocol { placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; insertSpaceBeforeTypeAnnotation?: boolean; + semicolons?: SemicolonPreference; } interface UserPreferences { readonly disableSuggestions?: boolean; @@ -8190,6 +8297,12 @@ declare namespace ts.server.protocol { * For those entries, The `insertText` and `replacementSpan` properties will be set to change from `.x` property access to `["x"]`. */ readonly includeCompletionsWithInsertText?: boolean; + /** + * Unless this option is `false`, or `includeCompletionsWithInsertText` is not enabled, + * member completion lists triggered with `.` will include entries on potentially-null and potentially-undefined + * values, with insertion text to replace preceding `.` tokens with `?.`. + */ + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; readonly allowTextChangesInNewFiles?: boolean; readonly lazyConfiguredProjectsFromExternalProject?: boolean; @@ -8259,6 +8372,7 @@ declare namespace ts.server.protocol { strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; + useDefineForClassFields?: boolean; target?: ScriptTarget | ts.ScriptTarget; traceResolution?: boolean; resolveJsonModule?: boolean; @@ -8454,12 +8568,12 @@ declare namespace ts.server { static resolveModule(moduleName: string, initialDir: string, host: ServerHost, log: (message: string) => void, logErrors?: (message: string) => void): {} | undefined; isKnownTypesPackageName(name: string): boolean; installPackage(options: InstallPackageOptions): Promise; - private readonly typingsCache; + private get typingsCache(); getCompilationSettings(): CompilerOptions; getCompilerOptions(): CompilerOptions; getNewLine(): string; getProjectVersion(): string; - getProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; getScriptFileNames(): string[]; private getOrCreateScriptInfoAndAttachToProject; getScriptKind(fileName: string): ScriptKind; @@ -8469,7 +8583,7 @@ declare namespace ts.server { getCurrentDirectory(): string; getDefaultLibFileName(): string; useCaseSensitiveFileNames(): boolean; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile(fileName: string): string | undefined; writeFile(fileName: string, content: string): void; fileExists(file: string): boolean; @@ -8484,10 +8598,9 @@ declare namespace ts.server { /** * Get the errors that dont have any file name associated */ - getGlobalProjectErrors(): ReadonlyArray; - getAllProjectErrors(): ReadonlyArray; + getGlobalProjectErrors(): readonly Diagnostic[]; + getAllProjectErrors(): readonly Diagnostic[]; getLanguageService(ensureSynchronized?: boolean): LanguageService; - private shouldEmitFile; getCompileOnSaveAffectedFileList(scriptInfo: ScriptInfo): string[]; /** * Returns true if emit was conducted @@ -8507,7 +8620,7 @@ declare namespace ts.server { getRootFiles(): NormalizedPath[]; getRootScriptInfos(): ScriptInfo[]; getScriptInfos(): ScriptInfo[]; - getExcludedFiles(): ReadonlyArray; + getExcludedFiles(): readonly NormalizedPath[]; getFileNames(excludeFilesFromExternalLibraries?: boolean, excludeConfigFiles?: boolean): NormalizedPath[]; hasConfigFile(configFilePath: NormalizedPath): boolean; containsScriptInfo(info: ScriptInfo): boolean; @@ -8541,6 +8654,7 @@ declare namespace ts.server { 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 watchPackageJsonFile; } /** * If a file is opened and no tsconfig (or jsconfig) is found, @@ -8568,27 +8682,49 @@ declare namespace ts.server { private typeAcquisition; private directoriesWatchedForWildcards; readonly canonicalConfigFilePath: NormalizedPath; + private projectReferenceCallbacks; + private mapOfDeclarationDirectories; + private symlinkedDirectories; + private symlinkedFiles; /** Ref count to the project when opened from external project */ private externalProjectRefCount; private projectErrors; private projectReferences; protected isInitialLoadPending: () => boolean; + private fileExistsIfProjectReferenceDts; + /** + * This implementation of fileExists checks if the file being requested is + * .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that file exists on host + */ + fileExists(file: string): boolean; + private directoryExistsIfProjectReferenceDeclDir; + /** + * This implementation of directoryExists checks if the directory being requested is + * directory of .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that directory exists on host + */ + directoryExists(path: string): boolean; + private realpathIfSymlinkedProjectReferenceDts; + private getRealpath; + private handleDirectoryCouldBeSymlink; + private fileOrDirectoryExistsUsingSource; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph * @returns: true if set of files in the project stays the same and false - otherwise. */ updateGraph(): boolean; getConfigFilePath(): NormalizedPath; - getProjectReferences(): ReadonlyArray | undefined; - updateReferences(refs: ReadonlyArray | undefined): void; + getProjectReferences(): readonly ProjectReference[] | undefined; + updateReferences(refs: readonly ProjectReference[] | undefined): void; /** * Get the errors that dont have any file name associated */ - getGlobalProjectErrors(): ReadonlyArray; + getGlobalProjectErrors(): readonly Diagnostic[]; /** * Get all the project errors */ - getAllProjectErrors(): ReadonlyArray; + getAllProjectErrors(): readonly Diagnostic[]; setProjectErrors(projectErrors: Diagnostic[]): void; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; getTypeAcquisition(): TypeAcquisition; @@ -8602,7 +8738,7 @@ declare namespace ts.server { class ExternalProject extends Project { externalProjectName: string; compileOnSaveEnabled: boolean; - excludedFiles: ReadonlyArray; + excludedFiles: readonly NormalizedPath[]; private typeAcquisition; updateGraph(): boolean; getExcludedFiles(): readonly NormalizedPath[]; @@ -8652,7 +8788,7 @@ declare namespace ts.server { data: { triggerFile: string; configFileName: string; - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; }; } export interface ProjectLanguageServiceStateEvent { @@ -8750,7 +8886,7 @@ declare namespace ts.server { } export interface OpenConfiguredProjectResult { configFileName?: NormalizedPath; - configFileErrors?: ReadonlyArray; + configFileErrors?: readonly Diagnostic[]; } export interface ProjectServiceOptions { host: ServerHost; @@ -8762,8 +8898,8 @@ declare namespace ts.server { eventHandler?: ProjectServiceEventHandler; suppressDiagnosticEvents?: boolean; throttleWaitMilliseconds?: number; - globalPlugins?: ReadonlyArray; - pluginProbeLocations?: ReadonlyArray; + globalPlugins?: readonly string[]; + pluginProbeLocations?: readonly string[]; allowLocalPluginLoads?: boolean; typesMapLocation?: string; syntaxOnly?: boolean; @@ -8832,8 +8968,8 @@ declare namespace ts.server { readonly throttleWaitMilliseconds?: number; private readonly eventHandler?; private readonly suppressDiagnosticEvents?; - readonly globalPlugins: ReadonlyArray; - readonly pluginProbeLocations: ReadonlyArray; + readonly globalPlugins: readonly string[]; + readonly pluginProbeLocations: readonly string[]; readonly allowLocalPluginLoads: boolean; private currentPluginConfigOverrides; readonly typesMapLocation: string | undefined; @@ -9059,8 +9195,8 @@ declare namespace ts.server { syntaxOnly?: boolean; throttleWaitMilliseconds?: number; noGetErrOnBackgroundUpdate?: boolean; - globalPlugins?: ReadonlyArray; - pluginProbeLocations?: ReadonlyArray; + globalPlugins?: readonly string[]; + pluginProbeLocations?: readonly string[]; allowLocalPluginLoads?: boolean; typesMapLocation?: string; } diff --git a/node_modules/typescript/lib/tsserverlibrary.js b/node_modules/typescript/lib/tsserverlibrary.js index 8df15d721..ecaed3c11 100644 --- a/node_modules/typescript/lib/tsserverlibrary.js +++ b/node_modules/typescript/lib/tsserverlibrary.js @@ -87,67 +87,20 @@ var __rest = (this && this.__rest) || function (s, e) { } return t; }; -var ts; -(function (ts) { - // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. - // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; - /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; -})(ts || (ts = {})); -(function (ts) { - /* @internal */ - var Comparison; - (function (Comparison) { - Comparison[Comparison["LessThan"] = -1] = "LessThan"; - Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; - Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; - })(Comparison = ts.Comparison || (ts.Comparison = {})); -})(ts || (ts = {})); /* @internal */ +var ts; (function (ts) { - ts.emptyArray = []; - /** Create a MapLike with good performance. */ - function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map.__ = undefined; - delete map.__; - return map; - } - /** Create a new map. If a template object is provided, the map will copy entries from it. */ - function createMap() { - return new ts.MapCtr(); - } - ts.createMap = createMap; - function createMapFromEntries(entries) { - var map = createMap(); - for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { - var _a = entries_1[_i], key = _a[0], value = _a[1]; - map.set(key, value); - } - return map; - } - ts.createMapFromEntries = createMapFromEntries; - function createMapFromTemplate(template) { - var map = new ts.MapCtr(); - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (var key in template) { - if (hasOwnProperty.call(template, key)) { - map.set(key, template[key]); - } + function createMapShim() { + /** Create a MapLike with good performance. */ + function createDictionaryObject() { + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-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; } - return map; - } - ts.createMapFromTemplate = createMapFromTemplate; - // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name - ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); - // Keep the class inside a function so it doesn't get compiled if it's not used. - function shimMap() { var MapIterator = /** @class */ (function () { function MapIterator(currentEntry, selector) { this.currentEntry = currentEntry; @@ -208,7 +161,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -283,7 +236,75 @@ var ts; return class_1; }()); } - ts.shimMap = shimMap; + ts.createMapShim = createMapShim; +})(ts || (ts = {})); +var ts; +(function (ts) { + // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. + // If changing the text in this section, be sure to test `configureNightly` too. + ts.versionMajorMinor = "3.7"; + /** The version of the TypeScript compiler release */ + ts.version = ts.versionMajorMinor + ".2"; +})(ts || (ts = {})); +(function (ts) { + /* @internal */ + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + /** + * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). + */ + function tryGetNativeMap() { + // Internet Explorer's Map doesn't support iteration, so don't use it. + // eslint-disable-next-line no-in-operator + return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined; + } + ts.tryGetNativeMap = tryGetNativeMap; +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + ts.emptyArray = []; + ts.Map = ts.tryGetNativeMap() || (function () { + // NOTE: createMapShim will be defined for typescriptServices.js but not for tsc.js, so we must test for it. + if (typeof ts.createMapShim === "function") { + return ts.createMapShim(); + } + throw new Error("TypeScript requires an environment that provides a compatible native Map implementation."); + })(); + /** Create a new map. */ + function createMap() { + return new ts.Map(); + } + ts.createMap = createMap; + /** Create a new map from an array of entries. */ + function createMapFromEntries(entries) { + var map = createMap(); + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var _a = entries_1[_i], key = _a[0], value = _a[1]; + map.set(key, value); + } + return map; + } + ts.createMapFromEntries = createMapFromEntries; + /** Create a new map from a template object is provided, the map will copy entries from it. */ + function createMapFromTemplate(template) { + var map = new ts.Map(); + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (var key in template) { + if (hasOwnProperty.call(template, key)) { + map.set(key, template[key]); + } + } + return map; + } + ts.createMapFromTemplate = createMapFromTemplate; function length(array) { return array ? array.length : 0; } @@ -305,6 +326,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -858,6 +894,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1398,6 +1435,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1457,7 +1500,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1491,7 +1534,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1843,20 +1886,6 @@ var ts; return str.indexOf(substring) !== -1; } ts.stringContains = stringContains; - function fileExtensionIs(path, extension) { - return path.length > extension.length && endsWith(path, extension); - } - ts.fileExtensionIs = fileExtensionIs; - function fileExtensionIsOneOf(path, extensions) { - for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { - var extension = extensions_1[_i]; - if (fileExtensionIs(path, extension)) { - return true; - } - } - return false; - } - ts.fileExtensionIsOneOf = fileExtensionIsOneOf; /** * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ @@ -1965,11 +1994,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2046,8 +2097,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2096,6 +2149,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2111,7 +2165,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2219,6 +2273,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2229,6 +2286,33 @@ var ts; ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); } : ts.noop; var isDebugInfoEnabled = false; + var extendedDebugModule; + function extendedDebug() { + enableDebugInfo(); + if (!extendedDebugModule) { + throw new Error("Debugging helpers could not be loaded."); + } + return extendedDebugModule; + } + function printControlFlowGraph(flowNode) { + return console.log(formatControlFlowGraph(flowNode)); + } + Debug.printControlFlowGraph = printControlFlowGraph; + function formatControlFlowGraph(flowNode) { + return extendedDebug().formatControlFlowGraph(flowNode); + } + Debug.formatControlFlowGraph = formatControlFlowGraph; + function attachFlowNodeDebugInfo(flowNode) { + if (isDebugInfoEnabled) { + if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line no-in-operator + Object.defineProperties(flowNode, { + __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, + __debugToString: { value: function () { return formatControlFlowGraph(this); } } + }); + } + } + } + Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo; /** * Injects debug information into frequently used types. */ @@ -2272,6 +2356,20 @@ var ts; }); } } + // attempt to load extended debugging information + try { + if (ts.sys && ts.sys.require) { + var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath())); + var result = ts.sys.require(basePath, "./compiler-debug"); + if (!result.error) { + result.module.init(ts); + extendedDebugModule = result.module; + } + } + } + catch (_a) { + // do nothing + } isDebugInfoEnabled = true; } Debug.enableDebugInfo = enableDebugInfo; @@ -2428,15 +2526,13 @@ var ts; try { // require() will throw an exception if the module is not installed // It may also return undefined if not installed properly - etwModule = require("@microsoft/typescript-etw"); // tslint:disable-line:no-implicit-dependencies + etwModule = require("@microsoft/typescript-etw"); } catch (e) { etwModule = undefined; } /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; - var args = typeof process === "undefined" ? [] : process.argv; - ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); })(ts || (ts = {})); /* @internal */ var ts; @@ -2838,360 +2934,366 @@ var ts; SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 297] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 298] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 299] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 300] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 301] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 302] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 303] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 304] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 305] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 306] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 307] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 308] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 309] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 310] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 311] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 312] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 313] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 314] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 315] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 316] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 317] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 318] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 319] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 320] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 313] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 301] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 313] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3201,20 +3303,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3224,23 +3327,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3279,7 +3382,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3321,6 +3427,7 @@ var ts; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; })(TokenFlags = ts.TokenFlags || (ts.TokenFlags = {})); + // NOTE: Ensure this is up-to-date with src/debug/debug.ts var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; @@ -3332,12 +3439,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3347,6 +3455,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3367,6 +3482,10 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped"; + /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3375,6 +3494,14 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + /* @internal */ + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + ContextFlags[ContextFlags["Completion"] = 4] = "Completion"; + })(ContextFlags = ts.ContextFlags || (ts.ContextFlags = {})); // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { @@ -3432,7 +3559,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3482,27 +3608,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3573,11 +3712,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3800,6 +3943,18 @@ var ts; SignatureKind[SignatureKind["Call"] = 0] = "Call"; SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + /* @internal */ + var SignatureFlags; + (function (SignatureFlags) { + SignatureFlags[SignatureFlags["None"] = 0] = "None"; + SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter"; + SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes"; + SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall"; + // We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us + // attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when + // instantiating the return type. + SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags"; + })(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {})); var IndexKind; (function (IndexKind) { IndexKind[IndexKind["String"] = 0] = "String"; @@ -4695,7 +4850,7 @@ var ts; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; /*@internal*/ - ts.sysLog = ts.noop; + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4800,6 +4955,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4816,12 +4997,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4833,6 +5016,8 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; @@ -4914,8 +5099,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4939,8 +5126,101 @@ var ts; bufferFrom: bufferFrom, base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); }, base64encode: function (input) { return bufferFrom(input).toString("base64"); }, + require: function (baseDir, moduleName) { + try { + var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem); + return { module: require(modulePath), modulePath: modulePath, error: undefined }; + } + catch (error) { + return { module: undefined, modulePath: undefined, error: error }; + } + } }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4993,6 +5273,7 @@ var ts; if (fsSupportsRecursive) { return watchDirectoryUsingFsWatch; } + // defer watchDirectoryRecursively as it depends on `ts.createMap()` which may not be usable yet. var watchDirectory = tscWatchDirectory === "RecursiveDirectoryUsingFsWatchFile" ? createWatchDirectoryUsing(fsWatchFile) : tscWatchDirectory === "RecursiveDirectoryUsingDynamicPriorityPolling" ? @@ -5412,16 +5693,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5433,14 +5704,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5454,311 +5718,985 @@ var ts; ts.Debug.isDebugging = true; } })(ts || (ts = {})); -// -// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + /** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + */ + ts.directorySeparator = "/"; + var altDirectorySeparator = "\\"; + var urlSchemeSeparator = "://"; + var backslashRegExp = /\\/g; + //// Path Tests + /** + * Determines whether a charCode corresponds to `/` or `\`. + */ + function isAnyDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; } - // tslint:disable-next-line variable-name - ts.Diagnostics = { - Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), - Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), - _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), - A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), - Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), - An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), - Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), - A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), - A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), - Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), - A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), - An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), - An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), - An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), - An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), - An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), - An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), - An_index_signature_parameter_type_must_be_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_or_number_1023", "An index signature parameter type must be 'string' or 'number'."), - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), - Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), - _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), - _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), - _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), - super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), - Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), - Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), - Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), - _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), - _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), - _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), - _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), - _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), - A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), - Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), - A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), - A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), - A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), - A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), - A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), - A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), - A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), - An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), - The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), - A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), - The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), - Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), - Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), - An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), - Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), - _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), - _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), - A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), - Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), - _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), - Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), - Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), - An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), - A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), - An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), - _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), - Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), - Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), - Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), - with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), - delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), - Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), - A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), - Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), - Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), - Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), - An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), - Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), - Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), - Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), - Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), - Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), - Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), - Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), - case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), - Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), - Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), - Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), - Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), - Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), - Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), - Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), - Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), - Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), - String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), - Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), - or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), - Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), - Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), - File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), - const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), - const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), - let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), - Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), - Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), - An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), - A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), - Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), - A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), - extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), - extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), - Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), - implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), - Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), - Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), - Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), - Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), - Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), - Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), - A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), - An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), - Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), - Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), - A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), - A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), - An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), - Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), - An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), - Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), - Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), - Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), - Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), - Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), - Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), - Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), - All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), - A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), - Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), - Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), - Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), - An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), - _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), - Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), - Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), - Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), - Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), - A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), - An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), - An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), - _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), - Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), - An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), - A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), - A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), - A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), - A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), - A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), - Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), - Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), - Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), - with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), - await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), - The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), - Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), - Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), - Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), - A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), - An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), - A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), - Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), - Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), - Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323", "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'."), - Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), - Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), - String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), - Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), - _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), - A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), - A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), - A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), - unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), - unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), - unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), - An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), - An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), - infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), - Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), - Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), - A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), - An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), - This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), - use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), - Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), - use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), - Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), - An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), - A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), - A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), - readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), - A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), - Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), - Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), - Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), - Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), - Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), - Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), - File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), - Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), - Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), - A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), - An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), - Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), - Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), - Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), - Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), - Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), - Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), - Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), - Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), - Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), - Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), - Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), - Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), - Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), - Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), - Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), - Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), - Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), - Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), - this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), - this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), - this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), - this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), + ts.isAnyDirectorySeparator = isAnyDirectorySeparator; + /** + * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.). + */ + function isUrl(path) { + return getEncodedRootLength(path) < 0; + } + ts.isUrl = isUrl; + /** + * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path + * like `c:`, `c:\` or `c:/`). + */ + function isRootedDiskPath(path) { + return getEncodedRootLength(path) > 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + /** + * Determines whether a path consists only of a path root. + */ + function isDiskPathRoot(path) { + var rootLength = getEncodedRootLength(path); + return rootLength > 0 && rootLength === path.length; + } + ts.isDiskPathRoot = isDiskPathRoot; + /** + * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.). + * + * ```ts + * // POSIX + * pathIsAbsolute("/path/to/file.ext") === true + * // DOS + * pathIsAbsolute("c:/path/to/file.ext") === true + * // URL + * pathIsAbsolute("file:///path/to/file.ext") === true + * // Non-absolute + * pathIsAbsolute("path/to/file.ext") === false + * pathIsAbsolute("./path/to/file.ext") === false + * ``` + */ + function pathIsAbsolute(path) { + return getEncodedRootLength(path) !== 0; + } + ts.pathIsAbsolute = pathIsAbsolute; + /** + * Determines whether a path starts with a relative path component (i.e. `.` or `..`). + */ + function pathIsRelative(path) { + return /^\.\.?($|[\\/])/.test(path); + } + ts.pathIsRelative = pathIsRelative; + function hasExtension(fileName) { + return ts.stringContains(getBaseFileName(fileName), "."); + } + ts.hasExtension = hasExtension; + function fileExtensionIs(path, extension) { + return path.length > extension.length && ts.endsWith(path, extension); + } + ts.fileExtensionIs = fileExtensionIs; + function fileExtensionIsOneOf(path, extensions) { + for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { + var extension = extensions_1[_i]; + if (fileExtensionIs(path, extension)) { + return true; + } + } + return false; + } + ts.fileExtensionIsOneOf = fileExtensionIsOneOf; + /** + * Determines whether a path has a trailing separator (`/` or `\\`). + */ + function hasTrailingDirectorySeparator(path) { + return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); + } + ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; + //// Path Parsing + function isVolumeCharacter(charCode) { + return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || + (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + } + function getFileUrlVolumeSeparatorEnd(url, start) { + var ch0 = url.charCodeAt(start); + if (ch0 === 58 /* colon */) + return start + 1; + if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + var ch2 = url.charCodeAt(start + 2); + if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + return start + 3; + } + return -1; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * If the root is part of a URL, the twos-complement of the root length is returned. + */ + function getEncodedRootLength(path) { + if (!path) + return 0; + var ch0 = path.charCodeAt(0); + // POSIX or UNC + if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (path.charCodeAt(1) !== ch0) + return 1; // POSIX: "/" (or non-normalized "\") + var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); + if (p1 < 0) + return path.length; // UNC: "//server" or "\\server" + return p1 + 1; // UNC: "//server/" or "\\server\" + } + // DOS + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + var ch2 = path.charCodeAt(2); + if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + return 3; // DOS: "c:/" or "c:\" + if (path.length === 2) + return 2; // DOS: "c:" (but not "c:d") + } + // URL + var schemeEnd = path.indexOf(urlSchemeSeparator); + if (schemeEnd !== -1) { + var authorityStart = schemeEnd + urlSchemeSeparator.length; + var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); + if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" + // For local "file" URLs, include the leading DOS volume (if present). + // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a + // special case interpreted as "the machine from which the URL is being interpreted". + var scheme = path.slice(0, schemeEnd); + var authority = path.slice(authorityStart, authorityEnd); + if (scheme === "file" && (authority === "" || authority === "localhost") && + isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { + var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); + if (volumeSeparatorEnd !== -1) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" + return ~(volumeSeparatorEnd + 1); + } + if (volumeSeparatorEnd === path.length) { + // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" + // but not "file:///c:d" or "file:///c%3ad" + return ~volumeSeparatorEnd; + } + } + } + return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" + } + return ~path.length; // URL: "file://server", "http://server" + } + // relative + return 0; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * + * For example: + * ```ts + * getRootLength("a") === 0 // "" + * getRootLength("/") === 1 // "/" + * getRootLength("c:") === 2 // "c:" + * getRootLength("c:d") === 0 // "" + * getRootLength("c:/") === 3 // "c:/" + * getRootLength("c:\\") === 3 // "c:\\" + * getRootLength("//server") === 7 // "//server" + * getRootLength("//server/share") === 8 // "//server/" + * getRootLength("\\\\server") === 7 // "\\\\server" + * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" + * getRootLength("file:///path") === 8 // "file:///" + * getRootLength("file:///c:") === 10 // "file:///c:" + * getRootLength("file:///c:d") === 8 // "file:///" + * getRootLength("file:///c:/path") === 11 // "file:///c:/" + * getRootLength("file://server") === 13 // "file://server" + * getRootLength("file://server/path") === 14 // "file://server/" + * getRootLength("http://server") === 13 // "http://server" + * getRootLength("http://server/path") === 14 // "http://server/" + * ``` + */ + function getRootLength(path) { + var rootLength = getEncodedRootLength(path); + return rootLength < 0 ? ~rootLength : rootLength; + } + ts.getRootLength = getRootLength; + function getDirectoryPath(path) { + path = normalizeSlashes(path); + // If the path provided is itself the root, then return it. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return path; + // return the leading portion of the path up to the last (non-terminal) directory separator + // but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function getBaseFileName(path, extensions, ignoreCase) { + path = normalizeSlashes(path); + // if the path provided is itself the root, then it has not file name. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return ""; + // return the trailing portion of the path starting after the last (non-terminal) directory + // separator but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); + var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; + return extension ? name.slice(0, name.length - extension.length) : name; + } + ts.getBaseFileName = getBaseFileName; + function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { + if (!ts.startsWith(extension, ".")) + extension = "." + extension; + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + var pathExtension = path.slice(path.length - extension.length); + if (stringEqualityComparer(pathExtension, extension)) { + return pathExtension; + } + } + } + function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { + if (typeof extensions === "string") { + return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || ""; + } + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer); + if (result) + return result; + } + return ""; + } + function getAnyExtensionFromPath(path, extensions, ignoreCase) { + // Retrieves any string from the final "." onwards from a base file name. + // Unlike extensionFromPath, which throws an exception on unrecognized extensions. + if (extensions) { + return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); + } + var baseFileName = getBaseFileName(path); + var extensionIndex = baseFileName.lastIndexOf("."); + if (extensionIndex >= 0) { + return baseFileName.substring(extensionIndex); + } + return ""; + } + ts.getAnyExtensionFromPath = getAnyExtensionFromPath; + function pathComponents(path, rootLength) { + var root = path.substring(0, rootLength); + var rest = path.substring(rootLength).split(ts.directorySeparator); + if (rest.length && !ts.lastOrUndefined(rest)) + rest.pop(); + return __spreadArrays([root], rest); + } + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is not normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * // POSIX + * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"] + * getPathComponents("/path/to/") === ["/", "path", "to"] + * getPathComponents("/") === ["/"] + * // DOS + * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"] + * getPathComponents("c:/path/to/") === ["c:/", "path", "to"] + * getPathComponents("c:/") === ["c:/"] + * getPathComponents("c:") === ["c:"] + * // URL + * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"] + * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"] + * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"] + * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"] + * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"] + * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"] + * getPathComponents("file://server/") === ["file://server/"] + * getPathComponents("file://server") === ["file://server"] + * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"] + * getPathComponents("file:///path/to/") === ["file:///", "path", "to"] + * getPathComponents("file:///") === ["file:///"] + * getPathComponents("file://") === ["file://"] + */ + function getPathComponents(path, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } + path = combinePaths(currentDirectory, path); + return pathComponents(path, getRootLength(path)); + } + ts.getPathComponents = getPathComponents; + //// Path Formatting + /** + * Formats a parsed path consisting of a root component (at index 0) and zero or more path + * segments (at indices > 0). + * + * ```ts + * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext" + * ``` + */ + function getPathFromPathComponents(pathComponents) { + if (pathComponents.length === 0) + return ""; + var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]); + return root + pathComponents.slice(1).join(ts.directorySeparator); + } + ts.getPathFromPathComponents = getPathFromPathComponents; + //// Path Normalization + /** + * Normalize path separators, converting `\` into `/`. + */ + function normalizeSlashes(path) { + return path.replace(backslashRegExp, ts.directorySeparator); + } + ts.normalizeSlashes = normalizeSlashes; + /** + * Reduce an array of path components to a more simplified path by navigating any + * `"."` or `".."` entries in the path. + */ + function reducePathComponents(components) { + if (!ts.some(components)) + return []; + var reduced = [components[0]]; + for (var i = 1; i < components.length; i++) { + var component = components[i]; + if (!component) + continue; + if (component === ".") + continue; + if (component === "..") { + if (reduced.length > 1) { + if (reduced[reduced.length - 1] !== "..") { + reduced.pop(); + continue; + } + } + else if (reduced[0]) + continue; + } + reduced.push(component); + } + return reduced; + } + ts.reducePathComponents = reducePathComponents; + /** + * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. + * + * ```ts + * // Non-rooted + * combinePaths("path", "to", "file.ext") === "path/to/file.ext" + * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext" + * // POSIX + * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext" + * combinePaths("/path", "/to", "file.ext") === "/to/file.ext" + * // DOS + * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext" + * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext" + * // URL + * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext" + * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext" + * ``` + */ + function combinePaths(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + if (path) + path = normalizeSlashes(path); + for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { + var relativePath = paths_1[_a]; + if (!relativePath) + continue; + relativePath = normalizeSlashes(relativePath); + if (!path || getRootLength(relativePath) !== 0) { + path = relativePath; + } + else { + path = ensureTrailingDirectorySeparator(path) + relativePath; + } + } + return path; + } + ts.combinePaths = combinePaths; + /** + * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any + * `.` and `..` path components are resolved. Trailing directory separators are preserved. + * + * ```ts + * resolvePath("/path", "to", "file.ext") === "path/to/file.ext" + * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/" + * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext" + * ``` + */ + function resolvePath(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path)); + } + ts.resolvePath = resolvePath; + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"] + */ + function getNormalizedPathComponents(path, currentDirectory) { + return reducePathComponents(getPathComponents(path, currentDirectory)); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function normalizePath(path) { + path = normalizeSlashes(path); + var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); + return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; + } + ts.normalizePath = normalizePath; + function getPathWithoutRoot(pathComponents) { + if (pathComponents.length === 0) + return ""; + return pathComponents.slice(1).join(ts.directorySeparator); + } + function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { + return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; + function normalizePathAndParts(path) { + path = normalizeSlashes(path); + var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; + } + else { + return { path: root, parts: parts }; + } + } + ts.normalizePathAndParts = normalizePathAndParts; + function removeTrailingDirectorySeparator(path) { + if (hasTrailingDirectorySeparator(path)) { + return path.substr(0, path.length - 1); + } + return path; + } + ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; + function ensureTrailingDirectorySeparator(path) { + if (!hasTrailingDirectorySeparator(path)) { + return path + ts.directorySeparator; + } + return path; + } + ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; + /** + * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed + * with `./` or `../`) so as not to be confused with an unprefixed module name. + * + * ```ts + * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext" + * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext" + * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext" + * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext" + * ``` + */ + function ensurePathIsNonModuleName(path) { + return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path; + } + ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; + function changeAnyExtension(path, ext, extensions, ignoreCase) { + var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); + return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; + } + ts.changeAnyExtension = changeAnyExtension; + //// Path Comparisons + // check path for these segments: '', '.'. '..' + var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + function comparePathsWorker(a, b, componentComparer) { + if (a === b) + return 0 /* EqualTo */; + if (a === undefined) + return -1 /* LessThan */; + if (b === undefined) + return 1 /* GreaterThan */; + // NOTE: Performance optimization - shortcut if the root segments differ as there would be no + // need to perform path reduction. + var aRoot = a.substring(0, getRootLength(a)); + var bRoot = b.substring(0, getRootLength(b)); + var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); + if (result !== 0 /* EqualTo */) { + return result; + } + // NOTE: Performance optimization - shortcut if there are no relative path segments in + // the non-root portion of the path + var aRest = a.substring(aRoot.length); + var bRest = b.substring(bRoot.length); + if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { + return componentComparer(aRest, bRest); + } + // The path contains a relative path segment. Normalize the paths and perform a slower component + // by component comparison. + var aComponents = reducePathComponents(getPathComponents(a)); + var bComponents = reducePathComponents(getPathComponents(b)); + var sharedLength = Math.min(aComponents.length, bComponents.length); + for (var i = 1; i < sharedLength; i++) { + var result_1 = componentComparer(aComponents[i], bComponents[i]); + if (result_1 !== 0 /* EqualTo */) { + return result_1; + } + } + return ts.compareValues(aComponents.length, bComponents.length); + } + /** + * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively. + */ + function comparePathsCaseSensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + } + ts.comparePathsCaseSensitive = comparePathsCaseSensitive; + /** + * Performs a case-insensitive comparison of two paths. + */ + function comparePathsCaseInsensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + } + ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; + function comparePaths(a, b, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + a = combinePaths(currentDirectory, a); + b = combinePaths(currentDirectory, b); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + } + ts.comparePaths = comparePaths; + function containsPath(parent, child, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + parent = combinePaths(currentDirectory, parent); + child = combinePaths(currentDirectory, child); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + if (parent === undefined || child === undefined) + return false; + if (parent === child) + return true; + var parentComponents = reducePathComponents(getPathComponents(parent)); + var childComponents = reducePathComponents(getPathComponents(child)); + if (childComponents.length < parentComponents.length) { + return false; + } + var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; + for (var i = 0; i < parentComponents.length; i++) { + var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; + if (!equalityComparer(parentComponents[i], childComponents[i])) { + return false; + } + } + return true; + } + ts.containsPath = containsPath; + /** + * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. + * Comparison is case-sensitive between the canonical paths. + * + * @deprecated Use `containsPath` if possible. + */ + function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { + var canonicalFileName = getCanonicalFileName(fileName); + var canonicalDirectoryName = getCanonicalFileName(directoryName); + return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); + } + ts.startsWithDirectory = startsWithDirectory; + //// Relative Paths + function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { + var fromComponents = reducePathComponents(getPathComponents(from)); + var toComponents = reducePathComponents(getPathComponents(to)); + var start; + for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { + var fromComponent = getCanonicalFileName(fromComponents[start]); + var toComponent = getCanonicalFileName(toComponents[start]); + var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; + if (!comparer(fromComponent, toComponent)) + break; + } + if (start === 0) { + return toComponents; + } + var components = toComponents.slice(start); + var relative = []; + for (; start < fromComponents.length; start++) { + relative.push(".."); + } + return __spreadArrays([""], relative, components); + } + ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; + function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { + ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); + var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; + var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; + var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathFromDirectory = getRelativePathFromDirectory; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + } + ts.convertToRelativePath = convertToRelativePath; + function getRelativePathFromFile(from, to, getCanonicalFileName) { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); + } + ts.getRelativePathFromFile = getRelativePathFromFile; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); + var firstComponent = pathComponents[0]; + if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) { + var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; + pathComponents[0] = prefix + firstComponent; + } + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } + ts.forEachAncestorDirectory = forEachAncestorDirectory; +})(ts || (ts = {})); +// +// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' +/* @internal */ +var ts; +(function (ts) { + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; + } + ts.Diagnostics = { + Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), + Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), + _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), + A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), + Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), + Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), + An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), + Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), + A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), + A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), + Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), + A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), + An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), + An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), + An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), + An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), + An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), + An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), + An_index_signature_parameter_type_must_be_either_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_either_string_or_number_1023", "An index signature parameter type must be either 'string' or 'number'."), + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), + Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), + _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), + _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), + _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), + super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), + Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), + Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), + Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), + _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), + _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), + _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), + _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), + _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), + A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), + Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), + A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), + A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), + A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), + A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), + A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), + A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), + A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), + An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), + A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), + Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), + An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), + _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), + _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), + A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), + Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), + _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), + _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), + Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), + Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), + An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), + A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), + An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), + _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), + Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), + Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), + Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), + with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), + delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), + A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), + Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), + Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), + Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), + An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), + Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), + Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), + Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), + Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), + Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), + Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), + Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), + Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), + case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), + Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), + Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), + Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), + Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), + Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), + Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), + Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), + Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), + Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), + String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), + Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), + or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), + Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), + Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), + Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), + File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), + const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), + const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), + let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), + Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), + Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), + An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), + A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), + Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), + A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), + extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), + extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), + Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), + implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), + Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), + Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), + Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), + Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), + Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), + Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), + A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), + An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), + Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), + Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), + A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), + A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), + An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), + Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), + An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), + Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), + Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), + Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), + Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), + Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), + Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), + Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), + All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), + A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), + Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), + Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), + Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), + An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), + _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), + Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), + Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), + Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), + Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), + A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), + An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), + An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), + _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), + Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), + An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), + A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), + A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), + A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), + _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), + A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), + A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), + Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), + with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), + await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), + The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), + Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), + Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), + Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), + A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), + An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd_1323", "Dynamic imports are only supported when the '--module' flag is set to 'esnext', 'commonjs', 'amd', 'system', or 'umd'."), + Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), + Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), + Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), + String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), + Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), + _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), + A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), + A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), + A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), + unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), + unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), + unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), + An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), + An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), + infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), + Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), + Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), + A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), + An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), + This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), + use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), + Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), + use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), + An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), + A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), + A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), + readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), + A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), + Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), + Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), + Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), + Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), + Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), + File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), + Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), + Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), + Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), + A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), + An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), + Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), + Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), + Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), + Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), + Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), + Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), + Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), + Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), + Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), + Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), + Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), + Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), + Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), + Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), + Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), + Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), + Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), + Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), + this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), + this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), + this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), + this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), @@ -5767,7 +6705,7 @@ var ts; Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), @@ -5845,7 +6783,6 @@ var ts; Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2424, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property."), Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."), Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."), Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."), @@ -6015,6 +6952,11 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(2613, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(2614, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -6137,6 +7079,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -6223,6 +7173,11 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), + Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), + Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6233,6 +7188,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6258,6 +7214,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6445,6 +7402,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6463,9 +7421,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), - Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6504,9 +7464,12 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), + Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -6590,6 +7553,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6619,6 +7584,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6736,6 +7702,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6746,94 +7720,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7097,6 +8072,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7449,7 +8425,7 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, @@ -7459,8 +8435,8 @@ var ts; hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7470,6 +8446,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7484,6 +8461,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7932,7 +8918,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7996,7 +8982,7 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; @@ -8067,12 +9053,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -8081,19 +9067,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -8102,13 +9088,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -8116,28 +9102,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8198,10 +9184,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8259,7 +9245,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8275,20 +9261,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8301,15 +9287,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8321,10 +9307,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8333,10 +9327,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8351,22 +9345,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { @@ -8412,29 +9406,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8496,12 +9490,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8511,10 +9510,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8590,7 +9589,7 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } @@ -8606,13 +9605,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8622,17 +9621,17 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; + return token = 61 /* BacktickToken */; case 92 /* backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -8654,7 +9653,7 @@ var ts; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion)) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); if (char === 92 /* backslash */) { @@ -8735,7 +9734,7 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -8806,7 +9805,7 @@ var ts; ts.getDeclarationOfKind = getDeclarationOfKind; /** Create a new escaped identifier map. */ function createUnderscoreEscapedMap() { - return new ts.MapCtr(); + return new ts.Map(); } ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap; function hasEntries(map) { @@ -8848,6 +9847,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8860,13 +9861,6 @@ var ts; reportPrivateInBaseOfClassExpression: ts.noop, }; } - function toPath(fileName, basePath, getCanonicalFileName) { - var nonCanonicalizedPath = ts.isRootedDiskPath(fileName) - ? ts.normalizePath(fileName) - : ts.getNormalizedAbsolutePath(fileName, basePath); - return getCanonicalFileName(nonCanonicalizedPath); - } - ts.toPath = toPath; function changesAffectModuleResolution(oldOptions, newOptions) { return oldOptions.configFilePath !== newOptions.configFilePath || optionsHaveModuleResolutionChanges(oldOptions, newOptions); @@ -8935,7 +9929,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -9023,28 +10017,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -9052,11 +10046,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -9224,7 +10218,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 314 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9243,7 +10237,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9311,10 +10305,8 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings return "`" + rawText + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings return "}" + rawText + "${"; case 17 /* TemplateTail */: return "}" + rawText + "`"; @@ -9345,7 +10337,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9377,16 +10369,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9398,9 +10390,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9453,22 +10445,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9478,9 +10470,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 300 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9490,25 +10482,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9518,8 +10510,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9528,15 +10520,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9566,13 +10558,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9583,11 +10575,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9632,7 +10624,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9646,7 +10638,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9655,32 +10647,38 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + var start = ts.skipTrivia(sourceFile.text, node.pos); + var end = node.statements.length > 0 ? node.statements[0].pos : node.end; + return ts.createTextSpanFromBounds(start, end); } if (errorNode === undefined) { // If we don't have a better node, then just set the error on the first token of // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9722,16 +10720,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 93 /* ImportKeyword */ + && n.keywordToken === 95 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -9740,7 +10738,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9749,11 +10747,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -9769,48 +10767,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9819,40 +10817,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9877,23 +10875,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9903,26 +10901,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -9945,10 +10943,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9958,12 +10956,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9971,14 +10969,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9990,8 +10988,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -10002,13 +11000,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -10019,7 +11017,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -10027,17 +11025,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -10050,7 +11048,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -10091,14 +11089,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -10113,9 +11111,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10126,26 +11124,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -10155,9 +11153,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -10179,27 +11177,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10215,21 +11213,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -10238,8 +11236,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -10247,20 +11245,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -10268,10 +11266,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -10280,25 +11278,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10314,10 +11312,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10326,9 +11324,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10336,57 +11334,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10396,49 +11394,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10446,7 +11444,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10455,7 +11453,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10467,15 +11465,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10483,22 +11481,22 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; - function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + function isRequireCall(callExpression, requireStringLiteralLikeArgument) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { return false; } var arg = args[0]; - return !checkArgumentIsStringLiteralLike || ts.isStringLiteralLike(arg); + return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { @@ -10522,21 +11520,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { - if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { - name = node.parent.parent.name; - decl = node.parent.parent; - } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10546,13 +11548,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10566,14 +11569,20 @@ var ts; } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; function hasExpandoValueProperty(node, isPrototypeAssignment) { - return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + return ts.forEach(node.properties, function (p) { + return ts.isPropertyAssignment(p) && + ts.isIdentifier(p.name) && + p.name.escapedText === "value" && + p.initializer && + getExpandoInitializer(p.initializer, isPrototypeAssignment); + }); } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10599,11 +11608,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10620,14 +11629,16 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10635,8 +11646,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10655,19 +11666,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10682,10 +11694,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10700,60 +11715,129 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0], /*excludeThisKeyword*/ true); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + /** x.y OR x[0] */ + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + /** x[0] OR x['a'] OR x[Symbol.y] */ + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + /** Any series of property and element accesses. */ + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + /** Any series of property and element accesses, ending in a literal element access */ + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); + } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; - if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { - // exports.name = expr OR module.exports.name = expr + if ((id.escapedText === "exports" || + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") && + // ExportsProperty does not support binding with computed names + isBindableStaticAccessExpression(lhs)) { + // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... return 1 /* ExportsProperty */; } - // F.G...x = expr - return 5 /* Property */; + if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs) && lhs.expression.kind !== 103 /* ThisKeyword */)) { + // F.G...x = expr + return 5 /* Property */; + } } return 0 /* None */; } @@ -10771,7 +11855,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10780,7 +11865,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10789,14 +11874,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10806,12 +11891,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10820,11 +11905,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10832,19 +11917,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10858,7 +11943,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 312 /* JSDocTypedefTag */ || node.kind === 305 /* JSDocCallbackTag */ || node.kind === 306 /* JSDocEnumTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10868,7 +11953,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10877,18 +11962,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10899,7 +11984,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10914,11 +11999,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10929,12 +12014,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10945,7 +12030,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10968,7 +12053,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10993,7 +12078,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -11003,7 +12088,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -11016,31 +12101,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -11067,22 +12152,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -11099,33 +12184,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -11147,11 +12232,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -11174,8 +12260,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -11183,32 +12269,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -11224,22 +12310,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -11253,24 +12356,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11297,11 +12400,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -11309,7 +12412,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -11317,6 +12420,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11340,14 +12448,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11361,10 +12469,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11377,7 +12485,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11397,10 +12505,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11414,12 +12525,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11435,7 +12546,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11446,11 +12557,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11465,7 +12576,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11474,11 +12585,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11486,15 +12597,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11513,38 +12624,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11553,15 +12664,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11571,73 +12682,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11646,41 +12757,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11798,22 +12911,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11864,6 +12978,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11875,7 +12990,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11885,17 +13000,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11909,6 +13036,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11928,6 +13056,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11942,12 +13072,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -12011,7 +13141,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -12029,7 +13159,7 @@ var ts; */ function getExternalModuleNameFromPath(host, fileName, referencePath) { var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = ts.removeFileExtension(relativePath); @@ -12152,11 +13282,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -12167,10 +13297,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -12190,10 +13320,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -12239,7 +13369,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 298 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12479,7 +13609,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12487,29 +13617,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12522,14 +13652,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12537,8 +13667,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12548,9 +13678,32 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function getFirstIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + node = node.expression; + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + ts.getFirstIdentifier = getFirstIdentifier; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12566,21 +13719,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12878,8 +14031,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12956,35 +14109,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && skipParenthesesUp(parent.parent).kind === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -13063,21 +14216,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ - function forEachAncestorDirectory(directory, callback) { - while (true) { - var result = callback(directory); - if (result !== undefined) { - return result; - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - return undefined; - } - directory = parentPath; - } - } - ts.forEachAncestorDirectory = forEachAncestorDirectory; // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { return !!(getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isAbstractConstructorSymbol(type.symbol); @@ -13104,7 +14242,7 @@ var ts; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { - return !!forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); + return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { @@ -13148,32 +14286,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -13186,6 +14324,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13293,7 +14435,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13410,9 +14552,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } @@ -13420,7 +14562,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13450,14 +14592,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13521,7 +14663,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13603,30 +14746,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 205 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13638,6 +14781,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13650,41 +14804,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 306 /* JSDocEnumTag */: + case 309 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13707,8 +14866,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13886,7 +15045,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 298 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13906,10 +15065,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13954,198 +15112,230 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + var kind = node.kind; + return !!(node.flags & 32 /* OptionalChain */) && + (kind === 193 /* PropertyAccessExpression */ + || kind === 194 /* ElementAccessExpression */ + || kind === 195 /* CallExpression */); + } + ts.isOptionalChain = isOptionalChain; + /** + * Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`). + */ + /* @internal */ + function isExpressionOfOptionalChainRoot(node) { + return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node; + } + ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot; + function isNullishCoalesce(node) { + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + } + ts.isNullishCoalesce = isNullishCoalesce; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -14154,376 +15344,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 316 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14532,105 +15722,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 298 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 303 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 302 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 304 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 306 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 309 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 307 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 308 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 310 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 311 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 312 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 313 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 313 /* JSDocPropertyTag */ || node.kind === 307 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 299 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 305 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 300 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14641,7 +15831,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 314 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14651,7 +15841,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14660,7 +15850,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14713,17 +15903,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14736,7 +15926,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14745,23 +15935,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14776,13 +15966,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14791,14 +15981,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14813,29 +16003,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14845,11 +16035,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14858,12 +16048,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14878,8 +16068,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14890,8 +16080,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14899,15 +16089,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14916,9 +16106,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14939,8 +16129,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14952,8 +16142,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14962,26 +16152,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14989,12 +16179,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -15005,34 +16195,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -15045,13 +16235,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -15060,11 +16250,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -15081,15 +16271,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 317 /* CommaListExpression */: - case 316 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -15097,21 +16287,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 316 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 315 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -15119,21 +16314,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -15157,113 +16373,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 312 /* JSDocTypedefTag */ - || kind === 305 /* JSDocCallbackTag */ - || kind === 313 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 315 /* NotEmittedStatement */ - || kind === 319 /* EndOfDeclarationMarker */ - || kind === 318 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 311 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -15290,10 +16506,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -15303,83 +16519,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 313 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 298 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 301 /* FirstJSDocTagNode */ && node.kind <= 313 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; + } + ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; } - ts.isGetAccessor = isGetAccessor; + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15407,12 +16628,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15448,7 +16669,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15466,7 +16687,12 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature(checker, flags) { + this.flags = flags; + if (ts.Debug.isDebugging) { + this.checker = checker; + } + } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15480,759 +16706,303 @@ var ts; } function SourceMapSource(fileName, text, skipTrivia) { this.fileName = fileName; - this.text = text; - this.skipTrivia = skipTrivia || (function (pos) { return pos; }); - } - ts.objectAllocator = { - getNodeConstructor: function () { return Node; }, - getTokenConstructor: function () { return Node; }, - getIdentifierConstructor: function () { return Node; }, - getSourceFileConstructor: function () { return Node; }, - getSymbolConstructor: function () { return Symbol; }, - getTypeConstructor: function () { return Type; }, - getSignatureConstructor: function () { return Signature; }, - getSourceMapSourceConstructor: function () { return SourceMapSource; }, - }; - function formatStringFromArgs(text, args, baseIndex) { - if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); - } - ts.formatStringFromArgs = formatStringFromArgs; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - ts.Debug.assertGreaterThanOrEqual(start, 0); - ts.Debug.assertGreaterThanOrEqual(length, 0); - if (file) { - ts.Debug.assertLessThanOrEqual(start, file.text.length); - ts.Debug.assertLessThanOrEqual(start + length, file.text.length); - } - var text = getLocaleSpecificMessage(message); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(_dummy, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return text; - } - ts.formatMessage = formatMessage; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function createCompilerDiagnosticFromMessageChain(chain) { - return { - file: undefined, - start: undefined, - length: undefined, - code: chain.code, - category: chain.category, - messageText: chain.next ? chain : chain.messageText, - }; - } - ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details === undefined || Array.isArray(details) ? details : [details] - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - var lastChain = headChain; - while (lastChain.next) { - lastChain = lastChain.next[0]; - } - lastChain.next = [tailChain]; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function getDiagnosticFilePath(diagnostic) { - return diagnostic.file ? diagnostic.file.path : undefined; - } - function compareDiagnostics(d1, d2) { - return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; - } - ts.compareDiagnostics = compareDiagnostics; - function compareDiagnosticsSkipRelatedInformation(d1, d2) { - return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || - ts.compareValues(d1.start, d2.start) || - ts.compareValues(d1.length, d2.length) || - ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; - } - ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; - function compareRelatedInformation(d1, d2) { - if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; - } - if (d1.relatedInformation && d2.relatedInformation) { - return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { - var d2i = d2.relatedInformation[index]; - return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; - } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; - } - function compareMessageText(t1, t2) { - if (typeof t1 === "string" && typeof t2 === "string") { - return ts.compareStringsCaseSensitive(t1, t2); - } - else if (typeof t1 === "string") { - return -1 /* LessThan */; - } - else if (typeof t2 === "string") { - return 1 /* GreaterThan */; - } - var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); - if (res) { - return res; - } - if (!t1.next && !t2.next) { - return 0 /* EqualTo */; - } - if (!t1.next) { - return -1 /* LessThan */; - } - if (!t2.next) { - return 1 /* GreaterThan */; - } - var len = Math.min(t1.next.length, t2.next.length); - for (var i = 0; i < len; i++) { - res = compareMessageText(t1.next[i], t2.next[i]); - if (res) { - return res; - } - } - if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; - } - else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; - } - return 0 /* EqualTo */; - } - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0 /* ES3 */; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; - function getEmitModuleResolutionKind(compilerOptions) { - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - } - return moduleResolution; - } - ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; - function hasJsonModuleEmitEnabled(options) { - switch (getEmitModuleKind(options)) { - case ts.ModuleKind.CommonJS: - case ts.ModuleKind.AMD: - case ts.ModuleKind.ES2015: - case ts.ModuleKind.ESNext: - return true; - default: - return false; - } - } - ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; - function unreachableCodeIsError(options) { - return options.allowUnreachableCode === false; - } - ts.unreachableCodeIsError = unreachableCodeIsError; - function unusedLabelIsError(options) { - return options.allowUnusedLabels === false; - } - ts.unusedLabelIsError = unusedLabelIsError; - function getAreDeclarationMapsEnabled(options) { - return !!(getEmitDeclarations(options) && options.declarationMap); - } - ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; - function getAllowSyntheticDefaultImports(compilerOptions) { - var moduleKind = getEmitModuleKind(compilerOptions); - return compilerOptions.allowSyntheticDefaultImports !== undefined - ? compilerOptions.allowSyntheticDefaultImports - : compilerOptions.esModuleInterop || - moduleKind === ts.ModuleKind.System; - } - ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; - function getEmitDeclarations(compilerOptions) { - return !!(compilerOptions.declaration || compilerOptions.composite); - } - ts.getEmitDeclarations = getEmitDeclarations; - function isIncrementalCompilation(options) { - return !!(options.incremental || options.composite); - } - ts.isIncrementalCompilation = isIncrementalCompilation; - function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; - } - ts.getStrictOptionValue = getStrictOptionValue; - function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; - function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; - function getCompilerOptionValue(options, option) { - return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; - } - ts.getCompilerOptionValue = getCompilerOptionValue; - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - // have already seen asterisk - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - /** - * Internally, we represent paths as strings with '/' as the directory separator. - * When we make system calls (eg: LanguageServiceHost.getDirectory()), - * we expect the host to correctly handle paths in our specified format. - */ - ts.directorySeparator = "/"; - var altDirectorySeparator = "\\"; - var urlSchemeSeparator = "://"; - var backslashRegExp = /\\/g; - /** - * Normalize path separators. - */ - function normalizeSlashes(path) { - return path.replace(backslashRegExp, ts.directorySeparator); - } - ts.normalizeSlashes = normalizeSlashes; - function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); - } - function getFileUrlVolumeSeparatorEnd(url, start) { - var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) - return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { - var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) - return start + 3; - } - return -1; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * If the root is part of a URL, the twos-complement of the root length is returned. - */ - function getEncodedRootLength(path) { - if (!path) - return 0; - var ch0 = path.charCodeAt(0); - // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { - if (path.charCodeAt(1) !== ch0) - return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); - if (p1 < 0) - return path.length; // UNC: "//server" or "\\server" - return p1 + 1; // UNC: "//server/" or "\\server\" - } - // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { - var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) - return 3; // DOS: "c:/" or "c:\" - if (path.length === 2) - return 2; // DOS: "c:" (but not "c:d") - } - // URL - var schemeEnd = path.indexOf(urlSchemeSeparator); - if (schemeEnd !== -1) { - var authorityStart = schemeEnd + urlSchemeSeparator.length; - var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); - if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" - // For local "file" URLs, include the leading DOS volume (if present). - // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a - // special case interpreted as "the machine from which the URL is being interpreted". - var scheme = path.slice(0, schemeEnd); - var authority = path.slice(authorityStart, authorityEnd); - if (scheme === "file" && (authority === "" || authority === "localhost") && - isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { - var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); - if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { - // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" - return ~(volumeSeparatorEnd + 1); - } - if (volumeSeparatorEnd === path.length) { - // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" - // but not "file:///c:d" or "file:///c%3ad" - return ~volumeSeparatorEnd; - } - } - } - return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" - } - return ~path.length; // URL: "file://server", "http://server" - } - // relative - return 0; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * - * For example: - * ```ts - * getRootLength("a") === 0 // "" - * getRootLength("/") === 1 // "/" - * getRootLength("c:") === 2 // "c:" - * getRootLength("c:d") === 0 // "" - * getRootLength("c:/") === 3 // "c:/" - * getRootLength("c:\\") === 3 // "c:\\" - * getRootLength("//server") === 7 // "//server" - * getRootLength("//server/share") === 8 // "//server/" - * getRootLength("\\\\server") === 7 // "\\\\server" - * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" - * getRootLength("file:///path") === 8 // "file:///" - * getRootLength("file:///c:") === 10 // "file:///c:" - * getRootLength("file:///c:d") === 8 // "file:///" - * getRootLength("file:///c:/path") === 11 // "file:///c:/" - * getRootLength("file://server") === 13 // "file://server" - * getRootLength("file://server/path") === 14 // "file://server/" - * getRootLength("http://server") === 13 // "http://server" - * getRootLength("http://server/path") === 14 // "http://server/" - * ``` - */ - function getRootLength(path) { - var rootLength = getEncodedRootLength(path); - return rootLength < 0 ? ~rootLength : rootLength; - } - ts.getRootLength = getRootLength; - // TODO(rbuckton): replace references with `resolvePath` - function normalizePath(path) { - return ts.resolvePath(path); - } - ts.normalizePath = normalizePath; - function normalizePathAndParts(path) { - path = normalizeSlashes(path); - var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); - if (parts.length) { - var joinedParts = root + parts.join(ts.directorySeparator); - return { path: ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; - } - else { - return { path: root, parts: parts }; - } - } - ts.normalizePathAndParts = normalizePathAndParts; - function getDirectoryPath(path) { - path = normalizeSlashes(path); - // If the path provided is itself the root, then return it. - var rootLength = getRootLength(path); - if (rootLength === path.length) - return path; - // return the leading portion of the path up to the last (non-terminal) directory separator - // but not including any trailing directory separator. - path = ts.removeTrailingDirectorySeparator(path); - return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { - var canonicalFileName = getCanonicalFileName(fileName); - var canonicalDirectoryName = getCanonicalFileName(directoryName); - return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); - } - ts.startsWithDirectory = startsWithDirectory; - function isUrl(path) { - return getEncodedRootLength(path) < 0; - } - ts.isUrl = isUrl; - function pathIsRelative(path) { - return /^\.\.?($|[\\/])/.test(path); - } - ts.pathIsRelative = pathIsRelative; - /** - * Determines whether a path is an absolute path (e.g. starts with `/`, or a dos path - * like `c:`, `c:\` or `c:/`). - */ - function isRootedDiskPath(path) { - return getEncodedRootLength(path) > 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - /** - * Determines whether a path consists only of a path root. - */ - function isDiskPathRoot(path) { - var rootLength = getEncodedRootLength(path); - return rootLength > 0 && rootLength === path.length; - } - ts.isDiskPathRoot = isDiskPathRoot; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - } - ts.convertToRelativePath = convertToRelativePath; - function pathComponents(path, rootLength) { - var root = path.substring(0, rootLength); - var rest = path.substring(rootLength).split(ts.directorySeparator); - if (rest.length && !ts.lastOrUndefined(rest)) - rest.pop(); - return __spreadArrays([root], rest); - } - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is not normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getPathComponents(path, currentDirectory) { - if (currentDirectory === void 0) { currentDirectory = ""; } - path = ts.combinePaths(currentDirectory, path); - var rootLength = getRootLength(path); - return pathComponents(path, rootLength); - } - ts.getPathComponents = getPathComponents; - /** - * Reduce an array of path components to a more simplified path by navigating any - * `"."` or `".."` entries in the path. - */ - function reducePathComponents(components) { - if (!ts.some(components)) - return []; - var reduced = [components[0]]; - for (var i = 1; i < components.length; i++) { - var component = components[i]; - if (!component) - continue; - if (component === ".") - continue; - if (component === "..") { - if (reduced.length > 1) { - if (reduced[reduced.length - 1] !== "..") { - reduced.pop(); - continue; - } - } - else if (reduced[0]) - continue; - } - reduced.push(component); - } - return reduced; - } - ts.reducePathComponents = reducePathComponents; - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getNormalizedPathComponents(path, currentDirectory) { - return reducePathComponents(getPathComponents(path, currentDirectory)); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - /** - * Formats a parsed path consisting of a root component (at index 0) and zero or more path - * segments (at indices > 0). - */ - function getPathFromPathComponents(pathComponents) { - if (pathComponents.length === 0) - return ""; - var root = pathComponents[0] && ts.ensureTrailingDirectorySeparator(pathComponents[0]); - return root + pathComponents.slice(1).join(ts.directorySeparator); + this.text = text; + this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } - ts.getPathFromPathComponents = getPathFromPathComponents; - function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { - return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + // eslint-disable-next-line prefer-const + ts.objectAllocator = { + getNodeConstructor: function () { return Node; }, + getTokenConstructor: function () { return Node; }, + getIdentifierConstructor: function () { return Node; }, + getSourceFileConstructor: function () { return Node; }, + getSymbolConstructor: function () { return Symbol; }, + getTypeConstructor: function () { return Type; }, + getSignatureConstructor: function () { return Signature; }, + getSourceMapSourceConstructor: function () { return SourceMapSource; }, + }; + function formatStringFromArgs(text, args, baseIndex) { + if (baseIndex === void 0) { baseIndex = 0; } + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } - ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; - function getPathWithoutRoot(pathComponents) { - if (pathComponents.length === 0) - return ""; - return pathComponents.slice(1).join(ts.directorySeparator); + ts.formatStringFromArgs = formatStringFromArgs; + function getLocaleSpecificMessage(message) { + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; } -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { - var fromComponents = ts.reducePathComponents(ts.getPathComponents(from)); - var toComponents = ts.reducePathComponents(ts.getPathComponents(to)); - var start; - for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { - var fromComponent = getCanonicalFileName(fromComponents[start]); - var toComponent = getCanonicalFileName(toComponents[start]); - var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; - if (!comparer(fromComponent, toComponent)) - break; + ts.getLocaleSpecificMessage = getLocaleSpecificMessage; + function createFileDiagnostic(file, start, length, message) { + ts.Debug.assertGreaterThanOrEqual(start, 0); + ts.Debug.assertGreaterThanOrEqual(length, 0); + if (file) { + ts.Debug.assertLessThanOrEqual(start, file.text.length); + ts.Debug.assertLessThanOrEqual(start + length, file.text.length); } - if (start === 0) { - return toComponents; + var text = getLocaleSpecificMessage(message); + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); } - var components = toComponents.slice(start); - var relative = []; - for (; start < fromComponents.length; start++) { - relative.push(".."); + return { + file: file, + start: start, + length: length, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; + } + ts.createFileDiagnostic = createFileDiagnostic; + function formatMessage(_dummy, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return __spreadArrays([""], relative, components); + return text; } - ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; - function getRelativePathFromFile(from, to, getCanonicalFileName) { - return ensurePathIsNonModuleName(getRelativePathFromDirectory(ts.getDirectoryPath(from), to, getCanonicalFileName)); + ts.formatMessage = formatMessage; + function createCompilerDiagnostic(message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 1) { + text = formatStringFromArgs(text, arguments, 1); + } + return { + file: undefined, + start: undefined, + length: undefined, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; } - ts.getRelativePathFromFile = getRelativePathFromFile; - function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { - ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); - var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; - var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; - var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); - return ts.getPathFromPathComponents(pathComponents); + ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText, + }; } - ts.getRelativePathFromDirectory = getRelativePathFromDirectory; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); - var firstComponent = pathComponents[0]; - if (isAbsolutePathAnUrl && ts.isRootedDiskPath(firstComponent)) { - var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; - pathComponents[0] = prefix + firstComponent; + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; + function chainDiagnosticMessages(details, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return ts.getPathFromPathComponents(pathComponents); + return { + messageText: text, + category: message.category, + code: message.code, + next: details === undefined || Array.isArray(details) ? details : [details] + }; } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - /** - * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed - * with `./` or `../`) so as not to be confused with an unprefixed module name. - */ - function ensurePathIsNonModuleName(path) { - return ts.getRootLength(path) === 0 && !ts.pathIsRelative(path) ? "./" + path : path; + ts.chainDiagnosticMessages = chainDiagnosticMessages; + function concatenateDiagnosticMessageChains(headChain, tailChain) { + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next[0]; + } + lastChain.next = [tailChain]; } - ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; - function getBaseFileName(path, extensions, ignoreCase) { - path = ts.normalizeSlashes(path); - // if the path provided is itself the root, then it has not file name. - var rootLength = ts.getRootLength(path); - if (rootLength === path.length) - return ""; - // return the trailing portion of the path starting after the last (non-terminal) directory - // separator but not including any trailing directory separator. - path = removeTrailingDirectorySeparator(path); - var name = path.slice(Math.max(ts.getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); - var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; - return extension ? name.slice(0, name.length - extension.length) : name; + ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; + function getDiagnosticFilePath(diagnostic) { + return diagnostic.file ? diagnostic.file.path : undefined; } - ts.getBaseFileName = getBaseFileName; - /** - * Combines paths. If a path is absolute, it replaces any previous path. - */ - function combinePaths(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + function compareDiagnosticsSkipRelatedInformation(d1, d2) { + return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || + ts.compareValues(d1.start, d2.start) || + ts.compareValues(d1.length, d2.length) || + ts.compareValues(d1.code, d2.code) || + compareMessageText(d1.messageText, d2.messageText) || + 0 /* EqualTo */; + } + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; } - if (path) - path = ts.normalizeSlashes(path); - for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { - var relativePath = paths_1[_a]; - if (!relativePath) - continue; - relativePath = ts.normalizeSlashes(relativePath); - if (!path || ts.getRootLength(relativePath) !== 0) { - path = relativePath; - } - else { - path = ensureTrailingDirectorySeparator(path) + relativePath; - } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; } - return path; + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; } - ts.combinePaths = combinePaths; - /** - * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any - * `.` and `..` path components are resolved. - */ - function resolvePath(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareMessageText(t1, t2) { + if (typeof t1 === "string" && typeof t2 === "string") { + return ts.compareStringsCaseSensitive(t1, t2); } - var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); - var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); - return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; - } - ts.resolvePath = resolvePath; - /** - * Determines whether a path has a trailing separator (`/` or `\\`). - */ - function hasTrailingDirectorySeparator(path) { - if (path.length === 0) - return false; - var ch = path.charCodeAt(path.length - 1); - return ch === 47 /* slash */ || ch === 92 /* backslash */; - } - ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; - function removeTrailingDirectorySeparator(path) { - if (hasTrailingDirectorySeparator(path)) { - return path.substr(0, path.length - 1); + else if (typeof t1 === "string") { + return -1 /* LessThan */; } - return path; - } - ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; - function ensureTrailingDirectorySeparator(path) { - if (!hasTrailingDirectorySeparator(path)) { - return path + ts.directorySeparator; + else if (typeof t2 === "string") { + return 1 /* GreaterThan */; } - return path; - } - ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; - // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; - function comparePathsWorker(a, b, componentComparer) { - if (a === b) + var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); + if (res) { + return res; + } + if (!t1.next && !t2.next) { return 0 /* EqualTo */; - if (a === undefined) + } + if (!t1.next) { return -1 /* LessThan */; - if (b === undefined) - return 1 /* GreaterThan */; - // NOTE: Performance optimization - shortcut if the root segments differ as there would be no - // need to perform path reduction. - var aRoot = a.substring(0, ts.getRootLength(a)); - var bRoot = b.substring(0, ts.getRootLength(b)); - var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { - return result; } - // NOTE: Performance optimization - shortcut if there are no relative path segments in - // the non-root portion of the path - var aRest = a.substring(aRoot.length); - var bRest = b.substring(bRoot.length); - if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { - return componentComparer(aRest, bRest); + if (!t2.next) { + return 1 /* GreaterThan */; } - // The path contains a relative path segment. Normalize the paths and perform a slower component - // by component comparison. - var aComponents = ts.reducePathComponents(ts.getPathComponents(a)); - var bComponents = ts.reducePathComponents(ts.getPathComponents(b)); - var sharedLength = Math.min(aComponents.length, bComponents.length); - for (var i = 1; i < sharedLength; i++) { - var result_1 = componentComparer(aComponents[i], bComponents[i]); - if (result_1 !== 0 /* EqualTo */) { - return result_1; + var len = Math.min(t1.next.length, t2.next.length); + for (var i = 0; i < len; i++) { + res = compareMessageText(t1.next[i], t2.next[i]); + if (res) { + return res; } } - return ts.compareValues(aComponents.length, bComponents.length); + if (t1.next.length < t2.next.length) { + return -1 /* LessThan */; + } + else if (t1.next.length > t2.next.length) { + return 1 /* GreaterThan */; + } + return 0 /* EqualTo */; } - /** - * Performs a case-sensitive comparison of two paths. - */ - function comparePathsCaseSensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0 /* ES3 */; } - ts.comparePathsCaseSensitive = comparePathsCaseSensitive; - /** - * Performs a case-insensitive comparison of two paths. - */ - function comparePathsCaseInsensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } - ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; - function comparePaths(a, b, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - a = combinePaths(currentDirectory, a); - b = combinePaths(currentDirectory, b); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; + ts.getEmitModuleKind = getEmitModuleKind; + function getEmitModuleResolutionKind(compilerOptions) { + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; } - return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + return moduleResolution; } - ts.comparePaths = comparePaths; - function containsPath(parent, child, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - parent = combinePaths(currentDirectory, parent); - child = combinePaths(currentDirectory, child); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; - } - if (parent === undefined || child === undefined) - return false; - if (parent === child) - return true; - var parentComponents = ts.reducePathComponents(ts.getPathComponents(parent)); - var childComponents = ts.reducePathComponents(ts.getPathComponents(child)); - if (childComponents.length < parentComponents.length) { - return false; - } - var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; - for (var i = 0; i < parentComponents.length; i++) { - var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; - if (!equalityComparer(parentComponents[i], childComponents[i])) { + ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function hasJsonModuleEmitEnabled(options) { + switch (getEmitModuleKind(options)) { + case ts.ModuleKind.CommonJS: + case ts.ModuleKind.AMD: + case ts.ModuleKind.ES2015: + case ts.ModuleKind.ESNext: + return true; + default: return false; + } + } + ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; + function getAreDeclarationMapsEnabled(options) { + return !!(getEmitDeclarations(options) && options.declarationMap); + } + ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; + function getAllowSyntheticDefaultImports(compilerOptions) { + var moduleKind = getEmitModuleKind(compilerOptions); + return compilerOptions.allowSyntheticDefaultImports !== undefined + ? compilerOptions.allowSyntheticDefaultImports + : compilerOptions.esModuleInterop || + moduleKind === ts.ModuleKind.System; + } + ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; + function getEmitDeclarations(compilerOptions) { + return !!(compilerOptions.declaration || compilerOptions.composite); + } + ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; + function getStrictOptionValue(compilerOptions, flag) { + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; + } + ts.getStrictOptionValue = getStrictOptionValue; + function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; + function compilerOptionsAffectEmit(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; + function getCompilerOptionValue(options, option) { + return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; + } + ts.getCompilerOptionValue = getCompilerOptionValue; + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42 /* asterisk */) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + // have already seen asterisk + return false; + } } } return true; } - ts.containsPath = containsPath; - function isDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { function stripLeadingDirectorySeparator(s) { - return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; } function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); @@ -16251,10 +17021,6 @@ var ts; return "\\" + match; } var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; - function hasExtension(fileName) { - return ts.stringContains(getBaseFileName(fileName), "."); - } - ts.hasExtension = hasExtension; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; var filesMatcher = { @@ -16330,7 +17096,7 @@ var ts; } // getNormalizedPathComponents includes the separator for the root component. // We need to remove to create our regex correctly. - components[0] = removeTrailingDirectorySeparator(components[0]); + components[0] = ts.removeTrailingDirectorySeparator(components[0]); if (isImplicitGlob(lastComponent)) { components.push("**", "*"); } @@ -16392,7 +17158,7 @@ var ts; function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = ts.normalizePath(path); currentDirectory = ts.normalizePath(currentDirectory); - var absolutePath = combinePaths(currentDirectory, path); + var absolutePath = ts.combinePaths(currentDirectory, path); return { includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), @@ -16421,7 +17187,7 @@ var ts; var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; - visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth); + visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); } return ts.flatten(results); function visitDirectory(path, absolutePath, depth) { @@ -16431,8 +17197,8 @@ var ts; visited.set(canonicalPath, true); var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; var _loop_1 = function (current) { - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if (extensions && !ts.fileExtensionIsOneOf(name, extensions)) return "continue"; if (excludeRegex && excludeRegex.test(absoluteName)) @@ -16459,8 +17225,8 @@ var ts; } for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) { var current = _d[_c]; - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { visitDirectory(name, absoluteName, depth); @@ -16482,14 +17248,14 @@ var ts; var include = includes_1[_i]; // We also need to check the relative paths by converting them to absolute and normalizing // in case they escape the base path (e.g "..\somedirectory") - var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(combinePaths(path, include)); + var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include)); // Append the literal and canonical candidate base paths. includeBasePaths.push(getIncludeBasePath(absolute)); } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames)); var _loop_2 = function (includeBasePath) { - if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; @@ -16506,9 +17272,9 @@ var ts; var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes); if (wildcardOffset < 0) { // No "*" or "?" in the path - return !hasExtension(absolute) + return !ts.hasExtension(absolute) ? absolute - : removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); + : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); } return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); } @@ -16673,14 +17439,9 @@ var ts; } ts.removeExtension = removeExtension; function changeExtension(path, newExtension) { - return changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); + return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; - function changeAnyExtension(path, ext, extensions, ignoreCase) { - var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); - return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; - } - ts.changeAnyExtension = changeAnyExtension; function tryParsePattern(pattern) { // This should be verified outside of here and a proper error thrown. ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern)); @@ -16723,36 +17484,6 @@ var ts; return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); }); } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; - function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { - if (typeof extensions === "string") - extensions = [extensions]; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - if (!ts.startsWith(extension, ".")) - extension = "." + extension; - if (path.length >= extension.length && path.charAt(path.length - extension.length) === ".") { - var pathExtension = path.slice(path.length - extension.length); - if (stringEqualityComparer(pathExtension, extension)) { - return pathExtension; - } - } - } - return ""; - } - function getAnyExtensionFromPath(path, extensions, ignoreCase) { - // Retrieves any string from the final "." onwards from a base file name. - // Unlike extensionFromPath, which throws an exception on unrecognized extensions. - if (extensions) { - return getAnyExtensionFromPathWorker(path, extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); - } - var baseFileName = getBaseFileName(path); - var extensionIndex = baseFileName.lastIndexOf("."); - if (extensionIndex >= 0) { - return baseFileName.substring(extensionIndex); - } - return ""; - } - ts.getAnyExtensionFromPath = getAnyExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } @@ -16882,14 +17613,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16993,17 +17727,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -17052,19 +17784,19 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17072,9 +17804,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -17082,7 +17814,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17090,51 +17822,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -17146,345 +17878,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 303 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 301 /* JSDocTag */: - case 304 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17538,7 +18275,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17567,14 +18304,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17705,18 +18440,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17725,7 +18460,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17741,6 +18476,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17766,10 +18504,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17797,7 +18535,7 @@ var ts; function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17862,7 +18600,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17883,16 +18621,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17933,40 +18671,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -18081,20 +18819,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -18182,7 +18920,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -18212,7 +18950,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -18224,7 +18962,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -18245,9 +18983,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -18256,7 +18994,12 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var isReservedWord = scanner.isReservedWord(); + var msgArg = scanner.getTokenText(); + var defaultMessage = isReservedWord ? + ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : + ts.Diagnostics.Identifier_expected; + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -18287,7 +19030,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18308,20 +19051,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18334,16 +19077,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18363,7 +19106,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18379,7 +19122,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18449,7 +19192,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18466,8 +19209,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18497,14 +19240,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18523,9 +19266,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18545,7 +19288,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18620,7 +19363,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18721,20 +19464,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18743,8 +19486,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18753,58 +19496,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18825,7 +19568,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18892,7 +19635,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18930,6 +19673,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18950,7 +19696,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18961,7 +19707,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18992,13 +19738,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -19010,7 +19756,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -19070,24 +19816,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -19095,20 +19841,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -19116,7 +19862,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -19137,43 +19883,43 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); if (moduleSpecifier) { - var moduleTag = createNode(297 /* JSDocNamepathType */, moduleSpecifier.pos); + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); terminate: while (true) { switch (token()) { case 19 /* CloseBraceToken */: @@ -19192,25 +19938,25 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -19229,18 +19975,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -19249,12 +19995,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -19276,7 +20022,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -19298,16 +20044,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -19354,10 +20100,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19401,21 +20147,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 56 /* QuestionToken */) { + if (token() !== 57 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19423,17 +20169,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -19445,7 +20191,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19467,20 +20213,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19491,7 +20237,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19499,14 +20245,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19523,37 +20269,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19564,23 +20310,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19588,9 +20334,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19598,14 +20344,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19618,23 +20364,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19644,50 +20390,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19695,51 +20445,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19757,27 +20510,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19796,16 +20549,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19813,11 +20566,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19838,13 +20591,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19854,7 +20607,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19876,8 +20629,8 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19886,7 +20639,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19898,7 +20651,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19909,45 +20663,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19956,14 +20717,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19974,18 +20735,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -20004,9 +20765,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -20029,7 +20790,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -20074,7 +20835,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -20090,7 +20851,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -20119,15 +20880,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -20138,20 +20899,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -20176,8 +20937,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -20187,10 +20948,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -20200,12 +20961,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -20219,8 +20980,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -20244,30 +21005,30 @@ var ts; // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -20276,7 +21037,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -20286,11 +21047,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -20323,7 +21084,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -20336,23 +21097,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20362,7 +21123,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20375,7 +21136,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20386,8 +21147,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20412,20 +21173,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20433,7 +21194,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20462,16 +21223,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20492,51 +21253,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20546,7 +21307,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20570,7 +21331,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20587,10 +21348,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -20615,23 +21376,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20654,16 +21415,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20686,21 +21447,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20741,14 +21502,14 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20756,21 +21517,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a - // CallExpression. As such, we need to consume the rest of it here to be complete. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20822,11 +21584,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20838,7 +21600,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20847,8 +21609,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20857,15 +21619,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20876,11 +21638,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20910,7 +21672,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20918,7 +21680,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20939,16 +21701,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20956,23 +21718,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20986,10 +21748,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20997,7 +21759,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -21023,9 +21785,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -21038,7 +21800,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -21046,78 +21808,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -21126,48 +21920,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -21176,12 +21992,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -21198,21 +22014,23 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* ColonToken */: // foo: case 26 /* SemicolonToken */: // foo; - case 56 /* QuestionToken */: // foo? - case 33 /* EqualsEqualsToken */: // foo == - case 35 /* EqualsEqualsEqualsToken */: // foo === - case 34 /* ExclamationEqualsToken */: // foo != - case 36 /* ExclamationEqualsEqualsToken */: // foo !== - case 54 /* AmpersandAmpersandToken */: // foo && - case 55 /* BarBarToken */: // foo || - case 51 /* CaretToken */: // foo ^ - case 49 /* AmpersandToken */: // foo & - case 50 /* BarToken */: // foo | + case 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // these cases can't legally follow a type arg list. However, they're not legal @@ -21224,6 +22042,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -21236,11 +22055,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -21248,7 +22067,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -21256,14 +22075,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -21274,28 +22093,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21307,25 +22126,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -21333,24 +22152,24 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21369,10 +22188,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21380,7 +22199,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21392,26 +22211,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21421,7 +22240,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21454,25 +22273,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21484,8 +22303,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21494,12 +22313,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21507,23 +22326,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21541,7 +22360,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21549,8 +22368,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21558,39 +22377,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21605,29 +22424,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21640,8 +22459,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21651,13 +22470,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21669,11 +22488,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21682,12 +22501,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -21710,41 +22529,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21757,50 +22576,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -21823,63 +22643,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21888,52 +22709,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21942,7 +22782,7 @@ var ts; if (node.decorators || node.modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21965,24 +22805,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21990,14 +22830,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -22019,10 +22859,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22032,14 +22872,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -22055,7 +22895,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -22070,25 +22910,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -22100,25 +22940,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22133,17 +22973,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -22151,13 +22991,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -22174,7 +23014,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -22190,18 +23030,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -22219,10 +23059,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -22242,7 +23082,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -22261,7 +23101,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -22272,20 +23112,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -22299,27 +23139,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22345,7 +23195,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -22357,33 +23207,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22391,11 +23240,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22405,14 +23254,14 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22424,7 +23273,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22435,7 +23284,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22447,11 +23296,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22467,15 +23316,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22483,52 +23332,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22540,7 +23389,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22550,7 +23399,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22560,8 +23409,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22583,9 +23432,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22598,14 +23447,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22619,9 +23468,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22630,24 +23479,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22655,12 +23504,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22675,15 +23524,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22691,7 +23538,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22742,9 +23589,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22754,8 +23601,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22766,11 +23613,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22835,7 +23682,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22854,7 +23701,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -22905,7 +23752,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(298 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22941,14 +23788,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22956,7 +23803,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -23040,7 +23887,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -23065,7 +23912,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -23073,7 +23920,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -23082,7 +23929,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -23105,7 +23952,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(301 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -23133,15 +23980,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -23150,9 +23997,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -23168,8 +24015,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(313 /* JSDocPropertyTag */, start) : - createNode(307 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -23186,20 +24033,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -23211,7 +24058,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(308 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -23220,13 +24067,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(310 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(303 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -23248,20 +24095,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -23280,14 +24127,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(302 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -23299,7 +24146,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -23307,19 +24154,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(304 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(309 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(306 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -23328,7 +24175,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(312 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -23342,9 +24189,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 310 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -23357,7 +24204,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23376,7 +24223,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23390,22 +24237,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(305 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(300 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 308 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23447,10 +24294,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23463,13 +24310,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23478,7 +24325,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23514,13 +24361,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(311 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23553,13 +24400,13 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - if (token() !== 73 /* Identifier */) { + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { result.originalKeywordKind = token(); } result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -23688,7 +24535,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -24254,10 +25101,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24407,6 +25254,14 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", @@ -24471,6 +25326,15 @@ var ts; isCommandLineOnly: true, description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, + { + name: "listFilesOnly", + type: "boolean", + category: ts.Diagnostics.Command_line_Options, + affectsSemanticDiagnostics: true, + affectsEmit: true, + isCommandLineOnly: true, + description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing + }, // Basic { name: "target", @@ -25027,6 +25891,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -25122,6 +25992,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -25219,7 +26096,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25449,6 +26327,7 @@ var ts; return { buildOptions: buildOptions, projects: projects, errors: errors }; } ts.parseBuildCommand = parseBuildCommand; + /* @internal */ function getDiagnosticText(_message) { var _args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -25457,104 +26336,7 @@ var ts; var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } - /* @internal */ - function printVersion() { - ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); - } - ts.printVersion = printVersion; - /* @internal */ - function printHelp(optionsList, syntaxPrefix) { - if (syntaxPrefix === void 0) { syntaxPrefix = ""; } - var output = []; - // We want to align our "syntax" and "examples" commands to a certain margin. - var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; - var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; - var marginLength = Math.max(syntaxLength, examplesLength); - // Build up the syntactic skeleton. - var syntax = makePadding(marginLength - syntaxLength); - syntax += "tsc " + syntaxPrefix + "[" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + "...]"; - output.push(getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax)); - output.push(ts.sys.newLine + ts.sys.newLine); - // Build up the list of examples. - var padding = makePadding(marginLength); - output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine); - output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine); - output.push(padding + "tsc @args.txt" + ts.sys.newLine); - output.push(padding + "tsc --build tsconfig.json" + ts.sys.newLine); - output.push(ts.sys.newLine); - output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); - // We want our descriptions to align at the same column in our output, - // so we keep track of the longest option usage string. - marginLength = 0; - var usageColumn = []; // Things like "-d, --declaration" go in here. - var descriptionColumn = []; - var optionsDescriptionMap = ts.createMap(); // Map between option.description and list of option.type if it is a kind - for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) { - var option = optionsList_1[_i]; - // If an option lacks a description, - // it is not officially supported. - if (!option.description) { - continue; - } - var usageText_1 = " "; - if (option.shortName) { - usageText_1 += "-" + option.shortName; - usageText_1 += getParamType(option); - usageText_1 += ", "; - } - usageText_1 += "--" + option.name; - usageText_1 += getParamType(option); - usageColumn.push(usageText_1); - var description = void 0; - if (option.name === "lib") { - description = getDiagnosticText(option.description); - var element = option.element; - var typeMap = element.type; - optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; })); - } - else { - description = getDiagnosticText(option.description); - } - descriptionColumn.push(description); - // Set the new margin for the description column if necessary. - marginLength = Math.max(usageText_1.length, marginLength); - } - // Special case that can't fit in the loop. - var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; - usageColumn.push(usageText); - descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); - marginLength = Math.max(usageText.length, marginLength); - // Print out each row, aligning all the descriptions on the same column. - for (var i = 0; i < usageColumn.length; i++) { - var usage = usageColumn[i]; - var description = descriptionColumn[i]; - var kindsList = optionsDescriptionMap.get(description); - output.push(usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine); - if (kindsList) { - output.push(makePadding(marginLength + 4)); - for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) { - var kind = kindsList_1[_a]; - output.push(kind + " "); - } - output.push(ts.sys.newLine); - } - } - for (var _b = 0, output_1 = output; _b < output_1.length; _b++) { - var line = output_1[_b]; - ts.sys.write(line); - } - return; - function getParamType(option) { - if (option.paramType !== undefined) { - return " " + getDiagnosticText(option.paramType); - } - return ""; - } - function makePadding(paddingLength) { - return Array(paddingLength + 1).join(" "); - } - } - ts.printHelp = printHelp; + ts.getDiagnosticText = getDiagnosticText; /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ @@ -25719,7 +26501,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25775,15 +26557,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25801,13 +26583,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25824,7 +26606,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25873,7 +26655,7 @@ var ts; /** @internal */ function convertToTSConfig(configParseResult, configFileName, host) { var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); + var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs, host)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; @@ -25894,12 +26676,12 @@ var ts; return undefined; return specs; } - function matchesSpecs(path, includeSpecs, excludeSpecs) { + function matchesSpecs(path, includeSpecs, excludeSpecs, host) { if (!includeSpecs) return function (_) { return true; }; - var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); - var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); - var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames); if (includeRe) { if (excludeRe) { return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); }; @@ -26076,6 +26858,35 @@ var ts; } } ts.generateTSConfig = generateTSConfig; + /* @internal */ + function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) { + var result = {}; + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name in options) { + if (ts.hasProperty(options, name)) { + result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); + } + } + if (result.configFilePath) { + result.configFilePath = toAbsolutePath(result.configFilePath); + } + return result; + } + ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; + function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { + if (option) { + if (option.type === "list") { + var values = value; + if (option.element.isFilePath && values.length) { + return values.map(toAbsolutePath); + } + } + else if (option.isFilePath) { + return toAbsolutePath(value); + } + } + return value; + } /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -26106,8 +26917,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -26527,7 +27337,7 @@ var ts; } function normalizeNonListOptionValue(option, basePath, value) { if (option.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + value = ts.getNormalizedAbsolutePath(value, basePath); if (value === "") { value = "."; } @@ -26962,8 +27772,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -27222,7 +28033,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27686,7 +28497,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -28166,35 +28977,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -28213,9 +29056,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -28224,6 +29067,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -28248,7 +29121,11 @@ var ts; ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; })(ContainerFlags || (ContainerFlags = {})); - var flowNodeCreated = ts.identity; + function initFlowNode(node) { + ts.Debug.attachFlowNodeDebugInfo(node); + return node; + } + var flowNodeCreated = initFlowNode; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -28288,7 +29165,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -28312,6 +29189,9 @@ var ts; symbolCount = 0; skipTransformFlagAggregation = file.isDeclarationFile; Symbol = ts.objectAllocator.getSymbolConstructor(); + // Attach debugging information if necessary + ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); + ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { bind(file); file.symbolCount = symbolCount; @@ -28356,7 +29236,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -28383,7 +29263,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -28392,7 +29272,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28404,39 +29284,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 295 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 298 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -28536,7 +29419,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28571,7 +29454,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28595,7 +29478,7 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } @@ -28638,7 +29521,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28664,34 +29547,35 @@ var ts; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isIIFE) { - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; hasExplicitReturn = false; - flowNodeCreated = ts.identity; + flowNodeCreated = initFlowNode; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28708,7 +29592,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28735,8 +29619,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28768,80 +29652,90 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28852,30 +29746,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && - isNarrowableReference(expr.expression); + ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || + ts.isOptionalChain(expr); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -28886,7 +29779,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28900,17 +29793,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28919,11 +29812,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28932,20 +29825,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28960,31 +29847,35 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if ((expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -28999,47 +29890,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -29067,7 +29963,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -29099,15 +29995,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -29129,7 +30025,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -29149,7 +30045,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -29177,7 +30073,7 @@ var ts; // as possible antecedents of the start of the `catch` or `finally` blocks. // Don't bother intercepting the call if there's no finally or catch block that needs the information if (node.catchClause || node.finallyBlock) { - flowNodeCreated = function (node) { return (tryPriors.push(node), node); }; + flowNodeCreated = function (node) { return (tryPriors.push(node), initFlowNode(node)); }; } bind(node.tryBlock); flowNodeCreated = oldFlowNodeCreated; @@ -29241,7 +30137,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = initFlowNode({ flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }); addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -29259,7 +30155,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -29277,9 +30173,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all - // case clauses have unreachable end points (e.g. they all return). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -29307,7 +30204,7 @@ var ts; bind(clause); fallthroughFlow = currentFlow; if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { - errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + clause.fallthroughFlowNode = currentFlow; } } clauses.transformFlags = subtreeTransformFlags | 536870912 /* HasComputedFlags */; @@ -29333,6 +30230,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -29344,14 +30252,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -29362,10 +30270,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -29373,16 +30281,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29390,7 +30298,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29401,7 +30309,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29411,20 +30319,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29438,7 +30346,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29449,7 +30357,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29488,27 +30396,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.kind !== 306 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // an immediately invoked function expression (IIFE). Initialize the flowNode property to - // the current control flow (which includes evaluation of the IIFE arguments). - var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29517,54 +30500,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -29597,45 +30580,45 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 300 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -29662,11 +30645,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29736,7 +30719,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29748,7 +30731,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29780,10 +30763,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29811,7 +30794,7 @@ var ts; var host = ts.getJSDocHost(typeAlias); container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -29819,12 +30802,17 @@ var ts; // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); if (isTopLevel) { - bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; })); + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - container = file; + if (!ts.isExternalOrCommonJsModule(file)) { + container = undefined; + } + else { + container = file; + } break; case 4 /* ThisProperty */: container = declName.parent.expression; @@ -29838,11 +30826,13 @@ var ts; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + if (container) { + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -29860,11 +30850,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */) && - !(node.flags & 2097152 /* JSDoc */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29898,7 +30888,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -29909,7 +30899,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29950,8 +30940,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -29977,7 +30967,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -30046,7 +31036,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -30086,8 +31076,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -30108,7 +31098,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -30121,27 +31111,28 @@ var ts; break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -30169,76 +31160,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 307 /* JSDocClassTag */: + return bindJSDocClassTag(node); + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -30257,65 +31250,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 307 /* JSDocParameterTag */: - if (node.parent.kind === 300 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 299 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 313 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30423,8 +31416,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30434,7 +31426,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30453,41 +31445,53 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + setValueDeclaration(symbol, node); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } - if (constructorSymbol) { + if (constructorSymbol && constructorSymbol.valueDeclaration) { // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -30500,11 +31504,21 @@ var ts; ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30517,11 +31531,14 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + if (namespaceSymbol) { + // Ensure the namespace symbol becomes class-like + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } /** @@ -30537,32 +31554,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30571,9 +31594,9 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; @@ -30590,6 +31613,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30600,20 +31626,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30642,7 +31695,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30659,7 +31712,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30671,7 +31724,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30682,7 +31735,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { + if (node.kind === 244 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -30745,10 +31798,10 @@ var ts; } } function bindParameter(node) { - if (node.kind === 307 /* JSDocParameterTag */ && container.kind !== 300 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30767,9 +31820,9 @@ var ts; } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); @@ -30782,9 +31835,9 @@ var ts; } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30795,8 +31848,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30822,7 +31875,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -30850,11 +31903,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30868,7 +31921,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30898,12 +31951,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30915,7 +31968,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30952,58 +32005,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -31014,6 +32067,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -31025,7 +32081,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31048,17 +32104,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -31101,8 +32160,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31142,11 +32201,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -31337,9 +32396,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31349,9 +32411,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31439,43 +32504,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31483,11 +32548,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31504,103 +32569,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31613,26 +32678,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31650,67 +32715,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31729,7 +32794,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31802,7 +32867,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31885,7 +32950,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -32039,6 +33104,7 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 7] = "ResolvedTypeArguments"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var CheckMode; (function (CheckMode) { @@ -32049,11 +33115,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); var AccessFlags; (function (AccessFlags) { AccessFlags[AccessFlags["None"] = 0] = "None"; @@ -32156,11 +33217,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -32242,8 +33301,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -32309,9 +33371,9 @@ var ts; }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (nodeIn) { + getContextualType: function (nodeIn, contextFlags) { var node = ts.getParseTreeNode(nodeIn, ts.isExpression); - return node ? getContextualType(node) : undefined; + return node ? getContextualType(node, contextFlags) : undefined; }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); @@ -32360,7 +33422,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -32376,6 +33438,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -32394,6 +33459,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -32422,7 +33488,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -32486,6 +33552,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -32515,6 +33582,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -32538,11 +33606,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var iterationTypesCache = ts.createMap(); // cache for common IterationTypes instances var noIterationTypes = { @@ -32635,6 +33703,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32647,13 +33718,13 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -32689,10 +33760,10 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { - return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; + return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText; } } } @@ -32702,7 +33773,7 @@ var ts; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); if (_jsxFactoryEntity) { - _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).escapedText; + _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText; } } else if (compilerOptions.reactNamespace) { @@ -32746,7 +33817,7 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32831,7 +33902,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32960,7 +34035,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32970,7 +34045,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -33019,7 +34094,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -33063,7 +34138,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -33077,17 +34152,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -33110,22 +34185,22 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -33146,16 +34221,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -33176,14 +34251,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -33229,12 +34304,12 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 298 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -33251,13 +34326,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -33272,14 +34347,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -33303,7 +34378,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -33317,12 +34392,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -33339,9 +34414,9 @@ var ts; } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! @@ -33360,7 +34435,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -33368,9 +34443,9 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -33388,9 +34463,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -33398,24 +34473,24 @@ var ts; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -33428,7 +34503,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -33437,7 +34512,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33452,25 +34527,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33490,7 +34565,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33563,7 +34638,7 @@ var ts; } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); @@ -33586,10 +34661,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33602,12 +34677,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33619,7 +34694,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 154 /* TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -33674,10 +34749,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33765,11 +34840,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 244 /* EnumDeclaration */); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33801,13 +34880,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33817,7 +34896,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33882,7 +34961,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33894,7 +34978,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33948,9 +35032,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33985,7 +35070,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -34005,34 +35095,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -34112,17 +35224,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 249 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -34138,17 +35250,17 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { - var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); + if (name.kind === 75 /* Identifier */) { + var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); if (!symbol) { return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -34200,7 +35312,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -34239,6 +35351,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -34250,9 +35376,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -34283,7 +35406,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -34354,7 +35477,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -34363,9 +35486,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -34373,15 +35500,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34455,7 +35583,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34592,7 +35720,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34601,7 +35730,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34609,7 +35749,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34617,20 +35757,29 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { @@ -34643,7 +35792,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34721,25 +35870,55 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals + // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would + // trigger resolving late-bound names, which we may already be in the process of doing while we're here! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } @@ -34776,12 +35955,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34798,7 +35977,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34834,7 +36013,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34849,10 +36028,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34969,14 +36148,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -35019,14 +36198,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -35035,7 +36214,7 @@ var ts; // Type Reference or TypeAlias entity = Identifier meaning = 788968 /* Type */; } - var firstIdentifier = getFirstIdentifier(entityName); + var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { @@ -35075,15 +36254,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -35106,14 +36285,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -35144,6 +36326,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -35154,7 +36339,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -35182,26 +36368,26 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -35221,7 +36407,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -35242,31 +36428,31 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -35280,10 +36466,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -35291,6 +36483,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -35301,12 +36494,6 @@ var ts; ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -35314,7 +36501,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -35378,17 +36565,14 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 111551 /* Value */); @@ -35405,24 +36589,7 @@ var ts; } } else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -35435,15 +36602,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35456,12 +36653,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35474,7 +36671,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35482,7 +36679,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35496,12 +36693,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35596,11 +36793,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35647,7 +36844,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35658,25 +36855,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35687,20 +36888,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35741,7 +36952,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35754,7 +36965,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35765,7 +36976,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35773,23 +36984,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -35809,9 +37023,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 307 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35821,15 +37035,14 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35839,22 +37052,22 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); + var firstIdentifier = ts.getFirstIdentifier(accessExpression); var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); @@ -35862,6 +37075,9 @@ var ts; } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35894,6 +37110,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35974,7 +37197,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -36066,16 +37289,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -36108,6 +37347,9 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -36153,9 +37395,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -36164,6 +37403,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -36191,12 +37433,1104 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + ts.forEachEntry(symbolTable, function (symbol, name) { + var baseName = ts.unescapeLeadingUnderscores(name); + void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` + }); + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && + symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && + symbol.escapedName !== "export=" /* ExportEquals */; + var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); + if (symbol.flags & 16 /* Function */ || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */) + && !isConstMergedWithNSPrintableAsSignatureMerge) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + if (ts.some(symbol.declarations, ts.isParameterDeclaration)) + return; + ts.Debug.assertDefined(deferredPrivates); + getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol); // Call to cache unique name for symbol + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function getNamespaceMembersForSerialization(symbol) { + return !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + } + function isTypeOnlyNamespace(symbol) { + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = getNamespaceMembersForSerialization(symbol); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s); + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + includePrivateSymbol(target || s); + var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName; + return ts.createExportSpecifier(name === targetName ? undefined : targetName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), + // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned + // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag + // In such cases, the `target` refers to the module itself already + ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + case 193 /* PropertyAccessExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + // If the target resolves and resolves to a thing defined in this file, emit as an alias, otherwise emit as a const + if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = ts.getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (symbol) { + input = getNameCandidateWorker(symbol, input); + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getNameCandidateWorker(symbol, localName) { + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; + } + if (localName === "default" /* Default */) { + localName = "_default"; + } + else if (localName === "export=" /* ExportEquals */) { + localName = "_exports"; + } + localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); + return localName; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + localName = getNameCandidateWorker(symbol, localName); + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -36241,8 +38575,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -36250,11 +38584,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -36292,9 +38626,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -36307,17 +38641,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -36334,28 +38671,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -36363,53 +38700,54 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -36418,14 +38756,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { + else if (node.parent.kind === 261 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -36442,9 +38783,11 @@ var ts; if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); + var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36504,6 +38847,8 @@ var ts; return !!target.immediateBaseConstraint; case 6 /* JSDocTypeReference */: return !!getSymbolLinks(target).resolvedJSDocType; + case 7 /* ResolvedTypeArguments */: + return !!target.resolvedTypeArguments; } return ts.Debug.assertNever(propertyName); } @@ -36519,12 +38864,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36557,7 +38902,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36609,7 +38954,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36624,23 +38969,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36658,11 +39003,11 @@ var ts; return parentType; } // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36730,30 +39075,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -36772,8 +39117,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36786,11 +39131,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36857,12 +39202,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36880,6 +39227,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36905,9 +39255,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -37000,9 +39350,9 @@ var ts; var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -37077,7 +39427,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -37100,7 +39450,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -37139,7 +39489,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -37195,22 +39545,26 @@ var ts; // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -37251,12 +39605,15 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -37265,7 +39622,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -37292,33 +39649,43 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { @@ -37328,25 +39695,21 @@ var ts; } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + } } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -37354,19 +39717,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -37378,8 +39732,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -37446,7 +39801,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37527,40 +39882,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: - case 305 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37568,7 +39933,8 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); + ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37577,9 +39943,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37598,19 +39965,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37703,24 +40070,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37758,14 +40119,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37773,7 +40141,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37809,8 +40177,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37831,9 +40199,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37849,7 +40223,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37891,10 +40265,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37902,18 +40276,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37927,10 +40302,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37954,7 +40329,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -38026,23 +40401,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -38068,7 +40443,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -38084,14 +40459,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -38146,9 +40521,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -38242,7 +40620,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -38258,9 +40637,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -38301,6 +40680,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -38311,7 +40705,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -38341,7 +40735,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -38404,12 +40798,12 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } - function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { - var sig = new Signature(checker); + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) { + var sig = new Signature(checker, flags); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; @@ -38417,15 +40811,13 @@ var ts; sig.resolvedReturnType = resolvedReturnType; sig.resolvedTypePredicate = resolvedTypePredicate; sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasLiteralTypes = hasLiteralTypes; sig.target = undefined; sig.mapper = undefined; return sig; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; return result; @@ -38437,13 +40829,22 @@ var ts; result.mapper = undefined; return result; } + function getOptionalCallSignature(signature) { + return signatureIsOptionalCall(signature) ? signature : + (signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature))); + } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.flags |= 4 /* IsOptionalCall */; + return result; + } function getExpandedParameters(sig) { - if (sig.hasRestParameter) { + if (signatureHasRestParameter(sig)) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38463,7 +40864,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38560,7 +40961,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38572,8 +40973,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38627,11 +41028,9 @@ var ts; var params = combineUnionParameters(left, right); var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter); var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); - var hasRestParam = left.hasRestParameter || right.hasRestParameter; - var hasLiteralTypes = left.hasLiteralTypes || right.hasLiteralTypes; var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, hasRestParam, hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 3 /* PropagatingFlags */); result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); return result; } @@ -38698,7 +41097,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38721,19 +41120,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38741,7 +41140,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38797,14 +41196,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38947,8 +41350,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38972,8 +41375,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -39189,11 +41592,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; if (t.flags & 63176704 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). @@ -39203,6 +41606,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -39215,8 +41621,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -39302,8 +41708,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39651,10 +42057,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39688,13 +42094,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; - } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39740,7 +42143,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var hasLiteralTypes = false; + var flags = 0 /* None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -39770,8 +42173,8 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { - hasLiteralTypes = true; + if (type && type.kind === 186 /* LiteralType */) { + flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -39784,22 +42187,24 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); - var hasRestLikeParameter = ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters); + if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { + flags |= 1 /* HasRestParameter */; + } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, - /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, hasRestLikeParameter, hasLiteralTypes); + /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); } return links.resolvedSignature; } @@ -39851,13 +42256,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39900,9 +42305,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39931,13 +42333,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39947,8 +42346,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signatureIsOptionalCall(signature)) { + type = addOptionalTypeMarker(type); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39973,7 +42374,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39983,12 +42384,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -40003,7 +42404,7 @@ var ts; return tryGetRestTypeOfSignature(signature) || anyType; } function tryGetRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType; return restType && getIndexTypeOfType(restType, 1 /* Number */); @@ -40078,7 +42479,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -40092,7 +42493,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -40126,13 +42527,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -40157,7 +42558,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -40181,7 +42582,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -40214,8 +42615,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -40230,7 +42631,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -40239,16 +42640,50 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; + return type; + } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; return type; } + function getTypeArguments(type) { + var _a, _b; + if (!type.resolvedTypeArguments) { + if (!pushTypeResolution(type, 7 /* ResolvedTypeArguments */)) { + return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; + } + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + if (popTypeResolution()) { + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + else { + type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray; + error(type.node || currentNode, type.target.symbol + ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves + : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol)); + } + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -40258,13 +42693,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -40272,10 +42707,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -40296,27 +42734,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -40334,13 +42772,15 @@ var ts; return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -40349,56 +42789,44 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSDocValueReference(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value, but resolve it as a type anyway. + * Note: If the value is imported from commonjs, it should really be an alias, + * but this function's special-case code fakes alias resolution as well. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + function getTypeFromJSDocValueReference(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType; + if (symbol.valueDeclaration) { + var decl = ts.getRootDeclaration(symbol.valueDeclaration); + var isRequireAlias = false; + if (ts.isVariableDeclaration(decl) && decl.initializer) { + var expr = decl.initializer; + // skip past entity names, eg `require("x").a.b.c` + while (ts.isPropertyAccessExpression(expr)) { + expr = expr.expression; } + isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol; } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); + var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol; + if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) { + typeType = getTypeReferenceType(node, valueType.symbol); } } + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } function getSubstitutionType(typeVariable, substitute) { if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === typeVariable) { @@ -40416,7 +42844,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -40425,9 +42853,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 298 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40438,7 +42866,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40475,10 +42903,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40490,7 +42918,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40548,9 +42976,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40669,15 +43097,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40714,7 +43182,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40748,27 +43216,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; - var elementTypes = ts.map(node.elementTypes, function (n) { - var type = getTypeFromTypeNode(n); - return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40817,8 +43271,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40847,8 +43301,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40933,10 +43387,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40955,14 +43409,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -41029,8 +43479,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -41305,21 +43755,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - // tslint:disable no-unnecessary-type-assertion - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -41355,7 +43806,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -41366,13 +43817,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41503,13 +43954,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41634,7 +44082,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41846,7 +44294,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41869,11 +44317,11 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { var errorMessage = targetMeaning === 111551 /* Value */ @@ -41885,16 +44333,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; if (meaning === 111551 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41918,7 +44366,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 137 /* ReadonlyKeyword */) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -42107,12 +44559,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -42125,89 +44591,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -42296,20 +44762,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -42329,7 +44782,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 3 /* PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -42363,17 +44816,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -42389,7 +44842,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -42402,13 +44855,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -42416,9 +44870,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 184 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -42427,7 +44881,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -42436,12 +44890,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42495,7 +44949,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42591,15 +45045,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42663,35 +45120,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42711,7 +45168,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -42723,7 +45180,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42826,23 +45283,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -43014,7 +45471,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -43023,9 +45480,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -43167,11 +45624,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -43206,20 +45663,20 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` */ function isAnySignature(s) { return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 && - s.hasRestParameter && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && + signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && isTypeAny(getReturnTypeOfSignature(s)); } /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -43243,8 +45700,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -43277,11 +45734,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is - compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -43292,15 +45749,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol)) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol)) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43321,6 +45780,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -43333,7 +45795,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -43342,7 +45804,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -43388,12 +45852,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -43404,7 +45868,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43481,9 +45945,9 @@ var ts; return true; } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, relation)); + var related = relation.get(getRelationKey(source, target, /*isIntersectionConstituent*/ false, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43515,9 +45979,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43560,8 +46029,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43574,6 +46166,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43592,8 +46186,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43715,14 +46309,14 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); var isIntersectionConstituent = !!isApparentIntersectionConstituent; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { @@ -43760,15 +46354,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -43778,21 +46372,30 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43812,6 +46415,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43848,7 +46452,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43863,6 +46467,11 @@ var ts; // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43891,9 +46500,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -44029,14 +46638,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { + function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); if (related) { return related; } @@ -44115,17 +46724,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -44135,25 +46733,25 @@ var ts; if (overflow) { return 0 /* False */; } - var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var id = getRelationKey(source, target, isIntersectionConstituent, relation); + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -44184,14 +46782,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -44199,7 +46809,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -44239,7 +46849,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. @@ -44329,7 +46939,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44340,7 +46950,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44349,25 +46959,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44376,13 +46986,23 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44391,14 +47011,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44412,7 +47032,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44431,7 +47051,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -44458,7 +47078,7 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); @@ -44473,7 +47093,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44504,7 +47124,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44532,7 +47152,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44608,11 +47228,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44628,8 +47248,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44642,9 +47262,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -44769,7 +47389,7 @@ var ts; var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44809,8 +47429,8 @@ var ts; if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44820,8 +47440,8 @@ var ts; else { reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44833,7 +47453,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44858,8 +47478,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44873,10 +47494,12 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { @@ -44941,14 +47564,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44962,7 +47586,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44971,10 +47595,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44987,11 +47611,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -45057,7 +47693,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -45189,7 +47825,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -45221,7 +47857,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -45247,8 +47883,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -45257,7 +47896,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -45280,17 +47919,18 @@ var ts; * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. * For other cases, the types ids are used. */ - function getRelationKey(source, target, relation) { + function getRelationKey(source, target, isIntersectionConstituent, relation) { if (relation === identityRelation && source.id > target.id) { var temp = source; source = target; target = temp; } + var intersection = isIntersectionConstituent ? "&" : ""; if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { var typeParameters = []; - return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + intersection; } - return source.id + "," + target.id; + return source.id + "," + target.id + intersection; } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. @@ -45486,20 +48126,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45538,7 +48180,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45546,7 +48188,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45630,7 +48272,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45645,8 +48287,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45711,6 +48353,23 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function isNotOptionalTypeMarker(type) { + return type !== optionalType; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function getOptionalExpressionType(exprType, expression) { + return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) : + ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : + exprType; + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45740,8 +48399,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45893,7 +48552,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45930,7 +48589,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45960,12 +48619,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -45980,23 +48639,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -46010,7 +48669,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -46052,8 +48711,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -46122,6 +48780,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -46131,7 +48795,7 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); @@ -46200,10 +48864,10 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames); @@ -46339,10 +49003,7 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; - inferFromTypes(source, target); - priority = savePriority; + inferWithPriority(source, target, 1 /* NakedTypeVariable */); return; } source = getUnionType(sources); @@ -46429,9 +49090,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -46441,10 +49103,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - var savePriority = priority; - priority |= 32 /* LiteralKeyof */; - inferFromTypes(empty, target.type); - priority = savePriority; + inferWithPriority(empty, target.type, 32 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -46496,6 +49155,12 @@ var ts; } } } + function inferWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromTypes(source, target); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -46561,6 +49226,18 @@ var ts; } return undefined; } + function getSingleTypeVariableFromIntersectionTypes(types) { + var typeVariable; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var type = types_13[_i]; + var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + if (!t || typeVariable && t !== typeVariable) { + return undefined; + } + typeVariable = t; + } + return typeVariable; + } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; if (targetFlags & 1048576 /* Union */) { @@ -46590,6 +49267,16 @@ var ts; } } } + if (typeVariableCount === 0) { + // If every target is an intersection of types containing a single naked type variable, + // make a lower priority inference to that type variable. This handles inferring from + // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. + var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); + if (intersectionTypeVariable) { + inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + } + return; + } // If the target has a single naked type variable and no inference circularities were // encountered above (meaning we explored the types fully), create a union of the source // types from which no inferences have been made so far and infer from that union to the @@ -46621,15 +49308,12 @@ var ts; // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferFromTypes(source, t); + inferWithPriority(source, t, 1 /* NakedTypeVariable */); } } - priority = savePriority; } } function inferToMappedType(source, target, constraintType) { @@ -46650,14 +49334,12 @@ var ts; if (inference && !inference.isFixed) { var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); if (inferredType) { - var savePriority = priority; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - priority |= ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? - 4 /* PartialHomomorphicMappedType */ : 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? + 4 /* PartialHomomorphicMappedType */ : + 2 /* HomomorphicMappedType */); } } return true; @@ -46665,10 +49347,7 @@ var ts; if (constraintType.flags & 262144 /* TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - var savePriority = priority; - priority |= 8 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; + inferWithPriority(getIndexType(source), constraintType, 8 /* MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -46710,6 +49389,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer // from S to T and from X to Y. @@ -46739,10 +49423,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46782,7 +49466,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46952,7 +49636,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46973,7 +49657,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -46983,16 +49667,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -47003,24 +49687,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -47028,8 +49712,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -47041,6 +49725,15 @@ var ts; } return false; } + function optionalChainContainsReference(source, target) { + while (ts.isOptionalChain(source)) { + source = source.expression; + if (isMatchingReference(source, target)) { + return true; + } + } + return false; + } // Return true if target is a property access xxx.yyy, source is a property access xxx.zzz, the declared // type of xxx is a union type, and yyy is a property that is possibly a discriminant. We consider a property // a possible discriminant if its type differs in the constituents of containing union type, and if every @@ -47053,7 +49746,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -47084,7 +49777,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -47112,14 +49805,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -47161,8 +49854,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -47267,15 +49960,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -47292,21 +49985,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -47314,7 +50007,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -47332,37 +50025,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -47372,13 +50060,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -47400,8 +50088,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -47484,8 +50172,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47537,8 +50224,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47561,33 +50248,94 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = void 0; + if (node.parent.kind === 225 /* ExpressionStatement */) { + funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); + } + else if (node.expression.kind !== 101 /* SuperKeyword */) { + if (ts.isOptionalChain(node)) { + funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); + } + else { + funcType = checkNonNullExpression(node.expression); + } + } + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + } + function getTypePredicateArgument(predicate, callExpression) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + return callExpression.arguments[predicate.parameterIndex]; + } + var invokedExpression = ts.skipParentheses(callExpression.expression); + return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined; } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47595,6 +50343,82 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isFalseExpression(expr) { + var node = ts.skipParentheses(expr); + return node.kind === 90 /* FalseKeyword */ || node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && predicate.kind === 3 /* AssertsIdentifier */) { + var predicateArgument = flow.node.arguments[predicate.parameterIndex]; + if (predicateArgument && isFalseExpression(predicateArgument)) { + return false; + } + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47606,6 +50430,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47614,7 +50439,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47636,16 +50461,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47657,13 +50473,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47675,14 +50491,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47709,11 +50523,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47725,7 +50539,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47735,11 +50549,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47748,11 +50585,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47761,27 +50598,63 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 90 /* FalseKeyword */) { + return unreachableNeverType; + } + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47789,7 +50662,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47824,7 +50697,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47839,14 +50712,27 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); - } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (containsMatchingReferenceDiscriminant(reference, expr)) { - type = declaredType; + else { + if (strictNullChecks) { + if (optionalChainContainsReference(expr, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + } + else if (expr.kind === 203 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + } + } + if (isMatchingReferenceDiscriminant(expr, type)) { + type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + } + else if (containsMatchingReferenceDiscriminant(reference, expr)) { + type = declaredType; + } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } } return createFlowType(type, isIncomplete(flowType)); } @@ -47856,7 +50742,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47916,25 +50802,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47981,6 +50874,9 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } + if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { + type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } if (isMatchingReferenceDiscriminant(expr, declaredType)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } @@ -48008,19 +50904,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -48029,6 +50925,14 @@ var ts; if (isMatchingReference(reference, right_1)) { return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); } + if (strictNullChecks) { + if (optionalChainContainsReference(left_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + } + else if (optionalChainContainsReference(right_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + } + } if (isMatchingReferenceDiscriminant(left_1, declaredType)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } @@ -48039,9 +50943,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -48052,15 +50956,24 @@ var ts; } return type; } + function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { + // We are in a branch of obj?.foo === value or obj?.foo !== value. We remove undefined and null from + // the type of obj if (a) the operator is === and the type of value doesn't include undefined or (b) the + // operator is !== and the type of value is undefined. + var effectiveTrue = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */ ? assumeTrue : !assumeTrue; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var valueNonNullish = !(getTypeFacts(getTypeOfExpression(value)) & (doubleEquals ? 262144 /* EQUndefinedOrNull */ : 65536 /* EQUndefined */)); + return effectiveTrue === valueNonNullish ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeByEquality(type, operator, value, assumeTrue) { if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -48073,7 +50986,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -48085,7 +50998,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -48098,9 +51011,15 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + assumeTrue = !assumeTrue; + } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { + if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the // narrowed type of 'y' to its declared type. if (containsMatchingReference(reference, target)) { @@ -48108,9 +51027,6 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { - assumeTrue = !assumeTrue; - } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } @@ -48143,6 +51059,10 @@ var ts; return type; } } + function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { + var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify // values with unit types, except for the case where @@ -48275,6 +51195,9 @@ var ts; function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { + if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the // narrowed type of 'y' to its declared type. We do this because preceding 'x.y' // references might reference a different 'y' property. However, we make an exception @@ -48335,38 +51258,29 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' - if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { - return type; - } - if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) { + var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } - if (containsMatchingReference(reference, predicateArgument)) { - return declaredType; - } - } - } - else { - var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { - var possibleReference = ts.skipParentheses(invokedExpression.expression); - if (isMatchingReference(reference, possibleReference)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && + !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (containsMatchingReference(reference, possibleReference)) { + if (containsMatchingReference(reference, predicateArgument)) { return declaredType; } } @@ -48376,27 +51290,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isExpressionOfOptionalChainRoot(expr) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -48404,7 +51335,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -48425,9 +51356,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -48446,10 +51377,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -48464,7 +51395,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -48472,10 +51403,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48512,7 +51443,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -48533,7 +51464,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48545,14 +51476,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48601,7 +51532,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48610,8 +51541,8 @@ var ts; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48619,11 +51550,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48657,7 +51588,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48680,7 +51611,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48698,8 +51629,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48717,7 +51648,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48725,9 +51656,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48738,7 +51669,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48806,37 +51737,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 158 /* Constructor */: + case 161 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48875,10 +51806,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48886,12 +51815,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48920,9 +51847,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48932,16 +51872,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48949,7 +51889,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -48974,7 +51914,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48988,15 +51928,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -49009,14 +51949,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -49024,7 +51964,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -49093,7 +52033,7 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -49107,7 +52047,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -49128,7 +52068,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; @@ -49143,7 +52083,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -49151,21 +52091,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -49173,14 +52113,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -49188,7 +52128,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -49215,7 +52155,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -49229,9 +52169,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -49295,9 +52235,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -49412,22 +52352,26 @@ var ts; return undefined; } // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. - function getContextualTypeForArgument(callTarget, arg) { + function getContextualTypeForArgument(callTarget, arg, contextFlags) { var args = getEffectiveCallArguments(callTarget); var argIndex = args.indexOf(arg); // -1 for e.g. the expression of a CallExpression, or the tag of a TaggedTemplateExpression - return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); + return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags); } - function getContextualTypeForArgumentAtIndex(callTarget, argIndex) { + function getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags) { // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } + if (contextFlags && contextFlags & 4 /* Completion */ && signature.target) { + var baseSignature = getBaseSignature(signature.target); + return intersectTypes(getTypeAtPosition(signature, argIndex), getTypeAtPosition(baseSignature, argIndex)); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -49436,7 +52380,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -49445,7 +52389,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -49454,7 +52399,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -49482,7 +52427,7 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); @@ -49493,8 +52438,11 @@ var ts; if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49516,12 +52464,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49565,7 +52514,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49654,25 +52603,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 279 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 271 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -49681,7 +52630,7 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { @@ -49749,7 +52698,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49758,58 +52707,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: - return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* NewExpression */: + return getContextualTypeForArgument(parent, node, contextFlags); + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49964,7 +52913,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49978,7 +52927,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -49992,8 +52941,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -50023,8 +52972,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -50036,7 +52985,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -50061,12 +53010,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -50108,9 +53057,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -50198,7 +53147,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -50213,13 +53162,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -50242,8 +53191,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -50268,7 +53217,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -50294,7 +53243,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -50354,7 +53303,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -50402,7 +53357,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -50447,7 +53402,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -50470,7 +53425,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -50889,7 +53844,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50984,32 +53939,43 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); } - function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + function checkNonNullExpression(node) { + return checkNonNullType(checkExpression(node), node); + } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; + } + function reportObjectPossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); } - function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); + } + function checkNonNullTypeWithReporter(type, node, reportError) { if (strictNullChecks && type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? - (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : - (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : - (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); + reportError(node, kind); var t = getNonNullableType(type); return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } + function checkNonNullType(type, node) { + return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError); + } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); if (nonNullType !== errorType && nonNullType.flags & 16384 /* Void */) { @@ -51018,20 +53984,24 @@ var ts; return nonNullType; } function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + } + function checkPropertyAccessChain(node) { + var leftType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(leftType, node.expression); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType); } function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -51045,6 +54015,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -51072,9 +54043,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -51090,7 +54061,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -51100,11 +54071,11 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -51135,9 +54106,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -51148,22 +54119,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -51203,7 +54174,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -51336,16 +54307,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -51362,13 +54333,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -51385,13 +54356,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -51405,28 +54376,22 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + } + function checkElementAccessChain(node) { + var exprType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(exprType, node.expression); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType); + } + function checkElementAccessExpression(node, exprType) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -51481,13 +54446,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51506,7 +54471,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51514,8 +54479,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51536,7 +54501,7 @@ var ts; lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless // of the cutoff position; see GH#1133 - if (signature.hasLiteralTypes) { + if (signatureHasLiteralTypes(signature)) { specializedIndex++; spliceIndex = specializedIndex; // The cutoff index always needs to be greater than or equal to the specialized signature index @@ -51547,11 +54512,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51565,9 +54530,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -51582,7 +54547,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51597,7 +54562,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51690,7 +54655,7 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51720,7 +54685,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51733,7 +54698,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51757,7 +54722,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51837,12 +54802,24 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + var thisArgumentType = void 0; + if (thisArgumentNode) { + thisArgumentType = checkExpression(thisArgumentNode); + if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { + thisArgumentType = getNonNullableType(thisArgumentType); + } + else if (ts.isOptionalChain(thisArgumentNode.parent)) { + thisArgumentType = removeOptionalTypeMarker(thisArgumentType); + } + } + else { + thisArgumentType = voidType; + } var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -51855,7 +54832,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51896,15 +54873,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51914,17 +54891,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51939,7 +54916,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51954,30 +54931,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 152 /* Parameter */: + case 155 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51991,17 +54968,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -52039,8 +55016,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -52069,7 +55046,7 @@ var ts; if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(getFirstIdentifier(paramDecl.name)) : undefined); + related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); } } if (min < argCount && argCount < max) { @@ -52109,8 +55086,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -52125,22 +55102,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -52189,7 +55166,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -52242,7 +55219,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -52260,7 +55237,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -52394,35 +55371,35 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { - var symbols = ts.mapDefined(candidates, function (_a) { - var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; - return hasRestParameter ? - i < parameters.length - 1 ? parameters[i] : ts.last(parameters) : - i < parameters.length ? parameters[i] : undefined; - }); + var _loop_15 = function (i) { + var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? + i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : + i < s.parameters.length ? s.parameters[i] : undefined; }); ts.Debug.assert(symbols.length !== 0); parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } - var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); - var hasRestParameter = restParameterSymbols.length !== 0; - if (hasRestParameter) { + var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); + var flags = 0 /* None */; + if (restParameterSymbols.length !== 0) { var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); + flags |= 1 /* HasRestParameter */; + } + if (candidates.some(signatureHasLiteralTypes)) { + flags |= 2 /* HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. thisParameter, parameters, /*resolvedReturnType*/ getIntersectionType(candidates.map(getReturnTypeOfSignature)), - /*typePredicate*/ undefined, minArgumentCount, hasRestParameter, - /*hasLiteralTypes*/ candidates.some(function (c) { return c.hasLiteralTypes; })); + /*typePredicate*/ undefined, minArgumentCount, flags); } function getNumNonRestParameters(signature) { var numParams = signature.parameters.length; - return signature.hasRestParameter ? numParams - 1 : numParams; + return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); @@ -52483,7 +55460,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -52498,12 +55475,22 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var isOptional; + var funcType = checkExpression(node.expression); + if (ts.isCallChain(node)) { + var nonOptionalType = getOptionalExpressionType(funcType, node.expression); + isOptional = nonOptionalType !== funcType; + funcType = nonOptionalType; + } + else { + isOptional = false; + } + funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52569,7 +55556,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52632,7 +55619,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52640,7 +55627,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52725,8 +55712,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var constituent = types_14[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var constituent = types_17[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52817,23 +55804,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52870,7 +55857,7 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); @@ -52879,15 +55866,13 @@ var ts; // file would probably be preferable. var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, - /*hasRestparameter*/ false, - /*hasLiteralTypes*/ false); + /*returnTypePredicate*/ undefined, 1, 0 /* None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -52910,7 +55895,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52920,22 +55905,22 @@ var ts; function isPotentiallyUncalledDecorator(decorator, signatures) { return signatures.length && ts.every(signatures, function (signature) { return signature.minArgumentCount === 0 && - !signature.hasRestParameter && + !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52986,57 +55971,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -53051,15 +56031,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -53079,18 +56059,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -53128,7 +56118,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -53176,19 +56166,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -53203,20 +56194,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -53252,10 +56243,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -53266,7 +56257,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -53280,7 +56271,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -53295,7 +56286,7 @@ var ts; return type; } function getParameterNameAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return signature.parameters[pos].escapedName; } @@ -53312,17 +56303,17 @@ var ts; return tryGetTypeAtPosition(signature, pos) || anyType; } function tryGetTypeAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return getTypeOfParameter(signature.parameters[pos]); } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // We want to return the value undefined for an out of bounds parameter position, // so we need to check bounds here before calling getIndexedAccessType (which // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -53351,16 +56342,16 @@ var ts; } function getParameterCount(signature) { var length = signature.parameters.length; - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; } function getMinArgumentCount(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { var minLength = restType.target.minLength; @@ -53372,14 +56363,14 @@ var ts; return signature.minArgumentCount; } function hasEffectiveRestParameter(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return !isTupleType(restType) || restType.target.hasRestElement; } return false; } function getEffectiveRestType(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType; } @@ -53396,7 +56387,7 @@ var ts; return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType; } function inferFromAnnotatedParameters(signature, context, inferenceContext) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -53429,7 +56420,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter)); } } - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53437,7 +56428,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53452,7 +56443,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -53466,7 +56457,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); @@ -53521,7 +56512,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53704,10 +56695,11 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); @@ -53727,13 +56719,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53773,11 +56759,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53803,10 +56789,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53836,7 +56822,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53847,7 +56833,7 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); returnOnlyType.objectFlags |= 1048576 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; @@ -53856,7 +56842,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53910,7 +56896,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53923,7 +56909,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -54004,11 +56990,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -54021,31 +57007,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -54067,14 +57057,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -54101,14 +57091,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -54116,32 +57106,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54155,7 +57145,7 @@ var ts; var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54176,8 +57166,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -54266,7 +57256,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -54279,9 +57269,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -54324,8 +57314,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -54343,7 +57333,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -54359,7 +57349,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -54375,24 +57365,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - if (checkReferenceExpression(target, error)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -54408,53 +57401,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -54466,15 +57459,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -54482,28 +57487,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54530,17 +57535,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54548,8 +57553,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54582,24 +57587,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54608,25 +57613,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54653,6 +57662,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54670,7 +57682,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54685,15 +57697,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54706,7 +57718,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54740,17 +57752,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; + } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54758,12 +57776,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54772,6 +57790,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54790,7 +57819,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54861,7 +57890,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -54900,12 +57929,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54927,10 +57956,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54982,7 +58011,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54993,7 +58022,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -55005,8 +58034,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -55136,11 +58165,22 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var isOptional = void 0; + var funcType = void 0; + if (ts.isCallChain(expr)) { + funcType = checkExpression(expr.expression); + var nonOptionalType = getOptionalExpressionType(funcType, expr.expression); + isOptional = funcType !== nonOptionalType; + funcType = checkNonNullType(nonOptionalType, expr.expression); + } + else { + isOptional = false; + funcType = checkNonNullExpression(expr.expression); + } var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -55186,18 +58226,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 258 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // We allow reexporting const enums + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -55215,20 +58255,20 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -55239,82 +58279,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -55351,7 +58391,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -55362,10 +58402,10 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -55389,18 +58429,20 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { if (typePredicate.parameterIndex >= 0) { - if (signature.hasRestParameter && typePredicate.parameterIndex === signature.parameters.length - 1) { + if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -55421,13 +58463,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -55441,11 +58483,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -55454,13 +58496,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -55490,10 +58532,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55523,7 +58565,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -55533,7 +58575,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { @@ -55548,16 +58590,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: addName(names, name, memberName, 8 /* Method */); break; } @@ -55620,7 +58662,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55628,7 +58670,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55645,7 +58687,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -55665,7 +58707,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55673,7 +58715,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55700,7 +58742,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55725,7 +58767,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55753,9 +58795,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55780,9 +58822,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55790,13 +58832,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55814,7 +58856,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55862,19 +58904,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55910,16 +58949,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55940,7 +58979,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -55991,7 +59030,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -56002,16 +59041,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -56101,7 +59140,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -56140,8 +59179,8 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -56152,10 +59191,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -56216,8 +59255,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -56286,41 +59325,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -56354,7 +59394,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -56550,7 +59590,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -56569,7 +59609,7 @@ var ts; return; } // Verify there is no local declaration that could collide with the promise constructor. - var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); @@ -56589,24 +59629,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56626,8 +59666,8 @@ var ts; function markEntityNameOrEntityExpressionAsReference(typeName) { if (!typeName) return; - var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var rootName = ts.getFirstIdentifier(typeName); + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56652,29 +59692,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var typeNode = types_16[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -56720,14 +59760,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56736,23 +59776,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56815,7 +59855,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 149 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56848,9 +59888,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56863,7 +59903,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56879,7 +59919,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56892,7 +59932,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56918,7 +59958,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56934,42 +59974,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56989,11 +60029,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -57002,7 +60042,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -57010,8 +60050,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -57038,7 +60078,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -57073,7 +60113,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -57123,7 +60163,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -57141,7 +60181,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -57162,7 +60202,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -57174,24 +60214,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -57208,7 +60248,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -57221,21 +60261,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -57245,7 +60285,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -57260,7 +60300,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -57286,7 +60326,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57301,7 +60341,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57336,7 +60376,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -57348,17 +60388,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -57388,18 +60428,18 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -57413,26 +60453,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -57469,7 +60509,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -57495,10 +60535,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -57507,7 +60547,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57517,8 +60557,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57555,13 +60595,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57584,12 +60667,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57623,14 +60706,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -57638,7 +60721,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57662,7 +60745,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -57676,7 +60759,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -57684,7 +60767,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -58037,7 +61120,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -58049,7 +61132,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58128,7 +61211,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -58139,7 +61222,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58175,11 +61258,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -58243,11 +61326,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -58340,12 +61425,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -58363,7 +61448,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -58371,7 +61456,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -58392,19 +61477,16 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -58421,6 +61503,9 @@ var ts; } } ts.forEach(clause.statements, checkSourceElement); + if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) { + error(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } }); if (node.caseBlock.locals) { registerForUnusedIdentifiersCheck(node.caseBlock); @@ -58433,7 +61518,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58540,8 +61625,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58618,7 +61703,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58718,7 +61803,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58731,11 +61816,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58773,12 +61859,9 @@ var ts; } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify - // that all instantiated base constructor signatures return the same type. We can simply compare the type - // references (as opposed to checking the structure of the types) because elsewhere we have already checked - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58821,7 +61904,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58840,7 +61923,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58866,7 +61949,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58917,7 +62000,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 210 /* ClassExpression */) { + if (derivedClassDecl.kind === 213 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -58932,17 +62015,55 @@ var ts; // either base or derived property is private - not override, skip it continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment + continue; + } + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; + } + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } + } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + // method is overridden with method or property -- correct case + continue; + } + else { + ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } else if (base.flags & 98304 /* Accessor */) { @@ -58988,12 +62109,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -59008,7 +62132,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -59032,7 +62156,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -59095,7 +62219,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -59127,7 +62251,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -59137,66 +62261,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 50 /* BarToken */: return left | right; - case 49 /* AmpersandToken */: return left & right; - case 47 /* GreaterThanGreaterThanToken */: return left >> right; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 46 /* LessThanLessThanToken */: return left << right; - case 51 /* CaretToken */: return left ^ right; - case 40 /* AsteriskToken */: return left * right; - case 42 /* SlashToken */: return left / right; - case 38 /* PlusToken */: return left + right; - case 39 /* MinusToken */: return left - right; - case 43 /* PercentToken */: return left % right; - case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); - } - } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); + } + } + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -59221,10 +62344,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -59258,7 +62381,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -59281,9 +62404,9 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -59306,7 +62429,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -59345,7 +62468,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -59395,23 +62518,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -59422,12 +62545,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -59446,19 +62569,22 @@ var ts; break; } } - function getFirstIdentifier(node) { + function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -59472,9 +62598,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -59504,20 +62630,21 @@ var ts; // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). + symbol = getMergedSymbol(symbol.exportSymbol || symbol); var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 258 /* ExportSpecifier */ + && node.kind === 261 /* ExportSpecifier */ && !(target.flags & 111551 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59542,7 +62669,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59566,12 +62693,12 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name - var moduleName = getFirstIdentifier(node.moduleReference); + var moduleName = ts.getFirstIdentifier(node.moduleReference); if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } @@ -59582,7 +62709,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59602,10 +62729,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59622,7 +62749,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59638,7 +62765,7 @@ var ts; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { @@ -59655,8 +62782,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59669,7 +62796,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -59689,10 +62816,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59718,9 +62845,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59770,159 +62897,162 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 307 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 299 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -60017,23 +63147,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -60062,7 +63192,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -60148,7 +63278,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -60163,26 +63293,26 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -60191,7 +63321,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -60233,17 +63363,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -60251,16 +63381,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -60288,13 +63418,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -60320,7 +63450,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -60330,7 +63460,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -60338,7 +63468,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -60348,7 +63478,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -60366,7 +63496,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -60382,10 +63512,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 307 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 311 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -60395,19 +63525,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -60417,22 +63547,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -60446,12 +63576,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -60461,11 +63591,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -60477,14 +63607,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -60495,7 +63625,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -60512,21 +63642,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -60538,7 +63668,7 @@ var ts; resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60594,27 +63724,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60653,17 +63783,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60715,7 +63844,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60771,7 +63900,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -60799,7 +63928,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60830,7 +63959,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60871,26 +64000,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60991,15 +64119,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -61084,7 +64212,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -61103,7 +64231,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61111,7 +64239,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61235,12 +64363,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -61253,10 +64381,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -61268,7 +64405,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -61319,7 +64456,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -61347,12 +64484,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -61485,7 +64622,7 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; @@ -61494,7 +64631,7 @@ var ts; var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61541,14 +64678,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -61565,23 +64702,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61595,11 +64732,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61608,7 +64745,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61618,10 +64755,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61630,18 +64767,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61654,52 +64791,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 126 /* DeclareKeyword */: + case 129 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61711,14 +64848,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61726,7 +64863,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61741,13 +64878,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61768,38 +64905,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61811,10 +64948,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61843,7 +64980,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61929,15 +65066,15 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); } - if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -61961,11 +65098,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61995,7 +65138,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -62008,7 +65151,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -62024,14 +65167,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -62042,21 +65185,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -62074,7 +65217,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -62085,21 +65228,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { - // tslint:disable no-unnecessary-type-assertion + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -62114,10 +65257,10 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -62125,13 +65268,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -62168,7 +65311,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -62178,7 +65321,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -62192,14 +65335,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -62210,7 +65353,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -62225,20 +65368,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -62248,7 +65391,7 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 4194304 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */)) { if (languageVersion < 1 /* ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -62263,11 +65406,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 159 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -62289,23 +65432,23 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -62315,13 +65458,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -62330,9 +65473,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -62345,10 +65488,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -62371,17 +65514,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -62392,11 +65535,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -62404,8 +65547,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -62420,13 +65563,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -62449,13 +65592,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -62468,7 +65611,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -62485,8 +65628,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -62498,11 +65641,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -62515,7 +65658,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62532,8 +65675,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62560,15 +65703,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62586,12 +65729,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -62649,7 +65792,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62657,7 +65800,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62665,11 +65808,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62686,13 +65829,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62701,7 +65844,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62710,10 +65853,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -62724,7 +65867,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62746,20 +65889,39 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62795,7 +65957,7 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd); } if (node.typeArguments) { return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); @@ -62819,14 +65981,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62834,21 +65996,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62858,7 +66019,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62867,6 +66027,18 @@ var ts; case 2 /* Next */: return "nextType"; } } + function signatureHasRestParameter(s) { + return !!(s.flags & 1 /* HasRestParameter */); + } + ts.signatureHasRestParameter = signatureHasRestParameter; + function signatureHasLiteralTypes(s) { + return !!(s.flags & 2 /* HasLiteralTypes */); + } + ts.signatureHasLiteralTypes = signatureHasLiteralTypes; + function signatureIsOptionalCall(s) { + return !!(s.flags & 4 /* IsOptionalCall */); + } + ts.signatureIsOptionalCall = signatureIsOptionalCall; })(ts || (ts = {})); var ts; (function (ts) { @@ -62929,6 +66101,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62976,7 +66149,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -63057,23 +66230,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -63084,44 +66257,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -63140,7 +66313,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -63153,7 +66326,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -63169,7 +66342,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -63193,7 +66366,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63206,7 +66379,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -63226,12 +66399,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -63241,8 +66414,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -63250,7 +66423,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -63267,7 +66440,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63280,6 +66453,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -63295,7 +66500,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -63315,7 +66520,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63338,7 +66543,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63359,7 +66564,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -63367,7 +66572,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -63375,7 +66580,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -63415,21 +66620,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -63443,7 +66658,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -63451,7 +66666,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -63459,7 +66674,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -63471,7 +66686,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -63483,7 +66698,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -63495,7 +66710,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -63507,7 +66722,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -63519,7 +66734,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63531,7 +66746,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63539,7 +66754,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63558,7 +66773,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63576,7 +66791,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63588,7 +66803,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63606,7 +66821,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63618,12 +66833,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63633,7 +66848,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63647,7 +66862,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63665,7 +66880,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63678,7 +66893,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63690,7 +66905,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63702,7 +66917,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63721,7 +66936,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63735,7 +66950,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63749,7 +66964,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63757,6 +66972,9 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + if (ts.isOptionalChain(node)) { + return updatePropertyAccessChain(node, expression, node.questionDotToken, name); + } // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63765,22 +66983,64 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + if (ts.isOptionalChain(node)) { + return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression); + } return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63788,6 +67048,9 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + if (ts.isOptionalChain(node)) { + return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray); + } return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63795,8 +67058,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63812,7 +67095,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63835,7 +67118,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63849,7 +67132,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63861,7 +67144,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63885,12 +67168,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63907,7 +67190,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63919,7 +67202,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63931,7 +67214,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63943,7 +67226,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63955,7 +67238,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63968,7 +67251,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63981,7 +67264,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63998,11 +67281,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -64018,7 +67301,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -64042,11 +67325,9 @@ var ts; rawTextScanner.setText("`" + rawText + "`"); break; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; case 17 /* TemplateTail */: @@ -64117,9 +67398,9 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -64131,7 +67412,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64143,7 +67424,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64164,11 +67445,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -64182,7 +67463,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -64196,7 +67477,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -64208,7 +67489,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -64222,7 +67503,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -64236,12 +67517,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -64255,7 +67536,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -64270,11 +67551,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -64290,7 +67571,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -64306,7 +67587,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -64320,7 +67601,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64334,7 +67615,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -64352,7 +67633,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -64368,10 +67649,10 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; - node.expression = expression; + node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression; node.statement = asEmbeddedStatement(statement); return node; } @@ -64386,7 +67667,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -64398,7 +67679,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -64410,7 +67691,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -64422,7 +67703,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64436,7 +67717,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -64450,7 +67731,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -64464,7 +67745,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -64476,7 +67757,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -64492,11 +67773,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -64513,7 +67794,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -64526,7 +67807,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -64552,7 +67833,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64574,7 +67855,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64596,7 +67877,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64616,7 +67897,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64635,8 +67916,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64654,7 +67935,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64666,7 +67947,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64678,7 +67959,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64690,7 +67971,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64708,7 +67989,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64726,7 +68007,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64740,7 +68021,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64752,7 +68033,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64764,7 +68045,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64778,11 +68059,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64795,7 +68076,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64812,8 +68093,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64825,7 +68111,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64840,7 +68126,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64854,14 +68140,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(310 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64869,7 +68155,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(308 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64877,14 +68163,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(309 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64894,7 +68180,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(298 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64908,7 +68194,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64924,7 +68210,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64940,7 +68226,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64956,7 +68242,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64968,7 +68254,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64990,11 +68276,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -65006,7 +68292,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -65020,7 +68306,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -65032,7 +68318,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -65044,7 +68330,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -65058,7 +68344,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -65072,7 +68358,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -65084,7 +68370,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -65097,7 +68383,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -65112,7 +68398,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -65127,7 +68413,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -65141,7 +68427,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -65154,7 +68440,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -65175,7 +68461,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -65259,7 +68545,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(315 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -65271,7 +68557,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(319 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65283,7 +68569,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65298,7 +68584,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(316 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -65314,7 +68600,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 317 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -65324,7 +68610,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(317 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -65335,9 +68621,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -65368,7 +68670,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -65450,8 +68752,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -65500,10 +68805,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -65521,14 +68826,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -65574,8 +68879,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65618,43 +68923,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65674,7 +68983,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65718,7 +69030,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65783,7 +69095,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -66259,7 +69570,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -66271,20 +69582,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -66299,7 +69610,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -66311,7 +69622,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66324,7 +69635,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66381,14 +69692,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66666,8 +69977,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66714,7 +70025,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66748,10 +70059,10 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66763,7 +70074,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66800,7 +70111,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66835,10 +70146,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66851,25 +70162,23 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { return ts.createParen(condition); } return condition; @@ -66901,8 +70210,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66918,9 +70227,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66943,7 +70252,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66981,7 +70290,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66992,29 +70301,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -67022,9 +70331,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -67050,28 +70359,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 316 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -67080,15 +70389,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 317 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -67101,13 +70410,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -67132,7 +70441,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -67140,11 +70449,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 316 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -67162,7 +70471,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -67281,10 +70590,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -67403,7 +70712,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -67415,11 +70724,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -67451,12 +70760,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -67468,7 +70777,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -67480,7 +70789,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -67492,7 +70801,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -67515,13 +70824,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -67561,11 +70870,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67689,7 +70998,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict) - statements = ts.ensureUseStrict(statements); // tslint:disable-line no-unnecessary-qualifier + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; @@ -67724,278 +71033,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 161 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -68037,58 +71355,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 315 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68097,12 +71415,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68110,7 +71428,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68118,50 +71436,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -68169,123 +71487,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68294,7 +71612,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68302,140 +71620,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -68508,7 +71826,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -68581,19 +71899,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68796,12 +72115,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68813,6 +72131,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -69181,7 +72500,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -69228,7 +72547,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -69241,13 +72560,13 @@ var ts; hasImportDefault = true; } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -69277,13 +72596,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -69291,7 +72610,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -69311,7 +72630,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -69409,7 +72728,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -69439,42 +72758,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); - } - ts.getInitializedProperties = getInitializedProperties; - /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.isStaticInitializedProperty = isStaticInitializedProperty; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -70000,8 +73305,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -70027,14 +73332,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -70085,16 +73390,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -70106,7 +73411,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -70149,10 +73454,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -70173,13 +73478,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -70199,11 +73504,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -70227,19 +73532,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -70249,7 +73554,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -70266,67 +73571,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70336,7 +73645,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70346,35 +73655,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -70384,35 +73693,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70450,7 +73759,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -70479,7 +73788,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70822,12 +74131,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70980,7 +74289,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? ts.createVoidZero() @@ -71081,13 +74390,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -71103,10 +74412,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -71116,7 +74425,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -71127,12 +74436,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -71149,15 +74458,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -71194,7 +74503,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -71239,69 +74548,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -71312,15 +74621,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var typeNode = types_20[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -71400,12 +74709,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -71421,7 +74730,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.getMutableClone(node); @@ -71429,7 +74738,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -71513,7 +74822,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -71976,12 +75285,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -72106,7 +75415,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -72152,13 +75461,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -72199,7 +75508,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -72412,7 +75721,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -72420,7 +75729,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72430,17 +75739,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -72499,11 +75808,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -72541,9 +75850,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -72565,9 +75874,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -72671,7 +75981,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72682,11 +75994,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72698,20 +76010,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72741,7 +76053,7 @@ var ts; // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { (pendingExpressions || (pendingExpressions = [])).push(expr); } @@ -72754,7 +76066,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72770,9 +76082,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72790,9 +76102,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72804,7 +76116,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72845,8 +76157,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72859,7 +76171,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72903,7 +76215,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72920,7 +76232,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72957,19 +76269,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72989,7 +76311,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -73107,34 +76429,34 @@ var ts; return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73143,27 +76465,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -73364,7 +76686,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -73455,17 +76777,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73513,23 +76835,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73549,11 +76871,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73621,7 +76943,7 @@ var ts; function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -73693,7 +77015,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; @@ -73715,62 +77037,62 @@ var ts; return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return doOutsideOfTopLevel(visitConstructorDeclaration, node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73804,7 +77126,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73816,7 +77138,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73825,7 +77147,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73859,7 +77181,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -74156,7 +77478,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); @@ -74225,17 +77547,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -74283,23 +77605,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -74319,11 +77641,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -74346,8 +77668,7 @@ var ts; }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getUnscopedHelperName("__assign"), @@ -74422,7 +77743,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -74441,6 +77762,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -74453,10 +77775,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -74491,13 +77946,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74507,13 +77962,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -74588,7 +78043,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -74682,7 +78137,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74988,7 +78443,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74996,9 +78451,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -75201,13 +78656,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -75220,72 +78675,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -75296,28 +78751,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -75408,14 +78863,14 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -75426,7 +78881,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75684,7 +79139,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75822,11 +79277,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75834,7 +79289,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75989,10 +79444,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -76016,7 +79471,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -76032,7 +79487,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -76053,25 +79508,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -76100,20 +79555,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -76139,12 +79594,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -76301,7 +79766,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -76345,7 +79810,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -76413,9 +79878,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -76434,9 +79899,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -76471,7 +79936,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -76645,14 +80110,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76840,7 +80305,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76895,7 +80360,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76961,11 +80426,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76990,11 +80455,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -77145,7 +80610,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -77207,7 +80672,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -77245,7 +80710,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -77256,7 +80721,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -77269,7 +80734,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -77283,7 +80748,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -77304,10 +80769,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -77393,20 +80858,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -77513,7 +80978,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77566,7 +81031,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -77690,10 +81155,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -77711,7 +81176,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77723,10 +81188,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -78014,13 +81479,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -78052,7 +81515,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -78062,14 +81525,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -78110,10 +81573,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -78126,9 +81589,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -78195,19 +81658,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -78262,15 +81725,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -78289,9 +81752,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -78348,7 +81811,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -78623,13 +82086,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -78642,24 +82105,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -78680,21 +82143,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -78707,9 +82170,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78908,23 +82371,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78937,7 +82400,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78949,7 +82412,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -79036,7 +82499,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -79325,35 +82788,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79783,7 +83246,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79796,7 +83259,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79969,11 +83432,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80108,7 +83570,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -81025,12 +84487,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -81358,23 +84820,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -81401,24 +84863,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -81896,7 +85358,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81951,10 +85413,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82136,8 +85598,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82153,7 +85615,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -82215,12 +85677,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -82241,7 +85703,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -82309,15 +85771,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -82393,13 +85855,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -82621,7 +86083,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -82646,7 +86108,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -82715,28 +86177,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82786,15 +86248,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82970,7 +86432,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -83034,7 +86496,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -83096,10 +86558,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -83279,43 +86741,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -83562,7 +87024,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -83578,8 +87040,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -83595,7 +87057,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -83645,7 +87107,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -83679,14 +87141,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -83772,22 +87234,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83814,7 +87276,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83853,8 +87315,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -83878,10 +87340,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83988,7 +87450,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84017,7 +87479,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84064,7 +87526,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84073,8 +87535,8 @@ var ts; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -84083,7 +87545,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84108,7 +87570,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.hasModifier(node, 32 /* Static */)) { @@ -84147,26 +87609,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84174,7 +87636,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84188,7 +87650,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84213,30 +87675,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84244,7 +87706,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84257,13 +87719,20 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -84272,39 +87741,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -84319,9 +87788,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -84356,11 +87825,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -84370,7 +87836,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -84434,7 +87900,6 @@ var ts; var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -84517,20 +87982,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -84543,18 +88017,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; - var statements_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(126 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -84591,12 +88065,20 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -84683,11 +88165,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -84695,7 +88177,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -84708,7 +88190,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -84733,19 +88215,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84753,12 +88235,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -84769,26 +88251,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84869,7 +88351,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84889,7 +88371,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84916,7 +88398,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84965,11 +88447,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84979,13 +88461,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -85012,7 +88487,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -85033,75 +88508,65 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 215 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - var isPrivate = ts.hasModifier(input, 8 /* Private */); - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(ts.updateGetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 160 /* SetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - return cleanup(ts.updateSetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 155 /* PropertyDeclaration */: + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } + case 158 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -85109,13 +88574,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 154 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 179 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -85127,13 +88592,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -85162,7 +88627,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -85172,7 +88637,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -85181,13 +88646,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -85197,7 +88662,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -85222,10 +88687,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -85246,14 +88711,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -85268,7 +88733,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -85301,17 +88766,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -85320,7 +88785,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -85347,7 +88812,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -85358,7 +88823,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -85388,7 +88853,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -85398,16 +88863,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -85418,10 +88883,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -85440,7 +88905,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -85461,7 +88926,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -85511,7 +88976,7 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -85532,43 +88997,15 @@ var ts; } return accessorType; } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; - } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -85593,7 +89030,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -85602,52 +89039,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -85776,7 +89213,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(320 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -86061,15 +89498,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -86079,22 +89516,21 @@ var ts; if (!onlyBuildInfo) { 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); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -86117,7 +89553,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -86125,14 +89561,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -86142,9 +89578,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -86185,7 +89619,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -86202,43 +89636,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -86254,11 +89718,11 @@ var ts; return jsFilePath; if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -86266,7 +89730,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -86280,7 +89744,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -86376,17 +89840,20 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle) + return; + if (!declarationFilePath) { + if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly) + emitSkipped = true; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -86418,7 +89885,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -86426,7 +89893,7 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -86437,7 +89904,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -86449,8 +89916,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -86491,7 +89958,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -86598,10 +90065,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -86613,7 +90081,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -86759,6 +90227,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -86787,9 +90257,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86958,8 +90428,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86971,7 +90440,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86987,6 +90456,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86996,21 +90467,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -87025,12 +90507,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -87044,10 +90526,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -87067,279 +90552,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 304 /* JSDocClassTag */: - case 301 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -87357,83 +90842,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -87446,8 +90931,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -87473,7 +90961,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -87573,7 +91061,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -87606,7 +91094,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87642,7 +91130,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -87704,7 +91192,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87745,11 +91233,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87881,18 +91375,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87972,66 +91465,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -88071,22 +91555,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -88111,9 +91595,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ - && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) - || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -88126,7 +91610,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -88154,7 +91638,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -88231,7 +91715,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88239,8 +91723,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -88250,14 +91734,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -88266,14 +91750,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -88285,25 +91769,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -88311,7 +91795,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -88320,12 +91804,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -88353,12 +91837,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88366,7 +91850,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88376,17 +91860,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -88395,13 +91879,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -88426,7 +91910,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -88598,7 +92082,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -88606,7 +92090,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88627,17 +92111,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88646,12 +92130,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -88666,9 +92150,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -88679,42 +92163,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -88734,7 +92218,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88812,7 +92296,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88823,13 +92307,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88841,12 +92325,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88857,7 +92341,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88927,7 +92411,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 310 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88961,7 +92445,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88980,7 +92464,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 299 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -89114,8 +92598,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { - var directive = types_18[_d]; + for (var _d = 0, types_21 = types; _d < types_21.length; _d++) { + var directive = types_21[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -89295,7 +92779,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -89333,8 +92817,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -89741,6 +93224,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -89758,7 +93244,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89823,81 +93309,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89906,12 +93392,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -90091,25 +93577,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -90152,11 +93638,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 315 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -90180,7 +93667,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -90210,6 +93697,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -90423,6 +93911,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -90437,7 +93926,7 @@ var ts; else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -90450,12 +93939,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -91379,6 +94869,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -91483,15 +94975,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -91573,11 +95067,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structuralIsReused; - structuralIsReused = tryReuseStructureFromOldProgram(); + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -91585,20 +95081,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -91611,7 +95123,7 @@ var ts; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -91647,8 +95159,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -91664,12 +95176,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91706,7 +95219,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -91733,9 +95248,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91939,6 +95459,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -92029,7 +95555,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -92066,28 +95592,26 @@ var ts; for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = getModuleNames(newSourceFile); - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); - // ensure that module resolution results are still correct - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); + // ensure that module resolution results are still correct + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -92101,11 +95625,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; var filePath = newSourceFile.path; addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); + if (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -92125,7 +95657,8 @@ var ts; function getEmitHost(writeFileCallback) { return __assign(__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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, 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) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, 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)) @@ -92190,15 +95723,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -92230,7 +95763,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -92305,15 +95839,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -92372,22 +95907,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -92395,41 +95930,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -92442,51 +95977,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -92503,24 +96039,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -92595,8 +96131,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -92626,7 +96162,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -92677,7 +96213,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -92758,24 +96294,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, diagnostic], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([diagnostic], args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -92798,15 +96328,36 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (!source && + host.realpath && + options.preserveSymlinks && + ts.isDeclarationFileName(fileName) && + ts.stringContains(fileName, ts.nodeModulesPathPart)) { + // use host's cached realpath + var realPath = host.realpath(fileName); + if (realPath !== fileName) + source = getSourceOfProjectReferenceRedirect(realPath); + } + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92815,34 +96366,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92860,14 +96412,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92898,7 +96443,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92921,8 +96466,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92937,8 +96492,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92977,6 +96532,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -93011,9 +96595,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -93029,10 +96621,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -93044,7 +96642,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -93054,8 +96652,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -93063,14 +96660,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -93088,20 +96685,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { + if (!refFile) { return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, message], args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -93141,14 +96738,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -93167,12 +96772,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; 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) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -93229,9 +96837,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -93269,14 +96874,12 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -93392,8 +96995,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -93458,8 +97061,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -93486,7 +97122,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -93561,7 +97197,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -93620,6 +97256,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -93665,9 +97307,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -93717,9 +97356,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93965,7 +97604,10 @@ var ts; } } else { - var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); var firstDts_1 = emitOutput_1.outputFiles && programOfThisState.getCompilerOptions().declarationMap ? emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : @@ -94077,6 +97719,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -94180,6 +97823,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -94193,8 +97841,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -94217,7 +97864,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -94263,16 +97911,17 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } + state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit; return state; } function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -94317,7 +97966,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -94394,13 +98044,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -94419,7 +98074,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -94444,7 +98099,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -94462,15 +98117,40 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { return; } + if (!isChangedSignagure(state, affectedFile.path)) + return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } + } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first @@ -94538,7 +98218,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, isEmitResult) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -94548,8 +98228,8 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); - if (isEmitResult) { - (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; @@ -94562,15 +98242,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); return { result: result, affected: affected }; } /** * Returns the result with affected file */ - function toAffectedFileEmitResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, /*isEmitResult*/ true); + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -94600,7 +98280,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -94793,11 +98473,12 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } @@ -94805,10 +98486,11 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94824,7 +98506,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94880,7 +98562,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94912,7 +98594,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94924,8 +98606,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94958,7 +98646,7 @@ var ts; } var state = { fileInfos: fileInfos, - compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), + compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), @@ -94994,33 +98682,6 @@ var ts; } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function convertFromReusableCompilerOptions(options, toAbsolutePath) { - var result = {}; - var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertFromReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); - } - } - if (result.configFilePath) { - result.configFilePath = toAbsolutePath(result.configFilePath); - } - return result; - } - function convertFromReusableCompilerOptionValue(option, value, toAbsolutePath) { - if (option) { - if (option.type === "list") { - var values = value; - if (option.element.isFilePath && values.length) { - return values.map(toAbsolutePath); - } - } - else if (option.isFilePath) { - return toAbsolutePath(value); - } - } - return value; - } function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -95087,15 +98748,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -95341,7 +99014,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -95552,6 +99225,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -95737,8 +99414,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -95754,13 +99432,19 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) @@ -95819,38 +99503,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95861,7 +99519,9 @@ var ts; var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95878,7 +99538,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95920,7 +99604,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95929,28 +99613,34 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); + var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) + var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)); + if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) { return undefined; + } // If the module was found in @types, get the actual Node package name var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1); var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName); @@ -96141,6 +99831,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96148,7 +99847,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -96157,7 +99856,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -96166,7 +99865,7 @@ var ts; /** Parses config file using System interface */ function parseConfigFileWithSystem(configFileName, optionsToExtend, system, reportDiagnostic) { var host = system; - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(ts.sys, reportDiagnostic, diagnostic); }; + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; @@ -96190,7 +99889,7 @@ var ts; } ts.getErrorSummaryText = getErrorSummaryText; function listFiles(program, writeFileName) { - if (program.getCompilerOptions().listFiles) { + if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) { ts.forEach(program.getSourceFiles(), function (file) { writeFileName(file.fileName); }); @@ -96201,6 +99900,7 @@ var ts; * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { + var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly; // First get and report any syntactic errors. var diagnostics = program.getConfigFileParsingDiagnostics().slice(); var configFileParsingDiagnosticsLength = diagnostics.length; @@ -96209,13 +99909,17 @@ var ts; // semantic errors. if (diagnostics.length === configFileParsingDiagnosticsLength) { ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken)); - ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); - if (diagnostics.length === configFileParsingDiagnosticsLength) { - ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + if (!isListFilesOnly) { + ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); + if (diagnostics.length === configFileParsingDiagnosticsLength) { + ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + } } } // Emit and report any errors we ran into. - var emitResult = program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = isListFilesOnly + ? { emitSkipped: true, diagnostics: ts.emptyArray } + : program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics; ts.addRange(diagnostics, emitDiagnostics); ts.sortAndDeduplicateDiagnostics(diagnostics).forEach(reportDiagnostic); @@ -96364,7 +100068,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -96398,7 +100104,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -96447,7 +100153,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -97005,12 +100711,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -97166,11 +100882,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -97179,8 +100898,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -97204,11 +100922,9 @@ var ts; } function createStateBuildOrder(state) { var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); - if (ts.arrayIsEqualTo(state.buildOrder, buildOrder)) - return state.buildOrder; // Clear all to ResolvedConfigFilePaths cache to start fresh state.resolvedConfigFilePaths.clear(); - var currentProjects = ts.arrayToSet(buildOrder, function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); var noopOnDelete = { onDeleteValue: ts.noop }; // Config file cache ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); @@ -97229,6 +100945,8 @@ var ts; function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -97236,6 +100954,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -97307,7 +101026,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -97647,6 +101366,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -97703,8 +101424,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97875,10 +101599,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97937,7 +101663,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -98085,33 +101811,34 @@ var ts; setupInitialBuild(state, cancellationToken); var reportQueue = true; var successfulProjects = 0; - var errorProjects = 0; while (true) { var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue); if (!invalidatedProject) break; reportQueue = false; invalidatedProject.done(cancellationToken); - if (state.diagnostics.has(invalidatedProject.projectPath)) { - errorProjects++; - } - else { + if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; - } } disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) + ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped + : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); }) + ? ts.ExitStatus.Success + : successfulProjects + ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated + : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -98254,8 +101981,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -98287,6 +102014,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -98323,23 +102051,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -98372,13 +102110,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -98400,7 +102141,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -98788,6 +102528,15 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ + var PackageJsonDependencyGroup; + (function (PackageJsonDependencyGroup) { + PackageJsonDependencyGroup[PackageJsonDependencyGroup["Dependencies"] = 1] = "Dependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["DevDependencies"] = 2] = "DevDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["PeerDependencies"] = 4] = "PeerDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["OptionalDependencies"] = 8] = "OptionalDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["All"] = 15] = "All"; + })(PackageJsonDependencyGroup = ts.PackageJsonDependencyGroup || (ts.PackageJsonDependencyGroup = {})); + /* @internal */ ts.emptyOptions = {}; var HighlightSpanKind; (function (HighlightSpanKind) { @@ -98802,6 +102551,12 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = ts.SemicolonPreference || (ts.SemicolonPreference = {})); function getDefaultFormatCodeSettings(newLineCharacter) { return { indentSize: 4, @@ -98823,6 +102578,7 @@ var ts; insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, + semicolons: SemicolonPreference.Ignore, }; } ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; @@ -99052,37 +102808,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 278 /* CatchClause */: + case 271 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 154 /* TypeParameter */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 172 /* TypeLiteral */: return 2 /* Type */; - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 282 /* EnumMember */: + case 244 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -99092,26 +102848,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 247 /* EnumDeclaration */: + case 256 /* NamedImports */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 258 /* ExportAssignment */ || node.parent.kind === 263 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -99143,11 +102899,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 152 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 252 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -99159,27 +102915,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 152 /* QualifiedName */) { + while (root.parent && root.parent.kind === 152 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 168 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 193 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 193 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 215 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 277 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 244 /* ClassDeclaration */ && root.parent.parent.token === 112 /* ImplementsKeyword */) || + (decl.kind === 245 /* InterfaceDeclaration */ && root.parent.parent.token === 89 /* ExtendsKeyword */); } return false; } @@ -99188,17 +102944,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return true; - case 184 /* ImportType */: + case 187 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -99225,7 +102981,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 237 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -99241,11 +102997,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 73 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 73 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -99257,40 +103013,40 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 248 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 73 /* Identifier */ && + return node.kind === 75 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 282 /* EnumMember */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 248 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 186 /* LiteralType */: + return node.parent.parent.kind === 184 /* IndexedAccessType */; default: return false; } @@ -99314,17 +103070,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return node; } } @@ -99332,48 +103088,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: + case 245 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 246 /* TypeAliasDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 247 /* EnumDeclaration */: return "enum" /* enumElement */; + case 241 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 162 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 163 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 279 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 166 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 165 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 164 /* CallSignature */: return "call" /* callSignatureElement */; + case 161 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 154 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 282 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 155 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -99400,7 +103161,7 @@ var ts; return "" /* unknown */; } } - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -99416,12 +103177,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 155 /* Parameter */; default: return false; } @@ -99486,42 +103247,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 172 /* TypeLiteral */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 250 /* CaseBlock */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 196 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 195 /* CallExpression */: + case 199 /* ParenthesizedExpression */: + case 181 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 201 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -99531,65 +103292,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 191 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 194 /* ElementAccessExpression */: + case 153 /* ComputedPropertyName */: + case 174 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 110 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 203 /* TypeOfExpression */: + case 202 /* DeleteExpression */: + case 204 /* VoidExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -99721,7 +103482,7 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - return ts.firstDefined(n.getChildren(), function (child) { + return ts.firstDefined(n.getChildren(sourceFile), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -99768,7 +103529,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 288 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -99834,21 +103595,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 267 /* JsxClosingElement */) { return true; } return false; @@ -99870,7 +103631,7 @@ var ts; if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 28 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -99897,6 +103658,12 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; + function removeOptionality(type, isOptionalExpression, isOptionalChain) { + return isOptionalExpression ? type.getNonNullableType() : + isOptionalChain ? type.getNonOptionalType() : + type; + } + ts.removeOptionality = removeOptionality; function isPossiblyTypeArgumentPosition(token, sourceFile, checker) { var info = getPossibleTypeArgumentsInfo(token, sourceFile); return info !== undefined && (ts.isPartOfTypeNode(info.called) || @@ -99906,6 +103673,9 @@ var ts; ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; function getPossibleGenericSignatures(called, typeArgumentCount, checker) { var type = checker.getTypeAtLocation(called); + if (ts.isOptionalChain(called.parent)) { + type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true); + } var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; }); } @@ -99922,9 +103692,12 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); + if (token && token.kind === 28 /* QuestionDotToken */) { + token = findPrecedingToken(token.getFullStart(), sourceFile); + } if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { @@ -99932,13 +103705,13 @@ var ts; } remainingLessThanTokens--; break; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: remainingLessThanTokens++; break; case 19 /* CloseBraceToken */: @@ -99966,20 +103739,22 @@ var ts; case 27 /* CommaToken */: nTypeArguments++; break; - case 37 /* EqualsGreaterThanToken */: - case 73 /* Identifier */: + case 38 /* EqualsGreaterThanToken */: + // falls through + case 75 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 105 /* TypeOfKeyword */: - case 87 /* ExtendsKeyword */: - case 130 /* KeyOfKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + // falls through + case 107 /* TypeOfKeyword */: + case 89 /* ExtendsKeyword */: + case 133 /* KeyOfKeyword */: case 24 /* DotToken */: - case 50 /* BarToken */: - case 56 /* QuestionToken */: - case 57 /* ColonToken */: + case 51 /* BarToken */: + case 57 /* QuestionToken */: + case 58 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -100028,16 +103803,16 @@ var ts; result.push("abstract" /* abstractModifier */); if (flags & 1 /* Export */) result.push("export" /* exportedModifier */); - if (node.flags & 4194304 /* Ambient */) + if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 168 /* TypeReference */ || node.kind === 195 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 244 /* ClassDeclaration */ || node.kind === 245 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -100057,7 +103832,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 72 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 74 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -100067,9 +103842,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: return true; } return false; @@ -100082,18 +103857,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 191 /* ArrayLiteralExpression */ || + node.kind === 192 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 208 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 60 /* EqualsToken */) { + node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 231 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -100101,7 +103876,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 279 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -100145,23 +103920,23 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 121 /* AnyKeyword */, - 147 /* BigIntKeyword */, - 124 /* BooleanKeyword */, - 88 /* FalseKeyword */, - 130 /* KeyOfKeyword */, - 133 /* NeverKeyword */, - 97 /* NullKeyword */, - 136 /* NumberKeyword */, - 137 /* ObjectKeyword */, - 134 /* ReadonlyKeyword */, - 139 /* StringKeyword */, - 140 /* SymbolKeyword */, - 103 /* TrueKeyword */, - 107 /* VoidKeyword */, - 142 /* UndefinedKeyword */, - 143 /* UniqueKeyword */, - 144 /* UnknownKeyword */, + 124 /* AnyKeyword */, + 150 /* BigIntKeyword */, + 127 /* BooleanKeyword */, + 90 /* FalseKeyword */, + 133 /* KeyOfKeyword */, + 136 /* NeverKeyword */, + 99 /* NullKeyword */, + 139 /* NumberKeyword */, + 140 /* ObjectKeyword */, + 137 /* ReadonlyKeyword */, + 142 /* StringKeyword */, + 143 /* SymbolKeyword */, + 105 /* TrueKeyword */, + 109 /* VoidKeyword */, + 145 /* UndefinedKeyword */, + 146 /* UniqueKeyword */, + 147 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -100197,7 +103972,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 153 /* ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.getTextOfIdentifierOrLiteral(name); @@ -100273,7 +104048,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 73 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 75 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -100357,12 +104132,31 @@ var ts; return a.fileName === b.fileName && textSpansEqual(a.textSpan, b.textSpan); } ts.documentSpansEqual = documentSpansEqual; + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ + function forEachUnique(array, callback) { + if (array) { + for (var i = 0; i < array.length; i++) { + if (array.indexOf(array[i]) === i) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + } + return undefined; + } + ts.forEachUnique = forEachUnique; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 155 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -100403,6 +104197,8 @@ var ts; getColumn: function () { return 0; }, getLine: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingWhitespace: function () { return false; }, + hasTrailingComment: function () { return false; }, rawWrite: ts.notImplemented, getIndent: function () { return indent; }, increaseIndent: function () { indent++; }, @@ -100824,15 +104620,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 272 /* CaseClause */: + case 275 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100860,10 +104656,10 @@ var ts; ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: return true; default: return false; @@ -100874,8 +104670,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: return true; default: return false; @@ -100896,7 +104692,6 @@ var ts; var notAccessible = function () { typeIsAccessible = false; }; var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { trackSymbol: function (symbol, declaration, meaning) { - // TODO: GH#18217 typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; }, reportInaccessibleThisError: notAccessible, @@ -100914,28 +104709,90 @@ var ts; return typeIsAccessible ? res : undefined; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; - function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; - } - ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; + function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { + return kind === 164 /* CallSignature */ + || kind === 165 /* ConstructSignature */ + || kind === 166 /* IndexSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */; + } + ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; + function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { + return kind === 243 /* FunctionDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; + } + ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; + function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { + return kind === 248 /* ModuleDeclaration */; + } + ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; + function syntaxRequiresTrailingSemicolonOrASI(kind) { + return kind === 224 /* VariableStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 227 /* DoStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 233 /* BreakStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 158 /* PropertyDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 258 /* ExportAssignment */; + } + ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; + ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); + function isASICandidate(node, sourceFile) { + var lastToken = node.getLastToken(sourceFile); + if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + return false; + } + if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { + if (lastToken && lastToken.kind === 27 /* CommaToken */) { + return false; + } + } + else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isModuleBlock(lastChild)) { + return false; + } + } + else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isFunctionBlock(lastChild)) { + return false; + } + } + else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) { + return false; + } + // See comment in parser’s `parseDoStatement` + if (node.kind === 227 /* DoStatement */) { + return true; + } + var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); + var nextToken = ts.findNextToken(node, topNode, sourceFile); + if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + return true; + } + var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line; + return startLine !== endLine; + } + ts.isASICandidate = isASICandidate; function probablyUsesSemicolons(sourceFile) { var withSemicolon = 0; var withoutSemicolon = 0; var nStatementsToObserve = 5; ts.forEachChild(sourceFile, function visit(node) { - if (syntaxUsuallyHasTrailingSemicolon(node.kind)) { + if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { withSemicolon++; @@ -100958,6 +104815,150 @@ var ts; return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; } ts.probablyUsesSemicolons = probablyUsesSemicolons; + function tryGetDirectories(host, directoryName) { + return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; + } + ts.tryGetDirectories = tryGetDirectories; + function tryReadDirectory(host, path, extensions, exclude, include) { + return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || ts.emptyArray; + } + ts.tryReadDirectory = tryReadDirectory; + function tryFileExists(host, path) { + return tryIOAndConsumeErrors(host, host.fileExists, path); + } + ts.tryFileExists = tryFileExists; + function tryDirectoryExists(host, path) { + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; + } + ts.tryDirectoryExists = tryDirectoryExists; + function tryAndIgnoreErrors(cb) { + try { + return cb(); + } + catch (_a) { + return undefined; + } + } + ts.tryAndIgnoreErrors = tryAndIgnoreErrors; + function tryIOAndConsumeErrors(host, toApply) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + return tryAndIgnoreErrors(function () { return toApply && toApply.apply(host, args); }); + } + ts.tryIOAndConsumeErrors = tryIOAndConsumeErrors; + function findPackageJsons(startDirectory, host, stopDirectory) { + var paths = []; + ts.forEachAncestorDirectory(startDirectory, function (ancestor) { + if (ancestor === stopDirectory) { + return true; + } + var currentConfigPath = ts.combinePaths(ancestor, "package.json"); + if (tryFileExists(host, currentConfigPath)) { + paths.push(currentConfigPath); + } + }); + return paths; + } + ts.findPackageJsons = findPackageJsons; + function findPackageJson(directory, host) { + var packageJson; + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (ancestor === "node_modules") + return true; + packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); + if (packageJson) { + return true; // break out + } + }); + return packageJson; + } + ts.findPackageJson = findPackageJson; + function getPackageJsonsVisibleToFile(fileName, host) { + if (!host.fileExists) { + return []; + } + var packageJsons = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(fileName), function (ancestor) { + var packageJsonFileName = ts.combinePaths(ancestor, "package.json"); + if (host.fileExists(packageJsonFileName)) { + var info = createPackageJsonInfo(packageJsonFileName, host); + if (info) { + packageJsons.push(info); + } + } + }); + return packageJsons; + } + ts.getPackageJsonsVisibleToFile = getPackageJsonsVisibleToFile; + function createPackageJsonInfo(fileName, host) { + if (!host.readFile) { + return undefined; + } + var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]; + var stringContent = host.readFile(fileName); + var content = stringContent && tryParseJson(stringContent); + if (!content) { + return undefined; + } + var info = {}; + for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) { + var key = dependencyKeys_1[_i]; + var dependencies = content[key]; + if (!dependencies) { + continue; + } + var dependencyMap = ts.createMap(); + for (var packageName in dependencies) { + dependencyMap.set(packageName, dependencies[packageName]); + } + info[key] = dependencyMap; + } + var dependencyGroups = [ + [1 /* Dependencies */, info.dependencies], + [2 /* DevDependencies */, info.devDependencies], + [8 /* OptionalDependencies */, info.optionalDependencies], + [4 /* PeerDependencies */, info.peerDependencies], + ]; + return __assign(__assign({}, info), { fileName: fileName, + get: get, + has: function (dependencyName, inGroups) { + return !!get(dependencyName, inGroups); + } }); + function get(dependencyName, inGroups) { + if (inGroups === void 0) { inGroups = 15 /* All */; } + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; + if (deps && (inGroups & group_1)) { + var dep = deps.get(dependencyName); + if (dep !== undefined) { + return dep; + } + } + } + } + } + ts.createPackageJsonInfo = createPackageJsonInfo; + function tryParseJson(text) { + try { + return JSON.parse(text); + } + catch (_a) { + return undefined; + } + } + function consumesNodeCoreModules(sourceFile) { + return ts.some(sourceFile.imports, function (_a) { + var text = _a.text; + return ts.JsTyping.nodeCoreModules.has(text); + }); + } + ts.consumesNodeCoreModules = consumesNodeCoreModules; + function isInsideNodeModules(fileOrDirectory) { + return ts.contains(ts.getPathComponents(fileOrDirectory), "node_modules"); + } + ts.isInsideNodeModules = isInsideNodeModules; })(ts || (ts = {})); var ts; (function (ts) { @@ -101039,36 +105040,36 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; - case 28 /* LessThanToken */: - if (lastNonTriviaToken === 73 /* Identifier */) { + case 29 /* LessThanToken */: + if (lastNonTriviaToken === 75 /* Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 121 /* AnyKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: + case 124 /* AnyKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 73 /* Identifier */; + token = 75 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -101107,14 +105108,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 73 /* Identifier */; + token = 75 /* Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 73 /* Identifier */; + token = 75 /* Identifier */; } } } @@ -101128,19 +105129,19 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 73 /* Identifier */, + 75 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 101 /* ThisKeyword */, - 44 /* PlusPlusToken */, - 45 /* MinusMinusToken */, + 103 /* ThisKeyword */, + 45 /* PlusPlusToken */, + 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 103 /* TrueKeyword */, - 88 /* FalseKeyword */, + 105 /* TrueKeyword */, + 90 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -101252,10 +105253,10 @@ var ts; return true; } switch (keyword2) { - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 125 /* ConstructorKeyword */: - case 117 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 128 /* ConstructorKeyword */: + case 119 /* StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -101288,43 +105289,44 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 49 /* AmpersandToken */: - case 51 /* CaretToken */: - case 50 /* BarToken */: - case 54 /* AmpersandAmpersandToken */: - case 55 /* BarBarToken */: - case 71 /* BarEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 60 /* EqualsToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 50 /* AmpersandToken */: + case 52 /* CaretToken */: + case 51 /* BarToken */: + case 55 /* AmpersandAmpersandToken */: + case 56 /* BarBarToken */: + case 73 /* BarEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: + case 60 /* QuestionQuestionToken */: return true; default: return false; @@ -101332,12 +105334,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: return true; default: return false; @@ -101350,7 +105352,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 72 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 74 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -101369,7 +105371,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 73 /* Identifier */: + case 75 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -101394,10 +105396,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -101424,8 +105426,10 @@ var ts; }); return { spans: spans, endOfLineState: 0 /* None */ }; function pushClassification(start, end, type) { + var length = end - start; + ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); spans.push(start); - spans.push(end - start); + spans.push(length); spans.push(type); } } @@ -101615,18 +105619,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 307 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 308 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -101667,6 +105671,7 @@ var ts; // defined in `ts.commentPragmas` would be excessive, but we can avoid // some obvious false positives (e.g. in XML-like doc comments) by // checking the element name. + // eslint-disable-next-line no-in-operator if (!match[3] || !(match[3] in ts.commentPragmas)) { return false; } @@ -101776,22 +105781,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -101808,7 +105813,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* GreaterThanToken */) { + if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -101818,19 +105823,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 60 /* EqualsToken */) { + if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 241 /* VariableDeclaration */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 155 /* Parameter */ || + parent.kind === 271 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 208 /* BinaryExpression */ || + parent.kind === 206 /* PrefixUnaryExpression */ || + parent.kind === 207 /* PostfixUnaryExpression */ || + parent.kind === 209 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -101843,8 +105848,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 271 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -101857,35 +105861,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 73 /* Identifier */) { + else if (tokenKind === 75 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 155 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -102008,11 +106012,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -102020,9 +106024,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 187 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 177 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -102032,7 +106036,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -102049,7 +106053,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -102062,8 +106066,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -102072,9 +106076,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 263 /* ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); @@ -102102,7 +106106,7 @@ var ts; var candidates = []; checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); var types = ts.flatMap(candidates, function (candidate) { - if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) + if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length) return; var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); @@ -102118,11 +106122,8 @@ var ts; if (!type) return ts.emptyArray; type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; + return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : + type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; @@ -102212,10 +106213,10 @@ var ts; var absolutePath = ts.resolvePath(scriptPath, fragment); var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (!tryDirectoryExists(host, baseDirectory)) + if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { /** * Multiple file entries might map to the same truncated name once we remove extensions @@ -102238,7 +106239,7 @@ var ts; }); } // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); + var directories = ts.tryGetDirectories(host, baseDirectory); if (directories) { for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var directory = directories_1[_b]; @@ -102249,7 +106250,7 @@ var ts; } } // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); + var packageJsonPath = ts.findPackageJson(baseDirectory, host); if (packageJsonPath) { var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; @@ -102327,7 +106328,7 @@ var ts; if (!foundGlobal) { ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); - if (tryDirectoryExists(host, nodeModules)) { + if (ts.tryDirectoryExists(host, nodeModules)) { getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); @@ -102377,12 +106378,12 @@ var ts; // that encodes the suffix, but we would have to escape the character "?" which readDirectory // doesn't support. For now, this is safer but slower var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = ts.mapDefined(tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); }); - var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { var name = trimPrefixAndSuffix(dir); return name === undefined ? undefined : directoryResult(name); }); @@ -102434,22 +106435,22 @@ var ts; if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { var root = typeRoots_1[_i]; getCompletionEntriesFromDirectories(root); } // Also get all @types typings installed in visible node_modules directories - for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + for (var _a = 0, _b = ts.findPackageJsons(scriptPath, host); _a < _b.length; _a++) { var packageJson = _b[_a]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); getCompletionEntriesFromDirectories(typesDir); } return result; function getCompletionEntriesFromDirectories(directory) { - if (!tryDirectoryExists(host, directory)) + if (!ts.tryDirectoryExists(host, directory)) return; - for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.tryGetDirectories(host, directory); _i < _a.length; _i++) { var typeDirectoryName = _a[_i]; var packageName = ts.unmangleScopedPackageName(typeDirectoryName); if (options.types && !ts.contains(options.types, packageName)) @@ -102470,34 +106471,11 @@ var ts; } } } - function findPackageJsons(directory, host) { - var paths = []; - ts.forEachAncestorDirectory(directory, function (ancestor) { - var currentConfigPath = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (!currentConfigPath) { - return true; // break out - } - paths.push(currentConfigPath); - }); - return paths; - } - function findPackageJson(directory, host) { - var packageJson; - ts.forEachAncestorDirectory(directory, function (ancestor) { - if (ancestor === "node_modules") - return true; - packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (packageJson) { - return true; // break out - } - }); - return packageJson; - } function enumerateNodeModulesVisibleToScript(host, scriptPath) { if (!host.readFile || !host.fileExists) return ts.emptyArray; var result = []; - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.findPackageJsons(scriptPath, host); _i < _a.length; _i++) { var packageJson = _a[_i]; var contents = ts.readJson(packageJson, host); // Cast to assert that readFile is defined // Provide completions for all non @types dependencies @@ -102546,33 +106524,6 @@ var ts; */ var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*" with type any // And at `
` (with a closing `>`), the completion list will contain "div". var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 30 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -102745,14 +106755,25 @@ var ts; function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; var replacementSpan; - if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; + var insertQuestionDot = origin && originIsNullableMember(origin); + var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; + if (origin && originIsThisType(origin)) { + insertText = needsConvertPropertyAccess + ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]" + : "this" + (insertQuestionDot ? "?." : ".") + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. - else if ((origin && originIsSymbolMember(origin) || needsConvertPropertyAccess) && propertyAccessToConvert) { - insertText = needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); + else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { + insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name; + if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { + insertText = "?." + insertText; + } + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + if (!dot) { + return undefined; + } // If the text after the '.' starts with this name, write over it. Else, add new text. var end = ts.startsWith(name, propertyAccessToConvert.name.text) ? propertyAccessToConvert.name.end : dot.end; replacementSpan = ts.createTextSpanFromBounds(dot.getStart(sourceFile), end); @@ -102765,6 +106786,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -102859,9 +106887,9 @@ var ts; } return entries; } - function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { + function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) { var compilerOptions = program.getCompilerOptions(); - var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { return { type: "none" }; } @@ -102901,7 +106929,7 @@ var ts; return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); } // Compute all the completion symbols again. - var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); switch (symbolCompletion.type) { case "request": { var request = symbolCompletion.request; @@ -102957,8 +106985,8 @@ var ts; var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } - function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { - var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) { + var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); return completion.type === "symbol" ? completion.symbol : undefined; } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; @@ -102991,34 +107019,34 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return checker.getContextualType(parent); - case 75 /* CaseKeyword */: + case 77 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 264 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side - ? checker.getTypeAtLocation(parent.left) - : checker.getContextualType(previousToken); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -103028,9 +107056,9 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 288 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 @@ -103079,11 +107107,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 313 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 316 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -103119,6 +107147,7 @@ var ts; var node = currentToken; var propertyAccessToConvert; var isRightOfDot = false; + var isRightOfQuestionDot = false; var isRightOfOpenTag = false; var isStartingCloseTag = false; var isJsxInitializer = false; @@ -103130,10 +107159,11 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */) { - isRightOfDot = true; + if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -103145,14 +107175,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 187 /* ImportType */: + case 218 /* MetaProperty */: node = parent; break; default: @@ -103165,56 +107195,56 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 193 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + case 31 /* GreaterThanToken */: + if (currentToken.parent.kind === 264 /* JsxElement */ || currentToken.parent.kind === 266 /* JsxOpeningElement */) { location = currentToken; } break; - case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + case 43 /* SlashToken */: + if (currentToken.parent.kind === 265 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: - if (contextToken.kind === 42 /* SlashToken */) { + case 267 /* JsxClosingElement */: + if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: - if (contextToken.kind === 28 /* LessThanToken */) { + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: + case 266 /* JsxOpeningElement */: + if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: switch (previousToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: isJsxInitializer = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 60 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 62 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -103226,10 +107256,12 @@ var ts; var completionKind = 5 /* None */; var isNewIdentifierLocation = false; var keywordFilters = 0 /* None */; + // This also gets mutated in nested-functions after the return var symbols = []; var symbolToOriginInfoMap = []; var symbolToSortTextMap = []; - if (isRightOfDot) { + var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { @@ -103279,11 +107311,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 312 /* JSDocTypedefTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 315 /* JSDocTypedefTag */: return true; default: return false; @@ -103327,24 +107359,54 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 288 /* SourceFile */ && d.kind !== 248 /* ModuleDeclaration */ && d.kind !== 247 /* EnumDeclaration */; })) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + var canCorrectToQuestionDot = isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 96 /* NewKeyword */ || node.keywordToken === 93 /* ImportKeyword */)) { - var completion = (node.keywordToken === 96 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 98 /* NewKeyword */ || node.keywordToken === 95 /* ImportKeyword */)) { + var completion = (node.keywordToken === 98 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + var type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + var canCorrectToQuestionDot = isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait, insertQuestionDot) { isNewIdentifierLocation = !!type.getStringIndexType(); + if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { + isNewIdentifierLocation = true; + } + var propertyAccess = node.kind === 187 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -103356,13 +107418,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { - addPropertySymbol(symbol); + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { + addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); + } + } + } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true, insertQuestionDot); + } } } } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait, insertQuestionDot) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -103376,15 +107449,32 @@ var ts; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) + ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } + : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addSymbolOriginInfo(symbol); symbols.push(symbol); } + function addSymbolOriginInfo(symbol) { + if (preferences.includeCompletionsWithInsertText) { + if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + } + else if (insertQuestionDot) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + } + } + } + function getNullableSymbolOriginInfoKind(kind) { + return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -103417,6 +107507,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -103470,19 +107561,38 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 288 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ }; + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; } } } if (shouldOfferImportCompletions()) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && ts.isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target); + var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); + if (!detailsEntryId && importSuggestionsCache) { + importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); + } + autoImportSuggestions.forEach(function (_a) { + var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; + if (detailsEntryId) { + if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { + return; + } + } + else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { + return; + } + var symbolId = ts.getSymbolId(symbol); + symbols.push(symbol); + symbolToOriginInfoMap[symbolId] = origin; + symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; + }); } filterGlobalCompletion(symbols); } @@ -103504,10 +107614,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 210 /* TemplateExpression */: + case 274 /* JsxExpression */: + case 222 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -103552,28 +107662,28 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 107 /* TypeOfKeyword */ && + (contextToken.parent.kind === 171 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + case 58 /* ColonToken */: + return parentKind === 158 /* PropertyDeclaration */ || + parentKind === 157 /* PropertySignature */ || + parentKind === 155 /* Parameter */ || + parentKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; - case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; - case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; - case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + case 62 /* EqualsToken */: + return parentKind === 246 /* TypeAliasDeclaration */; + case 122 /* AsKeyword */: + return parentKind === 216 /* AsExpression */; + case 29 /* LessThanToken */: + return parentKind === 168 /* TypeReference */ || + parentKind === 198 /* TypeAssertionExpression */; + case 89 /* ExtendsKeyword */: + return parentKind === 154 /* TypeParameter */; } } return false; @@ -103587,10 +107697,71 @@ var ts; ts.addToSeen(seenModules, ts.getSymbolId(sym)) && typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); } - function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { - var tokenTextLowerCase = tokenText.toLowerCase(); + /** + * Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates" + * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but + * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, + * if and only if the the first can be imported (it may be excluded due to package.json filtering in + * `codefix.forEachExternalModuleToImportFrom`). + * + * Example. Imagine a chain of node_modules re-exporting one original symbol: + * + * ```js + * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js + * +-----------------------+ +--------------------------+ +--------------------------+ + * | | | | | | + * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | + * | | | | | | + * +-----------------------+ +--------------------------+ +--------------------------+ + * ``` + * + * Also imagine three buckets, which we’ll reference soon: + * + * ```md + * | | | | | | + * | **Bucket A** | | **Bucket B** | | **Bucket C** | + * | Symbols to | | Aliases to symbols | | Symbols to return | + * | definitely | | in Buckets A or C | | if nothing better | + * | return | | (don’t return these) | | comes along | + * |__________________| |______________________| |___________________| + * ``` + * + * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it + * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not + * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we + * may not be sure whether or not it should go in the list. So, we’ll take the following steps: + * + * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is + * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B + * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. + * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. + * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' + * should never be returned in the final list, so put it in Bucket B. + * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so + * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. + * Put this symbol in Bucket A. + * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t + * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move + * everything from Bucket C to Bucket A. + */ + function getSymbolsFromOtherSourceFileExports(target, host) { + var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); + if (cached) { + log("getSymbolsFromOtherSourceFileExports: Using cached list"); + return cached; + } + var startTime = ts.timestamp(); + log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); var seenResolvedModules = ts.createMap(); - ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + /** Bucket B */ + var aliasesToAlreadyIncludedSymbols = ts.createMap(); + /** Bucket C */ + var aliasesToReturnIfOriginalsAreMissing = ts.createMap(); + /** Bucket A */ + var results = []; + /** Ids present in `results` for faster lookup */ + var resultSymbolIds = ts.createMap(); + ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; @@ -103600,41 +107771,75 @@ var ts; if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { return; } + // Don't add another completion for `export =` of a symbol that's already global. + // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. if (resolvedModuleSymbol !== moduleSymbol && - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { - symbols.push(resolvedModuleSymbol); - symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator && !ts.findAncestor(d, ts.isGlobalScopeAugmentation); })) { + pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true); } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; - // Don't add a completion for a re-export, only for the original. - // The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details. - // This is just to avoid adding duplicate completion entries. - // - // If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols. - if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol - || ts.some(symbol.declarations, function (d) { - // If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion. - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - return ts.isExportSpecifier(d) && (d.propertyName ? ts.isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier); - })) { + // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. + if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { continue; } - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + var symbolId = ts.getSymbolId(symbol).toString(); + // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. + var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; + // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { + // Walk the export chain back one module (step 1 or 2 in diagrammed example). + // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. + var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); + if (!nearestExportSymbol) + continue; + var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); + var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); + if (!symbolHasBeenSeen) { + aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol }); + aliasesToAlreadyIncludedSymbols.set(symbolId, true); + } + else { + // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here + // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. + ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); + } } - var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; - if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { - symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin; + else { + // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.delete(symbolId); + pushSymbol(symbol, moduleSymbol); } } }); + // By this point, any potential duplicates that were actually duplicates have been + // removed, so the rest need to be added. (Step 4 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { + var alias = _a.alias, moduleSymbol = _a.moduleSymbol; + return pushSymbol(alias, moduleSymbol); + }); + log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); + return results; + function pushSymbol(symbol, moduleSymbol, skipFilter) { + if (skipFilter === void 0) { skipFilter = false; } + var isDefaultExport = symbol.escapedName === "default" /* Default */; + if (isDefaultExport) { + symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + } + ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); + var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; + results.push({ + symbol: symbol, + symbolName: getSymbolName(symbol, origin, target), + origin: origin, + skipFilter: skipFilter, + }); + } + } + function getNearestExportSymbol(fromSymbol) { + return findAlias(typeChecker, fromSymbol, function (alias) { + return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); + }); } /** * True if you could remove some characters in `a` to get `b`. @@ -103681,12 +107886,12 @@ var ts; if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 266 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 267 /* JsxClosingElement */ || contextToken.parent.kind === 265 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 264 /* JsxElement */; } } return false; @@ -103697,40 +107902,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 195 /* CallExpression */ // func( a, | + || containingNodeKind === 161 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 196 /* NewExpression */ // new C(a, | + || containingNodeKind === 191 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 208 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 169 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 195 /* CallExpression */ // func( | + || containingNodeKind === 161 /* Constructor */ // constructor( | + || containingNodeKind === 196 /* NewExpression */ // new C(a| + || containingNodeKind === 199 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 181 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 131 /* ModuleKeyword */: // module | - case 132 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 191 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 166 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 153 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 134 /* ModuleKeyword */: // module | + case 135 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 248 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | - case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 244 /* ClassDeclaration */; // class A{ | + case 62 /* EqualsToken */: + return containingNodeKind === 241 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 208 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 210 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 220 /* TemplateSpan */; // `aa ${10} dd ${| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -103757,8 +107962,8 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { - var typeForObject = typeChecker.getContextualType(objectLikeContainer); + if (objectLikeContainer.kind === 192 /* ObjectLiteralExpression */) { + var typeForObject = typeChecker.getContextualType(objectLikeContainer, 4 /* Completion */); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = ts.hasIndexSignature(typeForObject); @@ -103766,7 +107971,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 188 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -103777,12 +107982,12 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 231 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 155 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 160 /* MethodDeclaration */ || rootDeclaration.parent.kind === 163 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -103799,6 +108004,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -103824,7 +108030,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 256 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -103847,7 +108053,7 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) @@ -103855,7 +108061,7 @@ var ts; var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 75 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -103890,9 +108096,9 @@ var ts; return parent; } break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 73 /* Identifier */: + case 75 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -103942,23 +108148,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 30 /* GreaterThanToken */: // End of a type argument list - case 29 /* LessThanSlashToken */: - case 42 /* SlashToken */: - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { - if (contextToken.kind === 30 /* GreaterThanToken */) { + case 31 /* GreaterThanToken */: // End of a type argument list + case 30 /* LessThanSlashToken */: + case 43 /* SlashToken */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 272 /* JsxAttributes */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 265 /* JsxSelfClosingElement */ || parent.kind === 266 /* JsxOpeningElement */)) { + if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) break; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103970,7 +108176,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 271 /* JsxAttribute */) || (parent.kind === 273 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103980,8 +108186,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 274 /* JsxExpression */ && + parent.parent && parent.parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103989,7 +108195,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 273 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -104009,64 +108215,64 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 241 /* VariableDeclaration */ || + containingNodeKind === 242 /* VariableDeclarationList */ || + containingNodeKind === 224 /* VariableStatement */ || + containingNodeKind === 247 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| - case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [.| + case 58 /* ColonToken */: + return containingNodeKind === 190 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 278 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | - case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 247 /* EnumDeclaration */; // enum a { | + case 29 /* LessThanToken */: + return containingNodeKind === 244 /* ClassDeclaration */ || // class A< | + containingNodeKind === 213 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 245 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 246 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 119 /* StaticKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + return containingNodeKind === 155 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 189 /* ArrayBindingPattern */); // var [...z| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 155 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 122 /* AsKeyword */: + return containingNodeKind === 257 /* ImportSpecifier */ || + containingNodeKind === 261 /* ExportSpecifier */ || + containingNodeKind === 255 /* NamespaceImport */; + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 111 /* InterfaceKeyword */: - case 91 /* FunctionKeyword */: - case 106 /* VarKeyword */: - case 93 /* ImportKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 118 /* YieldKeyword */: - case 141 /* TypeKeyword */: // type htm| + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 113 /* InterfaceKeyword */: + case 93 /* FunctionKeyword */: + case 108 /* VarKeyword */: + case 95 /* ImportKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 120 /* YieldKeyword */: + case 144 /* TypeKeyword */: // type htm| return true; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -104087,22 +108293,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 119 /* AbstractKeyword */: - case 77 /* ClassKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 91 /* FunctionKeyword */: - case 111 /* InterfaceKeyword */: - case 112 /* LetKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 117 /* StaticKeyword */: - case 106 /* VarKeyword */: - case 118 /* YieldKeyword */: + case 121 /* AbstractKeyword */: + case 79 /* ClassKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 93 /* FunctionKeyword */: + case 113 /* InterfaceKeyword */: + case 114 /* LetKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 119 /* StaticKeyword */: + case 108 /* VarKeyword */: + case 120 /* YieldKeyword */: return true; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -104112,7 +108318,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 161 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -104131,16 +108337,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 279 /* PropertyAssignment */ && + m.kind !== 280 /* ShorthandPropertyAssignment */ && + m.kind !== 190 /* BindingElement */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */ && + m.kind !== 281 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -104148,9 +108356,12 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 73 /* Identifier */) { + if (m.propertyName.kind === 75 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -104163,7 +108374,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -104175,10 +108419,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 158 /* PropertyDeclaration */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -104212,17 +108456,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 271 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -104233,7 +108483,7 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.startsWithQuote(name) + || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; @@ -104262,7 +108512,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 76 /* FirstKeyword */; i <= 151 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -104288,9 +108538,11 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 126 /* DeclareKeyword */ - || kind === 131 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 142 /* UndefinedKeyword */; + || kind === 129 /* DeclareKeyword */ + || kind === 134 /* ModuleKeyword */ + || kind === 144 /* TypeKeyword */ + || kind === 135 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 145 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -104300,7 +108552,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 78 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 80 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -104310,55 +108562,55 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 121 /* AnyKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 146 /* GlobalKeyword */: - case 110 /* ImplementsKeyword */: - case 128 /* InferKeyword */: - case 111 /* InterfaceKeyword */: - case 129 /* IsKeyword */: - case 130 /* KeyOfKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 133 /* NeverKeyword */: - case 136 /* NumberKeyword */: - case 137 /* ObjectKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: - case 139 /* StringKeyword */: - case 140 /* SymbolKeyword */: - case 141 /* TypeKeyword */: - case 143 /* UniqueKeyword */: - case 144 /* UnknownKeyword */: + case 121 /* AbstractKeyword */: + case 124 /* AnyKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 149 /* GlobalKeyword */: + case 112 /* ImplementsKeyword */: + case 131 /* InferKeyword */: + case 113 /* InterfaceKeyword */: + case 132 /* IsKeyword */: + case 133 /* KeyOfKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 136 /* NeverKeyword */: + case 139 /* NumberKeyword */: + case 140 /* ObjectKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: + case 142 /* StringKeyword */: + case 143 /* SymbolKeyword */: + case 144 /* TypeKeyword */: + case 146 /* UniqueKeyword */: + case 147 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 134 /* ReadonlyKeyword */; + return kind === 137 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 125 /* ConstructorKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 122 /* AsyncKeyword */: + case 121 /* AbstractKeyword */: + case 128 /* ConstructorKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 125 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 122 /* AsyncKeyword */ - || kind === 123 /* AwaitKeyword */ + return kind === 125 /* AsyncKeyword */ + || kind === 126 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -104396,7 +108648,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 314 /* SyntaxList */: + case 317 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -104404,7 +108656,7 @@ var ts; return cls; } break; - case 73 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } + case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return ts.findAncestor(location, ts.isObjectTypeDeclaration); } @@ -104430,7 +108682,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -104450,11 +108702,11 @@ var ts; return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -104463,6 +108715,14 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } + function findAlias(typeChecker, symbol, predicate) { + var currentAlias = symbol; + while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { + if (predicate(currentAlias)) { + return currentAlias; + } + } + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -104515,40 +108775,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 92 /* IfKeyword */: - case 84 /* ElseKeyword */: + case 94 /* IfKeyword */: + case 86 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 98 /* ReturnKeyword */: + case 100 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 104 /* TryKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: - var tryStatement = node.kind === 76 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 106 /* TryKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: + var tryStatement = node.kind === 78 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 75 /* CaseKeyword */: - case 81 /* DefaultKeyword */: + case 77 /* CaseKeyword */: + case 83 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 74 /* BreakKeyword */: - case 79 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 81 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 90 /* ForKeyword */: - case 108 /* WhileKeyword */: - case 83 /* DoKeyword */: + case 92 /* ForKeyword */: + case 110 /* WhileKeyword */: + case 85 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 125 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [125 /* ConstructorKeyword */]); - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [127 /* GetKeyword */, 138 /* SetKeyword */]); - case 123 /* AwaitKeyword */: + case 128 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [128 /* ConstructorKeyword */]); + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [130 /* GetKeyword */, 141 /* SetKeyword */]); + case 126 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 118 /* YieldKeyword */: + case 120 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -104591,7 +108851,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 288 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -104623,16 +108883,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 236 /* SwitchStatement */: + if (statement.kind === 232 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -104648,11 +108908,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 222 /* Block */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArrays(declaration.members, [declaration]); @@ -104660,14 +108920,14 @@ var ts; else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 172 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. @@ -104698,12 +108958,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 92 /* ForKeyword */, 110 /* WhileKeyword */, 85 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 227 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 110 /* WhileKeyword */)) { break; } } @@ -104711,7 +108971,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */, 79 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */, 81 /* ContinueKeyword */); } }); return keywords; @@ -104720,13 +108980,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -104734,13 +108994,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 100 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 102 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 75 /* CaseKeyword */, 81 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 77 /* CaseKeyword */, 83 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */); } }); }); @@ -104748,13 +109008,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 104 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 106 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 76 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 78 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 89 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 91 /* FinallyKeyword */); } return keywords; } @@ -104765,13 +109025,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -104783,11 +109043,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -104799,13 +109059,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 122 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 125 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 123 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 126 /* AwaitKeyword */); } }); }); @@ -104820,7 +109080,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 118 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 120 /* YieldKeyword */); } }); }); @@ -104839,7 +109099,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 84 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 86 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -104874,10 +109134,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 92 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 94 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 84 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 86 /* ElseKeyword */)) { break; } } @@ -105093,12 +109353,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 241 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { directImports.push(name); break; } @@ -105107,22 +109367,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 73 /* Identifier */: // for 'const x = require("y"); + case 75 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 255 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -105132,7 +109392,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 187 /* ImportType */: directImports.push(direct); break; default: @@ -105149,7 +109409,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 288 /* SourceFile */ || sourceFileLike.kind === 248 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -105204,17 +109464,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 252 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 73 /* Identifier */) { + if (decl.kind === 75 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 187 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -105229,17 +109489,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 259 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -105289,7 +109549,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 261 /* ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -105318,7 +109578,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 285 /* SourceFile */) { + if (searchSourceFile.kind === 288 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -105366,7 +109626,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 288 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -105381,15 +109641,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -105413,7 +109673,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 193 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -105547,13 +109807,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -105586,21 +109846,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 288 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 249 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 248 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 263 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -105649,7 +109909,7 @@ var ts; if (ts.isInJSFile(node)) { var binaryExpression = ts.isBinaryExpression(node.parent) ? node.parent : - ts.isPropertyAccessExpression(node.parent) && + ts.isAccessExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && node.parent.parent.left === node.parent ? node.parent.parent : @@ -105693,7 +109953,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 81 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 83 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -105702,7 +109962,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -105710,27 +109970,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -105774,18 +110034,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 99 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -105874,7 +110134,7 @@ var ts; return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 83 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -105929,13 +110189,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 213 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105964,7 +110224,7 @@ var ts; function getTextSpan(node, sourceFile, endNode) { var start = node.getStart(sourceFile); var end = (endNode || node).getEnd(); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { ts.Debug.assert(endNode === undefined); start += 1; end -= 1; @@ -105979,7 +110239,7 @@ var ts; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 81 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 83 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -105987,49 +110247,49 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 4194304 /* Ambient */)) + if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 208 /* BinaryExpression */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 83 /* DefaultKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 261 /* ExportSpecifier */: + case 254 /* ImportClause */: // default import + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 245 /* InterfaceDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 271 /* JsxAttribute */: + case 248 /* ModuleDeclaration */: + case 251 /* NamespaceExportDeclaration */: + case 255 /* NamespaceImport */: + case 155 /* Parameter */: + case 280 /* ShorthandPropertyAssignment */: + case 246 /* TypeAliasDeclaration */: + case 154 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: + case 159 /* MethodSignature */: + case 157 /* PropertySignature */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -106189,10 +110449,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -106209,11 +110469,9 @@ var ts; var sourceFile = decl.getSourceFile(); if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` - var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) - ? decl.left.expression - : ts.isExportAssignment(decl) - ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 88 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } @@ -106222,21 +110480,21 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 134 /* ReadonlyKeyword */ + return node.kind === 137 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 134 /* ReadonlyKeyword */; + && node.parent.operator === 137 /* ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 134 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 137 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 134 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 137 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -106252,7 +110510,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -106269,7 +110527,7 @@ var ts; // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 81 /* DefaultKeyword */) { + else if (node && node.kind === 83 /* DefaultKeyword */) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } @@ -106297,9 +110555,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: return 1 /* Constructor */; - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -106535,7 +110793,7 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 200 /* FunctionExpression */ || valueDeclaration.kind === 213 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -106545,7 +110803,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 244 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -106574,7 +110832,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -106682,8 +110940,9 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.text.length === searchSymbolName.length; + case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && @@ -106691,7 +110950,7 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 81 /* DefaultKeyword */: + case 83 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -106757,7 +111016,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 73 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 75 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -106813,12 +111072,14 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 81 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 81 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 83 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 83 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol); - var exportInfo = ts.Debug.assertDefined(FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker)); - searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); + var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); + if (exportInfo) { + searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); + } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { @@ -106877,7 +111138,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -106893,7 +111154,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 81 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 83 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -106920,7 +111181,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 101 /* ThisKeyword */) { + if (node.kind === 103 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -106939,18 +111200,18 @@ var ts; if (constructorSymbol) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 128 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 161 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 160 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 103 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -106971,10 +111232,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 161 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 101 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -106998,10 +111259,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 73 /* Identifier */) { + if (refNode.kind !== 75 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 280 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -107021,7 +111282,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 222 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -107049,13 +111310,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 191 /* ArrayLiteralExpression */: return true; default: return false; @@ -107108,13 +111369,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -107123,7 +111384,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 99 /* SuperKeyword */) { + if (node.kind !== 101 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -107135,41 +111396,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 75 /* Identifier */ && node.parent.kind === 155 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 288 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -107177,19 +111438,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 288 /* SourceFile */: + return container.kind === 288 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -107308,7 +111569,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 190 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -107358,11 +111619,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -107412,12 +111672,12 @@ var ts; /* @internal */ var ts; (function (ts) { - function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, _preferences, sourceMapper) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences, sourceMapper) { var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); - return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, function (changeTracker) { updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); @@ -107665,9 +111925,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); + return node.kind === 101 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -107675,7 +111935,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -107828,31 +112088,32 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 73 /* Identifier */) { + if (node.kind !== 75 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 257 /* ImportSpecifier */: + return declaration.parent.kind === 256 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { // There are cases when you extend a function by adding properties to it afterwards, - // we want to strip those extra properties - var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return !ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration; }) || undefined; + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 128 /* ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -107867,8 +112128,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -107921,9 +112186,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return true; default: return false; @@ -108025,7 +112290,7 @@ var ts; // The property length will have two declarations of property length coming // from Array - Array and Array var documentationComment = []; - forEachUnique(declarations, function (declaration) { + ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var comment = _a[_i].comment; if (comment === undefined) @@ -108041,11 +112306,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return [declaration]; - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -108054,7 +112319,7 @@ var ts; function getJsDocTagsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once. var tags = []; - forEachUnique(declarations, function (declaration) { + ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { var tag = _a[_i]; tags.push({ name: tag.tagName.text, text: getCommentText(tag) }); @@ -108066,16 +112331,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return withNode(tag.class); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -108091,24 +112356,6 @@ var ts; return comment === undefined ? s : s + " " + comment; } } - /** - * Iterates through 'array' by index and performs the callback on each element of array until the callback - * returns a truthy value, then returns that value. - * If no such value is found, the callback is applied to each element of array and undefined is returned. - */ - function forEachUnique(array, callback) { - if (array) { - for (var i = 0; i < array.length; i++) { - if (array.indexOf(array[i]) === i) { - var result = callback(array[i], i); - if (result) { - return result; - } - } - } - } - return undefined; - } function getJSDocTagNameCompletions() { return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { @@ -108252,7 +112499,7 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 73 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 75 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -108262,23 +112509,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 159 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 157 /* PropertySignature */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 246 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -108286,14 +112533,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 288 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 248 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 208 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -108312,14 +112559,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 199 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 213 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -108381,9 +112628,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -108393,7 +112640,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 153 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -108410,7 +112657,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 153 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -108454,6 +112701,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -108468,6 +112716,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -108478,13 +112731,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -108510,7 +112765,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -108535,28 +112790,56 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isPropertyNameLiteral(entityName)) { + var name = ts.getNameOrArgument(entityName); + var nameText = ts.getElementOrPropertyAccessName(entityName); + entityName = entityName.expression; + if (nameText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -108566,46 +112849,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 159 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -108617,90 +112902,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 280 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 281 /* SpreadAssignment */: + var expression = node.expression; + // Use the expression as the name of the SpreadAssignment, otherwise show as . + ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); + break; + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: + case 241 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + addNodeWithRecursiveChild(node, node.body); + break; + case 247 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 261 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 166 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 246 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && ts.getElementOrPropertyAccessName(assignmentTarget) !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else if (ts.isBindableStaticAccessExpression(assignmentTarget)) { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, ts.getNameOrArgument(assignmentTarget)); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -108723,8 +113086,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -108738,7 +113101,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -108747,7 +113110,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -108755,7 +113118,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -108768,12 +113224,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -108789,7 +113245,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 248 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -108819,43 +113275,46 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 248 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); if (declName && ts.isPropertyName(declName)) { - return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 + var propertyName = ts.getPropertyNameForPropertyNameNode(declName); + return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 248 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text + : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -108863,24 +113322,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 164 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -108890,28 +113352,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 246 /* TypeAliasDeclaration */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -108921,21 +113383,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -108948,18 +113404,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108990,7 +113446,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -109004,13 +113460,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 153 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 288 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 241 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -109018,14 +113474,14 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -109042,7 +113498,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -109063,14 +113523,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -109084,8 +113554,8 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, _preferences) { - var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext }); + function organizeImports(sourceFile, formatContext, host, program, preferences) { + var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); var coalesceAndOrganizeImports = function (importGroup) { return coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); @@ -109413,7 +113883,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 93 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 95 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -109530,7 +114000,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -109538,23 +114008,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 227 /* DoStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 278 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - return spanForNode(ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -109562,24 +114032,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 250 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -109621,7 +114091,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 201 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -110156,10 +114626,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 126 /* DeclareKeyword */) { + if (token === 129 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 131 /* ModuleKeyword */) { + if (token === 134 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -110177,7 +114647,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 93 /* ImportKeyword */) { + if (token === 95 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -110193,9 +114663,9 @@ var ts; return true; } else { - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -110203,7 +114673,7 @@ var ts; return true; } } - else if (token === 60 /* EqualsToken */) { + else if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -110226,7 +114696,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -110236,13 +114706,13 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 120 /* AsKeyword */) { + if (token === 122 /* AsKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -110260,7 +114730,7 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 86 /* ExportKeyword */) { + if (token === 88 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); if (token === 18 /* OpenBraceToken */) { @@ -110272,7 +114742,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -110282,9 +114752,9 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -110292,11 +114762,11 @@ var ts; } } } - else if (token === 93 /* ImportKeyword */) { + else if (token === 95 /* ImportKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 60 /* EqualsToken */) { + if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -110309,7 +114779,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 135 /* RequireKeyword */) { + if (token === 138 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -110324,7 +114794,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 73 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 75 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -110458,14 +114928,14 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 81 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 83 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 153 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -110512,7 +114982,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { // Exclude the quotes start += 1; width -= 2; @@ -110521,9 +114991,10 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -110563,7 +115034,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -110675,14 +115146,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 134 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 56 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 137 /* ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 154 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -110690,7 +115161,7 @@ var ts; // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; })), closeBraceToken, ]; @@ -110702,7 +115173,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -110715,14 +115186,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } return node.getChildren(); @@ -110789,7 +115260,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(314 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(317 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -110798,14 +115269,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 266 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 267 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -110898,7 +115369,7 @@ var ts; var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -110957,7 +115428,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -111010,10 +115481,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 197 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 210 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -111080,17 +115551,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 199 /* ParenthesizedExpression */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -111161,11 +115632,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -111214,7 +115685,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -111279,8 +115750,8 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(); - var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(28 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(29 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { @@ -111313,7 +115784,7 @@ var ts; var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(30 /* GreaterThanToken */)], parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -111389,6 +115860,10 @@ var ts; if (!sourceFile) return undefined; var program = host.getProgram(); + // If this is source file of project reference source (instead of redirect) there is no generated position + if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) { + return undefined; + } var options = program.getCompilerOptions(); var outPath = options.outFile || options.out; var declarationPath = outPath ? @@ -111526,7 +116001,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -111536,7 +116011,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -111569,11 +116044,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -111590,12 +116065,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 255 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -111653,13 +116128,13 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ - case 97 /* NullKeyword */: - case 73 /* Identifier */: // identifier includes undefined + // falls through + case 99 /* NullKeyword */: + case 75 /* Identifier */: // identifier includes undefined return true; default: return false; @@ -111682,7 +116157,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -111719,7 +116194,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 101 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 103 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -111770,11 +116245,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + return location.kind === 75 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 271 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -111801,13 +116276,13 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 101 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 103 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 101 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(101 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 103 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(103 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { @@ -111817,7 +116292,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 193 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -111837,7 +116312,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 196 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 101 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -111855,7 +116330,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -111872,14 +116347,14 @@ var ts; case "parameter" /* parameterElement */: case "local var" /* localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -111892,29 +116367,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 128 /* ConstructorKeyword */ && location.parent.kind === 161 /* Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration - var locationIsSymbolDeclaration = ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { + return declaration === (location.kind === 128 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 161 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 161 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 164 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -111924,7 +116399,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -111932,7 +116407,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(77 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(79 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -111940,37 +116415,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(111 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(113 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(78 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(80 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(85 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(87 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 248 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 75 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 135 /* NamespaceKeyword */ : 134 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -111989,7 +116464,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 154 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111997,21 +116472,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + if (declaration.kind === 165 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 164 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 246 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -112023,11 +116498,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 282 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -112053,32 +116528,32 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 251 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(135 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 258 /* ExportAssignment */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 83 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 261 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(93 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(95 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 252 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(135 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(138 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -112087,7 +116562,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -112101,7 +116576,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(101 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(103 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -112112,7 +116587,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -112150,10 +116625,10 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 288 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 208 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -112196,7 +116671,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(94 /* InKeyword */)); + displayParts.push(ts.keywordPart(96 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -112206,7 +116681,7 @@ var ts; var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(56 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -112241,7 +116716,7 @@ var ts; if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(38 /* PlusToken */)); + displayParts.push(ts.operatorPart(39 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); @@ -112266,16 +116741,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 200 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 241 /* VariableDeclaration */ && declaration.kind !== 243 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 288 /* SourceFile */ || parent.kind === 249 /* ModuleBlock */) { return false; } } @@ -112520,7 +116995,9 @@ var ts; var res = cb({ advance: advance, readTokenInfo: readTokenInfo, + readEOFTokenRange: readEOFTokenRange, isOnToken: isOnToken, + isOnEOF: isOnEOF, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, @@ -112560,11 +117037,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 32 /* GreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -112572,12 +117049,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 271 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 73 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 75 /* Identifier */; } } return false; @@ -112593,23 +117070,18 @@ var ts; container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 42 /* SlashToken */ || t === 65 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -112626,11 +117098,7 @@ var ts; scanner.scan(); } var currentToken = getNextToken(n, expectedScanAction); - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var token = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); // consume trailing trivia if (trailingTrivia) { trailingTrivia = undefined; @@ -112640,11 +117108,7 @@ var ts; if (!ts.isTrivia(currentToken)) { break; } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var trivia = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); if (!trailingTrivia) { trailingTrivia = []; } @@ -112663,7 +117127,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -112697,11 +117161,19 @@ var ts; } return token; } + function readEOFTokenRange() { + ts.Debug.assert(isOnEOF()); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } + function isOnEOF() { + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + return current === 1 /* EndOfFileToken */; + } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, // then kind needs to be fixed. This might happen in cases @@ -112733,10 +117205,16 @@ var ts; formatting.anyContext = ts.emptyArray; var RuleAction; (function (RuleAction) { - RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; - RuleAction[RuleAction["Space"] = 2] = "Space"; - RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; - RuleAction[RuleAction["Delete"] = 8] = "Delete"; + RuleAction[RuleAction["StopProcessingSpaceActions"] = 1] = "StopProcessingSpaceActions"; + RuleAction[RuleAction["StopProcessingTokenActions"] = 2] = "StopProcessingTokenActions"; + RuleAction[RuleAction["InsertSpace"] = 4] = "InsertSpace"; + RuleAction[RuleAction["InsertNewLine"] = 8] = "InsertNewLine"; + RuleAction[RuleAction["DeleteSpace"] = 16] = "DeleteSpace"; + RuleAction[RuleAction["DeleteToken"] = 32] = "DeleteToken"; + RuleAction[RuleAction["InsertTrailingSemicolon"] = 64] = "InsertTrailingSemicolon"; + RuleAction[RuleAction["StopAction"] = 3] = "StopAction"; + RuleAction[RuleAction["ModifySpaceAction"] = 28] = "ModifySpaceAction"; + RuleAction[RuleAction["ModifyTokenAction"] = 96] = "ModifyTokenAction"; })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); var RuleFlags; (function (RuleFlags) { @@ -112752,8 +117230,10 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { - allTokens.push(token); + for (var token = 0 /* FirstToken */; token <= 151 /* LastToken */; token++) { + if (token !== 1 /* EndOfFileToken */) { + allTokens.push(token); + } } function anyTokenExcept() { var tokens = []; @@ -112764,256 +117244,259 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; - var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArrays(allTokens, [1 /* EndOfFileToken */])); + var keywords = tokenRangeFromRange(76 /* FirstKeyword */, 151 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 74 /* LastBinaryOperator */); + var binaryKeywordOperators = [96 /* InKeyword */, 97 /* InstanceOfKeyword */, 151 /* OfKeyword */, 122 /* AsKeyword */, 132 /* IsKeyword */]; + var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 75 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostincrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; - var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; + var unaryPreincrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostincrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; + var unaryPredecrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostdecrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArrays([73 /* Identifier */], ts.typeKeywords); + var typeNames = __spreadArrays([75 /* Identifier */], ts.typeKeywords); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([73 /* Identifier */, 3 /* MultiLineCommentTrivia */, 77 /* ClassKeyword */, 86 /* ExportKeyword */, 93 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([75 /* Identifier */, 3 /* MultiLineCommentTrivia */, 79 /* ClassKeyword */, 88 /* ExportKeyword */, 95 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 83 /* DoKeyword */, 104 /* TryKeyword */, 89 /* FinallyKeyword */, 84 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 85 /* DoKeyword */, 106 /* TryKeyword */, 91 /* FinallyKeyword */, 86 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* Ignore */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* Ignore */), - rule("NotSpaceBeforeColon", anyToken, 57 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), - rule("SpaceAfterColon", 57 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeQuestionMark", anyToken, 56 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBetweenImportParenInImportType", 93 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 95 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPreincrementOperator", 44 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPredecrementOperator", 45 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 44 /* PlusPlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 38 /* PlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 38 /* PlusToken */, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 45 /* MinusMinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 39 /* MinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 39 /* MinusToken */, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 84 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 108 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 86 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 110 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 91 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, 73 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 91 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 93 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 75 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 93 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [127 /* GetKeyword */, 138 /* SetKeyword */], 73 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 118 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [118 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 98 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [106 /* VarKeyword */, 102 /* ThrowKeyword */, 96 /* NewKeyword */, 82 /* DeleteKeyword */, 98 /* ReturnKeyword */, 105 /* TypeOfKeyword */, 123 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [112 /* LetKeyword */, 78 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [130 /* GetKeyword */, 141 /* SetKeyword */], 75 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 120 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [120 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 100 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterCertainKeywords", [108 /* VarKeyword */, 104 /* ThrowKeyword */, 98 /* NewKeyword */, 84 /* DeleteKeyword */, 100 /* ReturnKeyword */, 107 /* TypeOfKeyword */, 126 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [114 /* LetKeyword */, 80 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 107 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 109 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 122 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 122 /* AsyncKeyword */, 91 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 125 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 125 /* AsyncKeyword */, 93 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [73 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 73 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 42 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 42 /* SlashToken */, 30 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 60 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 60 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 75 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [131 /* ModuleKeyword */, 135 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [134 /* ModuleKeyword */, 138 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 119 /* AbstractKeyword */, - 77 /* ClassKeyword */, - 126 /* DeclareKeyword */, - 81 /* DefaultKeyword */, - 85 /* EnumKeyword */, - 86 /* ExportKeyword */, - 87 /* ExtendsKeyword */, - 127 /* GetKeyword */, - 110 /* ImplementsKeyword */, - 93 /* ImportKeyword */, - 111 /* InterfaceKeyword */, - 131 /* ModuleKeyword */, - 132 /* NamespaceKeyword */, - 114 /* PrivateKeyword */, - 116 /* PublicKeyword */, - 115 /* ProtectedKeyword */, - 134 /* ReadonlyKeyword */, - 138 /* SetKeyword */, - 117 /* StaticKeyword */, - 141 /* TypeKeyword */, - 145 /* FromKeyword */, - 130 /* KeyOfKeyword */, - 128 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [87 /* ExtendsKeyword */, 110 /* ImplementsKeyword */, 145 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + 121 /* AbstractKeyword */, + 79 /* ClassKeyword */, + 129 /* DeclareKeyword */, + 83 /* DefaultKeyword */, + 87 /* EnumKeyword */, + 88 /* ExportKeyword */, + 89 /* ExtendsKeyword */, + 130 /* GetKeyword */, + 112 /* ImplementsKeyword */, + 95 /* ImportKeyword */, + 113 /* InterfaceKeyword */, + 134 /* ModuleKeyword */, + 135 /* NamespaceKeyword */, + 116 /* PrivateKeyword */, + 118 /* PublicKeyword */, + 117 /* ProtectedKeyword */, + 137 /* ReadonlyKeyword */, + 141 /* SetKeyword */, + 119 /* StaticKeyword */, + 144 /* TypeKeyword */, + 148 /* FromKeyword */, + 133 /* KeyOfKeyword */, + 131 /* InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [89 /* ExtendsKeyword */, 112 /* ImplementsKeyword */, 148 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 73 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 75 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterOpenAngularBracket", 28 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 30 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterCloseAngularBracket", 30 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 30 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 73 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 75 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 119 /* AbstractKeyword */, - 73 /* Identifier */, - 86 /* ExportKeyword */, - 81 /* DefaultKeyword */, - 77 /* ClassKeyword */, - 117 /* StaticKeyword */, - 116 /* PublicKeyword */, - 114 /* PrivateKeyword */, - 115 /* ProtectedKeyword */, - 127 /* GetKeyword */, - 138 /* SetKeyword */, + 121 /* AbstractKeyword */, + 75 /* Identifier */, + 88 /* ExportKeyword */, + 83 /* DefaultKeyword */, + 79 /* ClassKeyword */, + 119 /* StaticKeyword */, + 118 /* PublicKeyword */, + 116 /* PrivateKeyword */, + 117 /* ProtectedKeyword */, + 130 /* GetKeyword */, + 141 /* SetKeyword */, 22 /* OpenBracketToken */, - 40 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 96 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 28 /* LessThanToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + 41 /* AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 98 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), + rule("SpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), - rule("NoSpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), - rule("SpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(122 /* AsyncKeyword */, 75 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(125 /* AsyncKeyword */, 77 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 90 /* ForKeyword */, 123 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 92 /* ForKeyword */, 126 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 83 /* DoKeyword */, 84 /* ElseKeyword */, 75 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 85 /* DoKeyword */, 86 /* ElseKeyword */, 77 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [106 /* TryKeyword */, 91 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } @@ -113053,6 +117536,9 @@ var ts; /// /// Contexts /// + function optionEquals(optionName, optionValue) { + return function (context) { return context.options && context.options[optionName] === optionValue; }; + } function isOptionEnabled(optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; } @@ -113069,45 +117555,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 229 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 179 /* ConditionalType */: + case 216 /* AsExpression */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 167 /* TypePredicate */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 190 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 252 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 241 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 155 /* Parameter */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: - return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 154 /* TypeParameter */: + return context.currentTokenSpan.kind === 96 /* InKeyword */ || context.nextTokenSpan.kind === 96 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 231 /* ForOfStatement */: + return context.currentTokenSpan.kind === 151 /* OfKeyword */ || context.nextTokenSpan.kind === 151 /* OfKeyword */; } return false; } @@ -113119,22 +117610,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 158 /* PropertyDeclaration */ || + contextKind === 157 /* PropertySignature */ || + contextKind === 155 /* Parameter */ || + contextKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 209 /* ConditionalExpression */ || + context.contextNode.kind === 179 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 188 /* ObjectBindingPattern */ || + context.contextNode.kind === 185 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -113160,31 +117651,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 192 /* ObjectLiteralExpression */: + case 249 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 164 /* CallSignature */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 201 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 245 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -113193,40 +117687,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 243 /* FunctionDeclaration */ || context.contextNode.kind === 200 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 172 /* TypeLiteral */: + case 248 /* ModuleDeclaration */: + case 259 /* ExportDeclaration */: + case 260 /* NamedExports */: + case 253 /* ImportDeclaration */: + case 256 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 278 /* CatchClause */: + case 249 /* ModuleBlock */: + case 236 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 222 /* Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 201 /* ArrowFunction */ && blockParent.kind !== 200 /* FunctionExpression */) { return true; } } @@ -113235,31 +117729,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 235 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 278 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 192 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 195 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 196 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -113271,28 +117766,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 201 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 187 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 264 /* JsxElement */ && context.contextNode.kind !== 268 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 274 /* JsxExpression */ || context.contextNode.kind === 273 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 271 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 271 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 265 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -113307,45 +117802,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 242 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 248 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 172 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 165 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { + if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 198 /* TypeAssertionExpression */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -113356,16 +117851,78 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 198 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 109 /* VoidKeyword */ && context.currentTokenParent.kind === 204 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 211 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 217 /* NonNullExpression */; + } + function isSemicolonDeletionContext(context) { + var nextTokenKind = context.nextTokenSpan.kind; + var nextTokenStart = context.nextTokenSpan.pos; + if (ts.isTrivia(nextTokenKind)) { + var nextRealToken = context.nextTokenParent === context.currentTokenParent + ? ts.findNextToken(context.currentTokenParent, ts.findAncestor(context.currentTokenParent, function (a) { return !a.parent; }), context.sourceFile) + : context.nextTokenParent.getFirstToken(context.sourceFile); + if (!nextRealToken) { + return true; + } + nextTokenKind = nextRealToken.kind; + nextTokenStart = nextRealToken.getStart(context.sourceFile); + } + var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; + var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; + if (startLine === endLine) { + return nextTokenKind === 19 /* CloseBraceToken */ + || nextTokenKind === 1 /* EndOfFileToken */; + } + if (nextTokenKind === 221 /* SemicolonClassElement */ || + nextTokenKind === 26 /* SemicolonToken */) { + return false; + } + if (context.contextNode.kind === 245 /* InterfaceDeclaration */ || + context.contextNode.kind === 246 /* TypeAliasDeclaration */) { + // Can’t remove semicolon after `foo`; it would parse as a method declaration: + // + // interface I { + // foo; + // (): void + // } + return !ts.isPropertySignature(context.currentTokenParent) + || !!context.currentTokenParent.type + || nextTokenKind !== 20 /* OpenParenToken */; + } + if (ts.isPropertyDeclaration(context.currentTokenParent)) { + return !context.currentTokenParent.initializer; + } + return context.currentTokenParent.kind !== 229 /* ForStatement */ + && context.currentTokenParent.kind !== 223 /* EmptyStatement */ + && context.currentTokenParent.kind !== 221 /* SemicolonClassElement */ + && nextTokenKind !== 22 /* OpenBracketToken */ + && nextTokenKind !== 20 /* OpenParenToken */ + && nextTokenKind !== 39 /* PlusToken */ + && nextTokenKind !== 40 /* MinusToken */ + && nextTokenKind !== 43 /* SlashToken */ + && nextTokenKind !== 13 /* RegularExpressionLiteral */ + && nextTokenKind !== 27 /* CommaToken */ + && nextTokenKind !== 210 /* TemplateExpression */ + && nextTokenKind !== 15 /* TemplateHead */ + && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* DotToken */; + } + function isSemicolonInsertionContext(context) { + var contextAncestor = ts.findAncestor(context.currentTokenParent, function (ancestor) { + if (ancestor.end !== context.currentTokenSpan.end) { + return "quit"; + } + return ts.syntaxMayBeASICandidate(ancestor.kind); + }); + return !!contextAncestor && ts.isASICandidate(contextAncestor, context.sourceFile); } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -113375,7 +117932,7 @@ var ts; var formatting; (function (formatting) { function getFormatContext(options) { - return { options: options, getRule: getRulesMap() }; + return { options: options, getRules: getRulesMap() }; } formatting.getFormatContext = getFormatContext; var rulesMapCache; @@ -113385,11 +117942,45 @@ var ts; } return rulesMapCache; } + /** + * For a given rule action, gets a mask of other rule actions that + * cannot be applied at the same position. + */ + function getRuleActionExclusion(ruleAction) { + var mask = 0; + if (ruleAction & 1 /* StopProcessingSpaceActions */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 2 /* StopProcessingTokenActions */) { + mask |= 96 /* ModifyTokenAction */; + } + if (ruleAction & 28 /* ModifySpaceAction */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 96 /* ModifyTokenAction */) { + mask |= 96 /* ModifyTokenAction */; + } + return mask; + } function createRulesMap(rules) { var map = buildMap(rules); return function (context) { var bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)]; - return bucket && ts.find(bucket, function (rule) { return ts.every(rule.context, function (c) { return c(context); }); }); + if (bucket) { + var rules_1 = []; + var ruleActionMask = 0; + for (var _i = 0, bucket_1 = bucket; _i < bucket_1.length; _i++) { + var rule = bucket_1[_i]; + var acceptRuleActions = ~getRuleActionExclusion(ruleActionMask); + if (rule.action & acceptRuleActions && ts.every(rule.context, function (c) { return c(context); })) { + rules_1.push(rule); + ruleActionMask |= rule.action; + } + } + if (rules_1.length) { + return rules_1; + } + } }; } function buildMap(rules) { @@ -113397,8 +117988,8 @@ var ts; var map = new Array(mapRowLength * mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(map.length); - for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) { - var rule = rules_1[_i]; + for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) { + var rule = rules_2[_i]; var specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific; for (var _a = 0, _b = rule.leftTokenRange.tokens; _a < _b.length; _a++) { var left = _b[_a]; @@ -113416,16 +118007,16 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 151 /* LastKeyword */ && column <= 151 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 151 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = maskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; + RulesPosition[RulesPosition["StopRulesAny"] = maskBitSize * 1] = "StopRulesAny"; RulesPosition[RulesPosition["ContextRulesSpecific"] = maskBitSize * 2] = "ContextRulesSpecific"; RulesPosition[RulesPosition["ContextRulesAny"] = maskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = maskBitSize * 4] = "NoContextRulesSpecific"; @@ -113447,11 +118038,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action & 3 /* StopAction */ ? + specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -113476,6 +118067,16 @@ var ts; (function (ts) { var formatting; (function (formatting) { + function createTextRangeWithKind(pos, end, kind) { + var textRangeWithKind = { pos: pos, end: end, kind: kind }; + if (ts.Debug.isDebugging) { + Object.defineProperty(textRangeWithKind, "__debugKind", { + get: function () { return ts.Debug.formatSyntaxKind(kind); }, + }); + } + return textRangeWithKind; + } + formatting.createTextRangeWithKind = createTextRangeWithKind; var Constants; (function (Constants) { Constants[Constants["Unknown"] = -1] = "Unknown"; @@ -113599,17 +118200,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 249 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 288 /* SourceFile */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -113744,7 +118345,7 @@ var ts; return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) { - var options = _a.options, getRule = _a.getRule; + var options = _a.options, getRules = _a.getRules; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); var previousRange; @@ -113834,19 +118435,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: return 79 /* ClassKeyword */; + case 245 /* InterfaceDeclaration */: return 113 /* InterfaceKeyword */; + case 243 /* FunctionDeclaration */: return 93 /* FunctionKeyword */; + case 247 /* EnumDeclaration */: return 247 /* EnumDeclaration */; + case 162 /* GetAccessor */: return 130 /* GetKeyword */; + case 163 /* SetAccessor */: return 141 /* SetKeyword */; + case 160 /* MethodDeclaration */: if (node.asteriskToken) { - return 40 /* AsteriskToken */; + return 41 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -113896,22 +118497,22 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 84 /* ElseKeyword */: - case 108 /* WhileKeyword */: - case 58 /* AtToken */: + case 86 /* ElseKeyword */: + case 110 /* WhileKeyword */: + case 59 /* AtToken */: return false; - case 42 /* SlashToken */: - case 30 /* GreaterThanToken */: + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 185 /* MappedType */) { return false; } break; @@ -113958,6 +118559,12 @@ var ts; } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } + if (!node.parent && formattingScanner.isOnEOF()) { + var token = formattingScanner.readEOFTokenRange(); + if (token.end <= node.end && previousRange) { + processPair(token, sourceFile.getLineAndCharacterOfPosition(token.pos).line, node, previousRange, previousRangeStartLine, previousParent, contextNode, nodeDynamicIndentation); + } + } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; @@ -114003,7 +118610,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 156 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 11 /* JsxText */) { @@ -114011,7 +118618,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 191 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -114179,35 +118786,39 @@ var ts; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = getRule(formattingContext); - var trimTrailingWhitespaces; + var rules = getRules(formattingContext); + var trimTrailingWhitespaces = false; var lineAction = 0 /* None */; - if (rule) { - lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - switch (lineAction) { - case 2 /* LineRemoved */: - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); - } - break; - case 1 /* LineAdded */: - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); - } - break; - default: - ts.Debug.assert(lineAction === 0 /* None */); - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & 8 /* Delete */) && rule.flags !== 1 /* CanDeleteNewLines */; + if (rules) { + // Apply rules in reverse order so that higher priority rules (which are first in the array) + // win in a conflict with lower priority rules. + ts.forEachRight(rules, function (rule) { + lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + switch (lineAction) { + case 2 /* LineRemoved */: + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + } + break; + case 1 /* LineAdded */: + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + } + break; + default: + ts.Debug.assert(lineAction === 0 /* None */); + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + }); } else { - trimTrailingWhitespaces = true; + trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -114344,20 +118955,28 @@ var ts; edits.push(ts.createTextChangeFromStartLength(start, len, newText)); } } + function recordInsert(start, text) { + if (text) { + edits.push(ts.createTextChangeFromStartLength(start, 0, text)); + } + } function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* Ignore */: + case 1 /* StopProcessingSpaceActions */: // no action required return 0 /* None */; - case 8 /* Delete */: + case 16 /* DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } break; - case 4 /* NewLine */: + case 32 /* DeleteToken */: + recordDelete(previousRange.pos, previousRange.end - previousRange.pos); + break; + case 8 /* InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines @@ -114371,7 +118990,7 @@ var ts; return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; } break; - case 2 /* Space */: + case 4 /* InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { return 0 /* None */; @@ -114381,6 +119000,9 @@ var ts; recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } + break; + case 64 /* InsertTrailingSemicolon */: + recordInsert(previousRange.end, ";"); } return 0 /* None */; } @@ -114394,8 +119016,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -114404,6 +119025,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -114429,34 +119051,34 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 201 /* ArrowFunction */: if (node.typeParameters === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.parameters === list) { return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.arguments === list) { return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 168 /* TypeReference */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -114465,8 +119087,8 @@ var ts; switch (kind) { case 20 /* OpenParenToken */: return 21 /* CloseParenToken */; - case 28 /* LessThanToken */: - return 30 /* GreaterThanToken */; + case 29 /* LessThanToken */: + return 31 /* GreaterThanToken */; case 18 /* OpenBraceToken */: return 19 /* CloseBraceToken */; } @@ -114554,7 +119176,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -114573,7 +119196,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 208 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -114727,7 +119350,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 288 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -114775,8 +119398,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); + if (parent.kind === 226 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 86 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -114788,7 +119411,10 @@ var ts; if (ts.isCallOrNewExpression(parent)) { if (!parent.arguments) return false; - var currentNode = ts.Debug.assertDefined(ts.find(parent.arguments, function (arg) { return arg.pos === child.pos; })); + var currentNode = ts.find(parent.arguments, function (arg) { return arg.pos === child.pos; }); + // If it's not one of the arguments, don't look past this + if (!currentNode) + return false; var currentIndex = parent.arguments.indexOf(currentNode); if (currentIndex === 0) return false; // Can't look at previous node if first @@ -114810,40 +119436,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -114866,7 +119492,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 242 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114939,83 +119565,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 225 /* ExpressionStatement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 191 /* ArrayLiteralExpression */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 185 /* MappedType */: + case 174 /* TupleType */: + case 250 /* CaseBlock */: + case 276 /* DefaultClause */: + case 275 /* CaseClause */: + case 199 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 224 /* VariableStatement */: + case 258 /* ExportAssignment */: + case 234 /* ReturnStatement */: + case 209 /* ConditionalExpression */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: + case 265 /* JsxSelfClosingElement */: + case 274 /* JsxExpression */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 155 /* Parameter */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 181 /* ParenthesizedType */: + case 197 /* TaggedTemplateExpression */: + case 205 /* AwaitExpression */: + case 260 /* NamedExports */: + case 256 /* NamedImports */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 158 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 241 /* VariableDeclaration */: + case 279 /* PropertyAssignment */: + case 208 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 192 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 208 /* BinaryExpression */) { + return true; + } + break; + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return childKind !== 222 /* Block */; + case 259 /* ExportDeclaration */: + return childKind !== 260 /* NamedExports */; + case 253 /* ImportDeclaration */: + return childKind !== 254 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 256 /* NamedImports */); + case 264 /* JsxElement */: + return childKind !== 267 /* JsxClosingElement */; + case 268 /* JsxFragment */: + return childKind !== 270 /* JsxClosingFragment */; + case 178 /* IntersectionType */: + case 177 /* UnionType */: + if (childKind === 172 /* TypeLiteral */) { return false; } // falls through @@ -115026,11 +119656,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: + return parent.kind !== 222 /* Block */; default: return false; } @@ -115172,7 +119802,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 192 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -115203,6 +119833,18 @@ var ts; cb(tracker); return tracker.getChanges(); }; + ChangeTracker.prototype.pushRaw = function (sourceFile, change) { + ts.Debug.assertEqual(sourceFile.fileName, change.fileName); + for (var _i = 0, _a = change.textChanges; _i < _a.length; _i++) { + var c = _a[_i]; + this.changes.push({ + kind: ChangeKind.Text, + sourceFile: sourceFile, + text: c.newText, + range: ts.createTextRangeFromSpan(c.span), + }); + } + }; ChangeTracker.prototype.deleteRange = function (sourceFile, range) { this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); }; @@ -115331,15 +119973,16 @@ var ts; endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) - return; // Function missing parentheses, give up + return false; // Function missing parentheses, give up // If no `)`, is an arrow function `x => x`, so use the end of the first parameter endNode = ts.first(node.parameters); } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 241 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); + return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; @@ -115454,18 +120097,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 155 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -115474,12 +120117,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + if (node.kind === 201 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(91 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(93 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -115488,14 +120131,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 222 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(100 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 200 /* FunctionExpression */ ? 93 /* FunctionKeyword */ : 79 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -115746,29 +120389,34 @@ var ts; var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + noIndent + (options.suffix || ""); } + function getFormatCodeSettingsForWriting(_a, sourceFile) { + var options = _a.options; + var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore; + var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile); + return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore }); + } /** Note: this may mutate `nodeIn`. */ function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) { var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta; var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text; if (validate) validate(node, text); - var formatOptions = formatContext.options; + var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile); var initialIndentation = indentation !== undefined ? indentation : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos); if (delta === undefined) { - delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatContext.options, nodeIn) ? (formatOptions.indentSize || 0) : 0; + delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } var file = { text: text, getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); } }; - var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, formatContext); + var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, __assign(__assign({}, formatContext), { options: formatOptions })); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ function getNonformattedText(node, sourceFile, newLineCharacter) { - var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); - var writer = createWriter(newLineCharacter, omitTrailingSemicolon); + var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -115803,9 +120451,9 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - function createWriter(newLine, omitTrailingSemicolon) { + function createWriter(newLine) { var lastNonTriviaPosition = 0; - var writer = omitTrailingSemicolon ? ts.getTrailingSemicolonOmittingWriter(ts.createTextWriter(newLine)) : ts.createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var onEmitNode = function (hint, node, printCallback) { if (node) { setPos(node, lastNonTriviaPosition); @@ -115956,6 +120604,8 @@ var ts; getColumn: getColumn, getIndent: getIndent, isAtStartOfLine: isAtStartOfLine, + hasTrailingComment: function () { return writer.hasTrailingComment(); }, + hasTrailingWhitespace: function () { return writer.hasTrailingWhitespace(); }, clear: clear }; } @@ -116020,14 +120670,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 153 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 152 /* Parameter */: { + case 155 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -116042,14 +120692,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 189 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -116057,13 +120707,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -116072,7 +120722,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -116119,13 +120769,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 253 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 278 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -116136,14 +120786,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -116304,10 +120954,10 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) - : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(147 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(147 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -116345,7 +120995,7 @@ var ts; errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -116359,27 +121009,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -116393,7 +121054,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -116406,64 +121067,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = function (identifier) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return "continue"; + } + var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); + var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); + var variableStatement = ts.getAncestor(declaration, 224 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; - }); - if (isUsedElsewhere) { - return; + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - return declaration.initializer; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); + }); + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { - return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 243 /* FunctionDeclaration */ || + ancestor.parent.kind === 200 /* FunctionExpression */ || + ancestor.parent.kind === 201 /* ArrowFunction */ || + ancestor.parent.kind === 160 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -116526,16 +121269,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || fixedNodes.tryAdd(initializer)) { - changeTracker.insertModifierBefore(sourceFile, 78 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 80 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 75 /* Identifier */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -116549,8 +121292,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 75 /* Identifier */: + case 208 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -116570,6 +121313,42 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addMissingDeclareProperty"; + var errorCodes = [ + ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Prefix_with_declare, fixId, ts.Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var fixedNodes = new ts.NodeSet(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start, fixedNodes); }); + }, + }); + function makeChange(changeTracker, sourceFile, pos, fixedNodes) { + var token = ts.getTokenAtPosition(sourceFile, pos); + if (!ts.isIdentifier(token)) { + return; + } + var declaration = token.parent; + if (declaration.kind === 158 /* PropertyDeclaration */ && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, 129 /* DeclareKeyword */, declaration); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -116691,33 +121470,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 241 /* VariableDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 158 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -116739,7 +121518,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 299 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -116779,8 +121558,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -116830,20 +121609,20 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; + var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; var token = ts.getTokenAtPosition(sourceFile, start); var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, formatContext, preferences); }); var name = declaration && ts.getNameOfDeclaration(declaration); return !name || changes.length === 0 ? undefined : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, formatContext, preferences); }); }, }); @@ -116883,8 +121662,8 @@ var ts; } return errorCode; } - function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 73 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 101 /* ThisKeyword */) { + function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, formatContext, preferences) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 103 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -116894,7 +121673,7 @@ var ts; case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location - annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); + annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken, formatContext, preferences); return parent; } if (ts.isPropertyAccessExpression(parent)) { @@ -116911,7 +121690,7 @@ var ts; case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { var symbol = program.getTypeChecker().getSymbolAtLocation(token); if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { - annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); + annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken, formatContext, preferences); return symbol.valueDeclaration; } return undefined; @@ -116925,14 +121704,14 @@ var ts; // Parameter declarations case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); return containingFunction; } // falls through case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: if (markSeen(containingFunction)) { var param = ts.cast(parent, ts.isParameter); - annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken); + annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken, formatContext, preferences); return param; } return undefined; @@ -116940,14 +121719,14 @@ var ts; case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { - annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); + annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host, formatContext, preferences); return containingFunction; } return undefined; // Set Accessor declarations case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); return containingFunction; } return undefined; @@ -116962,22 +121741,17 @@ var ts; return ts.Debug.fail(String(errorCode)); } } - function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { + function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken, formatContext, preferences) { if (ts.isIdentifier(declaration.name)) { - annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); + annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host, formatContext, preferences); } } - function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { + function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken, formatContext, preferences) { if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116988,7 +121762,7 @@ var ts; for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { - annotate(changes, sourceFile, declaration, type, program, host); + annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences); } } if (needParens) @@ -116996,14 +121770,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -117020,7 +121791,7 @@ var ts; ts.createJSDocThisTag(ts.createJSDocTypeExpression(typeNode)), ]); } - function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { + function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken, formatContext, preferences) { var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); @@ -117031,14 +121802,14 @@ var ts; annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); } else { - annotate(changes, sourceFile, param, type, program, host); + annotate(changes, sourceFile, param, type, program, host, formatContext, preferences); } } } - function annotate(changes, sourceFile, declaration, type, program, host) { + function annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 157 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -117047,11 +121818,32 @@ var ts; var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); addJSDocTags(changes, sourceFile, parent, [typeTag]); } - else { + else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences)) { changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); } } } + function tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences) { + var _a; + if (ts.isLiteralImportTypeNode(typeNode) && typeNode.qualifier && type.symbol) { + // Replace 'import("./a").SomeType' with 'SomeType' and an actual import if possible + var moduleSymbol = (_a = ts.find(type.symbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) === null || _a === void 0 ? void 0 : _a.getSourceFile().symbol; + // Symbol for the left-most thing after the dot + if (moduleSymbol) { + var symbol = ts.getFirstIdentifier(typeNode.qualifier).symbol; + var action = codefix.getImportCompletionAction(symbol, moduleSymbol, sourceFile, symbol.name, host, program, formatContext, declaration.pos, preferences); + if (action.codeAction.changes.length && changes.tryInsertTypeAnnotation(sourceFile, declaration, ts.createTypeReferenceNode(typeNode.qualifier, typeNode.typeArguments))) { + for (var _i = 0, _b = action.codeAction.changes; _i < _b.length; _i++) { + var change = _b[_i]; + var file = sourceFile.fileName === change.fileName ? sourceFile : ts.Debug.assertDefined(program.getSourceFile(change.fileName)); + changes.pushRaw(file, change); + } + return true; + } + } + } + return false; + } function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { var signature = parameterInferences.length && parameterInferences[0].declaration.parent; if (!signature) { @@ -117079,13 +121871,13 @@ var ts; return !!merged; }); }); var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var jsDocNode = parent.kind === 201 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 158 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -117095,14 +121887,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 307 /* JSDocParameterTag */: { + case 310 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 308 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -117114,25 +121906,31 @@ var ts; } function inferTypeForVariableFromUsage(token, program, cancellationToken) { var references = getReferences(token, program, cancellationToken); - var checker = program.getTypeChecker(); - var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); - return InferFromReference.unifyFromContext(types, checker); + return inferTypeFromReferences(program, references, cancellationToken).single(); + } + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); + case 161 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 128 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -117141,54 +121939,109 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + var builtinConstructors = { + string: function () { return checker.getStringType(); }, + number: function () { return checker.getNumberType(); }, + Array: function (t) { return checker.createArrayType(t); }, + Promise: function (t) { return checker.createPromiseType(t); }, + }; + var builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function createEmptyUsage() { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + function combineUsages(usages) { + var combinedProperties = ts.createUnderscoreEscapedMap(); + for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { + var u = usages_1[_i]; + if (u.properties) { + u.properties.forEach(function (p, name) { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name).push(p); + }); + } } - return inferFromContext(usageContext, checker); + var properties = ts.createUnderscoreEscapedMap(); + combinedProperties.forEach(function (ps, name) { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(function (u) { return u.isNumber; }), + isString: usages.some(function (u) { return u.isString; }), + isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), + candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), + properties: properties, + calls: ts.flatMap(usages, function (u) { return u.calls; }), + constructs: ts.flatMap(usages, function (u) { return u.constructs; }), + numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), + stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), + candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), + inferredTypes: undefined, + }; } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function single() { + return combineTypes(inferTypesFromReferencesSingle(references)); + } + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = createEmptyUsage(); + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = __spreadArrays(usageContext.constructContexts || [], usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return declaration.parameters.map(function (parameter, parameterIndex) { var types = []; var isRest = ts.isRestParameter(parameter); var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.argumentTypes.length <= parameterIndex) { isOptional = ts.isInJSFile(declaration); types.push(checker.getUndefinedType()); } else if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = combineTypes(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -117196,242 +122049,255 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = createEmptyUsage(); + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return combineTypes(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = createEmptyUsage(); for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferTypes(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 225 /* ExpressionStatement */: + addCandidateType(usage, checker.getVoidType()); break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 207 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 206 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 208 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); + break; + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 193 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 194 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 158 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - usageContext.isNumber = true; + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + usage.isNumber = true; break; - case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + case 39 /* PlusToken */: + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: // MultiplicativeOperator - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + // falls through + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: // ShiftOperator - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // falls through + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator - case 49 /* AmpersandToken */: - case 50 /* BarToken */: - case 51 /* CaretToken */: + // falls through + case 50 /* AmpersandToken */: + case 51 /* BarToken */: + case 52 /* CaretToken */: // CompoundAssignmentOperator - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 71 /* BarEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: + // falls through + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 73 /* BarEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator - case 39 /* MinusToken */: + // falls through + case 40 /* MinusToken */: // RelationalOperator - case 28 /* LessThanToken */: - case 31 /* LessThanEqualsToken */: - case 30 /* GreaterThanToken */: - case 32 /* GreaterThanEqualsToken */: + // falls through + case 29 /* LessThanToken */: + case 32 /* LessThanEqualsToken */: + case 31 /* GreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; - case 61 /* PlusEqualsToken */: - case 38 /* PlusToken */: + case 63 /* PlusEqualsToken */: + case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; + } + else if (otherOperandType.flags & 1 /* Any */) { + // do nothing, maybe we'll learn something elsewhere } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators - case 60 /* EqualsToken */: - case 33 /* EqualsEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + case 62 /* EqualsToken */: + case 34 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 94 /* InKeyword */: + case 96 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; - // LogicalOperator - case 55 /* BarBarToken */: + // LogicalOperator Or NullishCoalescing + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 241 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: // nothing to infer here break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], - returnType: {} + return_: createEmptyUsage() }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.return_); + if (parent.kind === 195 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || createEmptyUsage(); + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = createEmptyUsage(); + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -117440,17 +122306,19 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { - if (fallback === void 0) { fallback = checker.getAnyType(); } + function combineFromUsage(usage) { + return combineTypes(inferTypes(usage)); + } + function combineTypes(inferences) { if (!inferences.length) - return fallback; + return checker.getAnyType(); // 1. string or number individually override string | number // 2. non-any, non-void overrides any or void // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types @@ -117473,12 +122341,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function combineAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -117514,109 +122381,173 @@ var ts; }); return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); } - function inferFromContext(usageContext, checker) { + function inferTypes(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); - if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types_1 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); - types_1.push(checker.createPromiseType(types_1.length ? checker.getUnionType(types_1, 2 /* Subtype */) : checker.getAnyType())); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); - } - if (usageContext.numberIndexContext) { - types.push(checker.createArrayType(recur(usageContext.numberIndexContext))); - } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_1 = ts.createUnderscoreEscapedMap(); - var callSignatures = []; - var constructSignatures = []; - var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { - var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); - members_1.set(name, symbol); - }); - } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); - } - } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); - } - } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); - } - types.push(checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); + } + if (usage.properties && usage.properties.size + || usage.calls && usage.calls.length + || usage.constructs && usage.constructs.length + || usage.stringIndex) { + types.push(inferStructuralType(usage)); } + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + types.push.apply(types, inferNamedTypesFromProperties(usage)); return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + function inferStructuralType(usage) { + var members = ts.createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach(function (u, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); } + var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + } + function inferNamedTypesFromProperties(usage) { + if (!usage.properties || !usage.properties.size) + return []; + var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); + if (0 < types.length && types.length < 3) { + return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); + } + return []; + } + function allPropertiesAreAssignableToUsage(type, usage) { + if (!usage.properties) + return false; + return !ts.forEachEntry(usage.properties, function (propUsage, name) { + var source = checker.getTypeOfPropertyOfType(type, name); + if (!source) { + return true; + } + if (propUsage.calls) { + var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type, usage) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + return type; + } + var generic = type.target; + var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) + return type; var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + usage.properties.forEach(function (propUsage, name) { + var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); + ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName](combineTypes(types)); + } + function inferTypeParameters(genericType, usageType, typeParameter) { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); + } + else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + var genericArgs = checker.getTypeArguments(genericType); + var usageArgs = checker.getTypeArguments(usageType); + var types = []; + if (genericArgs && usageArgs) { + for (var i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); } } } + return types; } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } - return undefined; + return []; } - function getSignatureFromCallContext(callContext, checker) { + function inferFromSignatures(genericSig, usageSig, typeParameter) { + var types = []; + for (var i = 0; i < genericSig.parameters.length; i++) { + var genericParam = genericSig.parameters[i]; + var usageParam = usageSig.parameters[i]; + var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); + } + var genericReturn = checker.getReturnTypeOfSignature(genericSig); + var usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; + } + function getFunctionFromCalls(calls) { + return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + function getSignatureFromCalls(calls) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); + var _loop_12 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); + if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { + symbol.flags |= 16777216 /* Optional */; + } parameters.push(symbol); + }; + for (var i = 0; i < length; i++) { + _loop_12(i); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -117645,12 +122576,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -117682,7 +122613,7 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(117 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(119 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -117705,7 +122636,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 225 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -117713,27 +122644,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 201 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 222 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -117754,17 +122685,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 200 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 73 /* Identifier */) { + if (node.name.kind !== 75 /* Identifier */) { return undefined; } var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(precedingNode, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 88 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -117775,7 +122706,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 88 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -117838,12 +122769,12 @@ var ts; return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 122 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 125 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_13 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -117855,7 +122786,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_13(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -118149,10 +123080,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 73 /* Identifier */: // identifier includes undefined + case 75 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -118174,8 +123105,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -118287,6 +123218,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -118378,10 +123310,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -118427,29 +123359,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 60 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 62 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 195 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -118489,8 +123421,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -118498,11 +123430,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -118541,18 +123473,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); + case 160 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(88 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -118581,12 +123514,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -118599,7 +123530,7 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(86 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(88 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -118608,14 +123539,14 @@ var ts; } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(86 /* ExportKeyword */), ts.createToken(78 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(88 /* ExportKeyword */), ts.createToken(80 /* ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported) { - var modifiers = [ts.createToken(86 /* ExportKeyword */)]; + var modifiers = [ts.createToken(88 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -118623,10 +123554,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -118644,18 +123575,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 188 /* ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 189 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -118666,10 +123599,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -118691,7 +123624,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` var idName = namedBindingsNames.get(propertyName); if (idName === undefined) { idName = makeUniqueName(propertyName, identifiers); @@ -118738,11 +123671,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -118817,8 +123750,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -118845,7 +123780,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118943,7 +123878,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118956,7 +123891,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118964,14 +123899,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -119012,11 +123947,11 @@ var ts; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function codeFixActionToCodeAction(_a) { @@ -119082,21 +124017,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 253 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 256 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 253 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 255 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -119107,22 +124042,35 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 253 /* ImportDeclaration */ || i.kind === 252 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); + var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); - // Sort to keep the shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + // Sort by presence in package.json, then shortest paths first + return ts.sort(choicesForEachExportingModule, function (a, b) { + var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); + var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); + if (allowsImportingA && !allowsImportingB) { + return -1; + } + if (allowsImportingB && !allowsImportingA) { + return 1; + } + return a.moduleSpecifier.length - b.moduleSpecifier.length; + }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -119130,9 +124078,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 253 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 263 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -119189,7 +124137,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -119202,22 +124150,23 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default" /* Default */); - var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host); + var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, host) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); function addSymbol(moduleSymbol, exportedSymbol, importKind) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { @@ -119276,7 +124225,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -119292,7 +124241,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -119326,12 +124275,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -119349,7 +124298,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -119389,12 +124338,34 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(checker, from, allSourceFiles, cb) { - forEachExternalModule(checker, allSourceFiles, function (module, sourceFile) { - if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { - cb(module); + function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) { + var filteredCount = 0; + var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host); + var allSourceFiles = program.getSourceFiles(); + var globalTypingsCache = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); + forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) { + if (sourceFile === undefined) { + if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } + } + else if (sourceFile && + sourceFile !== from && + isImportablePath(from.fileName, sourceFile.fileName, ts.hostGetCanonicalFileName(host), globalTypingsCache)) { + if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } } }); + if (host.log) { + host.log("forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); + } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; function forEachExternalModule(checker, allSourceFiles, cb) { @@ -119413,10 +124384,13 @@ var ts; * Don't include something from a `node_modules` that isn't actually reachable by a global import. * A relative import to node_modules is usually a bad idea. */ - function isImportablePath(fromPath, toPath) { + function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); - return toNodeModules === undefined || ts.startsWith(fromPath, ts.getDirectoryPath(toNodeModules)); + var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); + return toNodeModulesParent === undefined + || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) + || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); @@ -119449,6 +124423,110 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; + function createAutoImportFilter(fromFile, program, host) { + var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host); + var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */; + // Mix in `getProbablySymlinks` from Program when host doesn't have it + // in order for non-Project hosts to have a symlinks cache. + var moduleSpecifierResolutionHost = { + directoryExists: ts.maybeBind(host, host.directoryExists), + fileExists: ts.maybeBind(host, host.fileExists), + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + readFile: ts.maybeBind(host, host.readFile), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks, + getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), + }; + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName, dependencyGroups) || packageJson.has(ts.getTypesPackageName(packageName), dependencyGroups)) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + /** + * Use for a specific module specifier that has already been resolved. + * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve + * the best module specifier for a given module _and_ determine if it’s importable. + */ + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -119492,12 +124570,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -119600,7 +124678,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -119627,7 +124705,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_14(info); } }); })); @@ -119688,7 +124766,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 213 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -119714,7 +124792,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 208 /* BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); @@ -119724,7 +124802,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; } - return typeNode || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return typeNode || ts.createKeywordTypeNode(124 /* AnyKeyword */); } function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); }); @@ -119733,7 +124811,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -119757,7 +124835,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(139 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(142 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -119777,7 +124855,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 160 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119985,7 +125063,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 101 /* ThisKeyword */) + if (token.kind !== 103 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -120024,7 +125102,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 128 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -120068,6 +125146,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120095,14 +125210,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 87 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 89 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(110 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(112 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 87 /* ExtendsKeyword */ && - heritageClauses[1].token === 110 /* ImplementsKeyword */) { + heritageClauses[0].token === 89 /* ExtendsKeyword */ && + heritageClauses[1].token === 112 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* CommaToken */)); @@ -120189,7 +125304,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 28 /* LessThanToken */) { + if (token.kind === 29 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -120209,7 +125324,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -120241,7 +125356,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 128 /* InferKeyword */) + if (token.kind === 131 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -120250,7 +125365,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 28 /* LessThanToken */) { + else if (token.kind === 29 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -120260,7 +125375,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -120271,23 +125386,23 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(144 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(147 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 93 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 95 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 155 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -120298,7 +125413,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -120307,7 +125422,7 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -120316,14 +125431,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 155 /* Parameter */: + case 154 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return true; } } @@ -120370,26 +125485,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); - ts.Debug.assert(index !== -1); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 75 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -120425,11 +125540,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -120440,15 +125555,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -120490,7 +125605,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -120514,7 +125629,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 292 /* JSDocNullableType */) { + if (typeNode.kind === 295 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -120534,7 +125649,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 295 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -120551,22 +125666,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 216 /* AsExpression */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 162 /* GetAccessor */: + case 166 /* IndexSignature */: + case 185 /* MappedType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 198 /* TypeAssertionExpression */: + case 241 /* VariableDeclaration */: return true; default: return false; @@ -120595,12 +125710,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -120620,14 +125738,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 93 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -120642,11 +125760,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 73 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 75 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 122 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 125 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -120754,17 +125872,17 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 4194304 /* Ambient */); + var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); switch (declaration.kind) { - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 158 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: { + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: { var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var orderedAccessors = allAccessors.secondAccessor @@ -120777,7 +125895,7 @@ var ts; /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); } else { - ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration); + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); var parameter = ts.getSetAccessorValueParameter(accessor); var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; out(ts.createSetAccessor( @@ -120786,8 +125904,8 @@ var ts; } break; } - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 160 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -120800,7 +125918,7 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; @@ -120816,7 +125934,7 @@ var ts; outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); } else { - ts.Debug.assert(declarations.length === signatures.length); + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); } } @@ -120830,14 +125948,14 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 160 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(57 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -120851,15 +125969,14 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(41 /* AsteriskToken */) : undefined, methodName, /*questionToken*/ undefined, /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); @@ -120876,8 +125993,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(121 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(124 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -120894,22 +126011,22 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - if (sig.hasRestParameter) { + if (ts.signatureHasRestParameter(sig)) { someSigHasRestParameter = true; } - if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!ts.signatureHasRestParameter(sig) || ts.signatureHasRestParameter(maxArgsSignature))) { maxArgsSignature = sig; } } - var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + var maxNonRestArgs = maxArgsSignature.parameters.length - (ts.signatureHasRestParameter(maxArgsSignature) ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { - var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(121 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(124 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -120920,7 +126037,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -120931,10 +126048,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(116 /* PublicKeyword */); + return ts.createToken(118 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(115 /* ProtectedKeyword */); + return ts.createToken(117 /* ProtectedKeyword */); } return undefined; } @@ -121006,7 +126123,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 195 /* CallExpression */ : 196 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -121117,7 +126234,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties); } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -121125,7 +126242,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(145 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); @@ -121246,6 +126363,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -121267,8 +126417,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 95 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 187 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -121320,7 +126470,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(137 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); @@ -121351,7 +126501,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 123 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 126 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -121362,7 +126512,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 96 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 98 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -121373,6 +126523,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -121389,8 +126573,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -121410,16 +126594,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -121428,7 +126612,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + ts.Debug.assert(!wasDefault, "Can't have a default flag here"); return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } default: @@ -121442,40 +126626,40 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 83 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 88 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(83 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -121489,27 +126673,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 251 /* ImportClause */: { + case 254 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 255 /* NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; @@ -121530,11 +126714,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 257 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.createIdentifier(parent.name.text); @@ -121547,7 +126731,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 261 /* ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -121556,7 +126740,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -121580,13 +126764,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 255 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 255 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -121603,7 +126787,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 255 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -121624,7 +126808,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -121663,7 +126847,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -121682,7 +126866,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -121803,6 +126987,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -121894,6 +127079,9 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -121946,20 +127134,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 158 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 155 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 161 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 160 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -121977,13 +127165,13 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 4194304 /* Ambient */) { + if (nodeToCheck.flags & 8388608 /* Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -122002,7 +127190,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 241 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! @@ -122014,13 +127202,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 192 /* CallExpression */) { + if (node.parent.kind === 195 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -122035,8 +127223,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -122048,20 +127236,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 222 /* Block */: + if (node.parent && node.parent.kind === 239 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -122073,19 +127261,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 182 /* ThisType */: + case 103 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -122094,20 +127282,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 233 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -122161,7 +127349,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 152 /* Parameter */) { + if (current.kind === 155 /* Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -122172,7 +127360,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 288 /* SourceFile */) { return scopes; } } @@ -122262,32 +127450,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 244 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 246 /* ModuleBlock */ + return scope.kind === 249 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -122353,20 +127541,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(114 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(116 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(122 /* AsyncKeyword */)); + modifiers.push(ts.createToken(125 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(122 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(125 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -122383,7 +127571,7 @@ var ts; var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.createYield(ts.createToken(40 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(41 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -122391,8 +127579,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -122460,7 +127648,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -122507,9 +127695,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 142 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 145 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(142 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); } } /** @@ -122517,6 +127705,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -122527,16 +127716,17 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(114 /* PrivateKeyword */)); + modifiers.push(ts.createToken(116 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } - modifiers.push(ts.createToken(134 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(137 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -122565,7 +127755,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 225 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.createVariableStatement( @@ -122584,7 +127774,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 225 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -122598,6 +127788,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -122671,7 +127918,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 234 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -122734,11 +127981,11 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { - var member = members_2[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -122776,11 +128023,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -122849,7 +128096,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 243 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -122902,7 +128149,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -122912,7 +128159,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -122934,7 +128181,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -122952,7 +128199,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -123165,30 +128412,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 282 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 253 /* ImportDeclaration */ && + parent.kind !== 257 /* ImportSpecifier */; + case 212 /* SpreadElement */: + case 188 /* ObjectBindingPattern */: + case 190 /* BindingElement */: return false; - case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + case 75 /* Identifier */: + return parent.kind !== 190 /* BindingElement */ && + parent.kind !== 257 /* ImportSpecifier */ && + parent.kind !== 261 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 222 /* Block */: + case 288 /* SourceFile */: + case 249 /* ModuleBlock */: + case 275 /* CaseClause */: return true; default: return false; @@ -123204,6 +128451,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -123213,22 +128461,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -123243,14 +128503,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; } - function isStatementAndHasJSDoc(n) { - return ts.isStatement(n) && ts.hasJSDocNodes(n); + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function rangeContainsSkipTrivia(r1, node, file) { return ts.rangeContainsStartEnd(r1, ts.skipTrivia(file.text, node.pos), node.end); @@ -123298,15 +128580,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(312 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(315 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -123314,10 +128607,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(311 /* JSDocTemplateTag */); + var template = ts.createNode(314 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(154 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -123367,10 +128660,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 116 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 118 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 114 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 116 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -123408,7 +128701,7 @@ var ts; return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { - var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(117 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(119 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -123431,7 +128724,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 155 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -123477,24 +128770,22 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration, declaration.parent) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 101 /* ThisKeyword */ && + node.expression.kind === 103 /* ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 103 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -123519,7 +128810,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -123576,11 +128867,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -123633,10 +128924,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -123658,25 +128949,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 253 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 255 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -123704,20 +128995,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 253 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 252 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -123759,7 +129050,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -123787,19 +129078,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -123808,7 +129099,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 255 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -123820,7 +129111,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 256 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -123833,14 +129124,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -123914,7 +129205,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -123967,13 +129258,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -123985,7 +129276,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123995,18 +129286,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -124016,11 +129307,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 188 /* ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.createObjectBindingPattern(newElements) : undefined; @@ -124072,18 +129363,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -124091,17 +129382,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -124111,13 +129402,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -124125,9 +129416,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -124158,28 +129449,28 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(88 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { @@ -124187,26 +129478,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 225 /* ExpressionStatement */: + return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 60 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 62 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -124329,7 +129620,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -124468,15 +129759,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -124486,7 +129777,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -124505,14 +129796,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -124554,11 +129845,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 161 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -124566,8 +129857,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -124577,7 +129868,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 81 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 83 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -124692,7 +129983,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(56 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); ts.suppressLeadingAndTrailingTrivia(propertySignature); copyComments(parameterDeclaration.name, propertySignature.name); @@ -124738,15 +130029,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 83 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -124757,30 +130048,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 83 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: - var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + case 161 /* Constructor */: + var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 128 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 213 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -124792,10 +130083,10 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 73 /* Identifier */ ? new IdentifierObject(73 /* Identifier */, pos, end) : + kind === 75 /* Identifier */ ? new IdentifierObject(75 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 12679168 /* ContextFlags */; + node.flags = parent.flags & 25358336 /* ContextFlags */; return node; } var NodeObject = /** @class */ (function () { @@ -124809,7 +130100,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -124866,8 +130157,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 313 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 292 /* FirstJSDocNode */ || kid.kind > 316 /* LastJSDocNode */; }); + return child.kind < 152 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -124878,7 +130169,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 152 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -124924,7 +130215,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 73 /* Identifier */) { + if (token === 75 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -124936,7 +130227,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(314 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(317 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -125059,7 +130350,9 @@ var ts; var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { - return _super.call(this, pos, end) || this; + var _this = _super.call(this, pos, end) || this; + _this.kind = 75 /* Identifier */; + return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { get: function () { @@ -125070,7 +130363,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 73 /* Identifier */; + IdentifierObject.prototype.kind = 75 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -125106,9 +130399,15 @@ var ts; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; }; + TypeObject.prototype.isNullableType = function () { + return this.checker.isNullableType(this); + }; TypeObject.prototype.getNonNullableType = function () { return this.checker.getNonNullableType(this); }; + TypeObject.prototype.getNonOptionalType = function () { + return this.checker.getNonOptionalType(this); + }; TypeObject.prototype.getConstraint = function () { return this.checker.getBaseConstraintOfType(this); }; @@ -125142,11 +130441,25 @@ var ts; TypeObject.prototype.isClass = function () { return !!(ts.getObjectFlags(this) & 1 /* Class */); }; + Object.defineProperty(TypeObject.prototype, "typeArguments", { + /** + * This polyfills `referenceType.typeArguments` for API consumers + */ + get: function () { + if (ts.getObjectFlags(this) & 4 /* Reference */) { + return this.checker.getTypeArguments(this); + } + return undefined; + }, + enumerable: true, + configurable: true + }); return TypeObject; }()); var SignatureObject = /** @class */ (function () { - function SignatureObject(checker) { + function SignatureObject(checker, flags) { this.checker = checker; + this.flags = flags; } SignatureObject.prototype.getDeclaration = function () { return this.declaration; @@ -125184,13 +130497,12 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var declaration = declarations_4[_i]; + ts.forEachUnique(declarations, function (declaration) { var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); - } + }); } return doc; } @@ -125213,7 +130525,9 @@ var ts; var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - return _super.call(this, kind, pos, end) || this; + var _this = _super.call(this, kind, pos, end) || this; + _this.kind = 288 /* SourceFile */; + return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -125271,10 +130585,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -125294,31 +130608,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 172 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -125329,19 +130643,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -125353,7 +130667,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -125362,7 +130676,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -125559,7 +130873,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -125679,10 +130993,10 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; }, getCurrentDirectory: function () { return currentDirectory; }, getProgram: getProgram, - fileExists: host.fileExists && (function (f) { return host.fileExists(f); }), - readFile: host.readFile && (function (f, encoding) { return host.readFile(f, encoding); }), - getDocumentPositionMapper: host.getDocumentPositionMapper && (function (generatedFileName, sourceFileName) { return host.getDocumentPositionMapper(generatedFileName, sourceFileName); }), - getSourceFileLike: host.getSourceFileLike && (function (f) { return host.getSourceFileLike(f); }), + fileExists: ts.maybeBind(host, host.fileExists), + readFile: ts.maybeBind(host, host.readFile), + getDocumentPositionMapper: ts.maybeBind(host, host.getDocumentPositionMapper), + getSourceFileLike: ts.maybeBind(host, host.getSourceFileLike), log: log }); function getValidSourceFile(fileName) { @@ -125778,6 +131092,12 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }; } + if (host.setResolvedProjectReferenceCallbacks) { + compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); }; + } + if (host.useSourceOfProjectReferenceRedirect) { + compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); }; + } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -125938,7 +131258,7 @@ var ts; } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }); + return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host); } function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); @@ -125982,15 +131302,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 99 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 101 /* SuperKeyword */: return true; default: return false; @@ -126063,12 +131383,11 @@ var ts; var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } - function getEmitOutput(fileName, emitOnlyDtsFiles) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function getEmitOutput(fileName, emitOnlyDtsFiles, forceDtsEmit) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); - return ts.getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers); + return ts.getFileEmitOutput(program, sourceFile, !!emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit); } // Signature help /** @@ -126092,16 +131411,16 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: case 10 /* StringLiteral */: - case 88 /* FalseKeyword */: - case 103 /* TrueKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 73 /* Identifier */: + case 90 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 75 /* Identifier */: break; // Cant create the text span default: @@ -126117,7 +131436,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 248 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -126182,7 +131501,7 @@ var ts; _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, + _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -126306,7 +131625,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -126569,7 +131888,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 263 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -126585,14 +131904,15 @@ var ts; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 153 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 192 /* ObjectLiteralExpression */ || node.parent.parent.kind === 272 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -126634,7 +131954,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -126681,7 +132001,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 4194304 /* Ambient */) { + if (tokenAtLocation.flags & 8388608 /* Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -126714,114 +132034,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 190 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 156 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -126839,19 +132159,19 @@ var ts; return spanInOpenParenToken(node); case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 57 /* ColonToken */: + case 58 /* ColonToken */: return spanInColonToken(node); - case 30 /* GreaterThanToken */: - case 28 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return spanInWhileKeyword(node); - case 84 /* ElseKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + case 86 /* ElseKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 151 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -126863,14 +132183,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + if ((node.kind === 75 /* Identifier */ || + node.kind === 212 /* SpreadElement */ || + node.kind === 279 /* PropertyAssignment */ || + node.kind === 280 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 208 /* BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -126879,7 +132199,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 60 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -126892,22 +132212,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 156 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -126916,21 +132236,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -126938,7 +132258,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -126968,7 +132288,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 230 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -126980,7 +132300,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 231 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -127021,7 +132341,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 244 /* ClassDeclaration */ && functionDeclaration.kind !== 161 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -127044,26 +132364,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 230 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 242 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -127088,21 +132408,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 190 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 189 /* ArrayBindingPattern */ && node.kind !== 188 /* ObjectBindingPattern */); + var elements = node.kind === 191 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -127110,18 +132430,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 208 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -127129,25 +132449,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -127155,7 +132475,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -127171,7 +132491,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -127186,12 +132506,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 227 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 195 /* CallExpression */ || + node.parent.kind === 196 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 199 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -127200,21 +132520,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 199 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -127224,20 +132544,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 279 /* PropertyAssignment */ || + node.parent.kind === 155 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 198 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 227 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -127245,7 +132565,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 231 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -127290,10 +132610,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -127315,9 +132634,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -127388,6 +132709,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -127416,6 +132738,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -127427,6 +132750,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -127570,13 +132894,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -127584,13 +132908,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -128048,8 +133373,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; @@ -128266,9 +133590,10 @@ var ts; WatchType["MissingSourceMapFile"] = "Missing source map file"; WatchType["NoopConfigFileForInferredRoot"] = "Noop Config file for the inferred project root"; WatchType["MissingGeneratedFile"] = "Missing generated file"; + WatchType["PackageJsonFile"] = "package.json file for import suggestions"; })(WatchType = ts.WatchType || (ts.WatchType = {})); })(ts || (ts = {})); -// tslint:disable no-unnecessary-qualifier +/* eslint-disable @typescript-eslint/no-unnecessary-qualifier */ /** * Declaration module describing the TypeScript Server protocol */ @@ -128417,6 +133742,12 @@ var ts; IndentStyle["Block"] = "Block"; IndentStyle["Smart"] = "Smart"; })(IndentStyle = protocol.IndentStyle || (protocol.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = protocol.SemicolonPreference || (protocol.SemicolonPreference = {})); var JsxEmit; (function (JsxEmit) { JsxEmit["None"] = "None"; @@ -128842,20 +134173,43 @@ var ts; case 1: return this.containingProjects[0]; default: - // if this file belongs to multiple projects, the first configured project should be - // the default project; if no configured projects, the first external project should - // be the default project; otherwise the first inferred project should be the default. + // If this file belongs to multiple projects, below is the order in which default project is used + // - for open script info, its default configured project during opening is default if info is part of it + // - first configured project of which script info is not a source of project reference redirect + // - first configured project + // - first external project + // - first inferred project var firstExternalProject = void 0; - for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { - var project = _a[_i]; + var firstConfiguredProject = void 0; + var firstNonSourceOfProjectReferenceRedirect = void 0; + var defaultConfiguredProject = void 0; + for (var index = 0; index < this.containingProjects.length; index++) { + var project = this.containingProjects[index]; if (project.projectKind === server.ProjectKind.Configured) { - return project; + if (!project.isSourceOfProjectReferenceRedirect(this.fileName)) { + // If we havent found default configuredProject and + // its not the last one, find it and use that one if there + if (defaultConfiguredProject === undefined && + index !== this.containingProjects.length - 1) { + defaultConfiguredProject = project.projectService.findDefaultConfiguredProject(this) || false; + } + if (defaultConfiguredProject === project) + return project; + if (!firstNonSourceOfProjectReferenceRedirect) + firstNonSourceOfProjectReferenceRedirect = project; + } + if (!firstConfiguredProject) + firstConfiguredProject = project; } else if (project.projectKind === server.ProjectKind.External && !firstExternalProject) { firstExternalProject = project; } } - return firstExternalProject || this.containingProjects[0]; + return defaultConfiguredProject || + firstNonSourceOfProjectReferenceRedirect || + firstConfiguredProject || + firstExternalProject || + this.containingProjects[0]; } }; ScriptInfo.prototype.registerFileUpdate = function () { @@ -128918,7 +134272,7 @@ var ts; ScriptInfo.prototype.markContainingProjectsAsDirty = function () { for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { var p = _a[_i]; - p.markAsDirty(); + p.markFileAsDirty(this.path); } }; ScriptInfo.prototype.isOrphan = function () { @@ -129154,7 +134508,7 @@ var ts; var Project = /** @class */ (function () { /*@internal*/ function Project( - /*@internal*/ projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, directoryStructureHost, currentDirectory) { + /*@internal*/ projectName, projectKind, projectService, documentRegistry, hasExplicitListOfFiles, lastFileExceededProgramSize, compilerOptions, compileOnSaveEnabled, directoryStructureHost, currentDirectory, customRealpath) { var _this = this; this.projectName = projectName; this.projectKind = projectKind; @@ -129198,6 +134552,8 @@ var ts; /*@internal*/ this.typingFiles = server.emptyArray; /*@internal*/ + this.importSuggestionsCache = ts.Completions.createImportSuggestionsForFileCache(); + /*@internal*/ this.globalCacheResolutionModuleName = ts.JsTyping.nonRelativeModuleNameForTypingCache; this.directoryStructureHost = directoryStructureHost; this.currentDirectory = this.projectService.getNormalizedAbsolutePath(currentDirectory || ""); @@ -129222,7 +134578,7 @@ var ts; this.trace = function (s) { return host.trace(s); }; } if (host.realpath) { - this.realpath = function (path) { return host.realpath(path); }; + this.realpath = customRealpath || (function (path) { return host.realpath(path); }); } // Use the current directory as resolution root only if the project created using current directory string this.resolutionCache = ts.createResolutionCache(this, currentDirectory && this.currentDirectory, /*logChangesWhenResolvingModule*/ true); @@ -129232,7 +134588,12 @@ var ts; } this.markAsDirty(); this.projectService.pendingEnsureProjectForOpenFiles = true; + this.packageJsonCache = server.createPackageJsonCache(this); } + /*@internal*/ + Project.prototype.getResolvedProjectReferenceToRedirect = function (_fileName) { + return undefined; + }; Project.prototype.isNonTsProject = function () { server.updateProjectIfDirty(this); return allFilesAreJsOrDts(this); @@ -129258,6 +134619,10 @@ var ts; Project.prototype.installPackage = function (options) { return this.typingsCache.installPackage(__assign(__assign({}, options), { projectName: this.projectName, projectRootPath: this.toPath(this.currentDirectory) })); }; + /*@internal*/ + Project.prototype.getGlobalTypingsCacheLocation = function () { + return this.getGlobalCache(); + }; Object.defineProperty(Project.prototype, "typingsCache", { get: function () { return this.projectService.typingsCache; @@ -129265,6 +134630,10 @@ var ts; enumerable: true, configurable: true }); + /*@internal*/ + Project.prototype.getProbableSymlinks = function (files) { + return this.symlinks || (this.symlinks = ts.discoverProbableSymlinks(files, this.getCanonicalFileName, this.getCurrentDirectory())); + }; // Method of LanguageServiceHost Project.prototype.getCompilationSettings = function () { return this.compilerOptions; @@ -129346,6 +134715,10 @@ var ts; return this.projectService.host.writeFile(fileName, content); }; Project.prototype.fileExists = function (file) { + return this.fileExistsWithCache(file); + }; + /* @internal */ + Project.prototype.fileExistsWithCache = function (file) { // As an optimization, don't hit the disks for files we already know don't exist // (because we're watching for their creation). var path = this.toPath(file); @@ -129442,8 +134815,11 @@ var ts; Project.prototype.getSourceFileLike = function (fileName) { return this.projectService.getSourceFileLike(fileName, this); }; + /*@internal*/ Project.prototype.shouldEmitFile = function (scriptInfo) { - return scriptInfo && !scriptInfo.isDynamicOrHasMixedContent(); + return scriptInfo && + !scriptInfo.isDynamicOrHasMixedContent() && + !this.program.isSourceOfProjectReferenceRedirect(scriptInfo.path); }; Project.prototype.getCompileOnSaveAffectedFileList = function (scriptInfo) { var _this = this; @@ -129569,6 +134945,10 @@ var ts; ts.clearMap(this.missingFilesMap, ts.closeFileWatcher); this.missingFilesMap = undefined; } + if (this.packageJsonFilesMap) { + ts.clearMap(this.packageJsonFilesMap, ts.closeFileWatcher); + this.packageJsonFilesMap = undefined; + } this.clearGeneratedFileWatch(); // signal language service to release source files acquired from document registry this.languageService.dispose(); @@ -129725,6 +135105,13 @@ var ts; Project.prototype.registerFileUpdate = function (fileName) { (this.updatedFileNames || (this.updatedFileNames = ts.createMap())).set(fileName, true); }; + /*@internal*/ + Project.prototype.markFileAsDirty = function (changedFile) { + this.markAsDirty(); + if (!this.importSuggestionsCache.isEmpty()) { + (this.dirtyFilesForSuggestions || (this.dirtyFilesForSuggestions = ts.createMap())).set(changedFile, true); + } + }; Project.prototype.markAsDirty = function () { if (!this.dirty) { this.projectStateVersion++; @@ -129860,6 +135247,27 @@ var ts; this.resolutionCache.updateTypeRootsWatch(); } } + if (!this.importSuggestionsCache.isEmpty()) { + if (this.hasAddedorRemovedFiles || oldProgram && !oldProgram.structureIsReused) { + this.importSuggestionsCache.clear(); + } + else if (this.dirtyFilesForSuggestions && oldProgram && this.program) { + ts.forEachKey(this.dirtyFilesForSuggestions, function (fileName) { + var oldSourceFile = oldProgram.getSourceFile(fileName); + var sourceFile = _this.program.getSourceFile(fileName); + if (_this.sourceFileHasChangedOwnImportSuggestions(oldSourceFile, sourceFile)) { + _this.importSuggestionsCache.clear(); + return true; + } + }); + } + } + if (this.dirtyFilesForSuggestions) { + this.dirtyFilesForSuggestions.clear(); + } + if (this.hasAddedorRemovedFiles) { + this.symlinks = undefined; + } var oldExternalFiles = this.externalFiles || server.emptyArray; this.externalFiles = this.getExternalFiles(); ts.enumerateInsertsAndDeletes(this.externalFiles, oldExternalFiles, ts.getStringComparer(!this.useCaseSensitiveFileNames()), @@ -129880,6 +135288,54 @@ var ts; } return hasNewProgram; }; + /*@internal*/ + Project.prototype.sourceFileHasChangedOwnImportSuggestions = function (oldSourceFile, newSourceFile) { + if (!oldSourceFile && !newSourceFile) { + return false; + } + // Probably shouldn’t get this far, but on the off chance the file was added or removed, + // we can’t reliably tell anything about it. + if (!oldSourceFile || !newSourceFile) { + return true; + } + ts.Debug.assertEqual(oldSourceFile.fileName, newSourceFile.fileName); + // If ATA is enabled, auto-imports uses existing imports to guess whether you want auto-imports from node. + // Adding or removing imports from node could change the outcome of that guess, so could change the suggestions list. + if (this.getTypeAcquisition().enable && ts.consumesNodeCoreModules(oldSourceFile) !== ts.consumesNodeCoreModules(newSourceFile)) { + return true; + } + // Module agumentation and ambient module changes can add or remove exports available to be auto-imported. + // Changes elsewhere in the file can change the *type* of an export in a module augmentation, + // but type info is gathered in getCompletionEntryDetails, which doesn’t use the cache. + if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations) || + !this.ambientModuleDeclarationsAreEqual(oldSourceFile, newSourceFile)) { + return true; + } + return false; + }; + /*@internal*/ + Project.prototype.ambientModuleDeclarationsAreEqual = function (oldSourceFile, newSourceFile) { + if (!ts.arrayIsEqualTo(oldSourceFile.ambientModuleNames, newSourceFile.ambientModuleNames)) { + return false; + } + var oldFileStatementIndex = -1; + var newFileStatementIndex = -1; + var _loop_1 = function (ambientModuleName) { + var isMatchingModuleDeclaration = function (node) { return ts.isNonGlobalAmbientModule(node) && node.name.text === ambientModuleName; }; + oldFileStatementIndex = ts.findIndex(oldSourceFile.statements, isMatchingModuleDeclaration, oldFileStatementIndex + 1); + newFileStatementIndex = ts.findIndex(newSourceFile.statements, isMatchingModuleDeclaration, newFileStatementIndex + 1); + if (oldSourceFile.statements[oldFileStatementIndex] !== newSourceFile.statements[newFileStatementIndex]) { + return { value: false }; + } + }; + for (var _i = 0, _a = newSourceFile.ambientModuleNames; _i < _a.length; _i++) { + var ambientModuleName = _a[_i]; + var state_1 = _loop_1(ambientModuleName); + if (typeof state_1 === "object") + return state_1.value; + } + return true; + }; Project.prototype.detachScriptInfoFromProject = function (uncheckedFileName, noRemoveResolution) { var scriptInfoToDetach = this.projectService.getScriptInfo(uncheckedFileName); if (scriptInfoToDetach) { @@ -130056,6 +135512,10 @@ var ts; ts.orderedRemoveItem(this.rootFiles, info); this.rootFilesMap.delete(info.path); }; + /*@internal*/ + Project.prototype.isSourceOfProjectReferenceRedirect = function (fileName) { + return !!this.program && this.program.isSourceOfProjectReferenceRedirect(fileName); + }; Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { @@ -130066,7 +135526,7 @@ var ts; // ../../.. to walk from X/node_modules/typescript/lib/tsserver.js to X/node_modules/ var searchPaths = __spreadArrays([ts.combinePaths(this.projectService.getExecutingFilePath(), "../../..")], this.projectService.pluginProbeLocations); if (this.projectService.globalPlugins) { - var _loop_1 = function (globalPluginName) { + var _loop_2 = function (globalPluginName) { // Skip empty names from odd commandline parses if (!globalPluginName) return "continue"; @@ -130081,7 +135541,7 @@ var ts; // Enable global plugins with synthetic configuration entries for (var _i = 0, _a = this.projectService.globalPlugins; _i < _a.length; _i++) { var globalPluginName = _a[_i]; - _loop_1(globalPluginName); + _loop_2(globalPluginName); } } }; @@ -130126,6 +135586,7 @@ var ts; var newLS = pluginModule.create(info); for (var _i = 0, _a = Object.keys(this.languageService); _i < _a.length; _i++) { var k = _a[_i]; + // eslint-disable-next-line no-in-operator if (!(k in newLS)) { this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); newLS[k] = this.languageService[k]; @@ -130151,6 +135612,61 @@ var ts; Project.prototype.refreshDiagnostics = function () { this.projectService.sendProjectsUpdatedInBackgroundEvent(); }; + /*@internal*/ + Project.prototype.getPackageJsonsVisibleToFile = function (fileName, rootDir) { + var packageJsonCache = this.packageJsonCache; + var watchPackageJsonFile = this.watchPackageJsonFile.bind(this); + var toPath = this.toPath.bind(this); + var rootPath = rootDir && toPath(rootDir); + var filePath = toPath(fileName); + var result = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(filePath), function processDirectory(directory) { + switch (packageJsonCache.directoryHasPackageJson(directory)) { + // Sync and check same directory again + case 1 /* Maybe */: + packageJsonCache.searchDirectoryAndAncestors(directory); + return processDirectory(directory); + // Check package.json + case -1 /* True */: + var packageJsonFileName = ts.combinePaths(directory, "package.json"); + watchPackageJsonFile(packageJsonFileName); + result.push(ts.Debug.assertDefined(packageJsonCache.getInDirectory(directory))); + } + if (rootPath && rootPath === toPath(directory)) { + return true; + } + }); + return result; + }; + /*@internal*/ + Project.prototype.onAddPackageJson = function (path) { + this.packageJsonCache.addOrUpdate(path); + this.watchPackageJsonFile(path); + }; + /*@internal*/ + Project.prototype.getImportSuggestionsCache = function () { + return this.importSuggestionsCache; + }; + Project.prototype.watchPackageJsonFile = function (path) { + var _this = this; + var watchers = this.packageJsonFilesMap || (this.packageJsonFilesMap = ts.createMap()); + if (!watchers.has(path)) { + watchers.set(path, this.projectService.watchFactory.watchFile(this.projectService.host, path, function (fileName, eventKind) { + var path = _this.toPath(fileName); + switch (eventKind) { + case ts.FileWatcherEventKind.Created: + return ts.Debug.fail(); + case ts.FileWatcherEventKind.Changed: + _this.packageJsonCache.addOrUpdate(path); + break; + case ts.FileWatcherEventKind.Deleted: + _this.packageJsonCache.delete(path); + watchers.get(path).close(); + watchers.delete(path); + } + }, ts.PollingInterval.Low, "package.json file for import suggestions" /* PackageJsonFile */)); + } + }; return Project; }()); server.Project = Project; @@ -130282,7 +135798,7 @@ var ts; /*hasExplicitListOfFiles*/ false, /*lastFileExceededProgramSize*/ undefined, /*compilerOptions*/ {}, - /*compileOnSaveEnabled*/ false, cachedDirectoryStructureHost, ts.getDirectoryPath(configFileName)) || this; + /*compileOnSaveEnabled*/ false, cachedDirectoryStructureHost, ts.getDirectoryPath(configFileName), projectService.host.realpath && (function (s) { return _this.getRealpath(s); })) || this; /*@internal*/ _this.canConfigFileJsonReportNoInputFiles = false; /** Ref count to the project when opened from external project */ @@ -130290,9 +135806,138 @@ var ts; _this.isInitialLoadPending = ts.returnTrue; /*@internal*/ _this.sendLoadingProjectFinish = false; + /* @internal */ + _this.useSourceOfProjectReferenceRedirect = function () { return !!_this.languageServiceEnabled && + !_this.getCompilerOptions().disableSourceOfProjectReferenceRedirect; }; _this.canonicalConfigFilePath = server.asNormalizedPath(projectService.toCanonicalFileName(configFileName)); return _this; } + /* @internal */ + ConfiguredProject.prototype.setResolvedProjectReferenceCallbacks = function (projectReferenceCallbacks) { + this.projectReferenceCallbacks = projectReferenceCallbacks; + }; + ConfiguredProject.prototype.fileExistsIfProjectReferenceDts = function (file) { + var source = this.projectReferenceCallbacks.getSourceOfProjectReferenceRedirect(file); + return source !== undefined ? + ts.isString(source) ? _super.prototype.fileExists.call(this, source) : true : + undefined; + }; + /** + * This implementation of fileExists checks if the file being requested is + * .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that file exists on host + */ + ConfiguredProject.prototype.fileExists = function (file) { + if (_super.prototype.fileExists.call(this, file)) + return true; + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) + return false; + if (!ts.isDeclarationFileName(file)) + return false; + // Project references go to source file instead of .d.ts file + return this.fileOrDirectoryExistsUsingSource(file, /*isFile*/ true); + }; + ConfiguredProject.prototype.directoryExistsIfProjectReferenceDeclDir = function (dir) { + var dirPath = this.toPath(dir); + var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator; + return ts.forEachKey(this.mapOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath || ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator); }); + }; + /** + * This implementation of directoryExists checks if the directory being requested is + * directory of .d.ts file for the referenced Project. + * If it is it returns true irrespective of whether that directory exists on host + */ + ConfiguredProject.prototype.directoryExists = function (path) { + var _this = this; + if (_super.prototype.directoryExists.call(this, path)) { + this.handleDirectoryCouldBeSymlink(path); + return true; + } + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) + return false; + if (!this.mapOfDeclarationDirectories) { + this.mapOfDeclarationDirectories = ts.createMap(); + this.projectReferenceCallbacks.forEachResolvedProjectReference(function (ref) { + if (!ref) + return; + var out = ref.commandLine.options.outFile || ref.commandLine.options.out; + if (out) { + _this.mapOfDeclarationDirectories.set(ts.getDirectoryPath(_this.toPath(out)), true); + } + else { + // Set declaration's in different locations only, if they are next to source the directory present doesnt change + var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir; + if (declarationDir) { + _this.mapOfDeclarationDirectories.set(_this.toPath(declarationDir), true); + } + } + }); + } + return this.fileOrDirectoryExistsUsingSource(path, /*isFile*/ false); + }; + ConfiguredProject.prototype.realpathIfSymlinkedProjectReferenceDts = function (s) { + return this.symlinkedFiles && this.symlinkedFiles.get(this.toPath(s)); + }; + ConfiguredProject.prototype.getRealpath = function (s) { + return this.realpathIfSymlinkedProjectReferenceDts(s) || + this.projectService.host.realpath(s); + }; + ConfiguredProject.prototype.handleDirectoryCouldBeSymlink = function (directory) { + if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) + return; + // Because we already watch node_modules, handle symlinks in there + if (!this.realpath || !ts.stringContains(directory, ts.nodeModulesPathPart)) + return; + if (!this.symlinkedDirectories) + this.symlinkedDirectories = ts.createMap(); + var directoryPath = ts.ensureTrailingDirectorySeparator(this.toPath(directory)); + if (this.symlinkedDirectories.has(directoryPath)) + return; + var real = this.projectService.host.realpath(directory); + var realPath; + if (real === directory || + (realPath = ts.ensureTrailingDirectorySeparator(this.toPath(real))) === directoryPath) { + // not symlinked + this.symlinkedDirectories.set(directoryPath, false); + return; + } + this.symlinkedDirectories.set(directoryPath, { + real: ts.ensureTrailingDirectorySeparator(real), + realPath: realPath + }); + }; + ConfiguredProject.prototype.fileOrDirectoryExistsUsingSource = function (fileOrDirectory, isFile) { + var _this = this; + var fileOrDirectoryExistsUsingSource = isFile ? + function (file) { return _this.fileExistsIfProjectReferenceDts(file); } : + function (dir) { return _this.directoryExistsIfProjectReferenceDeclDir(dir); }; + // Check current directory or file + var result = fileOrDirectoryExistsUsingSource(fileOrDirectory); + if (result !== undefined) + return result; + if (!this.symlinkedDirectories) + return false; + var fileOrDirectoryPath = this.toPath(fileOrDirectory); + if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart)) + return false; + if (isFile && this.symlinkedFiles && this.symlinkedFiles.has(fileOrDirectoryPath)) + return true; + // If it contains node_modules check if its one of the symlinked path we know of + return ts.firstDefinedIterator(this.symlinkedDirectories.entries(), function (_a) { + var directoryPath = _a[0], symlinkedDirectory = _a[1]; + if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath)) + return undefined; + var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath)); + if (isFile && result) { + if (!_this.symlinkedFiles) + _this.symlinkedFiles = ts.createMap(); + // Store the real path for the file' + var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, _this.currentDirectory); + _this.symlinkedFiles.set(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), "")); + } + return result; + }) || false; + }; /** * If the project has reload from disk pending, it reloads (and then updates graph as part of that) instead of just updating the graph * @returns: true if set of files in the project stays the same and false - otherwise. @@ -130301,6 +135946,10 @@ var ts; this.isInitialLoadPending = ts.returnFalse; var reloadLevel = this.pendingReload; this.pendingReload = ts.ConfigFileProgramReloadLevel.None; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; + this.symlinkedDirectories = undefined; + this.symlinkedFiles = undefined; var result; switch (reloadLevel) { case ts.ConfigFileProgramReloadLevel.Partial: @@ -130338,6 +135987,11 @@ var ts; return program && program.forEachResolvedProjectReference(cb); }; /*@internal*/ + ConfiguredProject.prototype.getResolvedProjectReferenceToRedirect = function (fileName) { + var program = this.getCurrentProgram(); + return program && program.getResolvedProjectReferenceToRedirect(fileName); + }; + /*@internal*/ ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) { var host = this.projectService.host; if (!host.require) { @@ -130404,6 +136058,10 @@ var ts; this.stopWatchingWildCards(); this.projectErrors = undefined; this.configFileSpecs = undefined; + this.projectReferenceCallbacks = undefined; + this.mapOfDeclarationDirectories = undefined; + this.symlinkedDirectories = undefined; + this.symlinkedFiles = undefined; _super.prototype.close.call(this); }; /* @internal */ @@ -130497,7 +136155,6 @@ var ts; server.maxProgramSizeForNonTsFiles = 20 * 1024 * 1024; /*@internal*/ server.maxFileSize = 4 * 1024 * 1024; - // tslint:disable variable-name server.ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; server.ProjectLoadingStartEvent = "projectLoadingStart"; server.ProjectLoadingFinishEvent = "projectLoadingFinish"; @@ -131154,7 +136811,7 @@ var ts; var _this = this; return this.watchFactory.watchDirectory(this.host, directory, function (fileOrDirectory) { var fileOrDirectoryPath = _this.toPath(fileOrDirectory); - project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); + var fsResult = project.getCachedDirectoryStructureHost().addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath); // don't trigger callback on open, existing files if (project.fileIsOpen(fileOrDirectoryPath)) { return; @@ -131162,6 +136819,11 @@ var ts; if (ts.isPathIgnored(fileOrDirectoryPath)) return; var configFilename = project.getConfigFilePath(); + if (ts.getBaseFileName(fileOrDirectoryPath) === "package.json" && !ts.isInsideNodeModules(fileOrDirectoryPath) && + (fsResult && fsResult.fileExists || !fsResult && _this.host.fileExists(fileOrDirectoryPath))) { + _this.logger.info("Project: " + configFilename + " Detected new package.json: " + fileOrDirectory); + project.onAddPackageJson(fileOrDirectoryPath); + } // If the the added or created file or directory is not supported file name, ignore the file // But when watched directory is added/removed, we need to reload the file list if (fileOrDirectoryPath !== directory && ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, project.getCompilationSettings(), _this.hostConfiguration.extraFileExtensions)) { @@ -131265,7 +136927,7 @@ var ts; } project.updateGraph(); if (!this.useSingleInferredProject && !project.projectRootPath) { - var _loop_2 = function (inferredProject) { + var _loop_3 = function (inferredProject) { if (inferredProject === project || inferredProject.isOrphan()) { return "continue"; } @@ -131286,7 +136948,7 @@ var ts; // Note that we need to create a copy of the array since the list of project can change for (var _i = 0, _a = this.inferredProjects; _i < _a.length; _i++) { var inferredProject = _a[_i]; - _loop_2(inferredProject); + _loop_3(inferredProject); } } return project; @@ -131603,6 +137265,14 @@ var ts; } while (anySearchPathOk || isSearchPathInProjectRoot()); return undefined; }; + /*@internal*/ + ProjectService.prototype.findDefaultConfiguredProject = function (info) { + if (!info.isScriptOpen()) + return undefined; + var configFileName = this.getConfigFileNameForFile(info); + return configFileName && + this.findConfiguredProjectByProjectName(configFileName); + }; /** * This function tries to search for a tsconfig.json for the given file. * This is different from the method the compiler uses because @@ -131805,6 +137475,11 @@ var ts; if (parsedCommandLine.errors.length) { configFileErrors.push.apply(configFileErrors, parsedCommandLine.errors); } + this.logger.info("Config: " + configFilename + " : " + JSON.stringify({ + rootNames: parsedCommandLine.fileNames, + options: parsedCommandLine.options, + projectReferences: parsedCommandLine.projectReferences + }, /*replacer*/ undefined, " ")); ts.Debug.assert(!!parsedCommandLine.fileNames); var compilerOptions = parsedCommandLine.options; // Update the project @@ -131831,7 +137506,7 @@ var ts; } 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 + this.updateRootAndOptionsOfNonInferredProject(project, filesToAdd, fileNamePropertyReader, compilerOptions, parsedCommandLine.typeAcquisition, parsedCommandLine.compileOnSave); }; ProjectService.prototype.updateNonInferredProjectFiles = function (project, files, propertyReader) { var projectRootFilesMap = project.getRootFilesMap(); @@ -131844,7 +137519,7 @@ var ts; var scriptInfo = void 0; var path = void 0; // Use the project's fileExists so that it can use caching instead of reaching to disk for the query - if (!isDynamic && !project.fileExists(newRootFile)) { + if (!isDynamic && !project.fileExistsWithCache(newRootFile)) { path = server.normalizedPathToPath(normalizedPath, this.currentDirectory, this.toCanonicalFileName); var existingValue = projectRootFilesMap.get(path); if (server.isScriptInfo(existingValue)) { @@ -131876,7 +137551,7 @@ var ts; projectRootFilesMap.forEach(function (value, path) { if (!newRootScriptInfoMap.has(path)) { if (server.isScriptInfo(value)) { - project.removeFile(value, project.fileExists(path), /*detachFromProject*/ true); + project.removeFile(value, project.fileExistsWithCache(path), /*detachFromProject*/ true); } else { projectRootFilesMap.delete(path); @@ -132055,7 +137730,7 @@ var ts; return projects; function combineProjects(toAddInfo) { if (toAddInfo !== info) { - var _loop_3 = function (project) { + var _loop_4 = function (project) { // Add the projects only if they can use symLink targets and not already in the list if (project.languageServiceEnabled && !project.isOrphan() && @@ -132072,7 +137747,7 @@ var ts; }; for (var _i = 0, _a = toAddInfo.containingProjects; _i < _a.length; _i++) { var project = _a[_i]; - _loop_3(project); + _loop_4(project); } } } @@ -132537,7 +138212,9 @@ var ts; }; /*@internal*/ ProjectService.prototype.getOriginalLocationEnsuringConfiguredProject = function (project, location) { - var originalLocation = project.getSourceMapper().tryGetSourcePosition(location); + var originalLocation = project.isSourceOfProjectReferenceRedirect(location.fileName) ? + location : + project.getSourceMapper().tryGetSourcePosition(location); if (!originalLocation) return undefined; var fileName = originalLocation.fileName; @@ -132548,7 +138225,9 @@ var ts; if (!configFileName) return undefined; var configuredProject = this.findConfiguredProjectByProjectName(configFileName) || - this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + " for location: " + location.fileName); + this.createAndLoadConfiguredProject(configFileName, "Creating project for original file: " + originalFileInfo.fileName + (location !== originalLocation ? " for location: " + location.fileName : "")); + if (configuredProject === project) + return originalLocation; updateProjectIfDirty(configuredProject); // Keep this configured project as referenced from project addOriginalConfiguredProject(configuredProject); @@ -132769,13 +138448,13 @@ var ts; return result; }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_4 = function (proj) { + var _loop_5 = function (proj) { var knownProject = ts.find(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName(); }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_4(proj); + _loop_5(proj); } }; /* @internal */ @@ -132918,7 +138597,7 @@ var ts; var excludeRules = []; var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); var excludedFiles = []; - var _loop_5 = function (name) { + var _loop_6 = function (name) { var rule = this_2.safelist[name]; for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { var root = normalizedNames_1[_i]; @@ -132936,7 +138615,7 @@ var ts; } } if (rule.exclude) { - var _loop_7 = function (exclude) { + var _loop_8 = function (exclude) { var processedRule = root.replace(rule.match, function () { var groups = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -132963,7 +138642,7 @@ var ts; }; for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) { var exclude = _d[_c]; - _loop_7(exclude); + _loop_8(exclude); } } else { @@ -132979,11 +138658,11 @@ var ts; var this_2 = this; for (var _i = 0, _a = Object.keys(this.safelist); _i < _a.length; _i++) { var name = _a[_i]; - _loop_5(name); + _loop_6(name); } var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); var filesToKeep = []; - var _loop_6 = function (i) { + var _loop_7 = function (i) { if (excludeRegexes.some(function (re) { return re.test(normalizedNames[i]); })) { excludedFiles.push(normalizedNames[i]); } @@ -133021,7 +138700,7 @@ var ts; }; var this_3 = this; for (var i = 0; i < proj.rootFiles.length; i++) { - _loop_6(i); + _loop_7(i); } proj.rootFiles = filesToKeep; return excludedFiles; @@ -133179,6 +138858,55 @@ var ts; } })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + var server; + (function (server) { + function createPackageJsonCache(project) { + var packageJsons = ts.createMap(); + var directoriesWithoutPackageJson = ts.createMap(); + return { + addOrUpdate: addOrUpdate, + delete: function (fileName) { + packageJsons.delete(fileName); + directoriesWithoutPackageJson.set(ts.getDirectoryPath(fileName), true); + }, + getInDirectory: function (directory) { + return packageJsons.get(ts.combinePaths(directory, "package.json")); + }, + directoryHasPackageJson: directoryHasPackageJson, + searchDirectoryAndAncestors: function (directory) { + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (directoryHasPackageJson(ancestor) !== 1 /* Maybe */) { + return true; + } + var packageJsonFileName = project.toPath(ts.combinePaths(ancestor, "package.json")); + if (ts.tryFileExists(project, packageJsonFileName)) { + addOrUpdate(packageJsonFileName); + } + else { + directoriesWithoutPackageJson.set(ancestor, true); + } + }); + }, + }; + function addOrUpdate(fileName) { + var packageJsonInfo = ts.createPackageJsonInfo(fileName, project); + if (packageJsonInfo) { + packageJsons.set(fileName, packageJsonInfo); + directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName)); + } + } + function directoryHasPackageJson(directory) { + return packageJsons.has(ts.combinePaths(directory, "package.json")) ? -1 /* True */ : + directoriesWithoutPackageJson.has(directory) ? 0 /* False */ : + 1 /* Maybe */; + } + } + server.createPackageJsonCache = createPackageJsonCache; + })(server = ts.server || (ts.server = {})); +})(ts || (ts = {})); var ts; (function (ts) { var server; @@ -133273,7 +139001,7 @@ var ts; function allEditsBeforePos(edits, pos) { return edits.every(function (edit) { return ts.textSpanEnd(edit.span) < pos; }); } - server.CommandNames = server.protocol.CommandTypes; // tslint:disable-line variable-name + server.CommandNames = server.protocol.CommandTypes; function formatMessage(msg, logger, byteLength, newLine) { var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); @@ -133429,7 +139157,7 @@ var ts; var outputs = []; combineProjectOutputWorker(projects, defaultProject, initialLocation, function (_a, getMappedLocation) { var project = _a.project, location = _a.location; - var _loop_8 = function (outputReferencedSymbol) { + var _loop_9 = function (outputReferencedSymbol) { var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition)); var definition = mappedDefinitionFile === undefined ? outputReferencedSymbol.definition : __assign(__assign({}, outputReferencedSymbol.definition), { textSpan: ts.createTextSpan(mappedDefinitionFile.pos, outputReferencedSymbol.definition.textSpan.length), fileName: mappedDefinitionFile.fileName, contextSpan: getMappedContextSpan(outputReferencedSymbol.definition, project) }); @@ -133448,7 +139176,7 @@ var ts; }; for (var _i = 0, _b = project.getLanguageService().findReferences(location.fileName, location.pos) || server.emptyArray; _i < _b.length; _i++) { var outputReferencedSymbol = _b[_i]; - _loop_8(outputReferencedSymbol); + _loop_9(outputReferencedSymbol); } }, function () { return getDefinitionLocation(defaultProject, initialLocation); }); return outputs.filter(function (o) { return o.references.length !== 0; }); @@ -133482,7 +139210,7 @@ var ts; projectService.forEachEnabledProject(function (project) { if (!ts.addToSeen(seenProjects, project.projectName)) return; - var definition = getDefinitionInProject(memGetDefinition_1(), defaultProject, project); + var definition = mapDefinitionInProject(memGetDefinition_1(), defaultProject, project); if (definition) { toDo = callbackProjectAndLocation({ project: project, location: definition }, projectService, toDo, seenProjects, cb); } @@ -133492,15 +139220,41 @@ var ts; toDo = callbackProjectAndLocation(ts.Debug.assertDefined(toDo.pop()), projectService, toDo, seenProjects, cb); } } - function getDefinitionInProject(definition, definingProject, project) { - if (!definition || project.containsFile(server.toNormalizedPath(definition.fileName))) + function mapDefinitionInProject(definition, definingProject, project) { + // If the definition is actually from the project, definition is correct as is + if (!definition || + project.containsFile(server.toNormalizedPath(definition.fileName)) && + !isLocationProjectReferenceRedirect(project, definition)) { return definition; - var mappedDefinition = definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); + } + var mappedDefinition = definingProject.isSourceOfProjectReferenceRedirect(definition.fileName) ? + definition : + definingProject.getLanguageService().getSourceMapper().tryGetGeneratedPosition(definition); return mappedDefinition && project.containsFile(server.toNormalizedPath(mappedDefinition.fileName)) ? mappedDefinition : undefined; } + function isLocationProjectReferenceRedirect(project, location) { + if (!location) + return false; + var program = project.getLanguageService().getProgram(); + if (!program) + return false; + var sourceFile = program.getSourceFile(location.fileName); + // It is possible that location is attached to project but + // the program actually includes its redirect instead. + // This happens when rootFile in project is one of the file from referenced project + // Thus root is attached but program doesnt have the actual .ts file but .d.ts + // If this is not the file we were actually looking, return rest of the toDo + return !!sourceFile && + sourceFile.resolvedPath !== sourceFile.path && + sourceFile.resolvedPath !== project.toPath(location.fileName); + } function callbackProjectAndLocation(projectAndLocation, projectService, toDo, seenProjects, cb) { - if (projectAndLocation.project.getCancellationToken().isCancellationRequested()) + var project = projectAndLocation.project, location = projectAndLocation.location; + if (project.getCancellationToken().isCancellationRequested()) return undefined; // Skip rest of toDo if cancelled + // If this is not the file we were actually looking, return rest of the toDo + if (isLocationProjectReferenceRedirect(project, location)) + return toDo; cb(projectAndLocation, function (project, location) { seenProjects.set(projectAndLocation.project.projectName, true); var originalLocation = projectService.getOriginalLocationEnsuringConfiguredProject(project, location); @@ -133514,14 +139268,14 @@ var ts; } var symlinkedProjectsMap = projectService.getSymlinkedProjects(originalScriptInfo); if (symlinkedProjectsMap) { - symlinkedProjectsMap.forEach(function (symlinkedProjects) { + symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) { for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) { var symlinkedProject = symlinkedProjects_2[_i]; - addToTodo({ project: symlinkedProject, location: originalLocation }, toDo, seenProjects); + addToTodo({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } }, toDo, seenProjects); } }); } - return originalLocation; + return originalLocation === location ? undefined : originalLocation; }); return toDo; } @@ -134030,7 +139784,7 @@ var ts; msg += "\n\nFile text of " + fileRequest.file + ":" + server.indent(text) + "\n"; } } - catch (_b) { } // tslint:disable-line no-empty + catch (_b) { } // eslint-disable-line no-empty } if (err.ProgramFiles) { msg += "\n\nProgram files: " + JSON.stringify(err.ProgramFiles) + "\n"; @@ -134306,7 +140060,9 @@ var ts; }; Session.prototype.getEmitOutput = function (args) { var _a = this.getFileAndProject(args), file = _a.file, project = _a.project; - return project.getLanguageService().getEmitOutput(file); + return project.shouldEmitFile(project.getScriptInfo(file)) ? + project.getLanguageService().getEmitOutput(file) : + { emitSkipped: true, outputFiles: [] }; }; Session.prototype.mapDefinitionInfo = function (definitions, project) { var _this = this; @@ -134842,11 +140598,11 @@ var ts; return helpItems; } }; - Session.prototype.createCheckList = function (fileNames, defaultProject) { + Session.prototype.createCheckList = function (fileNames) { var _this = this; return ts.mapDefined(fileNames, function (uncheckedFileName) { var fileName = server.toNormalizedPath(uncheckedFileName); - var project = defaultProject || _this.projectService.tryGetDefaultProjectForFile(fileName); + var project = _this.projectService.tryGetDefaultProjectForFile(fileName); return project && { fileName: fileName, project: project }; }); }; diff --git a/node_modules/typescript/lib/typescript.d.ts b/node_modules/typescript/lib/typescript.d.ts index 48bfe8b34..eca1cf314 100644 --- a/node_modules/typescript/lib/typescript.d.ts +++ b/node_modules/typescript/lib/typescript.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.6"; + const versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ const version: string; } @@ -73,7 +73,7 @@ declare namespace ts { end: number; } export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | 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 KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.BigIntKeyword | 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 | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; export enum SyntaxKind { Unknown = 0, @@ -104,329 +104,335 @@ declare namespace ts { DotDotDotToken = 25, SemicolonToken = 26, CommaToken = 27, - LessThanToken = 28, - LessThanSlashToken = 29, - GreaterThanToken = 30, - LessThanEqualsToken = 31, - GreaterThanEqualsToken = 32, - EqualsEqualsToken = 33, - ExclamationEqualsToken = 34, - EqualsEqualsEqualsToken = 35, - ExclamationEqualsEqualsToken = 36, - EqualsGreaterThanToken = 37, - PlusToken = 38, - MinusToken = 39, - AsteriskToken = 40, - AsteriskAsteriskToken = 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 = 57, - AtToken = 58, + QuestionDotToken = 28, + LessThanToken = 29, + LessThanSlashToken = 30, + GreaterThanToken = 31, + LessThanEqualsToken = 32, + GreaterThanEqualsToken = 33, + EqualsEqualsToken = 34, + ExclamationEqualsToken = 35, + EqualsEqualsEqualsToken = 36, + ExclamationEqualsEqualsToken = 37, + EqualsGreaterThanToken = 38, + PlusToken = 39, + MinusToken = 40, + AsteriskToken = 41, + AsteriskAsteriskToken = 42, + SlashToken = 43, + PercentToken = 44, + PlusPlusToken = 45, + MinusMinusToken = 46, + LessThanLessThanToken = 47, + GreaterThanGreaterThanToken = 48, + GreaterThanGreaterThanGreaterThanToken = 49, + AmpersandToken = 50, + BarToken = 51, + CaretToken = 52, + ExclamationToken = 53, + TildeToken = 54, + AmpersandAmpersandToken = 55, + BarBarToken = 56, + QuestionToken = 57, + ColonToken = 58, + AtToken = 59, + QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 59, - EqualsToken = 60, - PlusEqualsToken = 61, - MinusEqualsToken = 62, - AsteriskEqualsToken = 63, - AsteriskAsteriskEqualsToken = 64, - SlashEqualsToken = 65, - PercentEqualsToken = 66, - LessThanLessThanEqualsToken = 67, - GreaterThanGreaterThanEqualsToken = 68, - GreaterThanGreaterThanGreaterThanEqualsToken = 69, - AmpersandEqualsToken = 70, - BarEqualsToken = 71, - CaretEqualsToken = 72, - Identifier = 73, - BreakKeyword = 74, - CaseKeyword = 75, - CatchKeyword = 76, - ClassKeyword = 77, - ConstKeyword = 78, - ContinueKeyword = 79, - DebuggerKeyword = 80, - DefaultKeyword = 81, - DeleteKeyword = 82, - DoKeyword = 83, - ElseKeyword = 84, - EnumKeyword = 85, - ExportKeyword = 86, - ExtendsKeyword = 87, - FalseKeyword = 88, - FinallyKeyword = 89, - ForKeyword = 90, - FunctionKeyword = 91, - IfKeyword = 92, - ImportKeyword = 93, - InKeyword = 94, - InstanceOfKeyword = 95, - NewKeyword = 96, - NullKeyword = 97, - ReturnKeyword = 98, - SuperKeyword = 99, - SwitchKeyword = 100, - ThisKeyword = 101, - ThrowKeyword = 102, - TrueKeyword = 103, - TryKeyword = 104, - TypeOfKeyword = 105, - VarKeyword = 106, - VoidKeyword = 107, - WhileKeyword = 108, - WithKeyword = 109, - ImplementsKeyword = 110, - InterfaceKeyword = 111, - LetKeyword = 112, - PackageKeyword = 113, - PrivateKeyword = 114, - ProtectedKeyword = 115, - PublicKeyword = 116, - StaticKeyword = 117, - YieldKeyword = 118, - AbstractKeyword = 119, - AsKeyword = 120, - AnyKeyword = 121, - AsyncKeyword = 122, - AwaitKeyword = 123, - BooleanKeyword = 124, - ConstructorKeyword = 125, - DeclareKeyword = 126, - GetKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocNamepathType = 297, - JSDocComment = 298, - JSDocTypeLiteral = 299, - JSDocSignature = 300, - JSDocTag = 301, - JSDocAugmentsTag = 302, - JSDocAuthorTag = 303, - JSDocClassTag = 304, - JSDocCallbackTag = 305, - JSDocEnumTag = 306, - JSDocParameterTag = 307, - JSDocReturnTag = 308, - JSDocThisTag = 309, - JSDocTypeTag = 310, - JSDocTemplateTag = 311, - JSDocTypedefTag = 312, - JSDocPropertyTag = 313, - SyntaxList = 314, - NotEmittedStatement = 315, - PartiallyEmittedExpression = 316, - CommaListExpression = 317, - MergeDeclarationMarker = 318, - EndOfDeclarationMarker = 319, - Count = 320, - FirstAssignment = 60, - LastAssignment = 72, - FirstCompoundAssignment = 61, - LastCompoundAssignment = 72, - FirstReservedWord = 74, - LastReservedWord = 109, - FirstKeyword = 74, - LastKeyword = 148, - FirstFutureReservedWord = 110, - LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + BacktickToken = 61, + EqualsToken = 62, + PlusEqualsToken = 63, + MinusEqualsToken = 64, + AsteriskEqualsToken = 65, + AsteriskAsteriskEqualsToken = 66, + SlashEqualsToken = 67, + PercentEqualsToken = 68, + LessThanLessThanEqualsToken = 69, + GreaterThanGreaterThanEqualsToken = 70, + GreaterThanGreaterThanGreaterThanEqualsToken = 71, + AmpersandEqualsToken = 72, + BarEqualsToken = 73, + CaretEqualsToken = 74, + Identifier = 75, + BreakKeyword = 76, + CaseKeyword = 77, + CatchKeyword = 78, + ClassKeyword = 79, + ConstKeyword = 80, + ContinueKeyword = 81, + DebuggerKeyword = 82, + DefaultKeyword = 83, + DeleteKeyword = 84, + DoKeyword = 85, + ElseKeyword = 86, + EnumKeyword = 87, + ExportKeyword = 88, + ExtendsKeyword = 89, + FalseKeyword = 90, + FinallyKeyword = 91, + ForKeyword = 92, + FunctionKeyword = 93, + IfKeyword = 94, + ImportKeyword = 95, + InKeyword = 96, + InstanceOfKeyword = 97, + NewKeyword = 98, + NullKeyword = 99, + ReturnKeyword = 100, + SuperKeyword = 101, + SwitchKeyword = 102, + ThisKeyword = 103, + ThrowKeyword = 104, + TrueKeyword = 105, + TryKeyword = 106, + TypeOfKeyword = 107, + VarKeyword = 108, + VoidKeyword = 109, + WhileKeyword = 110, + WithKeyword = 111, + ImplementsKeyword = 112, + InterfaceKeyword = 113, + LetKeyword = 114, + PackageKeyword = 115, + PrivateKeyword = 116, + ProtectedKeyword = 117, + PublicKeyword = 118, + StaticKeyword = 119, + YieldKeyword = 120, + AbstractKeyword = 121, + AsKeyword = 122, + AssertsKeyword = 123, + AnyKeyword = 124, + AsyncKeyword = 125, + AwaitKeyword = 126, + BooleanKeyword = 127, + ConstructorKeyword = 128, + DeclareKeyword = 129, + GetKeyword = 130, + InferKeyword = 131, + IsKeyword = 132, + KeyOfKeyword = 133, + ModuleKeyword = 134, + NamespaceKeyword = 135, + NeverKeyword = 136, + ReadonlyKeyword = 137, + RequireKeyword = 138, + NumberKeyword = 139, + ObjectKeyword = 140, + SetKeyword = 141, + StringKeyword = 142, + SymbolKeyword = 143, + TypeKeyword = 144, + UndefinedKeyword = 145, + UniqueKeyword = 146, + UnknownKeyword = 147, + FromKeyword = 148, + GlobalKeyword = 149, + BigIntKeyword = 150, + OfKeyword = 151, + QualifiedName = 152, + ComputedPropertyName = 153, + TypeParameter = 154, + Parameter = 155, + Decorator = 156, + PropertySignature = 157, + PropertyDeclaration = 158, + MethodSignature = 159, + MethodDeclaration = 160, + Constructor = 161, + GetAccessor = 162, + SetAccessor = 163, + CallSignature = 164, + ConstructSignature = 165, + IndexSignature = 166, + TypePredicate = 167, + TypeReference = 168, + FunctionType = 169, + ConstructorType = 170, + TypeQuery = 171, + TypeLiteral = 172, + ArrayType = 173, + TupleType = 174, + OptionalType = 175, + RestType = 176, + UnionType = 177, + IntersectionType = 178, + ConditionalType = 179, + InferType = 180, + ParenthesizedType = 181, + ThisType = 182, + TypeOperator = 183, + IndexedAccessType = 184, + MappedType = 185, + LiteralType = 186, + ImportType = 187, + ObjectBindingPattern = 188, + ArrayBindingPattern = 189, + BindingElement = 190, + ArrayLiteralExpression = 191, + ObjectLiteralExpression = 192, + PropertyAccessExpression = 193, + ElementAccessExpression = 194, + CallExpression = 195, + NewExpression = 196, + TaggedTemplateExpression = 197, + TypeAssertionExpression = 198, + ParenthesizedExpression = 199, + FunctionExpression = 200, + ArrowFunction = 201, + DeleteExpression = 202, + TypeOfExpression = 203, + VoidExpression = 204, + AwaitExpression = 205, + PrefixUnaryExpression = 206, + PostfixUnaryExpression = 207, + BinaryExpression = 208, + ConditionalExpression = 209, + TemplateExpression = 210, + YieldExpression = 211, + SpreadElement = 212, + ClassExpression = 213, + OmittedExpression = 214, + ExpressionWithTypeArguments = 215, + AsExpression = 216, + NonNullExpression = 217, + MetaProperty = 218, + SyntheticExpression = 219, + TemplateSpan = 220, + SemicolonClassElement = 221, + Block = 222, + EmptyStatement = 223, + VariableStatement = 224, + ExpressionStatement = 225, + IfStatement = 226, + DoStatement = 227, + WhileStatement = 228, + ForStatement = 229, + ForInStatement = 230, + ForOfStatement = 231, + ContinueStatement = 232, + BreakStatement = 233, + ReturnStatement = 234, + WithStatement = 235, + SwitchStatement = 236, + LabeledStatement = 237, + ThrowStatement = 238, + TryStatement = 239, + DebuggerStatement = 240, + VariableDeclaration = 241, + VariableDeclarationList = 242, + FunctionDeclaration = 243, + ClassDeclaration = 244, + InterfaceDeclaration = 245, + TypeAliasDeclaration = 246, + EnumDeclaration = 247, + ModuleDeclaration = 248, + ModuleBlock = 249, + CaseBlock = 250, + NamespaceExportDeclaration = 251, + ImportEqualsDeclaration = 252, + ImportDeclaration = 253, + ImportClause = 254, + NamespaceImport = 255, + NamedImports = 256, + ImportSpecifier = 257, + ExportAssignment = 258, + ExportDeclaration = 259, + NamedExports = 260, + ExportSpecifier = 261, + MissingDeclaration = 262, + ExternalModuleReference = 263, + JsxElement = 264, + JsxSelfClosingElement = 265, + JsxOpeningElement = 266, + JsxClosingElement = 267, + JsxFragment = 268, + JsxOpeningFragment = 269, + JsxClosingFragment = 270, + JsxAttribute = 271, + JsxAttributes = 272, + JsxSpreadAttribute = 273, + JsxExpression = 274, + CaseClause = 275, + DefaultClause = 276, + HeritageClause = 277, + CatchClause = 278, + PropertyAssignment = 279, + ShorthandPropertyAssignment = 280, + SpreadAssignment = 281, + EnumMember = 282, + UnparsedPrologue = 283, + UnparsedPrepend = 284, + UnparsedText = 285, + UnparsedInternalText = 286, + UnparsedSyntheticReference = 287, + SourceFile = 288, + Bundle = 289, + UnparsedSource = 290, + InputFiles = 291, + JSDocTypeExpression = 292, + JSDocAllType = 293, + JSDocUnknownType = 294, + JSDocNullableType = 295, + JSDocNonNullableType = 296, + JSDocOptionalType = 297, + JSDocFunctionType = 298, + JSDocVariadicType = 299, + JSDocNamepathType = 300, + JSDocComment = 301, + JSDocTypeLiteral = 302, + JSDocSignature = 303, + JSDocTag = 304, + JSDocAugmentsTag = 305, + JSDocAuthorTag = 306, + JSDocClassTag = 307, + JSDocCallbackTag = 308, + JSDocEnumTag = 309, + JSDocParameterTag = 310, + JSDocReturnTag = 311, + JSDocThisTag = 312, + JSDocTypeTag = 313, + JSDocTemplateTag = 314, + JSDocTypedefTag = 315, + JSDocPropertyTag = 316, + SyntaxList = 317, + NotEmittedStatement = 318, + PartiallyEmittedExpression = 319, + CommaListExpression = 320, + MergeDeclarationMarker = 321, + EndOfDeclarationMarker = 322, + SyntheticReferenceExpression = 323, + Count = 324, + FirstAssignment = 62, + LastAssignment = 74, + FirstCompoundAssignment = 63, + LastCompoundAssignment = 74, + FirstReservedWord = 76, + LastReservedWord = 111, + FirstKeyword = 76, + LastKeyword = 151, + FirstFutureReservedWord = 112, + LastFutureReservedWord = 120, + FirstTypeNode = 167, + LastTypeNode = 187, FirstPunctuation = 18, - LastPunctuation = 72, + LastPunctuation = 74, FirstToken = 0, - LastToken = 148, + LastToken = 151, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, LastLiteralToken = 14, FirstTemplateToken = 14, LastTemplateToken = 17, - FirstBinaryOperator = 28, - LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 313, - FirstJSDocTagNode = 301, - LastJSDocTagNode = 313, + FirstBinaryOperator = 29, + LastBinaryOperator = 74, + FirstStatement = 224, + LastStatement = 240, + FirstNode = 152, + FirstJSDocNode = 292, + LastJSDocNode = 316, + FirstJSDocTagNode = 304, + LastJSDocTagNode = 316, } export enum NodeFlags { None = 0, @@ -435,27 +441,28 @@ declare namespace ts { NestedNamespace = 4, Synthesized = 8, Namespace = 16, - ExportContext = 32, - ContainsThis = 64, - HasImplicitReturn = 128, - HasExplicitReturn = 256, - GlobalAugmentation = 512, - HasAsyncFunctions = 1024, - DisallowInContext = 2048, - YieldContext = 4096, - DecoratorContext = 8192, - AwaitContext = 16384, - ThisNodeHasError = 32768, - JavaScriptFile = 65536, - ThisNodeOrAnySubNodesHasError = 131072, - HasAggregatedChildData = 262144, - JSDoc = 2097152, - JsonFile = 16777216, + OptionalChain = 32, + ExportContext = 64, + ContainsThis = 128, + HasImplicitReturn = 256, + HasExplicitReturn = 512, + GlobalAugmentation = 1024, + HasAsyncFunctions = 2048, + DisallowInContext = 4096, + YieldContext = 8192, + DecoratorContext = 16384, + AwaitContext = 32768, + ThisNodeHasError = 65536, + JavaScriptFile = 131072, + ThisNodeOrAnySubNodesHasError = 262144, + HasAggregatedChildData = 524288, + JSDoc = 4194304, + JsonFile = 33554432, BlockScoped = 3, - ReachabilityCheckFlags = 384, - ReachabilityAndEmitFlags = 1408, - ContextFlags = 12679168, - TypeExcludesFlags = 20480, + ReachabilityCheckFlags = 768, + ReachabilityAndEmitFlags = 2816, + ContextFlags = 25358336, + TypeExcludesFlags = 40960, } export enum ModifierFlags { None = 0, @@ -505,8 +512,10 @@ declare namespace ts { export interface Token extends Node { kind: TKind; } + export type DotToken = Token; export type DotDotDotToken = Token; export type QuestionToken = Token; + export type QuestionDotToken = Token; export type ExclamationToken = Token; export type ColonToken = Token; export type EqualsToken = Token; @@ -517,6 +526,7 @@ declare namespace ts { export type AwaitKeywordToken = Token; export type PlusToken = Token; export type MinusToken = Token; + export type AssertsToken = Token; export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; export type ModifiersArray = NodeArray; export interface Identifier extends PrimaryExpression, Declaration { @@ -539,7 +549,7 @@ declare namespace ts { } export type EntityName = Identifier | QualifiedName; export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; + export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; export interface Declaration extends Node { _declarationBrand: any; } @@ -770,8 +780,9 @@ declare namespace ts { export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; + assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; - type: TypeNode; + type?: TypeNode; } export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; @@ -842,7 +853,7 @@ declare namespace ts { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - export interface StringLiteral extends LiteralExpression { + export interface StringLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.StringLiteral; } export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; @@ -943,7 +954,7 @@ declare namespace ts { export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - export type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator; export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; export type BinaryOperatorToken = Token; export interface BinaryExpression extends Expression, Declaration { @@ -1006,7 +1017,7 @@ declare namespace ts { export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } - export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode { + export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode, Declaration { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } export enum TokenFlags { @@ -1017,7 +1028,7 @@ declare namespace ts { BinarySpecifier = 128, OctalSpecifier = 256, } - export interface NumericLiteral extends LiteralExpression { + export interface NumericLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.NumericLiteral; } export interface BigIntLiteral extends LiteralExpression { @@ -1077,8 +1088,12 @@ declare namespace ts { export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; name: Identifier; } + export interface PropertyAccessChain extends PropertyAccessExpression { + _optionalChainBrand: any; + } export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } @@ -1090,8 +1105,12 @@ declare namespace ts { export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; argumentExpression: Expression; } + export interface ElementAccessChain extends ElementAccessExpression { + _optionalChainBrand: any; + } export interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } @@ -1099,9 +1118,14 @@ declare namespace ts { export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; typeArguments?: NodeArray; arguments: NodeArray; } + export interface CallChain extends CallExpression { + _optionalChainBrand: any; + } + export type OptionalChain = PropertyAccessChain | ElementAccessChain | CallChain; export interface SuperCall extends CallExpression { expression: SuperExpression; } @@ -1635,8 +1659,8 @@ declare namespace ts { } export interface JSDocSignature extends JSDocType, Declaration { kind: SyntaxKind.JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly JSDocTemplateTag[]; + parameters: readonly JSDocParameterTag[]; type: JSDocReturnTag | undefined; } export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { @@ -1655,7 +1679,7 @@ declare namespace ts { } export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: ReadonlyArray; + jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } @@ -1669,13 +1693,19 @@ declare namespace ts { FalseCondition = 64, SwitchClause = 128, ArrayMutation = 256, - Referenced = 512, - Shared = 1024, - PreFinally = 2048, - AfterFinally = 4096, + Call = 512, + Referenced = 1024, + Shared = 2048, + PreFinally = 4096, + AfterFinally = 8192, Label = 12, Condition = 96 } + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { + flags: FlowFlags; + id?: number; + } export interface FlowLock { locked?: boolean; } @@ -1686,13 +1716,8 @@ declare namespace ts { antecedent: FlowNode; lock: FlowLock; } - export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - export interface FlowNodeBase { - flags: FlowFlags; - id?: number; - } export interface FlowStart extends FlowNodeBase { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + node?: FunctionExpression | ArrowFunction | MethodDeclaration; } export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; @@ -1701,8 +1726,12 @@ declare namespace ts { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } + export interface FlowCall extends FlowNodeBase { + node: CallExpression; + antecedent: FlowNode; + } export interface FlowCondition extends FlowNodeBase { - expression: Expression; + node: Expression; antecedent: FlowNode; } export interface FlowSwitchClause extends FlowNodeBase { @@ -1730,11 +1759,11 @@ declare namespace ts { endOfFileToken: Token; fileName: string; text: string; - amdDependencies: ReadonlyArray; + amdDependencies: readonly AmdDependency[]; moduleName?: string; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray; - libReferenceDirectives: ReadonlyArray; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly FileReference[]; + libReferenceDirectives: readonly FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1750,8 +1779,8 @@ declare namespace ts { } export interface Bundle extends Node { kind: SyntaxKind.Bundle; - prepends: ReadonlyArray; - sourceFiles: ReadonlyArray; + prepends: readonly (InputFiles | UnparsedSource)[]; + sourceFiles: readonly SourceFile[]; } export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; @@ -1768,16 +1797,16 @@ declare namespace ts { kind: SyntaxKind.UnparsedSource; fileName: string; text: string; - prologues: ReadonlyArray; - helpers: ReadonlyArray | undefined; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray | undefined; - libReferenceDirectives: ReadonlyArray; + prologues: readonly UnparsedPrologue[]; + helpers: readonly UnscopedEmitHelper[] | undefined; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly string[] | undefined; + libReferenceDirectives: readonly FileReference[]; hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; - syntheticReferences?: ReadonlyArray; - texts: ReadonlyArray; + syntheticReferences?: readonly UnparsedSyntheticReference[]; + texts: readonly UnparsedSourceText[]; } export type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; export type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; @@ -1795,7 +1824,7 @@ declare namespace ts { kind: SyntaxKind.UnparsedPrepend; data: string; parent: UnparsedSource; - texts: ReadonlyArray; + texts: readonly UnparsedTextLike[]; } export interface UnparsedTextLike extends UnparsedSection { kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; @@ -1827,7 +1856,7 @@ declare namespace ts { } export interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. @@ -1844,7 +1873,7 @@ declare namespace ts { export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; + export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; export class OperationCanceledException { } export interface CancellationToken { @@ -1856,11 +1885,11 @@ declare namespace ts { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): ReadonlyArray; + getRootFileNames(): readonly string[]; /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1872,26 +1901,35 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** The first time this is called, it will return global diagnostics (no location). */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getRelationCacheSizes(): { + assignable: number; + identity: number; + subtype: number; + }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; + getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } export interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; - references?: ReadonlyArray; + references?: readonly (ResolvedProjectReference | undefined)[]; } export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; export interface CustomTransformer { @@ -1925,12 +1963,15 @@ declare namespace ts { Success = 0, DiagnosticsPresent_OutputsSkipped = 1, DiagnosticsPresent_OutputsGenerated = 2, - InvalidProject_OutputsSkipped = 3 + InvalidProject_OutputsSkipped = 3, + ProjectReferenceCycle_OutputsSkipped = 4, + /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ + ProjectReferenceCycle_OutputsSkupped = 4 } export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; emittedFiles?: string[]; } export interface TypeChecker { @@ -1939,7 +1980,7 @@ declare namespace ts { getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; + getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1947,6 +1988,7 @@ declare namespace ts { getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; + getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -1993,7 +2035,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): ReadonlyArray; + getRootSymbols(symbol: Symbol): readonly Symbol[]; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -2088,21 +2130,39 @@ declare namespace ts { } export enum TypePredicateKind { This = 0, - Identifier = 1 + Identifier = 1, + AssertsThis = 2, + AssertsIdentifier = 3 } export interface TypePredicateBase { kind: TypePredicateKind; - type: Type; + type: Type | undefined; } export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; + parameterName: undefined; + parameterIndex: undefined; + type: Type; } export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; + type: Type; + } + export interface AssertsThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsThis; + parameterName: undefined; + parameterIndex: undefined; + type: Type | undefined; + } + export interface AssertsIdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsIdentifier; + parameterName: string; + parameterIndex: number; + type: Type | undefined; } - export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2278,7 +2338,7 @@ declare namespace ts { symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: ReadonlyArray; + aliasTypeArguments?: readonly Type[]; } export interface LiteralType extends Type { value: string | number | PseudoBigInt; @@ -2330,7 +2390,7 @@ declare namespace ts { localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - export type BaseType = ObjectType | IntersectionType; + export type BaseType = ObjectType | IntersectionType | TypeVariable; export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -2350,7 +2410,9 @@ declare namespace ts { */ export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: ReadonlyArray; + node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; + } + export interface DeferredTypeReference extends TypeReference { } export interface GenericType extends InterfaceType, TypeReference { } @@ -2420,8 +2482,8 @@ declare namespace ts { } export interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly TypeParameter[]; + parameters: readonly Symbol[]; } export enum IndexKind { String = 0, @@ -2529,6 +2591,7 @@ declare namespace ts { emitDeclarationOnly?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + disableSourceOfProjectReferenceRedirect?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; @@ -2595,9 +2658,14 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; + useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } export interface TypeAcquisition { + /** + * @deprecated typingOptions.enableAutoDiscovery + * Use typeAcquisition.enable instead. + */ enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; @@ -2664,7 +2732,7 @@ declare namespace ts { options: CompilerOptions; typeAcquisition?: TypeAcquisition; fileNames: string[]; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; @@ -2679,12 +2747,12 @@ declare namespace ts { wildcardDirectories: MapLike; } export interface CreateProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; oldProgram?: Program; - configFileParsingDiagnostics?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; } export interface ModuleResolutionHost { fileExists(fileName: string): boolean; @@ -2765,7 +2833,7 @@ declare namespace ts { } export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: ReadonlyArray; + readonly failedLookupLocations: readonly string[]; } export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; @@ -2778,7 +2846,7 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; + readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files @@ -3016,6 +3084,11 @@ declare namespace ts { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } + export interface ModuleSpecifierResolutionHost extends GetEffectiveTypeRootsHost { + useCaseSensitiveFileNames?(): boolean; + fileExists?(path: string): boolean; + readFile?(path: string): string | undefined; + } export interface TextSpan { start: number; length: number; @@ -3098,6 +3171,7 @@ declare namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ @@ -3144,7 +3218,7 @@ declare namespace ts { getExecutingFilePath(): string; getCurrentDirectory(): string; getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; @@ -3192,6 +3266,7 @@ declare namespace ts { scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanQuestionToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; @@ -3229,7 +3304,7 @@ declare namespace ts { } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; + function sortAndDeduplicateDiagnostics(diagnostics: readonly T[]): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3258,7 +3333,7 @@ declare namespace ts { * This function will then merge those changes into a single change range valid between V1 and * Vn. */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; @@ -3330,7 +3405,7 @@ declare namespace ts { * * For binding patterns, parameter tags are matched by position. */ - function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the JSDoc type parameter tags for the node if present. * @@ -3341,7 +3416,7 @@ declare namespace ts { * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ - function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; /** * Return true if the node has JSDoc parameter tags. * @@ -3383,14 +3458,14 @@ declare namespace ts { */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ - function getJSDocTags(node: Node): ReadonlyArray; + function getJSDocTags(node: Node): readonly JSDocTag[]; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ - function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ - function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; } declare namespace ts { @@ -3444,8 +3519,13 @@ declare namespace ts { function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; + function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessExpression(node: Node): node is ElementAccessExpression; + function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallExpression(node: Node): node is CallExpression; + function isCallChain(node: Node): node is CallChain; + function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain; + function isNullishCoalesce(node: Node): boolean; function isNewExpression(node: Node): node is NewExpression; function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression; function isTypeAssertion(node: Node): node is TypeAssertion; @@ -3543,7 +3623,7 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; - function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; + function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType; @@ -3643,7 +3723,7 @@ declare namespace ts { export {}; } declare namespace ts { - export function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; + export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine; export type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics @@ -3697,7 +3777,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3705,7 +3785,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; export interface ParsedTsconfig { raw: any; options?: CompilerOptions; @@ -3771,7 +3851,7 @@ declare namespace ts { function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { - function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; + function createNodeArray(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; function createLiteral(value: number | PseudoBigInt): NumericLiteral; @@ -3809,62 +3889,64 @@ declare namespace ts { function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function createParameter(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + function createParameter(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createPropertySignature(modifiers: ReadonlyArray | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function updatePropertySignature(node: PropertySignature, modifiers: ReadonlyArray | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function createProperty(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function createMethodSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createProperty(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function createMethodSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; - function createMethod(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function createConstructor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function createGetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function createSetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createMethod(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; - function createConstructSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; + function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; - function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray | undefined): TypeReferenceNode; + function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; - function createFunctionTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): FunctionTypeNode; + function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; - function createConstructorTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructorTypeNode; + function createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; + function createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; - function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode; function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; function createRestTypeNode(type: TypeNode): RestTypeNode; function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; - function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; + function createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; - function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; + function createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray): IntersectionTypeNode; - function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray): UnionOrIntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: readonly TypeNode[]): UnionOrIntersectionTypeNode; function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; @@ -3877,36 +3959,42 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; - function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ReadonlyArray): ArrayBindingPattern; + function createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; - function createArrayLiteral(elements?: ReadonlyArray, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; - function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; + function createArrayLiteral(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier): PropertyAccessChain; + function updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier): PropertyAccessChain; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; - function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; + function createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; + function updateElementAccessChain(node: ElementAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, argumentExpression: Expression): ElementAccessChain; + function createCall(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; + function createCallChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallChain; + function updateCallChain(node: CallChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallChain; + function createNew(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; /** @deprecated */ function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; /** @deprecated */ function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; - function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3924,8 +4012,8 @@ declare namespace ts { /** @deprecated */ function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; function createTemplateHead(text: string, rawText?: string): TemplateHead; function createTemplateMiddle(text: string, rawText?: string): TemplateMiddle; function createTemplateTail(text: string, rawText?: string): TemplateTail; @@ -3935,11 +4023,11 @@ declare namespace ts { function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3949,10 +4037,10 @@ declare namespace ts { function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; - function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function updateBlock(node: Block, statements: ReadonlyArray): Block; - function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; + function createBlock(statements: readonly Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: readonly Statement[]): Block; + function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; function createExpressionStatement(expression: Expression): ExpressionStatement; function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; @@ -3991,76 +4079,76 @@ declare namespace ts { function createDebuggerStatement(): DebuggerStatement; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - function createVariableDeclarationList(declarations: ReadonlyArray, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; - function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function createEnumDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, members: ReadonlyArray): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, members: ReadonlyArray): EnumDeclaration; - function createModuleDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; - function createModuleBlock(statements: ReadonlyArray): ModuleBlock; - function updateModuleBlock(node: ModuleBlock, statements: ReadonlyArray): ModuleBlock; - function createCaseBlock(clauses: ReadonlyArray): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: ReadonlyArray): CaseBlock; + function createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; + function createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + function createModuleBlock(statements: readonly Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; + function createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ReadonlyArray): NamedImports; - function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; + function createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; - function createNamedExports(elements: ReadonlyArray): NamedExports; - function updateNamedExports(node: NamedExports, elements: ReadonlyArray): NamedExports; + function createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + function createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; - function createJsxElement(openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; + function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxFragment(openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function createJsxOpeningFragment(): JsxOpeningFragment; function createJsxJsxClosingFragment(): JsxClosingFragment; - function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxAttributes(properties: ReadonlyArray): JsxAttributes; - function updateJsxAttributes(node: JsxAttributes, properties: ReadonlyArray): JsxAttributes; + function createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; - function createCaseClause(expression: Expression, statements: ReadonlyArray): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: ReadonlyArray): CaseClause; - function createDefaultClause(statements: ReadonlyArray): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; - function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; + function createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; + function createDefaultClause(statements: readonly Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; + function createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; @@ -4071,7 +4159,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4093,20 +4181,20 @@ declare namespace ts { */ function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createCommaList(elements: ReadonlyArray): CommaListExpression; - function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; + function createCommaList(elements: readonly Expression[]): CommaListExpression; + function updateCommaList(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; + function createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; - function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + function updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -4118,6 +4206,7 @@ declare namespace ts { function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createNullishCoalesce(left: Expression, right: Expression): BinaryExpression; function createLogicalNot(operand: Expression): PrefixUnaryExpression; function createVoidZero(): VoidExpression; function createExportDefault(expression: Expression): ExportAssignment; @@ -4174,7 +4263,7 @@ declare namespace ts { /** * Sets the constant value to emit for an expression. */ - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): PropertyAccessExpression | ElementAccessExpression; + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): ElementAccessExpression | PropertyAccessExpression; /** * Adds an EmitHelper to a node. */ @@ -4279,23 +4368,25 @@ declare namespace ts { function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } declare namespace ts { + function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined; + function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[]; function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } declare namespace ts { export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; export function resolveTripleslashReference(moduleName: string, containingFile: string): string; export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; export interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; getNewLine(): string; } - export function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; + export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - export function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; + export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; - export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4321,7 +4412,7 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - export function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; + export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program; /** @deprecated */ export interface ResolveProjectReferencePathHost { fileExists(fileName: string): boolean; } @@ -4383,31 +4474,31 @@ declare namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Get the diagnostics for compiler options */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics that dont belong to any file */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics from config file parsing */ - getConfigFileParsingDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Get the syntax diagnostics, for all source files if source file is not supplied */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the declaration diagnostics, for all source files if source file is not supplied */ - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** * Get all the dependencies of the file */ - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + getAllDependencies(sourceFile: SourceFile): readonly string[]; /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -4416,7 +4507,7 @@ declare namespace ts { * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -4442,7 +4533,7 @@ declare namespace ts { * Gets the semantic diagnostics from the program for the next affected file and caches it * Returns undefined if the iteration is complete */ - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; } /** * The builder that can handle the changes in program and iterate through changed file to emit the files @@ -4459,19 +4550,19 @@ declare namespace ts { /** * Create the builder to manage semantic diagnostics and cache them */ - function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ - function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ - function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram; + function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram; } declare namespace ts { interface ReadBuildProgramHost { @@ -4482,21 +4573,21 @@ declare namespace ts { function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram | undefined; function createIncrementalCompilerHost(options: CompilerOptions, system?: System): CompilerHost; interface IncrementalProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - configFileParsingDiagnostics?: ReadonlyArray; - projectReferences?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; createProgram?: CreateProgram; } function createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: IncrementalProgramOptions): T; - type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; + type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ - type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + type CreateProgram = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T; /** Host that has watch functionality used in --watch mode */ interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ - onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; + onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number): void; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4532,7 +4623,7 @@ declare namespace ts { /** If provided, used in resolutions as well as handling directory structure */ getDirectories?(path: string): string[]; /** If provided, used to cache and handle directory structure modifications */ - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; /** Symbol links resolution */ realpath?(path: string): string; /** If provided would be used to write log about compilation */ @@ -4557,7 +4648,7 @@ declare namespace ts { /** Compiler options */ options: CompilerOptions; /** Project References */ - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; } /** * Host to create watch with config file @@ -4571,7 +4662,7 @@ declare namespace ts { * Used to generate source file names from the config file and its include, exclude, files rules * and also to cache the directory stucture */ - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; } interface Watch { /** Synchronize with host and get updated program */ @@ -4595,7 +4686,7 @@ declare namespace ts { * Create the watch compiler host for either configFile or fileNames and its options */ function createWatchCompilerHost(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray): WatchCompilerHostOfFilesAndCompilerOptions; + function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions; /** * Creates the watch from the host for root files and compiler options */ @@ -4648,8 +4739,8 @@ declare namespace ts { function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter; function createSolutionBuilderHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost; function createSolutionBuilderWithWatchHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost; - function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilder(host: SolutionBuilderHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; enum InvalidatedProjectKind { Build = 0, UpdateBundle = 1, @@ -4674,14 +4765,14 @@ declare namespace ts { getBuilderProgram(): T | undefined; getProgram(): Program | undefined; getSourceFile(fileName: string): SourceFile | undefined; - getSourceFiles(): ReadonlyArray; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSourceFiles(): readonly SourceFile[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getAllDependencies(sourceFile: SourceFile): readonly string[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } interface UpdateBundleProject extends InvalidatedProjectBase { @@ -4744,7 +4835,7 @@ declare namespace ts.server { readonly kind: EventBeginInstallTypes | EventEndInstallTypes; readonly eventId: number; readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; + readonly packagesToInstall: readonly string[]; } interface BeginInstallTypes extends InstallTypes { readonly kind: EventBeginInstallTypes; @@ -4797,8 +4888,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): ReadonlyArray; - getConstructSignatures(): ReadonlyArray; + getCallSignatures(): readonly Signature[]; + getConstructSignatures(): readonly Signature[]; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4815,6 +4906,9 @@ declare namespace ts { isClassOrInterface(): this is InterfaceType; isClass(): this is InterfaceType; } + interface TypeReference { + typeArguments?: readonly Type[]; + } interface Signature { getDeclaration(): SignatureDeclaration; getTypeParameters(): TypeParameter[] | undefined; @@ -4826,7 +4920,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): ReadonlyArray; + getLineStarts(): readonly number[]; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -4875,7 +4969,7 @@ declare namespace ts { fileName: Path; packageName: string; } - interface LanguageServiceHost extends GetEffectiveTypeRootsHost { + interface LanguageServiceHost extends ModuleSpecifierResolutionHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; getProjectVersion?(): string; @@ -4883,7 +4977,7 @@ declare namespace ts { getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getProjectReferences?(): ReadonlyArray | undefined; + getProjectReferences?(): readonly ProjectReference[] | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4891,8 +4985,7 @@ declare namespace ts { log?(s: string): void; trace?(s: string): void; error?(s: string): void; - useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; @@ -4937,17 +5030,17 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined; getSmartSelectionRange(fileName: string, position: number): SelectionRange; - getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; - getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | undefined; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4967,7 +5060,7 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[]; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -4980,9 +5073,9 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; - getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; + organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput; getProgram(): Program | undefined; dispose(): void; } @@ -5105,7 +5198,7 @@ declare namespace ts { } interface FileTextChanges { fileName: string; - textChanges: TextChange[]; + textChanges: readonly TextChange[]; isNewFile?: boolean; } interface CodeAction { @@ -5130,8 +5223,8 @@ declare namespace ts { fixAllDescription?: string; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray; + changes: readonly FileTextChanges[]; + commands?: readonly CodeActionCommand[]; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -5252,6 +5345,11 @@ declare namespace ts { Block = 1, Smart = 2 } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -5304,6 +5402,7 @@ declare namespace ts { readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; readonly insertSpaceBeforeTypeAnnotation?: boolean; readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: SemicolonPreference; } function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { @@ -5313,7 +5412,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions?: ReadonlyArray; + definitions?: readonly DefinitionInfo[]; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { diff --git a/node_modules/typescript/lib/typescript.js b/node_modules/typescript/lib/typescript.js index fd7aaa5b5..7d9452c7b 100644 --- a/node_modules/typescript/lib/typescript.js +++ b/node_modules/typescript/lib/typescript.js @@ -76,67 +76,20 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var ts; -(function (ts) { - // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. - // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; - /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; -})(ts || (ts = {})); -(function (ts) { - /* @internal */ - var Comparison; - (function (Comparison) { - Comparison[Comparison["LessThan"] = -1] = "LessThan"; - Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; - Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; - })(Comparison = ts.Comparison || (ts.Comparison = {})); -})(ts || (ts = {})); /* @internal */ +var ts; (function (ts) { - ts.emptyArray = []; - /** Create a MapLike with good performance. */ - function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map.__ = undefined; - delete map.__; - return map; - } - /** Create a new map. If a template object is provided, the map will copy entries from it. */ - function createMap() { - return new ts.MapCtr(); - } - ts.createMap = createMap; - function createMapFromEntries(entries) { - var map = createMap(); - for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { - var _a = entries_1[_i], key = _a[0], value = _a[1]; - map.set(key, value); - } - return map; - } - ts.createMapFromEntries = createMapFromEntries; - function createMapFromTemplate(template) { - var map = new ts.MapCtr(); - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (var key in template) { - if (hasOwnProperty.call(template, key)) { - map.set(key, template[key]); - } + function createMapShim() { + /** Create a MapLike with good performance. */ + function createDictionaryObject() { + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-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; } - return map; - } - ts.createMapFromTemplate = createMapFromTemplate; - // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name - ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); - // Keep the class inside a function so it doesn't get compiled if it's not used. - function shimMap() { var MapIterator = /** @class */ (function () { function MapIterator(currentEntry, selector) { this.currentEntry = currentEntry; @@ -197,7 +150,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -272,7 +225,75 @@ var ts; return class_1; }()); } - ts.shimMap = shimMap; + ts.createMapShim = createMapShim; +})(ts || (ts = {})); +var ts; +(function (ts) { + // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. + // If changing the text in this section, be sure to test `configureNightly` too. + ts.versionMajorMinor = "3.7"; + /** The version of the TypeScript compiler release */ + ts.version = ts.versionMajorMinor + ".2"; +})(ts || (ts = {})); +(function (ts) { + /* @internal */ + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + /** + * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). + */ + function tryGetNativeMap() { + // Internet Explorer's Map doesn't support iteration, so don't use it. + // eslint-disable-next-line no-in-operator + return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined; + } + ts.tryGetNativeMap = tryGetNativeMap; +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + ts.emptyArray = []; + ts.Map = ts.tryGetNativeMap() || (function () { + // NOTE: createMapShim will be defined for typescriptServices.js but not for tsc.js, so we must test for it. + if (typeof ts.createMapShim === "function") { + return ts.createMapShim(); + } + throw new Error("TypeScript requires an environment that provides a compatible native Map implementation."); + })(); + /** Create a new map. */ + function createMap() { + return new ts.Map(); + } + ts.createMap = createMap; + /** Create a new map from an array of entries. */ + function createMapFromEntries(entries) { + var map = createMap(); + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var _a = entries_1[_i], key = _a[0], value = _a[1]; + map.set(key, value); + } + return map; + } + ts.createMapFromEntries = createMapFromEntries; + /** Create a new map from a template object is provided, the map will copy entries from it. */ + function createMapFromTemplate(template) { + var map = new ts.Map(); + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (var key in template) { + if (hasOwnProperty.call(template, key)) { + map.set(key, template[key]); + } + } + return map; + } + ts.createMapFromTemplate = createMapFromTemplate; function length(array) { return array ? array.length : 0; } @@ -294,6 +315,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -847,6 +883,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1387,6 +1424,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1446,7 +1489,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1480,7 +1523,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1832,20 +1875,6 @@ var ts; return str.indexOf(substring) !== -1; } ts.stringContains = stringContains; - function fileExtensionIs(path, extension) { - return path.length > extension.length && endsWith(path, extension); - } - ts.fileExtensionIs = fileExtensionIs; - function fileExtensionIsOneOf(path, extensions) { - for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { - var extension = extensions_1[_i]; - if (fileExtensionIs(path, extension)) { - return true; - } - } - return false; - } - ts.fileExtensionIsOneOf = fileExtensionIsOneOf; /** * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ @@ -1954,11 +1983,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2035,8 +2086,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2085,6 +2138,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2100,7 +2154,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2208,6 +2262,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2218,6 +2275,33 @@ var ts; ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); } : ts.noop; var isDebugInfoEnabled = false; + var extendedDebugModule; + function extendedDebug() { + enableDebugInfo(); + if (!extendedDebugModule) { + throw new Error("Debugging helpers could not be loaded."); + } + return extendedDebugModule; + } + function printControlFlowGraph(flowNode) { + return console.log(formatControlFlowGraph(flowNode)); + } + Debug.printControlFlowGraph = printControlFlowGraph; + function formatControlFlowGraph(flowNode) { + return extendedDebug().formatControlFlowGraph(flowNode); + } + Debug.formatControlFlowGraph = formatControlFlowGraph; + function attachFlowNodeDebugInfo(flowNode) { + if (isDebugInfoEnabled) { + if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line no-in-operator + Object.defineProperties(flowNode, { + __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, + __debugToString: { value: function () { return formatControlFlowGraph(this); } } + }); + } + } + } + Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo; /** * Injects debug information into frequently used types. */ @@ -2261,6 +2345,20 @@ var ts; }); } } + // attempt to load extended debugging information + try { + if (ts.sys && ts.sys.require) { + var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath())); + var result = ts.sys.require(basePath, "./compiler-debug"); + if (!result.error) { + result.module.init(ts); + extendedDebugModule = result.module; + } + } + } + catch (_a) { + // do nothing + } isDebugInfoEnabled = true; } Debug.enableDebugInfo = enableDebugInfo; @@ -2417,15 +2515,13 @@ var ts; try { // require() will throw an exception if the module is not installed // It may also return undefined if not installed properly - etwModule = require("@microsoft/typescript-etw"); // tslint:disable-line:no-implicit-dependencies + etwModule = require("@microsoft/typescript-etw"); } catch (e) { etwModule = undefined; } /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; - var args = typeof process === "undefined" ? [] : process.argv; - ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); })(ts || (ts = {})); /* @internal */ var ts; @@ -2827,360 +2923,366 @@ var ts; SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 297] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 298] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 299] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 300] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 301] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 302] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 303] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 304] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 305] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 306] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 307] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 308] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 309] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 310] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 311] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 312] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 313] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 314] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 315] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 316] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 317] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 318] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 319] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 320] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 313] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 301] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 313] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3190,20 +3292,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3213,23 +3316,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3268,7 +3371,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3310,6 +3416,7 @@ var ts; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; })(TokenFlags = ts.TokenFlags || (ts.TokenFlags = {})); + // NOTE: Ensure this is up-to-date with src/debug/debug.ts var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; @@ -3321,12 +3428,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3336,6 +3444,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3356,6 +3471,10 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped"; + /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3364,6 +3483,14 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + /* @internal */ + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + ContextFlags[ContextFlags["Completion"] = 4] = "Completion"; + })(ContextFlags = ts.ContextFlags || (ts.ContextFlags = {})); // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { @@ -3421,7 +3548,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3471,27 +3597,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3562,11 +3701,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3789,6 +3932,18 @@ var ts; SignatureKind[SignatureKind["Call"] = 0] = "Call"; SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + /* @internal */ + var SignatureFlags; + (function (SignatureFlags) { + SignatureFlags[SignatureFlags["None"] = 0] = "None"; + SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter"; + SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes"; + SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall"; + // We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us + // attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when + // instantiating the return type. + SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags"; + })(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {})); var IndexKind; (function (IndexKind) { IndexKind[IndexKind["String"] = 0] = "String"; @@ -4684,7 +4839,7 @@ var ts; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; /*@internal*/ - ts.sysLog = ts.noop; + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4789,6 +4944,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4805,12 +4986,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4822,6 +5005,8 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; @@ -4903,8 +5088,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4928,8 +5115,101 @@ var ts; bufferFrom: bufferFrom, base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); }, base64encode: function (input) { return bufferFrom(input).toString("base64"); }, + require: function (baseDir, moduleName) { + try { + var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem); + return { module: require(modulePath), modulePath: modulePath, error: undefined }; + } + catch (error) { + return { module: undefined, modulePath: undefined, error: error }; + } + } }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4982,6 +5262,7 @@ var ts; if (fsSupportsRecursive) { return watchDirectoryUsingFsWatch; } + // defer watchDirectoryRecursively as it depends on `ts.createMap()` which may not be usable yet. var watchDirectory = tscWatchDirectory === "RecursiveDirectoryUsingFsWatchFile" ? createWatchDirectoryUsing(fsWatchFile) : tscWatchDirectory === "RecursiveDirectoryUsingDynamicPriorityPolling" ? @@ -5401,16 +5682,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5422,14 +5693,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5443,311 +5707,985 @@ var ts; ts.Debug.isDebugging = true; } })(ts || (ts = {})); -// -// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + /** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + */ + ts.directorySeparator = "/"; + var altDirectorySeparator = "\\"; + var urlSchemeSeparator = "://"; + var backslashRegExp = /\\/g; + //// Path Tests + /** + * Determines whether a charCode corresponds to `/` or `\`. + */ + function isAnyDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; } - // tslint:disable-next-line variable-name - ts.Diagnostics = { - Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), - Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), - _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), - A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), - Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), - An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), - Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), - A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), - A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), - Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), - A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), - An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), - An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), - An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), - An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), - An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), - An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), - An_index_signature_parameter_type_must_be_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_or_number_1023", "An index signature parameter type must be 'string' or 'number'."), - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), - Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), - _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), - _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), - _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), - super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), - Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), - Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), - Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), - _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), - _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), - _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), - _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), - _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), - A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), - Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), - A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), - A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), - A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), - A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), - A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), - A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), - A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), - An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), - The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), - A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), - The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), - Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), - Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), - An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), - Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), - _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), - _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), - A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), - Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), - _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), - Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), - Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), - An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), - A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), - An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), - _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), - Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), - Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), - Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), - with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), - delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), - Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), - A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), - Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), - Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), - Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), - An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), - Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), - Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), - Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), - Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), - Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), - Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), - Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), - case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), - Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), - Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), - Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), - Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), - Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), - Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), - Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), - Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), - Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), - String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), - Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), - or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), - Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), - Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), - File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), - const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), - const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), - let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), - Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), - Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), - An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), - A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), - Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), - A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), - extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), - extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), - Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), - implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), - Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), - Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), - Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), - Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), - Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), - Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), - A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), - An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), - Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), - Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), - A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), - A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), - An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), - Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), - An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), - Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), - Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), - Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), - Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), - Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), - Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), - Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), - All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), - A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), - Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), - Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), - Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), - An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), - _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), - Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), - Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), - Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), - Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), - A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), - An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), - An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), - _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), - Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), - An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), - A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), - A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), - A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), - A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), - A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), - Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), - Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), - Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), - with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), - await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), - The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), - Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), - Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), - Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), - A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), - An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), - A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), - Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), - Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), - Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323", "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'."), - Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), - Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), - String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), - Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), - _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), - A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), - A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), - A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), - unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), - unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), - unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), - An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), - An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), - infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), - Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), - Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), - A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), - An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), - This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), - use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), - Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), - use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), - Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), - An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), - A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), - A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), - readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), - A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), - Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), - Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), - Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), - Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), - Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), - Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), - File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), - Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), - Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), - A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), - An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), - Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), - Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), - Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), - Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), - Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), - Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), - Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), - Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), - Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), - Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), - Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), - Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), - Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), - Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), - Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), - Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), - Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), - Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), - this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), - this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), - this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), - this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), + ts.isAnyDirectorySeparator = isAnyDirectorySeparator; + /** + * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.). + */ + function isUrl(path) { + return getEncodedRootLength(path) < 0; + } + ts.isUrl = isUrl; + /** + * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path + * like `c:`, `c:\` or `c:/`). + */ + function isRootedDiskPath(path) { + return getEncodedRootLength(path) > 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + /** + * Determines whether a path consists only of a path root. + */ + function isDiskPathRoot(path) { + var rootLength = getEncodedRootLength(path); + return rootLength > 0 && rootLength === path.length; + } + ts.isDiskPathRoot = isDiskPathRoot; + /** + * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.). + * + * ```ts + * // POSIX + * pathIsAbsolute("/path/to/file.ext") === true + * // DOS + * pathIsAbsolute("c:/path/to/file.ext") === true + * // URL + * pathIsAbsolute("file:///path/to/file.ext") === true + * // Non-absolute + * pathIsAbsolute("path/to/file.ext") === false + * pathIsAbsolute("./path/to/file.ext") === false + * ``` + */ + function pathIsAbsolute(path) { + return getEncodedRootLength(path) !== 0; + } + ts.pathIsAbsolute = pathIsAbsolute; + /** + * Determines whether a path starts with a relative path component (i.e. `.` or `..`). + */ + function pathIsRelative(path) { + return /^\.\.?($|[\\/])/.test(path); + } + ts.pathIsRelative = pathIsRelative; + function hasExtension(fileName) { + return ts.stringContains(getBaseFileName(fileName), "."); + } + ts.hasExtension = hasExtension; + function fileExtensionIs(path, extension) { + return path.length > extension.length && ts.endsWith(path, extension); + } + ts.fileExtensionIs = fileExtensionIs; + function fileExtensionIsOneOf(path, extensions) { + for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { + var extension = extensions_1[_i]; + if (fileExtensionIs(path, extension)) { + return true; + } + } + return false; + } + ts.fileExtensionIsOneOf = fileExtensionIsOneOf; + /** + * Determines whether a path has a trailing separator (`/` or `\\`). + */ + function hasTrailingDirectorySeparator(path) { + return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); + } + ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; + //// Path Parsing + function isVolumeCharacter(charCode) { + return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || + (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + } + function getFileUrlVolumeSeparatorEnd(url, start) { + var ch0 = url.charCodeAt(start); + if (ch0 === 58 /* colon */) + return start + 1; + if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + var ch2 = url.charCodeAt(start + 2); + if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + return start + 3; + } + return -1; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * If the root is part of a URL, the twos-complement of the root length is returned. + */ + function getEncodedRootLength(path) { + if (!path) + return 0; + var ch0 = path.charCodeAt(0); + // POSIX or UNC + if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (path.charCodeAt(1) !== ch0) + return 1; // POSIX: "/" (or non-normalized "\") + var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); + if (p1 < 0) + return path.length; // UNC: "//server" or "\\server" + return p1 + 1; // UNC: "//server/" or "\\server\" + } + // DOS + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + var ch2 = path.charCodeAt(2); + if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + return 3; // DOS: "c:/" or "c:\" + if (path.length === 2) + return 2; // DOS: "c:" (but not "c:d") + } + // URL + var schemeEnd = path.indexOf(urlSchemeSeparator); + if (schemeEnd !== -1) { + var authorityStart = schemeEnd + urlSchemeSeparator.length; + var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); + if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" + // For local "file" URLs, include the leading DOS volume (if present). + // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a + // special case interpreted as "the machine from which the URL is being interpreted". + var scheme = path.slice(0, schemeEnd); + var authority = path.slice(authorityStart, authorityEnd); + if (scheme === "file" && (authority === "" || authority === "localhost") && + isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { + var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); + if (volumeSeparatorEnd !== -1) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" + return ~(volumeSeparatorEnd + 1); + } + if (volumeSeparatorEnd === path.length) { + // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" + // but not "file:///c:d" or "file:///c%3ad" + return ~volumeSeparatorEnd; + } + } + } + return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" + } + return ~path.length; // URL: "file://server", "http://server" + } + // relative + return 0; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * + * For example: + * ```ts + * getRootLength("a") === 0 // "" + * getRootLength("/") === 1 // "/" + * getRootLength("c:") === 2 // "c:" + * getRootLength("c:d") === 0 // "" + * getRootLength("c:/") === 3 // "c:/" + * getRootLength("c:\\") === 3 // "c:\\" + * getRootLength("//server") === 7 // "//server" + * getRootLength("//server/share") === 8 // "//server/" + * getRootLength("\\\\server") === 7 // "\\\\server" + * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" + * getRootLength("file:///path") === 8 // "file:///" + * getRootLength("file:///c:") === 10 // "file:///c:" + * getRootLength("file:///c:d") === 8 // "file:///" + * getRootLength("file:///c:/path") === 11 // "file:///c:/" + * getRootLength("file://server") === 13 // "file://server" + * getRootLength("file://server/path") === 14 // "file://server/" + * getRootLength("http://server") === 13 // "http://server" + * getRootLength("http://server/path") === 14 // "http://server/" + * ``` + */ + function getRootLength(path) { + var rootLength = getEncodedRootLength(path); + return rootLength < 0 ? ~rootLength : rootLength; + } + ts.getRootLength = getRootLength; + function getDirectoryPath(path) { + path = normalizeSlashes(path); + // If the path provided is itself the root, then return it. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return path; + // return the leading portion of the path up to the last (non-terminal) directory separator + // but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function getBaseFileName(path, extensions, ignoreCase) { + path = normalizeSlashes(path); + // if the path provided is itself the root, then it has not file name. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return ""; + // return the trailing portion of the path starting after the last (non-terminal) directory + // separator but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); + var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; + return extension ? name.slice(0, name.length - extension.length) : name; + } + ts.getBaseFileName = getBaseFileName; + function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { + if (!ts.startsWith(extension, ".")) + extension = "." + extension; + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + var pathExtension = path.slice(path.length - extension.length); + if (stringEqualityComparer(pathExtension, extension)) { + return pathExtension; + } + } + } + function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { + if (typeof extensions === "string") { + return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || ""; + } + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer); + if (result) + return result; + } + return ""; + } + function getAnyExtensionFromPath(path, extensions, ignoreCase) { + // Retrieves any string from the final "." onwards from a base file name. + // Unlike extensionFromPath, which throws an exception on unrecognized extensions. + if (extensions) { + return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); + } + var baseFileName = getBaseFileName(path); + var extensionIndex = baseFileName.lastIndexOf("."); + if (extensionIndex >= 0) { + return baseFileName.substring(extensionIndex); + } + return ""; + } + ts.getAnyExtensionFromPath = getAnyExtensionFromPath; + function pathComponents(path, rootLength) { + var root = path.substring(0, rootLength); + var rest = path.substring(rootLength).split(ts.directorySeparator); + if (rest.length && !ts.lastOrUndefined(rest)) + rest.pop(); + return __spreadArrays([root], rest); + } + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is not normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * // POSIX + * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"] + * getPathComponents("/path/to/") === ["/", "path", "to"] + * getPathComponents("/") === ["/"] + * // DOS + * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"] + * getPathComponents("c:/path/to/") === ["c:/", "path", "to"] + * getPathComponents("c:/") === ["c:/"] + * getPathComponents("c:") === ["c:"] + * // URL + * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"] + * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"] + * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"] + * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"] + * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"] + * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"] + * getPathComponents("file://server/") === ["file://server/"] + * getPathComponents("file://server") === ["file://server"] + * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"] + * getPathComponents("file:///path/to/") === ["file:///", "path", "to"] + * getPathComponents("file:///") === ["file:///"] + * getPathComponents("file://") === ["file://"] + */ + function getPathComponents(path, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } + path = combinePaths(currentDirectory, path); + return pathComponents(path, getRootLength(path)); + } + ts.getPathComponents = getPathComponents; + //// Path Formatting + /** + * Formats a parsed path consisting of a root component (at index 0) and zero or more path + * segments (at indices > 0). + * + * ```ts + * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext" + * ``` + */ + function getPathFromPathComponents(pathComponents) { + if (pathComponents.length === 0) + return ""; + var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]); + return root + pathComponents.slice(1).join(ts.directorySeparator); + } + ts.getPathFromPathComponents = getPathFromPathComponents; + //// Path Normalization + /** + * Normalize path separators, converting `\` into `/`. + */ + function normalizeSlashes(path) { + return path.replace(backslashRegExp, ts.directorySeparator); + } + ts.normalizeSlashes = normalizeSlashes; + /** + * Reduce an array of path components to a more simplified path by navigating any + * `"."` or `".."` entries in the path. + */ + function reducePathComponents(components) { + if (!ts.some(components)) + return []; + var reduced = [components[0]]; + for (var i = 1; i < components.length; i++) { + var component = components[i]; + if (!component) + continue; + if (component === ".") + continue; + if (component === "..") { + if (reduced.length > 1) { + if (reduced[reduced.length - 1] !== "..") { + reduced.pop(); + continue; + } + } + else if (reduced[0]) + continue; + } + reduced.push(component); + } + return reduced; + } + ts.reducePathComponents = reducePathComponents; + /** + * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. + * + * ```ts + * // Non-rooted + * combinePaths("path", "to", "file.ext") === "path/to/file.ext" + * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext" + * // POSIX + * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext" + * combinePaths("/path", "/to", "file.ext") === "/to/file.ext" + * // DOS + * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext" + * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext" + * // URL + * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext" + * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext" + * ``` + */ + function combinePaths(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + if (path) + path = normalizeSlashes(path); + for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { + var relativePath = paths_1[_a]; + if (!relativePath) + continue; + relativePath = normalizeSlashes(relativePath); + if (!path || getRootLength(relativePath) !== 0) { + path = relativePath; + } + else { + path = ensureTrailingDirectorySeparator(path) + relativePath; + } + } + return path; + } + ts.combinePaths = combinePaths; + /** + * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any + * `.` and `..` path components are resolved. Trailing directory separators are preserved. + * + * ```ts + * resolvePath("/path", "to", "file.ext") === "path/to/file.ext" + * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/" + * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext" + * ``` + */ + function resolvePath(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path)); + } + ts.resolvePath = resolvePath; + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"] + */ + function getNormalizedPathComponents(path, currentDirectory) { + return reducePathComponents(getPathComponents(path, currentDirectory)); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function normalizePath(path) { + path = normalizeSlashes(path); + var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); + return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; + } + ts.normalizePath = normalizePath; + function getPathWithoutRoot(pathComponents) { + if (pathComponents.length === 0) + return ""; + return pathComponents.slice(1).join(ts.directorySeparator); + } + function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { + return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; + function normalizePathAndParts(path) { + path = normalizeSlashes(path); + var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; + } + else { + return { path: root, parts: parts }; + } + } + ts.normalizePathAndParts = normalizePathAndParts; + function removeTrailingDirectorySeparator(path) { + if (hasTrailingDirectorySeparator(path)) { + return path.substr(0, path.length - 1); + } + return path; + } + ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; + function ensureTrailingDirectorySeparator(path) { + if (!hasTrailingDirectorySeparator(path)) { + return path + ts.directorySeparator; + } + return path; + } + ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; + /** + * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed + * with `./` or `../`) so as not to be confused with an unprefixed module name. + * + * ```ts + * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext" + * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext" + * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext" + * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext" + * ``` + */ + function ensurePathIsNonModuleName(path) { + return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path; + } + ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; + function changeAnyExtension(path, ext, extensions, ignoreCase) { + var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); + return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; + } + ts.changeAnyExtension = changeAnyExtension; + //// Path Comparisons + // check path for these segments: '', '.'. '..' + var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + function comparePathsWorker(a, b, componentComparer) { + if (a === b) + return 0 /* EqualTo */; + if (a === undefined) + return -1 /* LessThan */; + if (b === undefined) + return 1 /* GreaterThan */; + // NOTE: Performance optimization - shortcut if the root segments differ as there would be no + // need to perform path reduction. + var aRoot = a.substring(0, getRootLength(a)); + var bRoot = b.substring(0, getRootLength(b)); + var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); + if (result !== 0 /* EqualTo */) { + return result; + } + // NOTE: Performance optimization - shortcut if there are no relative path segments in + // the non-root portion of the path + var aRest = a.substring(aRoot.length); + var bRest = b.substring(bRoot.length); + if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { + return componentComparer(aRest, bRest); + } + // The path contains a relative path segment. Normalize the paths and perform a slower component + // by component comparison. + var aComponents = reducePathComponents(getPathComponents(a)); + var bComponents = reducePathComponents(getPathComponents(b)); + var sharedLength = Math.min(aComponents.length, bComponents.length); + for (var i = 1; i < sharedLength; i++) { + var result_1 = componentComparer(aComponents[i], bComponents[i]); + if (result_1 !== 0 /* EqualTo */) { + return result_1; + } + } + return ts.compareValues(aComponents.length, bComponents.length); + } + /** + * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively. + */ + function comparePathsCaseSensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + } + ts.comparePathsCaseSensitive = comparePathsCaseSensitive; + /** + * Performs a case-insensitive comparison of two paths. + */ + function comparePathsCaseInsensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + } + ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; + function comparePaths(a, b, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + a = combinePaths(currentDirectory, a); + b = combinePaths(currentDirectory, b); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + } + ts.comparePaths = comparePaths; + function containsPath(parent, child, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + parent = combinePaths(currentDirectory, parent); + child = combinePaths(currentDirectory, child); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + if (parent === undefined || child === undefined) + return false; + if (parent === child) + return true; + var parentComponents = reducePathComponents(getPathComponents(parent)); + var childComponents = reducePathComponents(getPathComponents(child)); + if (childComponents.length < parentComponents.length) { + return false; + } + var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; + for (var i = 0; i < parentComponents.length; i++) { + var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; + if (!equalityComparer(parentComponents[i], childComponents[i])) { + return false; + } + } + return true; + } + ts.containsPath = containsPath; + /** + * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. + * Comparison is case-sensitive between the canonical paths. + * + * @deprecated Use `containsPath` if possible. + */ + function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { + var canonicalFileName = getCanonicalFileName(fileName); + var canonicalDirectoryName = getCanonicalFileName(directoryName); + return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); + } + ts.startsWithDirectory = startsWithDirectory; + //// Relative Paths + function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { + var fromComponents = reducePathComponents(getPathComponents(from)); + var toComponents = reducePathComponents(getPathComponents(to)); + var start; + for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { + var fromComponent = getCanonicalFileName(fromComponents[start]); + var toComponent = getCanonicalFileName(toComponents[start]); + var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; + if (!comparer(fromComponent, toComponent)) + break; + } + if (start === 0) { + return toComponents; + } + var components = toComponents.slice(start); + var relative = []; + for (; start < fromComponents.length; start++) { + relative.push(".."); + } + return __spreadArrays([""], relative, components); + } + ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; + function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { + ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); + var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; + var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; + var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathFromDirectory = getRelativePathFromDirectory; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + } + ts.convertToRelativePath = convertToRelativePath; + function getRelativePathFromFile(from, to, getCanonicalFileName) { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); + } + ts.getRelativePathFromFile = getRelativePathFromFile; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); + var firstComponent = pathComponents[0]; + if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) { + var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; + pathComponents[0] = prefix + firstComponent; + } + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } + ts.forEachAncestorDirectory = forEachAncestorDirectory; +})(ts || (ts = {})); +// +// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' +/* @internal */ +var ts; +(function (ts) { + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; + } + ts.Diagnostics = { + Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), + Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), + _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), + A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), + Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), + Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), + An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), + Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), + A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), + A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), + Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), + A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), + An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), + An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), + An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), + An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), + An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), + An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), + An_index_signature_parameter_type_must_be_either_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_either_string_or_number_1023", "An index signature parameter type must be either 'string' or 'number'."), + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), + Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), + _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), + _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), + _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), + super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), + Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), + Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), + Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), + _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), + _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), + _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), + _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), + _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), + A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), + Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), + A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), + A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), + A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), + A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), + A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), + A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), + A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), + An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), + A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), + Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), + An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), + _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), + _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), + A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), + Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), + _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), + _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), + Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), + Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), + An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), + A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), + An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), + _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), + Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), + Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), + Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), + with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), + delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), + A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), + Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), + Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), + Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), + An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), + Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), + Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), + Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), + Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), + Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), + Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), + Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), + Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), + case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), + Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), + Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), + Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), + Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), + Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), + Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), + Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), + Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), + Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), + String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), + Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), + or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), + Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), + Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), + Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), + File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), + const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), + const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), + let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), + Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), + Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), + An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), + A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), + Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), + A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), + extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), + extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), + Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), + implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), + Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), + Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), + Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), + Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), + Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), + Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), + A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), + An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), + Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), + Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), + A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), + A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), + An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), + Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), + An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), + Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), + Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), + Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), + Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), + Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), + Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), + Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), + All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), + A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), + Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), + Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), + Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), + An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), + _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), + Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), + Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), + Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), + Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), + A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), + An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), + An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), + _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), + Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), + An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), + A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), + A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), + A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), + _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), + A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), + A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), + Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), + with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), + await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), + The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), + Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), + Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), + Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), + A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), + An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd_1323", "Dynamic imports are only supported when the '--module' flag is set to 'esnext', 'commonjs', 'amd', 'system', or 'umd'."), + Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), + Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), + Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), + String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), + Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), + _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), + A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), + A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), + A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), + unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), + unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), + unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), + An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), + An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), + infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), + Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), + Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), + A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), + An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), + This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), + use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), + Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), + use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), + An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), + A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), + A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), + readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), + A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), + Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), + Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), + Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), + Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), + Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), + File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), + Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), + Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), + Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), + A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), + An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), + Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), + Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), + Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), + Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), + Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), + Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), + Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), + Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), + Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), + Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), + Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), + Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), + Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), + Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), + Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), + Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), + Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), + Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), + this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), + this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), + this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), + this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), @@ -5756,7 +6694,7 @@ var ts; Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), @@ -5834,7 +6772,6 @@ var ts; Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2424, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property."), Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."), Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."), Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."), @@ -6004,6 +6941,11 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(2613, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(2614, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -6126,6 +7068,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -6212,6 +7162,11 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), + Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), + Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6222,6 +7177,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6247,6 +7203,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6434,6 +7391,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6452,9 +7410,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), - Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6493,9 +7453,12 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), + Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -6579,6 +7542,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6608,6 +7573,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6725,6 +7691,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6735,94 +7709,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7086,6 +8061,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7438,7 +8414,7 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, @@ -7448,8 +8424,8 @@ var ts; hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7459,6 +8435,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7473,6 +8450,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7921,7 +8907,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7985,7 +8971,7 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; @@ -8056,12 +9042,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -8070,19 +9056,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -8091,13 +9077,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -8105,28 +9091,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8187,10 +9173,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8248,7 +9234,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8264,20 +9250,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8290,15 +9276,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8310,10 +9296,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8322,10 +9316,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8340,22 +9334,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { @@ -8401,29 +9395,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8485,12 +9479,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8500,10 +9499,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8579,7 +9578,7 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } @@ -8595,13 +9594,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8611,17 +9610,17 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; + return token = 61 /* BacktickToken */; case 92 /* backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -8643,7 +9642,7 @@ var ts; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion)) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); if (char === 92 /* backslash */) { @@ -8724,7 +9723,7 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -8795,7 +9794,7 @@ var ts; ts.getDeclarationOfKind = getDeclarationOfKind; /** Create a new escaped identifier map. */ function createUnderscoreEscapedMap() { - return new ts.MapCtr(); + return new ts.Map(); } ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap; function hasEntries(map) { @@ -8837,6 +9836,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8849,13 +9850,6 @@ var ts; reportPrivateInBaseOfClassExpression: ts.noop, }; } - function toPath(fileName, basePath, getCanonicalFileName) { - var nonCanonicalizedPath = ts.isRootedDiskPath(fileName) - ? ts.normalizePath(fileName) - : ts.getNormalizedAbsolutePath(fileName, basePath); - return getCanonicalFileName(nonCanonicalizedPath); - } - ts.toPath = toPath; function changesAffectModuleResolution(oldOptions, newOptions) { return oldOptions.configFilePath !== newOptions.configFilePath || optionsHaveModuleResolutionChanges(oldOptions, newOptions); @@ -8924,7 +9918,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -9012,28 +10006,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -9041,11 +10035,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -9213,7 +10207,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 314 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9232,7 +10226,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9300,10 +10294,8 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings return "`" + rawText + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings return "}" + rawText + "${"; case 17 /* TemplateTail */: return "}" + rawText + "`"; @@ -9334,7 +10326,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9366,16 +10358,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9387,9 +10379,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9442,22 +10434,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9467,9 +10459,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 300 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9479,25 +10471,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9507,8 +10499,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9517,15 +10509,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9555,13 +10547,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9572,11 +10564,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9621,7 +10613,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9635,7 +10627,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9644,32 +10636,38 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + var start = ts.skipTrivia(sourceFile.text, node.pos); + var end = node.statements.length > 0 ? node.statements[0].pos : node.end; + return ts.createTextSpanFromBounds(start, end); } if (errorNode === undefined) { // If we don't have a better node, then just set the error on the first token of // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9711,16 +10709,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 93 /* ImportKeyword */ + && n.keywordToken === 95 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -9729,7 +10727,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9738,11 +10736,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -9758,48 +10756,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9808,40 +10806,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9866,23 +10864,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9892,26 +10890,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -9934,10 +10932,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9947,12 +10945,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9960,14 +10958,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9979,8 +10977,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9991,13 +10989,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -10008,7 +11006,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -10016,17 +11014,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -10039,7 +11037,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -10080,14 +11078,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -10102,9 +11100,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10115,26 +11113,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -10144,9 +11142,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -10168,27 +11166,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10204,21 +11202,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -10227,8 +11225,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -10236,20 +11234,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -10257,10 +11255,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -10269,25 +11267,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10303,10 +11301,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10315,9 +11313,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10325,57 +11323,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10385,49 +11383,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10435,7 +11433,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10444,7 +11442,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10456,15 +11454,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10472,22 +11470,22 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; - function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + function isRequireCall(callExpression, requireStringLiteralLikeArgument) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { return false; } var arg = args[0]; - return !checkArgumentIsStringLiteralLike || ts.isStringLiteralLike(arg); + return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { @@ -10511,21 +11509,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { - if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { - name = node.parent.parent.name; - decl = node.parent.parent; - } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10535,13 +11537,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10555,14 +11558,20 @@ var ts; } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; function hasExpandoValueProperty(node, isPrototypeAssignment) { - return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + return ts.forEach(node.properties, function (p) { + return ts.isPropertyAssignment(p) && + ts.isIdentifier(p.name) && + p.name.escapedText === "value" && + p.initializer && + getExpandoInitializer(p.initializer, isPrototypeAssignment); + }); } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10588,11 +11597,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10609,14 +11618,16 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10624,8 +11635,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10644,19 +11655,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10671,10 +11683,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10689,60 +11704,129 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0], /*excludeThisKeyword*/ true); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + /** x.y OR x[0] */ + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + /** x[0] OR x['a'] OR x[Symbol.y] */ + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + /** Any series of property and element accesses. */ + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + /** Any series of property and element accesses, ending in a literal element access */ + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); + } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; - if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { - // exports.name = expr OR module.exports.name = expr + if ((id.escapedText === "exports" || + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") && + // ExportsProperty does not support binding with computed names + isBindableStaticAccessExpression(lhs)) { + // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... return 1 /* ExportsProperty */; } - // F.G...x = expr - return 5 /* Property */; + if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs) && lhs.expression.kind !== 103 /* ThisKeyword */)) { + // F.G...x = expr + return 5 /* Property */; + } } return 0 /* None */; } @@ -10760,7 +11844,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10769,7 +11854,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10778,14 +11863,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10795,12 +11880,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10809,11 +11894,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10821,19 +11906,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10847,7 +11932,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 312 /* JSDocTypedefTag */ || node.kind === 305 /* JSDocCallbackTag */ || node.kind === 306 /* JSDocEnumTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10857,7 +11942,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10866,18 +11951,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10888,7 +11973,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10903,11 +11988,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10918,12 +12003,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10934,7 +12019,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10957,7 +12042,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10982,7 +12067,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10992,7 +12077,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -11005,31 +12090,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -11056,22 +12141,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -11088,33 +12173,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -11136,11 +12221,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -11163,8 +12249,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -11172,32 +12258,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -11213,22 +12299,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -11242,24 +12345,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11286,11 +12389,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -11298,7 +12401,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -11306,6 +12409,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11329,14 +12437,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11350,10 +12458,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11366,7 +12474,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11386,10 +12494,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11403,12 +12514,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11424,7 +12535,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11435,11 +12546,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11454,7 +12565,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11463,11 +12574,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11475,15 +12586,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11502,38 +12613,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11542,15 +12653,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11560,73 +12671,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11635,41 +12746,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11787,22 +12900,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11853,6 +12967,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11864,7 +12979,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11874,17 +12989,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11898,6 +13025,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11917,6 +13045,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11931,12 +13061,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -12000,7 +13130,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -12018,7 +13148,7 @@ var ts; */ function getExternalModuleNameFromPath(host, fileName, referencePath) { var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = ts.removeFileExtension(relativePath); @@ -12141,11 +13271,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -12156,10 +13286,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -12179,10 +13309,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -12228,7 +13358,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 298 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12468,7 +13598,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12476,29 +13606,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12511,14 +13641,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12526,8 +13656,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12537,9 +13667,32 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function getFirstIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + node = node.expression; + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + ts.getFirstIdentifier = getFirstIdentifier; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12555,21 +13708,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12867,8 +14020,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12945,35 +14098,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && skipParenthesesUp(parent.parent).kind === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -13052,21 +14205,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ - function forEachAncestorDirectory(directory, callback) { - while (true) { - var result = callback(directory); - if (result !== undefined) { - return result; - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - return undefined; - } - directory = parentPath; - } - } - ts.forEachAncestorDirectory = forEachAncestorDirectory; // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { return !!(getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isAbstractConstructorSymbol(type.symbol); @@ -13093,7 +14231,7 @@ var ts; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { - return !!forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); + return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { @@ -13137,32 +14275,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -13175,6 +14313,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13282,7 +14424,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13399,9 +14541,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } @@ -13409,7 +14551,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13439,14 +14581,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13510,7 +14652,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13592,30 +14735,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 205 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13627,6 +14770,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13639,41 +14793,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 306 /* JSDocEnumTag */: + case 309 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13696,8 +14855,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13875,7 +15034,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 298 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13895,10 +15054,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13943,198 +15101,230 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + var kind = node.kind; + return !!(node.flags & 32 /* OptionalChain */) && + (kind === 193 /* PropertyAccessExpression */ + || kind === 194 /* ElementAccessExpression */ + || kind === 195 /* CallExpression */); + } + ts.isOptionalChain = isOptionalChain; + /** + * Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`). + */ + /* @internal */ + function isExpressionOfOptionalChainRoot(node) { + return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node; + } + ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot; + function isNullishCoalesce(node) { + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + } + ts.isNullishCoalesce = isNullishCoalesce; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -14143,376 +15333,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 316 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14521,105 +15711,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 298 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 303 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 302 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 304 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 306 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 309 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 307 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 308 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 310 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 311 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 312 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 313 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 313 /* JSDocPropertyTag */ || node.kind === 307 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 299 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 305 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 300 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14630,7 +15820,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 314 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14640,7 +15830,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14649,7 +15839,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14702,17 +15892,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14725,7 +15915,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14734,23 +15924,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14765,13 +15955,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14780,14 +15970,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14802,29 +15992,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14834,11 +16024,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14847,12 +16037,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14867,8 +16057,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14879,8 +16069,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14888,15 +16078,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14905,9 +16095,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14928,8 +16118,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14941,8 +16131,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14951,26 +16141,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14978,12 +16168,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14994,34 +16184,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -15034,13 +16224,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -15049,11 +16239,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -15070,15 +16260,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 317 /* CommaListExpression */: - case 316 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -15086,21 +16276,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 316 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 315 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -15108,21 +16303,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -15146,113 +16362,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 312 /* JSDocTypedefTag */ - || kind === 305 /* JSDocCallbackTag */ - || kind === 313 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 315 /* NotEmittedStatement */ - || kind === 319 /* EndOfDeclarationMarker */ - || kind === 318 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 311 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -15279,10 +16495,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -15292,83 +16508,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 313 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 298 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 301 /* FirstJSDocTagNode */ && node.kind <= 313 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; + } + ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; } - ts.isGetAccessor = isGetAccessor; + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15396,12 +16617,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15437,7 +16658,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15455,7 +16676,12 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature(checker, flags) { + this.flags = flags; + if (ts.Debug.isDebugging) { + this.checker = checker; + } + } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15469,759 +16695,303 @@ var ts; } function SourceMapSource(fileName, text, skipTrivia) { this.fileName = fileName; - this.text = text; - this.skipTrivia = skipTrivia || (function (pos) { return pos; }); - } - ts.objectAllocator = { - getNodeConstructor: function () { return Node; }, - getTokenConstructor: function () { return Node; }, - getIdentifierConstructor: function () { return Node; }, - getSourceFileConstructor: function () { return Node; }, - getSymbolConstructor: function () { return Symbol; }, - getTypeConstructor: function () { return Type; }, - getSignatureConstructor: function () { return Signature; }, - getSourceMapSourceConstructor: function () { return SourceMapSource; }, - }; - function formatStringFromArgs(text, args, baseIndex) { - if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); - } - ts.formatStringFromArgs = formatStringFromArgs; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - ts.Debug.assertGreaterThanOrEqual(start, 0); - ts.Debug.assertGreaterThanOrEqual(length, 0); - if (file) { - ts.Debug.assertLessThanOrEqual(start, file.text.length); - ts.Debug.assertLessThanOrEqual(start + length, file.text.length); - } - var text = getLocaleSpecificMessage(message); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(_dummy, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return text; - } - ts.formatMessage = formatMessage; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function createCompilerDiagnosticFromMessageChain(chain) { - return { - file: undefined, - start: undefined, - length: undefined, - code: chain.code, - category: chain.category, - messageText: chain.next ? chain : chain.messageText, - }; - } - ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details === undefined || Array.isArray(details) ? details : [details] - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - var lastChain = headChain; - while (lastChain.next) { - lastChain = lastChain.next[0]; - } - lastChain.next = [tailChain]; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function getDiagnosticFilePath(diagnostic) { - return diagnostic.file ? diagnostic.file.path : undefined; - } - function compareDiagnostics(d1, d2) { - return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; - } - ts.compareDiagnostics = compareDiagnostics; - function compareDiagnosticsSkipRelatedInformation(d1, d2) { - return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || - ts.compareValues(d1.start, d2.start) || - ts.compareValues(d1.length, d2.length) || - ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; - } - ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; - function compareRelatedInformation(d1, d2) { - if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; - } - if (d1.relatedInformation && d2.relatedInformation) { - return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { - var d2i = d2.relatedInformation[index]; - return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; - } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; - } - function compareMessageText(t1, t2) { - if (typeof t1 === "string" && typeof t2 === "string") { - return ts.compareStringsCaseSensitive(t1, t2); - } - else if (typeof t1 === "string") { - return -1 /* LessThan */; - } - else if (typeof t2 === "string") { - return 1 /* GreaterThan */; - } - var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); - if (res) { - return res; - } - if (!t1.next && !t2.next) { - return 0 /* EqualTo */; - } - if (!t1.next) { - return -1 /* LessThan */; - } - if (!t2.next) { - return 1 /* GreaterThan */; - } - var len = Math.min(t1.next.length, t2.next.length); - for (var i = 0; i < len; i++) { - res = compareMessageText(t1.next[i], t2.next[i]); - if (res) { - return res; - } - } - if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; - } - else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; - } - return 0 /* EqualTo */; - } - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0 /* ES3 */; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; - function getEmitModuleResolutionKind(compilerOptions) { - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - } - return moduleResolution; - } - ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; - function hasJsonModuleEmitEnabled(options) { - switch (getEmitModuleKind(options)) { - case ts.ModuleKind.CommonJS: - case ts.ModuleKind.AMD: - case ts.ModuleKind.ES2015: - case ts.ModuleKind.ESNext: - return true; - default: - return false; - } - } - ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; - function unreachableCodeIsError(options) { - return options.allowUnreachableCode === false; - } - ts.unreachableCodeIsError = unreachableCodeIsError; - function unusedLabelIsError(options) { - return options.allowUnusedLabels === false; - } - ts.unusedLabelIsError = unusedLabelIsError; - function getAreDeclarationMapsEnabled(options) { - return !!(getEmitDeclarations(options) && options.declarationMap); - } - ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; - function getAllowSyntheticDefaultImports(compilerOptions) { - var moduleKind = getEmitModuleKind(compilerOptions); - return compilerOptions.allowSyntheticDefaultImports !== undefined - ? compilerOptions.allowSyntheticDefaultImports - : compilerOptions.esModuleInterop || - moduleKind === ts.ModuleKind.System; - } - ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; - function getEmitDeclarations(compilerOptions) { - return !!(compilerOptions.declaration || compilerOptions.composite); - } - ts.getEmitDeclarations = getEmitDeclarations; - function isIncrementalCompilation(options) { - return !!(options.incremental || options.composite); - } - ts.isIncrementalCompilation = isIncrementalCompilation; - function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; - } - ts.getStrictOptionValue = getStrictOptionValue; - function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; - function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; - function getCompilerOptionValue(options, option) { - return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; - } - ts.getCompilerOptionValue = getCompilerOptionValue; - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - // have already seen asterisk - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - /** - * Internally, we represent paths as strings with '/' as the directory separator. - * When we make system calls (eg: LanguageServiceHost.getDirectory()), - * we expect the host to correctly handle paths in our specified format. - */ - ts.directorySeparator = "/"; - var altDirectorySeparator = "\\"; - var urlSchemeSeparator = "://"; - var backslashRegExp = /\\/g; - /** - * Normalize path separators. - */ - function normalizeSlashes(path) { - return path.replace(backslashRegExp, ts.directorySeparator); - } - ts.normalizeSlashes = normalizeSlashes; - function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); - } - function getFileUrlVolumeSeparatorEnd(url, start) { - var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) - return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { - var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) - return start + 3; - } - return -1; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * If the root is part of a URL, the twos-complement of the root length is returned. - */ - function getEncodedRootLength(path) { - if (!path) - return 0; - var ch0 = path.charCodeAt(0); - // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { - if (path.charCodeAt(1) !== ch0) - return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); - if (p1 < 0) - return path.length; // UNC: "//server" or "\\server" - return p1 + 1; // UNC: "//server/" or "\\server\" - } - // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { - var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) - return 3; // DOS: "c:/" or "c:\" - if (path.length === 2) - return 2; // DOS: "c:" (but not "c:d") - } - // URL - var schemeEnd = path.indexOf(urlSchemeSeparator); - if (schemeEnd !== -1) { - var authorityStart = schemeEnd + urlSchemeSeparator.length; - var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); - if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" - // For local "file" URLs, include the leading DOS volume (if present). - // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a - // special case interpreted as "the machine from which the URL is being interpreted". - var scheme = path.slice(0, schemeEnd); - var authority = path.slice(authorityStart, authorityEnd); - if (scheme === "file" && (authority === "" || authority === "localhost") && - isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { - var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); - if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { - // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" - return ~(volumeSeparatorEnd + 1); - } - if (volumeSeparatorEnd === path.length) { - // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" - // but not "file:///c:d" or "file:///c%3ad" - return ~volumeSeparatorEnd; - } - } - } - return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" - } - return ~path.length; // URL: "file://server", "http://server" - } - // relative - return 0; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * - * For example: - * ```ts - * getRootLength("a") === 0 // "" - * getRootLength("/") === 1 // "/" - * getRootLength("c:") === 2 // "c:" - * getRootLength("c:d") === 0 // "" - * getRootLength("c:/") === 3 // "c:/" - * getRootLength("c:\\") === 3 // "c:\\" - * getRootLength("//server") === 7 // "//server" - * getRootLength("//server/share") === 8 // "//server/" - * getRootLength("\\\\server") === 7 // "\\\\server" - * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" - * getRootLength("file:///path") === 8 // "file:///" - * getRootLength("file:///c:") === 10 // "file:///c:" - * getRootLength("file:///c:d") === 8 // "file:///" - * getRootLength("file:///c:/path") === 11 // "file:///c:/" - * getRootLength("file://server") === 13 // "file://server" - * getRootLength("file://server/path") === 14 // "file://server/" - * getRootLength("http://server") === 13 // "http://server" - * getRootLength("http://server/path") === 14 // "http://server/" - * ``` - */ - function getRootLength(path) { - var rootLength = getEncodedRootLength(path); - return rootLength < 0 ? ~rootLength : rootLength; - } - ts.getRootLength = getRootLength; - // TODO(rbuckton): replace references with `resolvePath` - function normalizePath(path) { - return ts.resolvePath(path); - } - ts.normalizePath = normalizePath; - function normalizePathAndParts(path) { - path = normalizeSlashes(path); - var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); - if (parts.length) { - var joinedParts = root + parts.join(ts.directorySeparator); - return { path: ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; - } - else { - return { path: root, parts: parts }; - } - } - ts.normalizePathAndParts = normalizePathAndParts; - function getDirectoryPath(path) { - path = normalizeSlashes(path); - // If the path provided is itself the root, then return it. - var rootLength = getRootLength(path); - if (rootLength === path.length) - return path; - // return the leading portion of the path up to the last (non-terminal) directory separator - // but not including any trailing directory separator. - path = ts.removeTrailingDirectorySeparator(path); - return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { - var canonicalFileName = getCanonicalFileName(fileName); - var canonicalDirectoryName = getCanonicalFileName(directoryName); - return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); - } - ts.startsWithDirectory = startsWithDirectory; - function isUrl(path) { - return getEncodedRootLength(path) < 0; - } - ts.isUrl = isUrl; - function pathIsRelative(path) { - return /^\.\.?($|[\\/])/.test(path); - } - ts.pathIsRelative = pathIsRelative; - /** - * Determines whether a path is an absolute path (e.g. starts with `/`, or a dos path - * like `c:`, `c:\` or `c:/`). - */ - function isRootedDiskPath(path) { - return getEncodedRootLength(path) > 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - /** - * Determines whether a path consists only of a path root. - */ - function isDiskPathRoot(path) { - var rootLength = getEncodedRootLength(path); - return rootLength > 0 && rootLength === path.length; - } - ts.isDiskPathRoot = isDiskPathRoot; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - } - ts.convertToRelativePath = convertToRelativePath; - function pathComponents(path, rootLength) { - var root = path.substring(0, rootLength); - var rest = path.substring(rootLength).split(ts.directorySeparator); - if (rest.length && !ts.lastOrUndefined(rest)) - rest.pop(); - return __spreadArrays([root], rest); - } - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is not normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getPathComponents(path, currentDirectory) { - if (currentDirectory === void 0) { currentDirectory = ""; } - path = ts.combinePaths(currentDirectory, path); - var rootLength = getRootLength(path); - return pathComponents(path, rootLength); - } - ts.getPathComponents = getPathComponents; - /** - * Reduce an array of path components to a more simplified path by navigating any - * `"."` or `".."` entries in the path. - */ - function reducePathComponents(components) { - if (!ts.some(components)) - return []; - var reduced = [components[0]]; - for (var i = 1; i < components.length; i++) { - var component = components[i]; - if (!component) - continue; - if (component === ".") - continue; - if (component === "..") { - if (reduced.length > 1) { - if (reduced[reduced.length - 1] !== "..") { - reduced.pop(); - continue; - } - } - else if (reduced[0]) - continue; - } - reduced.push(component); - } - return reduced; - } - ts.reducePathComponents = reducePathComponents; - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getNormalizedPathComponents(path, currentDirectory) { - return reducePathComponents(getPathComponents(path, currentDirectory)); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - /** - * Formats a parsed path consisting of a root component (at index 0) and zero or more path - * segments (at indices > 0). - */ - function getPathFromPathComponents(pathComponents) { - if (pathComponents.length === 0) - return ""; - var root = pathComponents[0] && ts.ensureTrailingDirectorySeparator(pathComponents[0]); - return root + pathComponents.slice(1).join(ts.directorySeparator); + this.text = text; + this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } - ts.getPathFromPathComponents = getPathFromPathComponents; - function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { - return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + // eslint-disable-next-line prefer-const + ts.objectAllocator = { + getNodeConstructor: function () { return Node; }, + getTokenConstructor: function () { return Node; }, + getIdentifierConstructor: function () { return Node; }, + getSourceFileConstructor: function () { return Node; }, + getSymbolConstructor: function () { return Symbol; }, + getTypeConstructor: function () { return Type; }, + getSignatureConstructor: function () { return Signature; }, + getSourceMapSourceConstructor: function () { return SourceMapSource; }, + }; + function formatStringFromArgs(text, args, baseIndex) { + if (baseIndex === void 0) { baseIndex = 0; } + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } - ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; - function getPathWithoutRoot(pathComponents) { - if (pathComponents.length === 0) - return ""; - return pathComponents.slice(1).join(ts.directorySeparator); + ts.formatStringFromArgs = formatStringFromArgs; + function getLocaleSpecificMessage(message) { + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; } -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { - var fromComponents = ts.reducePathComponents(ts.getPathComponents(from)); - var toComponents = ts.reducePathComponents(ts.getPathComponents(to)); - var start; - for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { - var fromComponent = getCanonicalFileName(fromComponents[start]); - var toComponent = getCanonicalFileName(toComponents[start]); - var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; - if (!comparer(fromComponent, toComponent)) - break; + ts.getLocaleSpecificMessage = getLocaleSpecificMessage; + function createFileDiagnostic(file, start, length, message) { + ts.Debug.assertGreaterThanOrEqual(start, 0); + ts.Debug.assertGreaterThanOrEqual(length, 0); + if (file) { + ts.Debug.assertLessThanOrEqual(start, file.text.length); + ts.Debug.assertLessThanOrEqual(start + length, file.text.length); } - if (start === 0) { - return toComponents; + var text = getLocaleSpecificMessage(message); + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); } - var components = toComponents.slice(start); - var relative = []; - for (; start < fromComponents.length; start++) { - relative.push(".."); + return { + file: file, + start: start, + length: length, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; + } + ts.createFileDiagnostic = createFileDiagnostic; + function formatMessage(_dummy, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return __spreadArrays([""], relative, components); + return text; } - ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; - function getRelativePathFromFile(from, to, getCanonicalFileName) { - return ensurePathIsNonModuleName(getRelativePathFromDirectory(ts.getDirectoryPath(from), to, getCanonicalFileName)); + ts.formatMessage = formatMessage; + function createCompilerDiagnostic(message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 1) { + text = formatStringFromArgs(text, arguments, 1); + } + return { + file: undefined, + start: undefined, + length: undefined, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; } - ts.getRelativePathFromFile = getRelativePathFromFile; - function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { - ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); - var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; - var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; - var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); - return ts.getPathFromPathComponents(pathComponents); + ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText, + }; } - ts.getRelativePathFromDirectory = getRelativePathFromDirectory; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); - var firstComponent = pathComponents[0]; - if (isAbsolutePathAnUrl && ts.isRootedDiskPath(firstComponent)) { - var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; - pathComponents[0] = prefix + firstComponent; + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; + function chainDiagnosticMessages(details, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return ts.getPathFromPathComponents(pathComponents); + return { + messageText: text, + category: message.category, + code: message.code, + next: details === undefined || Array.isArray(details) ? details : [details] + }; } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - /** - * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed - * with `./` or `../`) so as not to be confused with an unprefixed module name. - */ - function ensurePathIsNonModuleName(path) { - return ts.getRootLength(path) === 0 && !ts.pathIsRelative(path) ? "./" + path : path; + ts.chainDiagnosticMessages = chainDiagnosticMessages; + function concatenateDiagnosticMessageChains(headChain, tailChain) { + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next[0]; + } + lastChain.next = [tailChain]; } - ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; - function getBaseFileName(path, extensions, ignoreCase) { - path = ts.normalizeSlashes(path); - // if the path provided is itself the root, then it has not file name. - var rootLength = ts.getRootLength(path); - if (rootLength === path.length) - return ""; - // return the trailing portion of the path starting after the last (non-terminal) directory - // separator but not including any trailing directory separator. - path = removeTrailingDirectorySeparator(path); - var name = path.slice(Math.max(ts.getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); - var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; - return extension ? name.slice(0, name.length - extension.length) : name; + ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; + function getDiagnosticFilePath(diagnostic) { + return diagnostic.file ? diagnostic.file.path : undefined; } - ts.getBaseFileName = getBaseFileName; - /** - * Combines paths. If a path is absolute, it replaces any previous path. - */ - function combinePaths(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + function compareDiagnosticsSkipRelatedInformation(d1, d2) { + return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || + ts.compareValues(d1.start, d2.start) || + ts.compareValues(d1.length, d2.length) || + ts.compareValues(d1.code, d2.code) || + compareMessageText(d1.messageText, d2.messageText) || + 0 /* EqualTo */; + } + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; } - if (path) - path = ts.normalizeSlashes(path); - for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { - var relativePath = paths_1[_a]; - if (!relativePath) - continue; - relativePath = ts.normalizeSlashes(relativePath); - if (!path || ts.getRootLength(relativePath) !== 0) { - path = relativePath; - } - else { - path = ensureTrailingDirectorySeparator(path) + relativePath; - } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; } - return path; + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; } - ts.combinePaths = combinePaths; - /** - * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any - * `.` and `..` path components are resolved. - */ - function resolvePath(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareMessageText(t1, t2) { + if (typeof t1 === "string" && typeof t2 === "string") { + return ts.compareStringsCaseSensitive(t1, t2); } - var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); - var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); - return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; - } - ts.resolvePath = resolvePath; - /** - * Determines whether a path has a trailing separator (`/` or `\\`). - */ - function hasTrailingDirectorySeparator(path) { - if (path.length === 0) - return false; - var ch = path.charCodeAt(path.length - 1); - return ch === 47 /* slash */ || ch === 92 /* backslash */; - } - ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; - function removeTrailingDirectorySeparator(path) { - if (hasTrailingDirectorySeparator(path)) { - return path.substr(0, path.length - 1); + else if (typeof t1 === "string") { + return -1 /* LessThan */; } - return path; - } - ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; - function ensureTrailingDirectorySeparator(path) { - if (!hasTrailingDirectorySeparator(path)) { - return path + ts.directorySeparator; + else if (typeof t2 === "string") { + return 1 /* GreaterThan */; } - return path; - } - ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; - // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; - function comparePathsWorker(a, b, componentComparer) { - if (a === b) + var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); + if (res) { + return res; + } + if (!t1.next && !t2.next) { return 0 /* EqualTo */; - if (a === undefined) + } + if (!t1.next) { return -1 /* LessThan */; - if (b === undefined) - return 1 /* GreaterThan */; - // NOTE: Performance optimization - shortcut if the root segments differ as there would be no - // need to perform path reduction. - var aRoot = a.substring(0, ts.getRootLength(a)); - var bRoot = b.substring(0, ts.getRootLength(b)); - var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { - return result; } - // NOTE: Performance optimization - shortcut if there are no relative path segments in - // the non-root portion of the path - var aRest = a.substring(aRoot.length); - var bRest = b.substring(bRoot.length); - if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { - return componentComparer(aRest, bRest); + if (!t2.next) { + return 1 /* GreaterThan */; } - // The path contains a relative path segment. Normalize the paths and perform a slower component - // by component comparison. - var aComponents = ts.reducePathComponents(ts.getPathComponents(a)); - var bComponents = ts.reducePathComponents(ts.getPathComponents(b)); - var sharedLength = Math.min(aComponents.length, bComponents.length); - for (var i = 1; i < sharedLength; i++) { - var result_1 = componentComparer(aComponents[i], bComponents[i]); - if (result_1 !== 0 /* EqualTo */) { - return result_1; + var len = Math.min(t1.next.length, t2.next.length); + for (var i = 0; i < len; i++) { + res = compareMessageText(t1.next[i], t2.next[i]); + if (res) { + return res; } } - return ts.compareValues(aComponents.length, bComponents.length); + if (t1.next.length < t2.next.length) { + return -1 /* LessThan */; + } + else if (t1.next.length > t2.next.length) { + return 1 /* GreaterThan */; + } + return 0 /* EqualTo */; } - /** - * Performs a case-sensitive comparison of two paths. - */ - function comparePathsCaseSensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0 /* ES3 */; } - ts.comparePathsCaseSensitive = comparePathsCaseSensitive; - /** - * Performs a case-insensitive comparison of two paths. - */ - function comparePathsCaseInsensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } - ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; - function comparePaths(a, b, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - a = combinePaths(currentDirectory, a); - b = combinePaths(currentDirectory, b); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; + ts.getEmitModuleKind = getEmitModuleKind; + function getEmitModuleResolutionKind(compilerOptions) { + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; } - return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + return moduleResolution; } - ts.comparePaths = comparePaths; - function containsPath(parent, child, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - parent = combinePaths(currentDirectory, parent); - child = combinePaths(currentDirectory, child); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; - } - if (parent === undefined || child === undefined) - return false; - if (parent === child) - return true; - var parentComponents = ts.reducePathComponents(ts.getPathComponents(parent)); - var childComponents = ts.reducePathComponents(ts.getPathComponents(child)); - if (childComponents.length < parentComponents.length) { - return false; - } - var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; - for (var i = 0; i < parentComponents.length; i++) { - var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; - if (!equalityComparer(parentComponents[i], childComponents[i])) { + ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function hasJsonModuleEmitEnabled(options) { + switch (getEmitModuleKind(options)) { + case ts.ModuleKind.CommonJS: + case ts.ModuleKind.AMD: + case ts.ModuleKind.ES2015: + case ts.ModuleKind.ESNext: + return true; + default: return false; + } + } + ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; + function getAreDeclarationMapsEnabled(options) { + return !!(getEmitDeclarations(options) && options.declarationMap); + } + ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; + function getAllowSyntheticDefaultImports(compilerOptions) { + var moduleKind = getEmitModuleKind(compilerOptions); + return compilerOptions.allowSyntheticDefaultImports !== undefined + ? compilerOptions.allowSyntheticDefaultImports + : compilerOptions.esModuleInterop || + moduleKind === ts.ModuleKind.System; + } + ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; + function getEmitDeclarations(compilerOptions) { + return !!(compilerOptions.declaration || compilerOptions.composite); + } + ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; + function getStrictOptionValue(compilerOptions, flag) { + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; + } + ts.getStrictOptionValue = getStrictOptionValue; + function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; + function compilerOptionsAffectEmit(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; + function getCompilerOptionValue(options, option) { + return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; + } + ts.getCompilerOptionValue = getCompilerOptionValue; + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42 /* asterisk */) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + // have already seen asterisk + return false; + } } } return true; } - ts.containsPath = containsPath; - function isDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { function stripLeadingDirectorySeparator(s) { - return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; } function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); @@ -16240,10 +17010,6 @@ var ts; return "\\" + match; } var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; - function hasExtension(fileName) { - return ts.stringContains(getBaseFileName(fileName), "."); - } - ts.hasExtension = hasExtension; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; var filesMatcher = { @@ -16319,7 +17085,7 @@ var ts; } // getNormalizedPathComponents includes the separator for the root component. // We need to remove to create our regex correctly. - components[0] = removeTrailingDirectorySeparator(components[0]); + components[0] = ts.removeTrailingDirectorySeparator(components[0]); if (isImplicitGlob(lastComponent)) { components.push("**", "*"); } @@ -16381,7 +17147,7 @@ var ts; function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = ts.normalizePath(path); currentDirectory = ts.normalizePath(currentDirectory); - var absolutePath = combinePaths(currentDirectory, path); + var absolutePath = ts.combinePaths(currentDirectory, path); return { includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), @@ -16410,7 +17176,7 @@ var ts; var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; - visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth); + visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); } return ts.flatten(results); function visitDirectory(path, absolutePath, depth) { @@ -16420,8 +17186,8 @@ var ts; visited.set(canonicalPath, true); var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; var _loop_1 = function (current) { - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if (extensions && !ts.fileExtensionIsOneOf(name, extensions)) return "continue"; if (excludeRegex && excludeRegex.test(absoluteName)) @@ -16448,8 +17214,8 @@ var ts; } for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) { var current = _d[_c]; - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { visitDirectory(name, absoluteName, depth); @@ -16471,14 +17237,14 @@ var ts; var include = includes_1[_i]; // We also need to check the relative paths by converting them to absolute and normalizing // in case they escape the base path (e.g "..\somedirectory") - var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(combinePaths(path, include)); + var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include)); // Append the literal and canonical candidate base paths. includeBasePaths.push(getIncludeBasePath(absolute)); } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames)); var _loop_2 = function (includeBasePath) { - if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; @@ -16495,9 +17261,9 @@ var ts; var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes); if (wildcardOffset < 0) { // No "*" or "?" in the path - return !hasExtension(absolute) + return !ts.hasExtension(absolute) ? absolute - : removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); + : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); } return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); } @@ -16662,14 +17428,9 @@ var ts; } ts.removeExtension = removeExtension; function changeExtension(path, newExtension) { - return changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); + return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; - function changeAnyExtension(path, ext, extensions, ignoreCase) { - var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); - return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; - } - ts.changeAnyExtension = changeAnyExtension; function tryParsePattern(pattern) { // This should be verified outside of here and a proper error thrown. ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern)); @@ -16712,36 +17473,6 @@ var ts; return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); }); } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; - function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { - if (typeof extensions === "string") - extensions = [extensions]; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - if (!ts.startsWith(extension, ".")) - extension = "." + extension; - if (path.length >= extension.length && path.charAt(path.length - extension.length) === ".") { - var pathExtension = path.slice(path.length - extension.length); - if (stringEqualityComparer(pathExtension, extension)) { - return pathExtension; - } - } - } - return ""; - } - function getAnyExtensionFromPath(path, extensions, ignoreCase) { - // Retrieves any string from the final "." onwards from a base file name. - // Unlike extensionFromPath, which throws an exception on unrecognized extensions. - if (extensions) { - return getAnyExtensionFromPathWorker(path, extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); - } - var baseFileName = getBaseFileName(path); - var extensionIndex = baseFileName.lastIndexOf("."); - if (extensionIndex >= 0) { - return baseFileName.substring(extensionIndex); - } - return ""; - } - ts.getAnyExtensionFromPath = getAnyExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } @@ -16871,14 +17602,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16982,17 +17716,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -17041,19 +17773,19 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17061,9 +17793,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -17071,7 +17803,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17079,51 +17811,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -17135,345 +17867,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 303 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 301 /* JSDocTag */: - case 304 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17527,7 +18264,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17556,14 +18293,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17694,18 +18429,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17714,7 +18449,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17730,6 +18465,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17755,10 +18493,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17786,7 +18524,7 @@ var ts; function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17851,7 +18589,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17872,16 +18610,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17922,40 +18660,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -18070,20 +18808,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -18171,7 +18909,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -18201,7 +18939,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -18213,7 +18951,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -18234,9 +18972,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -18245,7 +18983,12 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var isReservedWord = scanner.isReservedWord(); + var msgArg = scanner.getTokenText(); + var defaultMessage = isReservedWord ? + ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : + ts.Diagnostics.Identifier_expected; + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -18276,7 +19019,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18297,20 +19040,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18323,16 +19066,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18352,7 +19095,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18368,7 +19111,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18438,7 +19181,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18455,8 +19198,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18486,14 +19229,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18512,9 +19255,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18534,7 +19277,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18609,7 +19352,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18710,20 +19453,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18732,8 +19475,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18742,58 +19485,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18814,7 +19557,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18881,7 +19624,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18919,6 +19662,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18939,7 +19685,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18950,7 +19696,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18981,13 +19727,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18999,7 +19745,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -19059,24 +19805,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -19084,20 +19830,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -19105,7 +19851,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -19126,43 +19872,43 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); if (moduleSpecifier) { - var moduleTag = createNode(297 /* JSDocNamepathType */, moduleSpecifier.pos); + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); terminate: while (true) { switch (token()) { case 19 /* CloseBraceToken */: @@ -19181,25 +19927,25 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -19218,18 +19964,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -19238,12 +19984,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -19265,7 +20011,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -19287,16 +20033,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -19343,10 +20089,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19390,21 +20136,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 56 /* QuestionToken */) { + if (token() !== 57 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19412,17 +20158,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -19434,7 +20180,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19456,20 +20202,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19480,7 +20226,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19488,14 +20234,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19512,37 +20258,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19553,23 +20299,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19577,9 +20323,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19587,14 +20333,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19607,23 +20353,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19633,50 +20379,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19684,51 +20434,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19746,27 +20499,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19785,16 +20538,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19802,11 +20555,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19827,13 +20580,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19843,7 +20596,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19865,8 +20618,8 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19875,7 +20628,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19887,7 +20640,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19898,45 +20652,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19945,14 +20706,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19963,18 +20724,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -19993,9 +20754,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -20018,7 +20779,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -20063,7 +20824,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -20079,7 +20840,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -20108,15 +20869,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -20127,20 +20888,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -20165,8 +20926,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -20176,10 +20937,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -20189,12 +20950,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -20208,8 +20969,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -20233,30 +20994,30 @@ var ts; // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -20265,7 +21026,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -20275,11 +21036,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -20312,7 +21073,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -20325,23 +21086,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20351,7 +21112,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20364,7 +21125,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20375,8 +21136,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20401,20 +21162,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20422,7 +21183,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20451,16 +21212,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20481,51 +21242,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20535,7 +21296,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20559,7 +21320,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20576,10 +21337,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -20604,23 +21365,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20643,16 +21404,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20675,21 +21436,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20730,14 +21491,14 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20745,21 +21506,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a - // CallExpression. As such, we need to consume the rest of it here to be complete. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20811,11 +21573,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20827,7 +21589,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20836,8 +21598,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20846,15 +21608,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20865,11 +21627,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20899,7 +21661,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20907,7 +21669,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20928,16 +21690,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20945,23 +21707,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20975,10 +21737,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20986,7 +21748,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -21012,9 +21774,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -21027,7 +21789,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -21035,78 +21797,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -21115,48 +21909,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -21165,12 +21981,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -21187,21 +22003,23 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* ColonToken */: // foo: case 26 /* SemicolonToken */: // foo; - case 56 /* QuestionToken */: // foo? - case 33 /* EqualsEqualsToken */: // foo == - case 35 /* EqualsEqualsEqualsToken */: // foo === - case 34 /* ExclamationEqualsToken */: // foo != - case 36 /* ExclamationEqualsEqualsToken */: // foo !== - case 54 /* AmpersandAmpersandToken */: // foo && - case 55 /* BarBarToken */: // foo || - case 51 /* CaretToken */: // foo ^ - case 49 /* AmpersandToken */: // foo & - case 50 /* BarToken */: // foo | + case 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // these cases can't legally follow a type arg list. However, they're not legal @@ -21213,6 +22031,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -21225,11 +22044,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -21237,7 +22056,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -21245,14 +22064,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -21263,28 +22082,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21296,25 +22115,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -21322,24 +22141,24 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21358,10 +22177,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21369,7 +22188,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21381,26 +22200,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21410,7 +22229,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21443,25 +22262,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21473,8 +22292,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21483,12 +22302,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21496,23 +22315,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21530,7 +22349,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21538,8 +22357,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21547,39 +22366,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21594,29 +22413,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21629,8 +22448,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21640,13 +22459,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21658,11 +22477,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21671,12 +22490,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -21699,41 +22518,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21746,50 +22565,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -21812,63 +22632,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21877,52 +22698,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21931,7 +22771,7 @@ var ts; if (node.decorators || node.modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21954,24 +22794,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21979,14 +22819,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -22008,10 +22848,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22021,14 +22861,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -22044,7 +22884,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -22059,25 +22899,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -22089,25 +22929,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22122,17 +22962,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -22140,13 +22980,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -22163,7 +23003,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -22179,18 +23019,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -22208,10 +23048,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -22231,7 +23071,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -22250,7 +23090,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -22261,20 +23101,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -22288,27 +23128,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22334,7 +23184,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -22346,33 +23196,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22380,11 +23229,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22394,14 +23243,14 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22413,7 +23262,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22424,7 +23273,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22436,11 +23285,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22456,15 +23305,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22472,52 +23321,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22529,7 +23378,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22539,7 +23388,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22549,8 +23398,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22572,9 +23421,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22587,14 +23436,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22608,9 +23457,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22619,24 +23468,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22644,12 +23493,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22664,15 +23513,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22680,7 +23527,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22731,9 +23578,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22743,8 +23590,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22755,11 +23602,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22824,7 +23671,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22843,7 +23690,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -22894,7 +23741,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(298 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22930,14 +23777,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22945,7 +23792,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -23029,7 +23876,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -23054,7 +23901,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -23062,7 +23909,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -23071,7 +23918,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -23094,7 +23941,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(301 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -23122,15 +23969,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -23139,9 +23986,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -23157,8 +24004,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(313 /* JSDocPropertyTag */, start) : - createNode(307 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -23175,20 +24022,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -23200,7 +24047,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(308 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -23209,13 +24056,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(310 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(303 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -23237,20 +24084,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -23269,14 +24116,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(302 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -23288,7 +24135,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -23296,19 +24143,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(304 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(309 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(306 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -23317,7 +24164,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(312 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -23331,9 +24178,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 310 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -23346,7 +24193,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23365,7 +24212,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23379,22 +24226,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(305 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(300 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 308 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23436,10 +24283,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23452,13 +24299,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23467,7 +24314,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23503,13 +24350,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(311 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23542,13 +24389,13 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - if (token() !== 73 /* Identifier */) { + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { result.originalKeywordKind = token(); } result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -23677,7 +24524,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -24243,10 +25090,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24396,6 +25243,14 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", @@ -24460,6 +25315,15 @@ var ts; isCommandLineOnly: true, description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, + { + name: "listFilesOnly", + type: "boolean", + category: ts.Diagnostics.Command_line_Options, + affectsSemanticDiagnostics: true, + affectsEmit: true, + isCommandLineOnly: true, + description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing + }, // Basic { name: "target", @@ -25016,6 +25880,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -25111,6 +25981,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -25208,7 +26085,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25438,6 +26316,7 @@ var ts; return { buildOptions: buildOptions, projects: projects, errors: errors }; } ts.parseBuildCommand = parseBuildCommand; + /* @internal */ function getDiagnosticText(_message) { var _args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -25446,104 +26325,7 @@ var ts; var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } - /* @internal */ - function printVersion() { - ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); - } - ts.printVersion = printVersion; - /* @internal */ - function printHelp(optionsList, syntaxPrefix) { - if (syntaxPrefix === void 0) { syntaxPrefix = ""; } - var output = []; - // We want to align our "syntax" and "examples" commands to a certain margin. - var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; - var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; - var marginLength = Math.max(syntaxLength, examplesLength); - // Build up the syntactic skeleton. - var syntax = makePadding(marginLength - syntaxLength); - syntax += "tsc " + syntaxPrefix + "[" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + "...]"; - output.push(getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax)); - output.push(ts.sys.newLine + ts.sys.newLine); - // Build up the list of examples. - var padding = makePadding(marginLength); - output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine); - output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine); - output.push(padding + "tsc @args.txt" + ts.sys.newLine); - output.push(padding + "tsc --build tsconfig.json" + ts.sys.newLine); - output.push(ts.sys.newLine); - output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); - // We want our descriptions to align at the same column in our output, - // so we keep track of the longest option usage string. - marginLength = 0; - var usageColumn = []; // Things like "-d, --declaration" go in here. - var descriptionColumn = []; - var optionsDescriptionMap = ts.createMap(); // Map between option.description and list of option.type if it is a kind - for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) { - var option = optionsList_1[_i]; - // If an option lacks a description, - // it is not officially supported. - if (!option.description) { - continue; - } - var usageText_1 = " "; - if (option.shortName) { - usageText_1 += "-" + option.shortName; - usageText_1 += getParamType(option); - usageText_1 += ", "; - } - usageText_1 += "--" + option.name; - usageText_1 += getParamType(option); - usageColumn.push(usageText_1); - var description = void 0; - if (option.name === "lib") { - description = getDiagnosticText(option.description); - var element = option.element; - var typeMap = element.type; - optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; })); - } - else { - description = getDiagnosticText(option.description); - } - descriptionColumn.push(description); - // Set the new margin for the description column if necessary. - marginLength = Math.max(usageText_1.length, marginLength); - } - // Special case that can't fit in the loop. - var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; - usageColumn.push(usageText); - descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); - marginLength = Math.max(usageText.length, marginLength); - // Print out each row, aligning all the descriptions on the same column. - for (var i = 0; i < usageColumn.length; i++) { - var usage = usageColumn[i]; - var description = descriptionColumn[i]; - var kindsList = optionsDescriptionMap.get(description); - output.push(usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine); - if (kindsList) { - output.push(makePadding(marginLength + 4)); - for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) { - var kind = kindsList_1[_a]; - output.push(kind + " "); - } - output.push(ts.sys.newLine); - } - } - for (var _b = 0, output_1 = output; _b < output_1.length; _b++) { - var line = output_1[_b]; - ts.sys.write(line); - } - return; - function getParamType(option) { - if (option.paramType !== undefined) { - return " " + getDiagnosticText(option.paramType); - } - return ""; - } - function makePadding(paddingLength) { - return Array(paddingLength + 1).join(" "); - } - } - ts.printHelp = printHelp; + ts.getDiagnosticText = getDiagnosticText; /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ @@ -25708,7 +26490,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25764,15 +26546,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25790,13 +26572,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25813,7 +26595,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25862,7 +26644,7 @@ var ts; /** @internal */ function convertToTSConfig(configParseResult, configFileName, host) { var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); + var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs, host)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; @@ -25883,12 +26665,12 @@ var ts; return undefined; return specs; } - function matchesSpecs(path, includeSpecs, excludeSpecs) { + function matchesSpecs(path, includeSpecs, excludeSpecs, host) { if (!includeSpecs) return function (_) { return true; }; - var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); - var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); - var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames); if (includeRe) { if (excludeRe) { return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); }; @@ -26065,6 +26847,35 @@ var ts; } } ts.generateTSConfig = generateTSConfig; + /* @internal */ + function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) { + var result = {}; + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name in options) { + if (ts.hasProperty(options, name)) { + result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); + } + } + if (result.configFilePath) { + result.configFilePath = toAbsolutePath(result.configFilePath); + } + return result; + } + ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; + function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { + if (option) { + if (option.type === "list") { + var values = value; + if (option.element.isFilePath && values.length) { + return values.map(toAbsolutePath); + } + } + else if (option.isFilePath) { + return toAbsolutePath(value); + } + } + return value; + } /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -26095,8 +26906,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -26516,7 +27326,7 @@ var ts; } function normalizeNonListOptionValue(option, basePath, value) { if (option.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + value = ts.getNormalizedAbsolutePath(value, basePath); if (value === "") { value = "."; } @@ -26951,8 +27761,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -27211,7 +28022,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27675,7 +28486,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -28155,35 +28966,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -28202,9 +29045,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -28213,6 +29056,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -28237,7 +29110,11 @@ var ts; ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; })(ContainerFlags || (ContainerFlags = {})); - var flowNodeCreated = ts.identity; + function initFlowNode(node) { + ts.Debug.attachFlowNodeDebugInfo(node); + return node; + } + var flowNodeCreated = initFlowNode; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -28277,7 +29154,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -28301,6 +29178,9 @@ var ts; symbolCount = 0; skipTransformFlagAggregation = file.isDeclarationFile; Symbol = ts.objectAllocator.getSymbolConstructor(); + // Attach debugging information if necessary + ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); + ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { bind(file); file.symbolCount = symbolCount; @@ -28345,7 +29225,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -28372,7 +29252,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -28381,7 +29261,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28393,39 +29273,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 295 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 298 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -28525,7 +29408,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28560,7 +29443,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28584,7 +29467,7 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } @@ -28627,7 +29510,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28653,34 +29536,35 @@ var ts; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isIIFE) { - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; hasExplicitReturn = false; - flowNodeCreated = ts.identity; + flowNodeCreated = initFlowNode; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28697,7 +29581,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28724,8 +29608,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28757,80 +29641,90 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28841,30 +29735,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && - isNarrowableReference(expr.expression); + ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || + ts.isOptionalChain(expr); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -28875,7 +29768,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28889,17 +29782,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28908,11 +29801,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28921,20 +29814,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28949,31 +29836,35 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if ((expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -28988,47 +29879,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -29056,7 +29952,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -29088,15 +29984,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -29118,7 +30014,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -29138,7 +30034,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -29166,7 +30062,7 @@ var ts; // as possible antecedents of the start of the `catch` or `finally` blocks. // Don't bother intercepting the call if there's no finally or catch block that needs the information if (node.catchClause || node.finallyBlock) { - flowNodeCreated = function (node) { return (tryPriors.push(node), node); }; + flowNodeCreated = function (node) { return (tryPriors.push(node), initFlowNode(node)); }; } bind(node.tryBlock); flowNodeCreated = oldFlowNodeCreated; @@ -29230,7 +30126,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = initFlowNode({ flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }); addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -29248,7 +30144,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -29266,9 +30162,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all - // case clauses have unreachable end points (e.g. they all return). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -29296,7 +30193,7 @@ var ts; bind(clause); fallthroughFlow = currentFlow; if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { - errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + clause.fallthroughFlowNode = currentFlow; } } clauses.transformFlags = subtreeTransformFlags | 536870912 /* HasComputedFlags */; @@ -29322,6 +30219,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -29333,14 +30241,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -29351,10 +30259,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -29362,16 +30270,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29379,7 +30287,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29390,7 +30298,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29400,20 +30308,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29427,7 +30335,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29438,7 +30346,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29477,27 +30385,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.kind !== 306 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // an immediately invoked function expression (IIFE). Initialize the flowNode property to - // the current control flow (which includes evaluation of the IIFE arguments). - var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29506,54 +30489,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -29586,45 +30569,45 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 300 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -29651,11 +30634,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29725,7 +30708,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29737,7 +30720,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29769,10 +30752,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29800,7 +30783,7 @@ var ts; var host = ts.getJSDocHost(typeAlias); container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -29808,12 +30791,17 @@ var ts; // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); if (isTopLevel) { - bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; })); + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - container = file; + if (!ts.isExternalOrCommonJsModule(file)) { + container = undefined; + } + else { + container = file; + } break; case 4 /* ThisProperty */: container = declName.parent.expression; @@ -29827,11 +30815,13 @@ var ts; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + if (container) { + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -29849,11 +30839,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */) && - !(node.flags & 2097152 /* JSDoc */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29887,7 +30877,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -29898,7 +30888,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29939,8 +30929,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -29966,7 +30956,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -30035,7 +31025,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -30075,8 +31065,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -30097,7 +31087,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -30110,27 +31100,28 @@ var ts; break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -30158,76 +31149,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 307 /* JSDocClassTag */: + return bindJSDocClassTag(node); + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -30246,65 +31239,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 307 /* JSDocParameterTag */: - if (node.parent.kind === 300 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 299 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 313 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30412,8 +31405,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30423,7 +31415,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30442,41 +31434,53 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + setValueDeclaration(symbol, node); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } - if (constructorSymbol) { + if (constructorSymbol && constructorSymbol.valueDeclaration) { // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -30489,11 +31493,21 @@ var ts; ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30506,11 +31520,14 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + if (namespaceSymbol) { + // Ensure the namespace symbol becomes class-like + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } /** @@ -30526,32 +31543,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30560,9 +31583,9 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; @@ -30579,6 +31602,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30589,20 +31615,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30631,7 +31684,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30648,7 +31701,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30660,7 +31713,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30671,7 +31724,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { + if (node.kind === 244 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -30734,10 +31787,10 @@ var ts; } } function bindParameter(node) { - if (node.kind === 307 /* JSDocParameterTag */ && container.kind !== 300 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30756,9 +31809,9 @@ var ts; } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); @@ -30771,9 +31824,9 @@ var ts; } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30784,8 +31837,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30811,7 +31864,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -30839,11 +31892,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30857,7 +31910,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30887,12 +31940,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30904,7 +31957,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30941,58 +31994,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -31003,6 +32056,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -31014,7 +32070,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31037,17 +32093,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -31090,8 +32149,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31131,11 +32190,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -31326,9 +32385,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31338,9 +32400,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31428,43 +32493,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31472,11 +32537,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31493,103 +32558,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31602,26 +32667,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31639,67 +32704,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31718,7 +32783,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31791,7 +32856,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31874,7 +32939,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -32028,6 +33093,7 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 7] = "ResolvedTypeArguments"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var CheckMode; (function (CheckMode) { @@ -32038,11 +33104,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); var AccessFlags; (function (AccessFlags) { AccessFlags[AccessFlags["None"] = 0] = "None"; @@ -32145,11 +33206,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -32231,8 +33290,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -32298,9 +33360,9 @@ var ts; }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (nodeIn) { + getContextualType: function (nodeIn, contextFlags) { var node = ts.getParseTreeNode(nodeIn, ts.isExpression); - return node ? getContextualType(node) : undefined; + return node ? getContextualType(node, contextFlags) : undefined; }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); @@ -32349,7 +33411,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -32365,6 +33427,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -32383,6 +33448,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -32411,7 +33477,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -32475,6 +33541,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -32504,6 +33571,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -32527,11 +33595,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var iterationTypesCache = ts.createMap(); // cache for common IterationTypes instances var noIterationTypes = { @@ -32624,6 +33692,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32636,13 +33707,13 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -32678,10 +33749,10 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { - return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; + return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText; } } } @@ -32691,7 +33762,7 @@ var ts; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); if (_jsxFactoryEntity) { - _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).escapedText; + _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText; } } else if (compilerOptions.reactNamespace) { @@ -32735,7 +33806,7 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32820,7 +33891,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32949,7 +34024,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32959,7 +34034,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -33008,7 +34083,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -33052,7 +34127,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -33066,17 +34141,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -33099,22 +34174,22 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -33135,16 +34210,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -33165,14 +34240,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -33218,12 +34293,12 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 298 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -33240,13 +34315,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -33261,14 +34336,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -33292,7 +34367,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -33306,12 +34381,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -33328,9 +34403,9 @@ var ts; } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! @@ -33349,7 +34424,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -33357,9 +34432,9 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -33377,9 +34452,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -33387,24 +34462,24 @@ var ts; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -33417,7 +34492,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -33426,7 +34501,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33441,25 +34516,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33479,7 +34554,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33552,7 +34627,7 @@ var ts; } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); @@ -33575,10 +34650,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33591,12 +34666,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33608,7 +34683,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 154 /* TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -33663,10 +34738,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33754,11 +34829,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 244 /* EnumDeclaration */); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33790,13 +34869,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33806,7 +34885,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33871,7 +34950,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33883,7 +34967,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33937,9 +35021,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33974,7 +35059,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -33994,34 +35084,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -34101,17 +35213,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 249 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -34127,17 +35239,17 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { - var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); + if (name.kind === 75 /* Identifier */) { + var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); if (!symbol) { return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -34189,7 +35301,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -34228,6 +35340,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -34239,9 +35365,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -34272,7 +35395,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -34343,7 +35466,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -34352,9 +35475,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -34362,15 +35489,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34444,7 +35572,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34581,7 +35709,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34590,7 +35719,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34598,7 +35738,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34606,20 +35746,29 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { @@ -34632,7 +35781,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34710,25 +35859,55 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals + // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would + // trigger resolving late-bound names, which we may already be in the process of doing while we're here! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } @@ -34765,12 +35944,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34787,7 +35966,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34823,7 +36002,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34838,10 +36017,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34958,14 +36137,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -35008,14 +36187,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -35024,7 +36203,7 @@ var ts; // Type Reference or TypeAlias entity = Identifier meaning = 788968 /* Type */; } - var firstIdentifier = getFirstIdentifier(entityName); + var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { @@ -35064,15 +36243,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -35095,14 +36274,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -35133,6 +36315,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -35143,7 +36328,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -35171,26 +36357,26 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -35210,7 +36396,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -35231,31 +36417,31 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -35269,10 +36455,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -35280,6 +36472,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -35290,12 +36483,6 @@ var ts; ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -35303,7 +36490,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -35367,17 +36554,14 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 111551 /* Value */); @@ -35394,24 +36578,7 @@ var ts; } } else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -35424,15 +36591,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35445,12 +36642,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35463,7 +36660,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35471,7 +36668,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35485,12 +36682,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35585,11 +36782,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35636,7 +36833,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35647,25 +36844,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35676,20 +36877,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35730,7 +36941,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35743,7 +36954,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35754,7 +36965,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35762,23 +36973,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -35798,9 +37012,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 307 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35810,15 +37024,14 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35828,22 +37041,22 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); + var firstIdentifier = ts.getFirstIdentifier(accessExpression); var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); @@ -35851,6 +37064,9 @@ var ts; } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35883,6 +37099,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35963,7 +37186,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -36055,16 +37278,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -36097,6 +37336,9 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -36142,9 +37384,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -36153,6 +37392,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -36180,12 +37422,1104 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + ts.forEachEntry(symbolTable, function (symbol, name) { + var baseName = ts.unescapeLeadingUnderscores(name); + void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` + }); + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && + symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && + symbol.escapedName !== "export=" /* ExportEquals */; + var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); + if (symbol.flags & 16 /* Function */ || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */) + && !isConstMergedWithNSPrintableAsSignatureMerge) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + if (ts.some(symbol.declarations, ts.isParameterDeclaration)) + return; + ts.Debug.assertDefined(deferredPrivates); + getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol); // Call to cache unique name for symbol + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function getNamespaceMembersForSerialization(symbol) { + return !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + } + function isTypeOnlyNamespace(symbol) { + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = getNamespaceMembersForSerialization(symbol); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s); + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + includePrivateSymbol(target || s); + var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName; + return ts.createExportSpecifier(name === targetName ? undefined : targetName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), + // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned + // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag + // In such cases, the `target` refers to the module itself already + ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + case 193 /* PropertyAccessExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + // If the target resolves and resolves to a thing defined in this file, emit as an alias, otherwise emit as a const + if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = ts.getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (symbol) { + input = getNameCandidateWorker(symbol, input); + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getNameCandidateWorker(symbol, localName) { + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; + } + if (localName === "default" /* Default */) { + localName = "_default"; + } + else if (localName === "export=" /* ExportEquals */) { + localName = "_exports"; + } + localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); + return localName; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + localName = getNameCandidateWorker(symbol, localName); + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -36230,8 +38564,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -36239,11 +38573,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -36281,9 +38615,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -36296,17 +38630,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -36323,28 +38660,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -36352,53 +38689,54 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -36407,14 +38745,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { + else if (node.parent.kind === 261 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -36431,9 +38772,11 @@ var ts; if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); + var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36493,6 +38836,8 @@ var ts; return !!target.immediateBaseConstraint; case 6 /* JSDocTypeReference */: return !!getSymbolLinks(target).resolvedJSDocType; + case 7 /* ResolvedTypeArguments */: + return !!target.resolvedTypeArguments; } return ts.Debug.assertNever(propertyName); } @@ -36508,12 +38853,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36546,7 +38891,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36598,7 +38943,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36613,23 +38958,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36647,11 +38992,11 @@ var ts; return parentType; } // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36719,30 +39064,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -36761,8 +39106,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36775,11 +39120,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36846,12 +39191,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36869,6 +39216,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36894,9 +39244,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -36989,9 +39339,9 @@ var ts; var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -37066,7 +39416,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -37089,7 +39439,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -37128,7 +39478,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -37184,22 +39534,26 @@ var ts; // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -37240,12 +39594,15 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -37254,7 +39611,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -37281,33 +39638,43 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { @@ -37317,25 +39684,21 @@ var ts; } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + } } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -37343,19 +39706,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -37367,8 +39721,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -37435,7 +39790,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37516,40 +39871,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: - case 305 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37557,7 +39922,8 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); + ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37566,9 +39932,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37587,19 +39954,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37692,24 +40059,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37747,14 +40108,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37762,7 +40130,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37798,8 +40166,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37820,9 +40188,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37838,7 +40212,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37880,10 +40254,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37891,18 +40265,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37916,10 +40291,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37943,7 +40318,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -38015,23 +40390,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -38057,7 +40432,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -38073,14 +40448,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -38135,9 +40510,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -38231,7 +40609,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -38247,9 +40626,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -38290,6 +40669,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -38300,7 +40694,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -38330,7 +40724,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -38393,12 +40787,12 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } - function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { - var sig = new Signature(checker); + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) { + var sig = new Signature(checker, flags); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; @@ -38406,15 +40800,13 @@ var ts; sig.resolvedReturnType = resolvedReturnType; sig.resolvedTypePredicate = resolvedTypePredicate; sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasLiteralTypes = hasLiteralTypes; sig.target = undefined; sig.mapper = undefined; return sig; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; return result; @@ -38426,13 +40818,22 @@ var ts; result.mapper = undefined; return result; } + function getOptionalCallSignature(signature) { + return signatureIsOptionalCall(signature) ? signature : + (signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature))); + } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.flags |= 4 /* IsOptionalCall */; + return result; + } function getExpandedParameters(sig) { - if (sig.hasRestParameter) { + if (signatureHasRestParameter(sig)) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38452,7 +40853,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38549,7 +40950,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38561,8 +40962,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38616,11 +41017,9 @@ var ts; var params = combineUnionParameters(left, right); var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter); var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); - var hasRestParam = left.hasRestParameter || right.hasRestParameter; - var hasLiteralTypes = left.hasLiteralTypes || right.hasLiteralTypes; var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, hasRestParam, hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 3 /* PropagatingFlags */); result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); return result; } @@ -38687,7 +41086,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38710,19 +41109,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38730,7 +41129,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38786,14 +41185,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38936,8 +41339,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38961,8 +41364,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -39178,11 +41581,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; if (t.flags & 63176704 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). @@ -39192,6 +41595,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -39204,8 +41610,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -39291,8 +41697,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39640,10 +42046,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39677,13 +42083,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; - } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39729,7 +42132,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var hasLiteralTypes = false; + var flags = 0 /* None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -39759,8 +42162,8 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { - hasLiteralTypes = true; + if (type && type.kind === 186 /* LiteralType */) { + flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -39773,22 +42176,24 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); - var hasRestLikeParameter = ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters); + if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { + flags |= 1 /* HasRestParameter */; + } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, - /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, hasRestLikeParameter, hasLiteralTypes); + /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); } return links.resolvedSignature; } @@ -39840,13 +42245,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39889,9 +42294,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39920,13 +42322,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39936,8 +42335,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signatureIsOptionalCall(signature)) { + type = addOptionalTypeMarker(type); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39962,7 +42363,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39972,12 +42373,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39992,7 +42393,7 @@ var ts; return tryGetRestTypeOfSignature(signature) || anyType; } function tryGetRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType; return restType && getIndexTypeOfType(restType, 1 /* Number */); @@ -40067,7 +42468,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -40081,7 +42482,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -40115,13 +42516,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -40146,7 +42547,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -40170,7 +42571,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -40203,8 +42604,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -40219,7 +42620,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -40228,16 +42629,50 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + return type; + } + function getTypeArguments(type) { + var _a, _b; + if (!type.resolvedTypeArguments) { + if (!pushTypeResolution(type, 7 /* ResolvedTypeArguments */)) { + return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; + } + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + if (popTypeResolution()) { + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + else { + type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray; + error(type.node || currentNode, type.target.symbol + ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves + : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol)); + } + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -40247,13 +42682,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -40261,10 +42696,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -40285,27 +42723,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -40323,13 +42761,15 @@ var ts; return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -40338,56 +42778,44 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSDocValueReference(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value, but resolve it as a type anyway. + * Note: If the value is imported from commonjs, it should really be an alias, + * but this function's special-case code fakes alias resolution as well. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + function getTypeFromJSDocValueReference(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType; + if (symbol.valueDeclaration) { + var decl = ts.getRootDeclaration(symbol.valueDeclaration); + var isRequireAlias = false; + if (ts.isVariableDeclaration(decl) && decl.initializer) { + var expr = decl.initializer; + // skip past entity names, eg `require("x").a.b.c` + while (ts.isPropertyAccessExpression(expr)) { + expr = expr.expression; } + isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol; } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); + var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol; + if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) { + typeType = getTypeReferenceType(node, valueType.symbol); } } + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } function getSubstitutionType(typeVariable, substitute) { if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === typeVariable) { @@ -40405,7 +42833,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -40414,9 +42842,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 298 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40427,7 +42855,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40464,10 +42892,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40479,7 +42907,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40537,9 +42965,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40658,15 +43086,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40703,7 +43171,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40737,27 +43205,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; - var elementTypes = ts.map(node.elementTypes, function (n) { - var type = getTypeFromTypeNode(n); - return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40806,8 +43260,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40836,8 +43290,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40922,10 +43376,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40944,14 +43398,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -41018,8 +43468,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -41294,21 +43744,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - // tslint:disable no-unnecessary-type-assertion - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -41344,7 +43795,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -41355,13 +43806,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41492,13 +43943,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41623,7 +44071,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41835,7 +44283,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41858,11 +44306,11 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { var errorMessage = targetMeaning === 111551 /* Value */ @@ -41874,16 +44322,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; if (meaning === 111551 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41907,7 +44355,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 137 /* ReadonlyKeyword */) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -42096,12 +44548,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -42114,89 +44580,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -42285,20 +44751,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -42318,7 +44771,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 3 /* PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -42352,17 +44805,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -42378,7 +44831,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -42391,13 +44844,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -42405,9 +44859,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 184 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -42416,7 +44870,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -42425,12 +44879,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42484,7 +44938,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42580,15 +45034,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42652,35 +45109,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42700,7 +45157,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -42712,7 +45169,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42815,23 +45272,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -43003,7 +45460,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -43012,9 +45469,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -43156,11 +45613,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -43195,20 +45652,20 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` */ function isAnySignature(s) { return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 && - s.hasRestParameter && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && + signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && isTypeAny(getReturnTypeOfSignature(s)); } /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -43232,8 +45689,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -43266,11 +45723,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is - compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -43281,15 +45738,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol)) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol)) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43310,6 +45769,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -43322,7 +45784,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -43331,7 +45793,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -43377,12 +45841,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -43393,7 +45857,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43470,9 +45934,9 @@ var ts; return true; } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, relation)); + var related = relation.get(getRelationKey(source, target, /*isIntersectionConstituent*/ false, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43504,9 +45968,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43549,8 +46018,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43563,6 +46155,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43581,8 +46175,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43704,14 +46298,14 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); var isIntersectionConstituent = !!isApparentIntersectionConstituent; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { @@ -43749,15 +46343,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -43767,21 +46361,30 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43801,6 +46404,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43837,7 +46441,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43852,6 +46456,11 @@ var ts; // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43880,9 +46489,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -44018,14 +46627,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { + function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); if (related) { return related; } @@ -44104,17 +46713,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -44124,25 +46722,25 @@ var ts; if (overflow) { return 0 /* False */; } - var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var id = getRelationKey(source, target, isIntersectionConstituent, relation); + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -44173,14 +46771,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -44188,7 +46798,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -44228,7 +46838,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. @@ -44318,7 +46928,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44329,7 +46939,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44338,25 +46948,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44365,13 +46975,23 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44380,14 +47000,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44401,7 +47021,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44420,7 +47040,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -44447,7 +47067,7 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); @@ -44462,7 +47082,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44493,7 +47113,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44521,7 +47141,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44597,11 +47217,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44617,8 +47237,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44631,9 +47251,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -44758,7 +47378,7 @@ var ts; var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44798,8 +47418,8 @@ var ts; if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44809,8 +47429,8 @@ var ts; else { reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44822,7 +47442,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44847,8 +47467,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44862,10 +47483,12 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { @@ -44930,14 +47553,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44951,7 +47575,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44960,10 +47584,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44976,11 +47600,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -45046,7 +47682,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -45178,7 +47814,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -45210,7 +47846,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -45236,8 +47872,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -45246,7 +47885,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -45269,17 +47908,18 @@ var ts; * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. * For other cases, the types ids are used. */ - function getRelationKey(source, target, relation) { + function getRelationKey(source, target, isIntersectionConstituent, relation) { if (relation === identityRelation && source.id > target.id) { var temp = source; source = target; target = temp; } + var intersection = isIntersectionConstituent ? "&" : ""; if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { var typeParameters = []; - return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + intersection; } - return source.id + "," + target.id; + return source.id + "," + target.id + intersection; } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. @@ -45475,20 +48115,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45527,7 +48169,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45535,7 +48177,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45619,7 +48261,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45634,8 +48276,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45700,6 +48342,23 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function isNotOptionalTypeMarker(type) { + return type !== optionalType; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function getOptionalExpressionType(exprType, expression) { + return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) : + ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : + exprType; + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45729,8 +48388,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45882,7 +48541,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45919,7 +48578,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45949,12 +48608,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -45969,23 +48628,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -45999,7 +48658,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -46041,8 +48700,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -46111,6 +48769,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -46120,7 +48784,7 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); @@ -46189,10 +48853,10 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames); @@ -46328,10 +48992,7 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; - inferFromTypes(source, target); - priority = savePriority; + inferWithPriority(source, target, 1 /* NakedTypeVariable */); return; } source = getUnionType(sources); @@ -46418,9 +49079,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -46430,10 +49092,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - var savePriority = priority; - priority |= 32 /* LiteralKeyof */; - inferFromTypes(empty, target.type); - priority = savePriority; + inferWithPriority(empty, target.type, 32 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -46485,6 +49144,12 @@ var ts; } } } + function inferWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromTypes(source, target); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -46550,6 +49215,18 @@ var ts; } return undefined; } + function getSingleTypeVariableFromIntersectionTypes(types) { + var typeVariable; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var type = types_13[_i]; + var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + if (!t || typeVariable && t !== typeVariable) { + return undefined; + } + typeVariable = t; + } + return typeVariable; + } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; if (targetFlags & 1048576 /* Union */) { @@ -46579,6 +49256,16 @@ var ts; } } } + if (typeVariableCount === 0) { + // If every target is an intersection of types containing a single naked type variable, + // make a lower priority inference to that type variable. This handles inferring from + // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. + var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); + if (intersectionTypeVariable) { + inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + } + return; + } // If the target has a single naked type variable and no inference circularities were // encountered above (meaning we explored the types fully), create a union of the source // types from which no inferences have been made so far and infer from that union to the @@ -46610,15 +49297,12 @@ var ts; // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferFromTypes(source, t); + inferWithPriority(source, t, 1 /* NakedTypeVariable */); } } - priority = savePriority; } } function inferToMappedType(source, target, constraintType) { @@ -46639,14 +49323,12 @@ var ts; if (inference && !inference.isFixed) { var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); if (inferredType) { - var savePriority = priority; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - priority |= ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? - 4 /* PartialHomomorphicMappedType */ : 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? + 4 /* PartialHomomorphicMappedType */ : + 2 /* HomomorphicMappedType */); } } return true; @@ -46654,10 +49336,7 @@ var ts; if (constraintType.flags & 262144 /* TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - var savePriority = priority; - priority |= 8 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; + inferWithPriority(getIndexType(source), constraintType, 8 /* MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -46699,6 +49378,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer // from S to T and from X to Y. @@ -46728,10 +49412,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46771,7 +49455,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46941,7 +49625,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46962,7 +49646,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -46972,16 +49656,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46992,24 +49676,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -47017,8 +49701,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -47030,6 +49714,15 @@ var ts; } return false; } + function optionalChainContainsReference(source, target) { + while (ts.isOptionalChain(source)) { + source = source.expression; + if (isMatchingReference(source, target)) { + return true; + } + } + return false; + } // Return true if target is a property access xxx.yyy, source is a property access xxx.zzz, the declared // type of xxx is a union type, and yyy is a property that is possibly a discriminant. We consider a property // a possible discriminant if its type differs in the constituents of containing union type, and if every @@ -47042,7 +49735,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -47073,7 +49766,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -47101,14 +49794,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -47150,8 +49843,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -47256,15 +49949,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -47281,21 +49974,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -47303,7 +49996,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -47321,37 +50014,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -47361,13 +50049,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -47389,8 +50077,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -47473,8 +50161,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47526,8 +50213,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47550,33 +50237,94 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = void 0; + if (node.parent.kind === 225 /* ExpressionStatement */) { + funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); + } + else if (node.expression.kind !== 101 /* SuperKeyword */) { + if (ts.isOptionalChain(node)) { + funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); + } + else { + funcType = checkNonNullExpression(node.expression); + } + } + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + } + function getTypePredicateArgument(predicate, callExpression) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + return callExpression.arguments[predicate.parameterIndex]; + } + var invokedExpression = ts.skipParentheses(callExpression.expression); + return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined; } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47584,6 +50332,82 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isFalseExpression(expr) { + var node = ts.skipParentheses(expr); + return node.kind === 90 /* FalseKeyword */ || node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && predicate.kind === 3 /* AssertsIdentifier */) { + var predicateArgument = flow.node.arguments[predicate.parameterIndex]; + if (predicateArgument && isFalseExpression(predicateArgument)) { + return false; + } + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47595,6 +50419,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47603,7 +50428,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47625,16 +50450,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47646,13 +50462,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47664,14 +50480,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47698,11 +50512,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47714,7 +50528,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47724,11 +50538,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47737,11 +50574,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47750,27 +50587,63 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 90 /* FalseKeyword */) { + return unreachableNeverType; + } + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47778,7 +50651,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47813,7 +50686,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47828,14 +50701,27 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); - } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (containsMatchingReferenceDiscriminant(reference, expr)) { - type = declaredType; + else { + if (strictNullChecks) { + if (optionalChainContainsReference(expr, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + } + else if (expr.kind === 203 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + } + } + if (isMatchingReferenceDiscriminant(expr, type)) { + type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + } + else if (containsMatchingReferenceDiscriminant(reference, expr)) { + type = declaredType; + } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } } return createFlowType(type, isIncomplete(flowType)); } @@ -47845,7 +50731,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47905,25 +50791,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47970,6 +50863,9 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } + if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { + type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } if (isMatchingReferenceDiscriminant(expr, declaredType)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } @@ -47997,19 +50893,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -48018,6 +50914,14 @@ var ts; if (isMatchingReference(reference, right_1)) { return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); } + if (strictNullChecks) { + if (optionalChainContainsReference(left_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + } + else if (optionalChainContainsReference(right_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + } + } if (isMatchingReferenceDiscriminant(left_1, declaredType)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } @@ -48028,9 +50932,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -48041,15 +50945,24 @@ var ts; } return type; } + function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { + // We are in a branch of obj?.foo === value or obj?.foo !== value. We remove undefined and null from + // the type of obj if (a) the operator is === and the type of value doesn't include undefined or (b) the + // operator is !== and the type of value is undefined. + var effectiveTrue = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */ ? assumeTrue : !assumeTrue; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var valueNonNullish = !(getTypeFacts(getTypeOfExpression(value)) & (doubleEquals ? 262144 /* EQUndefinedOrNull */ : 65536 /* EQUndefined */)); + return effectiveTrue === valueNonNullish ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeByEquality(type, operator, value, assumeTrue) { if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -48062,7 +50975,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -48074,7 +50987,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -48087,9 +51000,15 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + assumeTrue = !assumeTrue; + } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { + if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the // narrowed type of 'y' to its declared type. if (containsMatchingReference(reference, target)) { @@ -48097,9 +51016,6 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { - assumeTrue = !assumeTrue; - } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } @@ -48132,6 +51048,10 @@ var ts; return type; } } + function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { + var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify // values with unit types, except for the case where @@ -48264,6 +51184,9 @@ var ts; function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { + if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the // narrowed type of 'y' to its declared type. We do this because preceding 'x.y' // references might reference a different 'y' property. However, we make an exception @@ -48324,38 +51247,29 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' - if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { - return type; - } - if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) { + var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } - if (containsMatchingReference(reference, predicateArgument)) { - return declaredType; - } - } - } - else { - var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { - var possibleReference = ts.skipParentheses(invokedExpression.expression); - if (isMatchingReference(reference, possibleReference)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && + !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (containsMatchingReference(reference, possibleReference)) { + if (containsMatchingReference(reference, predicateArgument)) { return declaredType; } } @@ -48365,27 +51279,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isExpressionOfOptionalChainRoot(expr) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -48393,7 +51324,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -48414,9 +51345,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -48435,10 +51366,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -48453,7 +51384,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -48461,10 +51392,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48501,7 +51432,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -48522,7 +51453,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48534,14 +51465,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48590,7 +51521,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48599,8 +51530,8 @@ var ts; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48608,11 +51539,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48646,7 +51577,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48669,7 +51600,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48687,8 +51618,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48706,7 +51637,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48714,9 +51645,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48727,7 +51658,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48795,37 +51726,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 158 /* Constructor */: + case 161 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48864,10 +51795,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48875,12 +51804,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48909,9 +51836,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48921,16 +51861,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48938,7 +51878,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -48963,7 +51903,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48977,15 +51917,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48998,14 +51938,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -49013,7 +51953,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -49082,7 +52022,7 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -49096,7 +52036,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -49117,7 +52057,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; @@ -49132,7 +52072,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -49140,21 +52080,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -49162,14 +52102,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -49177,7 +52117,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -49204,7 +52144,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -49218,9 +52158,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -49284,9 +52224,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -49401,22 +52341,26 @@ var ts; return undefined; } // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. - function getContextualTypeForArgument(callTarget, arg) { + function getContextualTypeForArgument(callTarget, arg, contextFlags) { var args = getEffectiveCallArguments(callTarget); var argIndex = args.indexOf(arg); // -1 for e.g. the expression of a CallExpression, or the tag of a TaggedTemplateExpression - return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); + return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags); } - function getContextualTypeForArgumentAtIndex(callTarget, argIndex) { + function getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags) { // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } + if (contextFlags && contextFlags & 4 /* Completion */ && signature.target) { + var baseSignature = getBaseSignature(signature.target); + return intersectTypes(getTypeAtPosition(signature, argIndex), getTypeAtPosition(baseSignature, argIndex)); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -49425,7 +52369,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -49434,7 +52378,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -49443,7 +52388,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -49471,7 +52416,7 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); @@ -49482,8 +52427,11 @@ var ts; if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49505,12 +52453,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49554,7 +52503,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49643,25 +52592,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 279 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 271 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -49670,7 +52619,7 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { @@ -49738,7 +52687,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49747,58 +52696,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: - return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* NewExpression */: + return getContextualTypeForArgument(parent, node, contextFlags); + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49953,7 +52902,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49967,7 +52916,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -49981,8 +52930,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -50012,8 +52961,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -50025,7 +52974,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -50050,12 +52999,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -50097,9 +53046,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -50187,7 +53136,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -50202,13 +53151,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -50231,8 +53180,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -50257,7 +53206,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -50283,7 +53232,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -50343,7 +53292,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -50391,7 +53346,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -50436,7 +53391,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -50459,7 +53414,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -50878,7 +53833,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50973,32 +53928,43 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); } - function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + function checkNonNullExpression(node) { + return checkNonNullType(checkExpression(node), node); + } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; } - function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + function reportObjectPossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + } + function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); + } + function checkNonNullTypeWithReporter(type, node, reportError) { if (strictNullChecks && type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? - (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : - (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : - (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); + reportError(node, kind); var t = getNonNullableType(type); return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } + function checkNonNullType(type, node) { + return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError); + } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); if (nonNullType !== errorType && nonNullType.flags & 16384 /* Void */) { @@ -51007,20 +53973,24 @@ var ts; return nonNullType; } function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + } + function checkPropertyAccessChain(node) { + var leftType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(leftType, node.expression); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType); } function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -51034,6 +54004,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -51061,9 +54032,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -51079,7 +54050,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -51089,11 +54060,11 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -51124,9 +54095,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -51137,22 +54108,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -51192,7 +54163,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -51325,16 +54296,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -51351,13 +54322,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -51374,13 +54345,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -51394,28 +54365,22 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + } + function checkElementAccessChain(node) { + var exprType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(exprType, node.expression); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType); + } + function checkElementAccessExpression(node, exprType) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -51470,13 +54435,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51495,7 +54460,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51503,8 +54468,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51525,7 +54490,7 @@ var ts; lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless // of the cutoff position; see GH#1133 - if (signature.hasLiteralTypes) { + if (signatureHasLiteralTypes(signature)) { specializedIndex++; spliceIndex = specializedIndex; // The cutoff index always needs to be greater than or equal to the specialized signature index @@ -51536,11 +54501,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51554,9 +54519,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -51571,7 +54536,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51586,7 +54551,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51679,7 +54644,7 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51709,7 +54674,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51722,7 +54687,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51746,7 +54711,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51826,12 +54791,24 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + var thisArgumentType = void 0; + if (thisArgumentNode) { + thisArgumentType = checkExpression(thisArgumentNode); + if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { + thisArgumentType = getNonNullableType(thisArgumentType); + } + else if (ts.isOptionalChain(thisArgumentNode.parent)) { + thisArgumentType = removeOptionalTypeMarker(thisArgumentType); + } + } + else { + thisArgumentType = voidType; + } var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -51844,7 +54821,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51885,15 +54862,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51903,17 +54880,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51928,7 +54905,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51943,30 +54920,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 152 /* Parameter */: + case 155 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51980,17 +54957,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -52028,8 +55005,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -52058,7 +55035,7 @@ var ts; if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(getFirstIdentifier(paramDecl.name)) : undefined); + related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); } } if (min < argCount && argCount < max) { @@ -52098,8 +55075,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -52114,22 +55091,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -52178,7 +55155,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -52231,7 +55208,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -52249,7 +55226,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -52383,35 +55360,35 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { - var symbols = ts.mapDefined(candidates, function (_a) { - var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; - return hasRestParameter ? - i < parameters.length - 1 ? parameters[i] : ts.last(parameters) : - i < parameters.length ? parameters[i] : undefined; - }); + var _loop_15 = function (i) { + var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? + i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : + i < s.parameters.length ? s.parameters[i] : undefined; }); ts.Debug.assert(symbols.length !== 0); parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } - var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); - var hasRestParameter = restParameterSymbols.length !== 0; - if (hasRestParameter) { + var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); + var flags = 0 /* None */; + if (restParameterSymbols.length !== 0) { var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); + flags |= 1 /* HasRestParameter */; + } + if (candidates.some(signatureHasLiteralTypes)) { + flags |= 2 /* HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. thisParameter, parameters, /*resolvedReturnType*/ getIntersectionType(candidates.map(getReturnTypeOfSignature)), - /*typePredicate*/ undefined, minArgumentCount, hasRestParameter, - /*hasLiteralTypes*/ candidates.some(function (c) { return c.hasLiteralTypes; })); + /*typePredicate*/ undefined, minArgumentCount, flags); } function getNumNonRestParameters(signature) { var numParams = signature.parameters.length; - return signature.hasRestParameter ? numParams - 1 : numParams; + return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); @@ -52472,7 +55449,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -52487,12 +55464,22 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var isOptional; + var funcType = checkExpression(node.expression); + if (ts.isCallChain(node)) { + var nonOptionalType = getOptionalExpressionType(funcType, node.expression); + isOptional = nonOptionalType !== funcType; + funcType = nonOptionalType; + } + else { + isOptional = false; + } + funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52558,7 +55545,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52621,7 +55608,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52629,7 +55616,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52714,8 +55701,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var constituent = types_14[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var constituent = types_17[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52806,23 +55793,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52859,7 +55846,7 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); @@ -52868,15 +55855,13 @@ var ts; // file would probably be preferable. var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, - /*hasRestparameter*/ false, - /*hasLiteralTypes*/ false); + /*returnTypePredicate*/ undefined, 1, 0 /* None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -52899,7 +55884,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52909,22 +55894,22 @@ var ts; function isPotentiallyUncalledDecorator(decorator, signatures) { return signatures.length && ts.every(signatures, function (signature) { return signature.minArgumentCount === 0 && - !signature.hasRestParameter && + !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52975,57 +55960,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); - } - return false; - } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -53040,15 +56020,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -53068,18 +56048,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -53117,7 +56107,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -53165,19 +56155,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -53192,20 +56183,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -53241,10 +56232,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -53255,7 +56246,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -53269,7 +56260,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -53284,7 +56275,7 @@ var ts; return type; } function getParameterNameAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return signature.parameters[pos].escapedName; } @@ -53301,17 +56292,17 @@ var ts; return tryGetTypeAtPosition(signature, pos) || anyType; } function tryGetTypeAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return getTypeOfParameter(signature.parameters[pos]); } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // We want to return the value undefined for an out of bounds parameter position, // so we need to check bounds here before calling getIndexedAccessType (which // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -53340,16 +56331,16 @@ var ts; } function getParameterCount(signature) { var length = signature.parameters.length; - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; } function getMinArgumentCount(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { var minLength = restType.target.minLength; @@ -53361,14 +56352,14 @@ var ts; return signature.minArgumentCount; } function hasEffectiveRestParameter(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return !isTupleType(restType) || restType.target.hasRestElement; } return false; } function getEffectiveRestType(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType; } @@ -53385,7 +56376,7 @@ var ts; return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType; } function inferFromAnnotatedParameters(signature, context, inferenceContext) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -53418,7 +56409,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter)); } } - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53426,7 +56417,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53441,7 +56432,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -53455,7 +56446,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); @@ -53510,7 +56501,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53693,10 +56684,11 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); @@ -53716,13 +56708,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53762,11 +56748,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53792,10 +56778,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53825,7 +56811,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53836,7 +56822,7 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); returnOnlyType.objectFlags |= 1048576 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; @@ -53845,7 +56831,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53899,7 +56885,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53912,7 +56898,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -53993,11 +56979,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -54010,31 +56996,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -54056,14 +57046,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -54090,14 +57080,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -54105,32 +57095,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54144,7 +57134,7 @@ var ts; var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54165,8 +57155,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -54255,7 +57245,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -54268,9 +57258,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -54313,8 +57303,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -54332,7 +57322,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -54348,7 +57338,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -54364,24 +57354,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - if (checkReferenceExpression(target, error)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -54397,53 +57390,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -54455,15 +57448,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -54471,28 +57476,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54519,17 +57524,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54537,8 +57542,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54571,24 +57576,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54597,25 +57602,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54642,6 +57651,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54659,7 +57671,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54674,15 +57686,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54695,7 +57707,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54729,17 +57741,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; + } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54747,12 +57765,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54761,6 +57779,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54779,7 +57808,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54850,7 +57879,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -54889,12 +57918,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54916,10 +57945,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54971,7 +58000,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54982,7 +58011,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54994,8 +58023,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -55125,11 +58154,22 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var isOptional = void 0; + var funcType = void 0; + if (ts.isCallChain(expr)) { + funcType = checkExpression(expr.expression); + var nonOptionalType = getOptionalExpressionType(funcType, expr.expression); + isOptional = funcType !== nonOptionalType; + funcType = checkNonNullType(nonOptionalType, expr.expression); + } + else { + isOptional = false; + funcType = checkNonNullExpression(expr.expression); + } var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -55175,18 +58215,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 258 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // We allow reexporting const enums + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -55204,20 +58244,20 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -55228,82 +58268,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -55340,7 +58380,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -55351,10 +58391,10 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -55378,18 +58418,20 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { if (typePredicate.parameterIndex >= 0) { - if (signature.hasRestParameter && typePredicate.parameterIndex === signature.parameters.length - 1) { + if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -55410,13 +58452,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -55430,11 +58472,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -55443,13 +58485,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -55479,10 +58521,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55512,7 +58554,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -55522,7 +58564,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { @@ -55537,16 +58579,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: addName(names, name, memberName, 8 /* Method */); break; } @@ -55609,7 +58651,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55617,7 +58659,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55634,7 +58676,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -55654,7 +58696,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55662,7 +58704,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55689,7 +58731,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55714,7 +58756,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55742,9 +58784,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55769,9 +58811,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55779,13 +58821,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55803,7 +58845,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55851,19 +58893,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55899,16 +58938,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55929,7 +58968,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -55980,7 +59019,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -55991,16 +59030,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -56090,7 +59129,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -56129,8 +59168,8 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -56141,10 +59180,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -56205,8 +59244,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -56275,41 +59314,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -56343,7 +59383,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -56539,7 +59579,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -56558,7 +59598,7 @@ var ts; return; } // Verify there is no local declaration that could collide with the promise constructor. - var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); @@ -56578,24 +59618,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56615,8 +59655,8 @@ var ts; function markEntityNameOrEntityExpressionAsReference(typeName) { if (!typeName) return; - var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var rootName = ts.getFirstIdentifier(typeName); + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56641,29 +59681,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var typeNode = types_16[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -56709,14 +59749,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56725,23 +59765,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56804,7 +59844,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 149 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56837,9 +59877,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56852,7 +59892,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56868,7 +59908,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56881,7 +59921,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56907,7 +59947,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56923,42 +59963,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56978,11 +60018,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56991,7 +60031,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -56999,8 +60039,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -57027,7 +60067,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -57062,7 +60102,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -57112,7 +60152,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -57130,7 +60170,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -57151,7 +60191,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -57163,24 +60203,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -57197,7 +60237,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -57210,21 +60250,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -57234,7 +60274,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -57249,7 +60289,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -57275,7 +60315,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57290,7 +60330,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57325,7 +60365,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -57337,17 +60377,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -57377,18 +60417,18 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -57402,26 +60442,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -57458,7 +60498,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -57484,10 +60524,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -57496,7 +60536,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57506,8 +60546,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57544,13 +60584,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57573,12 +60656,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57612,14 +60695,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -57627,7 +60710,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57651,7 +60734,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -57665,7 +60748,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -57673,7 +60756,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -58026,7 +61109,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -58038,7 +61121,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58117,7 +61200,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -58128,7 +61211,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58164,11 +61247,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -58232,11 +61315,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -58329,12 +61414,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -58352,7 +61437,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -58360,7 +61445,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -58381,19 +61466,16 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -58410,6 +61492,9 @@ var ts; } } ts.forEach(clause.statements, checkSourceElement); + if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) { + error(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } }); if (node.caseBlock.locals) { registerForUnusedIdentifiersCheck(node.caseBlock); @@ -58422,7 +61507,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58529,8 +61614,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58607,7 +61692,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58707,7 +61792,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58720,11 +61805,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58762,12 +61848,9 @@ var ts; } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify - // that all instantiated base constructor signatures return the same type. We can simply compare the type - // references (as opposed to checking the structure of the types) because elsewhere we have already checked - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58810,7 +61893,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58829,7 +61912,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58855,7 +61938,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58906,7 +61989,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 210 /* ClassExpression */) { + if (derivedClassDecl.kind === 213 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -58921,17 +62004,55 @@ var ts; // either base or derived property is private - not override, skip it continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment + continue; + } + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; + } + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } + } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + // method is overridden with method or property -- correct case + continue; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } else if (base.flags & 98304 /* Accessor */) { @@ -58977,12 +62098,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -58997,7 +62121,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -59021,7 +62145,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -59084,7 +62208,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -59116,7 +62240,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -59126,66 +62250,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 50 /* BarToken */: return left | right; - case 49 /* AmpersandToken */: return left & right; - case 47 /* GreaterThanGreaterThanToken */: return left >> right; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 46 /* LessThanLessThanToken */: return left << right; - case 51 /* CaretToken */: return left ^ right; - case 40 /* AsteriskToken */: return left * right; - case 42 /* SlashToken */: return left / right; - case 38 /* PlusToken */: return left + right; - case 39 /* MinusToken */: return left - right; - case 43 /* PercentToken */: return left % right; - case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -59210,10 +62333,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -59247,7 +62370,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -59270,9 +62393,9 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -59295,7 +62418,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -59334,7 +62457,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -59384,23 +62507,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -59411,12 +62534,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -59435,19 +62558,22 @@ var ts; break; } } - function getFirstIdentifier(node) { + function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -59461,9 +62587,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -59493,20 +62619,21 @@ var ts; // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). + symbol = getMergedSymbol(symbol.exportSymbol || symbol); var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 258 /* ExportSpecifier */ + && node.kind === 261 /* ExportSpecifier */ && !(target.flags & 111551 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59531,7 +62658,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59555,12 +62682,12 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name - var moduleName = getFirstIdentifier(node.moduleReference); + var moduleName = ts.getFirstIdentifier(node.moduleReference); if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } @@ -59571,7 +62698,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59591,10 +62718,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59611,7 +62738,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59627,7 +62754,7 @@ var ts; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { @@ -59644,8 +62771,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59658,7 +62785,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -59678,10 +62805,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59707,9 +62834,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59759,159 +62886,162 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 307 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 299 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -60006,23 +63136,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -60051,7 +63181,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -60137,7 +63267,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -60152,26 +63282,26 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -60180,7 +63310,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -60222,17 +63352,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -60240,16 +63370,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -60277,13 +63407,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -60309,7 +63439,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -60319,7 +63449,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -60327,7 +63457,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -60337,7 +63467,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -60355,7 +63485,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -60371,10 +63501,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 307 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 311 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -60384,19 +63514,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -60406,22 +63536,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -60435,12 +63565,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -60450,11 +63580,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -60466,14 +63596,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -60484,7 +63614,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -60501,21 +63631,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -60527,7 +63657,7 @@ var ts; resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60583,27 +63713,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60642,17 +63772,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60704,7 +63833,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60760,7 +63889,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -60788,7 +63917,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60819,7 +63948,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60860,26 +63989,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60980,15 +64108,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -61073,7 +64201,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -61092,7 +64220,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61100,7 +64228,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61224,12 +64352,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -61242,10 +64370,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -61257,7 +64394,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -61308,7 +64445,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -61336,12 +64473,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -61474,7 +64611,7 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; @@ -61483,7 +64620,7 @@ var ts; var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61530,14 +64667,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -61554,23 +64691,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61584,11 +64721,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61597,7 +64734,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61607,10 +64744,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61619,18 +64756,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61643,52 +64780,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 126 /* DeclareKeyword */: + case 129 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61700,14 +64837,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61715,7 +64852,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61730,13 +64867,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61757,38 +64894,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61800,10 +64937,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61832,7 +64969,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61918,15 +65055,15 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); } - if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -61950,11 +65087,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61984,7 +65127,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -61997,7 +65140,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -62013,14 +65156,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -62031,21 +65174,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -62063,7 +65206,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -62074,21 +65217,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { - // tslint:disable no-unnecessary-type-assertion + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -62103,10 +65246,10 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -62114,13 +65257,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -62157,7 +65300,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -62167,7 +65310,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -62181,14 +65324,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -62199,7 +65342,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -62214,20 +65357,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -62237,7 +65380,7 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 4194304 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */)) { if (languageVersion < 1 /* ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -62252,11 +65395,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 159 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -62278,23 +65421,23 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -62304,13 +65447,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -62319,9 +65462,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -62334,10 +65477,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -62360,17 +65503,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -62381,11 +65524,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -62393,8 +65536,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -62409,13 +65552,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -62438,13 +65581,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -62457,7 +65600,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -62474,8 +65617,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -62487,11 +65630,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -62504,7 +65647,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62521,8 +65664,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62549,15 +65692,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62575,12 +65718,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -62638,7 +65781,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62646,7 +65789,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62654,11 +65797,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62675,13 +65818,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62690,7 +65833,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62699,10 +65842,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -62713,7 +65856,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62735,20 +65878,39 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62784,7 +65946,7 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd); } if (node.typeArguments) { return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); @@ -62808,14 +65970,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62823,21 +65985,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62847,7 +66008,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62856,6 +66016,18 @@ var ts; case 2 /* Next */: return "nextType"; } } + function signatureHasRestParameter(s) { + return !!(s.flags & 1 /* HasRestParameter */); + } + ts.signatureHasRestParameter = signatureHasRestParameter; + function signatureHasLiteralTypes(s) { + return !!(s.flags & 2 /* HasLiteralTypes */); + } + ts.signatureHasLiteralTypes = signatureHasLiteralTypes; + function signatureIsOptionalCall(s) { + return !!(s.flags & 4 /* IsOptionalCall */); + } + ts.signatureIsOptionalCall = signatureIsOptionalCall; })(ts || (ts = {})); var ts; (function (ts) { @@ -62918,6 +66090,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62965,7 +66138,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -63046,23 +66219,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -63073,44 +66246,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -63129,7 +66302,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -63142,7 +66315,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -63158,7 +66331,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -63182,7 +66355,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63195,7 +66368,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -63215,12 +66388,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -63230,8 +66403,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -63239,7 +66412,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -63256,7 +66429,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63269,6 +66442,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -63284,7 +66489,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -63304,7 +66509,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63327,7 +66532,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63348,7 +66553,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -63356,7 +66561,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -63364,7 +66569,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -63404,21 +66609,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -63432,7 +66647,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -63440,7 +66655,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -63448,7 +66663,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -63460,7 +66675,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -63472,7 +66687,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -63484,7 +66699,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -63496,7 +66711,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -63508,7 +66723,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63520,7 +66735,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63528,7 +66743,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63547,7 +66762,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63565,7 +66780,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63577,7 +66792,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63595,7 +66810,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63607,12 +66822,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63622,7 +66837,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63636,7 +66851,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63654,7 +66869,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63667,7 +66882,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63679,7 +66894,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63691,7 +66906,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63710,7 +66925,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63724,7 +66939,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63738,7 +66953,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63746,6 +66961,9 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + if (ts.isOptionalChain(node)) { + return updatePropertyAccessChain(node, expression, node.questionDotToken, name); + } // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63754,22 +66972,64 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + if (ts.isOptionalChain(node)) { + return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression); + } return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63777,6 +67037,9 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + if (ts.isOptionalChain(node)) { + return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray); + } return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63784,8 +67047,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63801,7 +67084,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63824,7 +67107,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63838,7 +67121,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63850,7 +67133,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63874,12 +67157,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63896,7 +67179,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63908,7 +67191,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63920,7 +67203,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63932,7 +67215,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63944,7 +67227,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63957,7 +67240,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63970,7 +67253,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63987,11 +67270,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -64007,7 +67290,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -64031,11 +67314,9 @@ var ts; rawTextScanner.setText("`" + rawText + "`"); break; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; case 17 /* TemplateTail */: @@ -64106,9 +67387,9 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -64120,7 +67401,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64132,7 +67413,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64153,11 +67434,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -64171,7 +67452,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -64185,7 +67466,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -64197,7 +67478,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -64211,7 +67492,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -64225,12 +67506,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -64244,7 +67525,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -64259,11 +67540,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -64279,7 +67560,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -64295,7 +67576,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -64309,7 +67590,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64323,7 +67604,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -64341,7 +67622,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -64357,10 +67638,10 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; - node.expression = expression; + node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression; node.statement = asEmbeddedStatement(statement); return node; } @@ -64375,7 +67656,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -64387,7 +67668,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -64399,7 +67680,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -64411,7 +67692,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64425,7 +67706,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -64439,7 +67720,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -64453,7 +67734,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -64465,7 +67746,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -64481,11 +67762,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -64502,7 +67783,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -64515,7 +67796,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -64541,7 +67822,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64563,7 +67844,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64585,7 +67866,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64605,7 +67886,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64624,8 +67905,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64643,7 +67924,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64655,7 +67936,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64667,7 +67948,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64679,7 +67960,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64697,7 +67978,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64715,7 +67996,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64729,7 +68010,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64741,7 +68022,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64753,7 +68034,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64767,11 +68048,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64784,7 +68065,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64801,8 +68082,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64814,7 +68100,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64829,7 +68115,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64843,14 +68129,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(310 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64858,7 +68144,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(308 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64866,14 +68152,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(309 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64883,7 +68169,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(298 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64897,7 +68183,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64913,7 +68199,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64929,7 +68215,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64945,7 +68231,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64957,7 +68243,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64979,11 +68265,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64995,7 +68281,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -65009,7 +68295,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -65021,7 +68307,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -65033,7 +68319,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -65047,7 +68333,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -65061,7 +68347,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -65073,7 +68359,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -65086,7 +68372,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -65101,7 +68387,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -65116,7 +68402,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -65130,7 +68416,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -65143,7 +68429,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -65164,7 +68450,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -65248,7 +68534,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(315 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -65260,7 +68546,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(319 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65272,7 +68558,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65287,7 +68573,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(316 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -65303,7 +68589,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 317 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -65313,7 +68599,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(317 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -65324,9 +68610,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -65357,7 +68659,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -65439,8 +68741,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -65489,10 +68794,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -65510,14 +68815,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -65563,8 +68868,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65607,43 +68912,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65663,7 +68972,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65707,7 +69019,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65772,7 +69084,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -66248,7 +69559,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -66260,20 +69571,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -66288,7 +69599,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -66300,7 +69611,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66313,7 +69624,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66370,14 +69681,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66655,8 +69966,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66703,7 +70014,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66737,10 +70048,10 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66752,7 +70063,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66789,7 +70100,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66824,10 +70135,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66840,25 +70151,23 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { return ts.createParen(condition); } return condition; @@ -66890,8 +70199,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66907,9 +70216,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66932,7 +70241,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66970,7 +70279,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66981,29 +70290,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -67011,9 +70320,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -67039,28 +70348,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 316 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -67069,15 +70378,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 317 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -67090,13 +70399,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -67121,7 +70430,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -67129,11 +70438,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 316 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -67151,7 +70460,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -67270,10 +70579,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -67392,7 +70701,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -67404,11 +70713,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -67440,12 +70749,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -67457,7 +70766,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -67469,7 +70778,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -67481,7 +70790,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -67504,13 +70813,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -67550,11 +70859,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67678,7 +70987,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict) - statements = ts.ensureUseStrict(statements); // tslint:disable-line no-unnecessary-qualifier + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; @@ -67713,278 +71022,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 161 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -68026,58 +71344,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 315 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68086,12 +71404,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68099,7 +71417,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68107,50 +71425,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -68158,123 +71476,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68283,7 +71601,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68291,140 +71609,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -68497,7 +71815,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -68570,19 +71888,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68785,12 +72104,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68802,6 +72120,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -69170,7 +72489,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -69217,7 +72536,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -69230,13 +72549,13 @@ var ts; hasImportDefault = true; } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -69266,13 +72585,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -69280,7 +72599,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -69300,7 +72619,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -69398,7 +72717,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -69428,42 +72747,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.getInitializedProperties = getInitializedProperties; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); - } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -69989,8 +73294,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -70016,14 +73321,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -70074,16 +73379,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -70095,7 +73400,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -70138,10 +73443,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -70162,13 +73467,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -70188,11 +73493,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -70216,19 +73521,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -70238,7 +73543,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -70255,67 +73560,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70325,7 +73634,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70335,35 +73644,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -70373,35 +73682,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70439,7 +73748,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -70468,7 +73777,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70811,12 +74120,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70969,7 +74278,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? ts.createVoidZero() @@ -71070,13 +74379,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -71092,10 +74401,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -71105,7 +74414,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -71116,12 +74425,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -71138,15 +74447,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -71183,7 +74492,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -71228,69 +74537,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -71301,15 +74610,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var typeNode = types_20[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -71389,12 +74698,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -71410,7 +74719,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.getMutableClone(node); @@ -71418,7 +74727,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -71502,7 +74811,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -71965,12 +75274,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -72095,7 +75404,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -72141,13 +75450,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -72188,7 +75497,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -72401,7 +75710,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -72409,7 +75718,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72419,17 +75728,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -72488,11 +75797,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -72530,9 +75839,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -72554,9 +75863,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -72660,7 +75970,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72671,11 +75983,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72687,20 +75999,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72730,7 +76042,7 @@ var ts; // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { (pendingExpressions || (pendingExpressions = [])).push(expr); } @@ -72743,7 +76055,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72759,9 +76071,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72779,9 +76091,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72793,7 +76105,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72834,8 +76146,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72848,7 +76160,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72892,7 +76204,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72909,7 +76221,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72946,19 +76258,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72978,7 +76300,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -73096,34 +76418,34 @@ var ts; return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73132,27 +76454,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -73353,7 +76675,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -73444,17 +76766,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73502,23 +76824,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73538,11 +76860,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73610,7 +76932,7 @@ var ts; function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -73682,7 +77004,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; @@ -73704,62 +77026,62 @@ var ts; return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return doOutsideOfTopLevel(visitConstructorDeclaration, node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73793,7 +77115,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73805,7 +77127,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73814,7 +77136,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73848,7 +77170,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -74145,7 +77467,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); @@ -74214,17 +77536,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -74272,23 +77594,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -74308,11 +77630,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -74335,8 +77657,7 @@ var ts; }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getUnscopedHelperName("__assign"), @@ -74411,7 +77732,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -74430,6 +77751,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -74442,10 +77764,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -74480,13 +77935,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74496,13 +77951,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -74577,7 +78032,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -74671,7 +78126,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74977,7 +78432,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74985,9 +78440,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -75190,13 +78645,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -75209,72 +78664,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -75285,28 +78740,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -75397,14 +78852,14 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -75415,7 +78870,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75673,7 +79128,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75811,11 +79266,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75823,7 +79278,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75978,10 +79433,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -76005,7 +79460,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -76021,7 +79476,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -76042,25 +79497,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -76089,20 +79544,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -76128,12 +79583,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -76290,7 +79755,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -76334,7 +79799,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -76402,9 +79867,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -76423,9 +79888,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -76460,7 +79925,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -76634,14 +80099,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76829,7 +80294,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76884,7 +80349,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76950,11 +80415,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76979,11 +80444,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -77134,7 +80599,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -77196,7 +80661,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -77234,7 +80699,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -77245,7 +80710,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -77258,7 +80723,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -77272,7 +80737,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -77293,10 +80758,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -77382,20 +80847,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -77502,7 +80967,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77555,7 +81020,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -77679,10 +81144,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -77700,7 +81165,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77712,10 +81177,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -78003,13 +81468,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -78041,7 +81504,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -78051,14 +81514,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -78099,10 +81562,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -78115,9 +81578,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -78184,19 +81647,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -78251,15 +81714,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -78278,9 +81741,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -78337,7 +81800,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -78612,13 +82075,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -78631,24 +82094,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -78669,21 +82132,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -78696,9 +82159,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78897,23 +82360,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78926,7 +82389,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78938,7 +82401,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -79025,7 +82488,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -79314,35 +82777,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79772,7 +83235,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79785,7 +83248,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79958,11 +83421,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80097,7 +83559,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -81014,12 +84476,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -81347,23 +84809,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -81390,24 +84852,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -81885,7 +85347,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81940,10 +85402,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82125,8 +85587,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82142,7 +85604,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -82204,12 +85666,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -82230,7 +85692,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -82298,15 +85760,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -82382,13 +85844,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -82610,7 +86072,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -82635,7 +86097,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -82704,28 +86166,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82775,15 +86237,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82959,7 +86421,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -83023,7 +86485,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -83085,10 +86547,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -83268,43 +86730,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -83551,7 +87013,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -83567,8 +87029,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -83584,7 +87046,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -83634,7 +87096,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -83668,14 +87130,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -83761,22 +87223,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83803,7 +87265,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83842,8 +87304,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -83867,10 +87329,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83977,7 +87439,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84006,7 +87468,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84053,7 +87515,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84062,8 +87524,8 @@ var ts; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -84072,7 +87534,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84097,7 +87559,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.hasModifier(node, 32 /* Static */)) { @@ -84136,26 +87598,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84163,7 +87625,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84177,7 +87639,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84202,30 +87664,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84233,7 +87695,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84246,13 +87708,20 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -84261,39 +87730,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -84308,9 +87777,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -84345,11 +87814,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -84359,7 +87825,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -84423,7 +87889,6 @@ var ts; var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -84506,20 +87971,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -84532,18 +88006,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; - var statements_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(126 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -84580,12 +88054,20 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -84672,11 +88154,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -84684,7 +88166,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -84697,7 +88179,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -84722,19 +88204,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84742,12 +88224,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -84758,26 +88240,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84858,7 +88340,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84878,7 +88360,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84905,7 +88387,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84954,11 +88436,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84968,13 +88450,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -85001,7 +88476,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -85022,75 +88497,65 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 215 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - var isPrivate = ts.hasModifier(input, 8 /* Private */); - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(ts.updateGetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 160 /* SetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - return cleanup(ts.updateSetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 155 /* PropertyDeclaration */: + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } + case 158 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -85098,13 +88563,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 154 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 179 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -85116,13 +88581,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -85151,7 +88616,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -85161,7 +88626,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -85170,13 +88635,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -85186,7 +88651,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -85211,10 +88676,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -85235,14 +88700,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -85257,7 +88722,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -85290,17 +88755,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -85309,7 +88774,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -85336,7 +88801,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -85347,7 +88812,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -85377,7 +88842,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -85387,16 +88852,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -85407,10 +88872,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -85429,7 +88894,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -85450,7 +88915,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -85500,7 +88965,7 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -85521,43 +88986,15 @@ var ts; } return accessorType; } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; - } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -85582,7 +89019,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -85591,52 +89028,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -85765,7 +89202,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(320 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -86050,15 +89487,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -86068,22 +89505,21 @@ var ts; if (!onlyBuildInfo) { 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); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -86106,7 +89542,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -86114,14 +89550,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -86131,9 +89567,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -86174,7 +89608,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -86191,43 +89625,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -86243,11 +89707,11 @@ var ts; return jsFilePath; if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -86255,7 +89719,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -86269,7 +89733,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -86365,17 +89829,20 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle) + return; + if (!declarationFilePath) { + if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly) + emitSkipped = true; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -86407,7 +89874,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -86415,7 +89882,7 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -86426,7 +89893,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -86438,8 +89905,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -86480,7 +89947,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -86587,10 +90054,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -86602,7 +90070,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -86748,6 +90216,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -86776,9 +90246,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86947,8 +90417,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86960,7 +90429,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86976,6 +90445,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86985,21 +90456,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -87014,12 +90496,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -87033,10 +90515,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -87056,279 +90541,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 304 /* JSDocClassTag */: - case 301 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -87346,83 +90831,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -87435,8 +90920,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -87462,7 +90950,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -87562,7 +91050,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -87595,7 +91083,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87631,7 +91119,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -87693,7 +91181,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87734,11 +91222,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87870,18 +91364,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87961,66 +91454,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -88060,22 +91544,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -88100,9 +91584,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ - && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) - || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -88115,7 +91599,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -88143,7 +91627,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -88220,7 +91704,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88228,8 +91712,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -88239,14 +91723,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -88255,14 +91739,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -88274,25 +91758,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -88300,7 +91784,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -88309,12 +91793,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -88342,12 +91826,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88355,7 +91839,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88365,17 +91849,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -88384,13 +91868,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -88415,7 +91899,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -88587,7 +92071,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -88595,7 +92079,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88616,17 +92100,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88635,12 +92119,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -88655,9 +92139,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -88668,42 +92152,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -88723,7 +92207,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88801,7 +92285,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88812,13 +92296,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88830,12 +92314,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88846,7 +92330,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88916,7 +92400,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 310 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88950,7 +92434,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88969,7 +92453,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 299 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -89103,8 +92587,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { - var directive = types_18[_d]; + for (var _d = 0, types_21 = types; _d < types_21.length; _d++) { + var directive = types_21[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -89284,7 +92768,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -89322,8 +92806,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -89730,6 +93213,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -89747,7 +93233,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89812,81 +93298,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89895,12 +93381,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -90080,25 +93566,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -90141,11 +93627,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 315 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -90169,7 +93656,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -90199,6 +93686,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -90412,6 +93900,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -90426,7 +93915,7 @@ var ts; else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -90439,12 +93928,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -91368,6 +94858,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -91472,15 +94964,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -91562,11 +95056,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structuralIsReused; - structuralIsReused = tryReuseStructureFromOldProgram(); + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -91574,20 +95070,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -91600,7 +95112,7 @@ var ts; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -91636,8 +95148,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -91653,12 +95165,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91695,7 +95208,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -91722,9 +95237,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91928,6 +95448,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -92018,7 +95544,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -92055,28 +95581,26 @@ var ts; for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = getModuleNames(newSourceFile); - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); - // ensure that module resolution results are still correct - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); + // ensure that module resolution results are still correct + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -92090,11 +95614,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; var filePath = newSourceFile.path; addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); + if (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -92114,7 +95646,8 @@ var ts; function getEmitHost(writeFileCallback) { return __assign(__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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, 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) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, 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)) @@ -92179,15 +95712,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -92219,7 +95752,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -92294,15 +95828,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -92361,22 +95896,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -92384,41 +95919,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -92431,51 +95966,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -92492,24 +96028,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -92584,8 +96120,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -92615,7 +96151,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -92666,7 +96202,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -92747,24 +96283,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, diagnostic], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([diagnostic], args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -92787,15 +96317,36 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (!source && + host.realpath && + options.preserveSymlinks && + ts.isDeclarationFileName(fileName) && + ts.stringContains(fileName, ts.nodeModulesPathPart)) { + // use host's cached realpath + var realPath = host.realpath(fileName); + if (realPath !== fileName) + source = getSourceOfProjectReferenceRedirect(realPath); + } + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92804,34 +96355,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92849,14 +96401,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92887,7 +96432,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92910,8 +96455,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92926,8 +96481,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92966,6 +96521,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -93000,9 +96584,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -93018,10 +96610,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -93033,7 +96631,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -93043,8 +96641,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -93052,14 +96649,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -93077,20 +96674,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { + if (!refFile) { return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, message], args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -93130,14 +96727,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -93156,12 +96761,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; 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) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -93218,9 +96826,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -93258,14 +96863,12 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -93381,8 +96984,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -93447,8 +97050,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -93475,7 +97111,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -93550,7 +97186,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -93609,6 +97245,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -93654,9 +97296,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -93706,9 +97345,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93954,7 +97593,10 @@ var ts; } } else { - var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); var firstDts_1 = emitOutput_1.outputFiles && programOfThisState.getCompilerOptions().declarationMap ? emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : @@ -94066,6 +97708,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -94169,6 +97812,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -94182,8 +97830,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -94206,7 +97853,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -94252,16 +97900,17 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } + state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit; return state; } function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -94306,7 +97955,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -94383,13 +98033,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -94408,7 +98063,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -94433,7 +98088,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -94451,15 +98106,40 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { return; } + if (!isChangedSignagure(state, affectedFile.path)) + return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } + } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first @@ -94527,7 +98207,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, isEmitResult) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -94537,8 +98217,8 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); - if (isEmitResult) { - (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; @@ -94551,15 +98231,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); return { result: result, affected: affected }; } /** * Returns the result with affected file */ - function toAffectedFileEmitResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, /*isEmitResult*/ true); + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -94589,7 +98269,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -94782,11 +98462,12 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } @@ -94794,10 +98475,11 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94813,7 +98495,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94869,7 +98551,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94901,7 +98583,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94913,8 +98595,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94947,7 +98635,7 @@ var ts; } var state = { fileInfos: fileInfos, - compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), + compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), @@ -94983,33 +98671,6 @@ var ts; } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function convertFromReusableCompilerOptions(options, toAbsolutePath) { - var result = {}; - var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertFromReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); - } - } - if (result.configFilePath) { - result.configFilePath = toAbsolutePath(result.configFilePath); - } - return result; - } - function convertFromReusableCompilerOptionValue(option, value, toAbsolutePath) { - if (option) { - if (option.type === "list") { - var values = value; - if (option.element.isFilePath && values.length) { - return values.map(toAbsolutePath); - } - } - else if (option.isFilePath) { - return toAbsolutePath(value); - } - } - return value; - } function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -95076,15 +98737,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -95330,7 +99003,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -95541,6 +99214,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -95726,8 +99403,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -95743,13 +99421,19 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) @@ -95808,38 +99492,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95850,7 +99508,9 @@ var ts; var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95867,7 +99527,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95909,7 +99593,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95918,28 +99602,34 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); + var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) + var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)); + if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) { return undefined; + } // If the module was found in @types, get the actual Node package name var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1); var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName); @@ -96130,6 +99820,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96137,7 +99836,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -96146,7 +99845,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -96155,7 +99854,7 @@ var ts; /** Parses config file using System interface */ function parseConfigFileWithSystem(configFileName, optionsToExtend, system, reportDiagnostic) { var host = system; - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(ts.sys, reportDiagnostic, diagnostic); }; + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; @@ -96179,7 +99878,7 @@ var ts; } ts.getErrorSummaryText = getErrorSummaryText; function listFiles(program, writeFileName) { - if (program.getCompilerOptions().listFiles) { + if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) { ts.forEach(program.getSourceFiles(), function (file) { writeFileName(file.fileName); }); @@ -96190,6 +99889,7 @@ var ts; * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { + var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly; // First get and report any syntactic errors. var diagnostics = program.getConfigFileParsingDiagnostics().slice(); var configFileParsingDiagnosticsLength = diagnostics.length; @@ -96198,13 +99898,17 @@ var ts; // semantic errors. if (diagnostics.length === configFileParsingDiagnosticsLength) { ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken)); - ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); - if (diagnostics.length === configFileParsingDiagnosticsLength) { - ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + if (!isListFilesOnly) { + ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); + if (diagnostics.length === configFileParsingDiagnosticsLength) { + ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + } } } // Emit and report any errors we ran into. - var emitResult = program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = isListFilesOnly + ? { emitSkipped: true, diagnostics: ts.emptyArray } + : program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics; ts.addRange(diagnostics, emitDiagnostics); ts.sortAndDeduplicateDiagnostics(diagnostics).forEach(reportDiagnostic); @@ -96353,7 +100057,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -96387,7 +100093,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -96436,7 +100142,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -96994,12 +100700,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -97155,11 +100871,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -97168,8 +100887,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -97193,11 +100911,9 @@ var ts; } function createStateBuildOrder(state) { var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); - if (ts.arrayIsEqualTo(state.buildOrder, buildOrder)) - return state.buildOrder; // Clear all to ResolvedConfigFilePaths cache to start fresh state.resolvedConfigFilePaths.clear(); - var currentProjects = ts.arrayToSet(buildOrder, function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); var noopOnDelete = { onDeleteValue: ts.noop }; // Config file cache ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); @@ -97218,6 +100934,8 @@ var ts; function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -97225,6 +100943,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -97296,7 +101015,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -97636,6 +101355,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -97692,8 +101413,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97864,10 +101588,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97926,7 +101652,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -98074,33 +101800,34 @@ var ts; setupInitialBuild(state, cancellationToken); var reportQueue = true; var successfulProjects = 0; - var errorProjects = 0; while (true) { var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue); if (!invalidatedProject) break; reportQueue = false; invalidatedProject.done(cancellationToken); - if (state.diagnostics.has(invalidatedProject.projectPath)) { - errorProjects++; - } - else { + if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; - } } disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) + ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped + : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); }) + ? ts.ExitStatus.Success + : successfulProjects + ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated + : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -98243,8 +101970,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -98276,6 +102003,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -98312,23 +102040,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -98361,13 +102099,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -98389,7 +102130,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -98777,6 +102517,15 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ + var PackageJsonDependencyGroup; + (function (PackageJsonDependencyGroup) { + PackageJsonDependencyGroup[PackageJsonDependencyGroup["Dependencies"] = 1] = "Dependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["DevDependencies"] = 2] = "DevDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["PeerDependencies"] = 4] = "PeerDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["OptionalDependencies"] = 8] = "OptionalDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["All"] = 15] = "All"; + })(PackageJsonDependencyGroup = ts.PackageJsonDependencyGroup || (ts.PackageJsonDependencyGroup = {})); + /* @internal */ ts.emptyOptions = {}; var HighlightSpanKind; (function (HighlightSpanKind) { @@ -98791,6 +102540,12 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = ts.SemicolonPreference || (ts.SemicolonPreference = {})); function getDefaultFormatCodeSettings(newLineCharacter) { return { indentSize: 4, @@ -98812,6 +102567,7 @@ var ts; insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, + semicolons: SemicolonPreference.Ignore, }; } ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; @@ -99041,37 +102797,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 278 /* CatchClause */: + case 271 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 154 /* TypeParameter */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 172 /* TypeLiteral */: return 2 /* Type */; - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 282 /* EnumMember */: + case 244 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -99081,26 +102837,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 247 /* EnumDeclaration */: + case 256 /* NamedImports */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 258 /* ExportAssignment */ || node.parent.kind === 263 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -99132,11 +102888,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 152 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 252 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -99148,27 +102904,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 152 /* QualifiedName */) { + while (root.parent && root.parent.kind === 152 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 168 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 193 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 193 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 215 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 277 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 244 /* ClassDeclaration */ && root.parent.parent.token === 112 /* ImplementsKeyword */) || + (decl.kind === 245 /* InterfaceDeclaration */ && root.parent.parent.token === 89 /* ExtendsKeyword */); } return false; } @@ -99177,17 +102933,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return true; - case 184 /* ImportType */: + case 187 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -99214,7 +102970,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 237 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -99230,11 +102986,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 73 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 73 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -99246,40 +103002,40 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 248 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 73 /* Identifier */ && + return node.kind === 75 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 282 /* EnumMember */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 248 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 186 /* LiteralType */: + return node.parent.parent.kind === 184 /* IndexedAccessType */; default: return false; } @@ -99303,17 +103059,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return node; } } @@ -99321,48 +103077,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: + case 245 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 246 /* TypeAliasDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 247 /* EnumDeclaration */: return "enum" /* enumElement */; + case 241 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 162 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 163 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 279 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 166 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 165 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 164 /* CallSignature */: return "call" /* callSignatureElement */; + case 161 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 154 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 282 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 155 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -99389,7 +103150,7 @@ var ts; return "" /* unknown */; } } - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -99405,12 +103166,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 155 /* Parameter */; default: return false; } @@ -99475,42 +103236,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 172 /* TypeLiteral */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 250 /* CaseBlock */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 196 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 195 /* CallExpression */: + case 199 /* ParenthesizedExpression */: + case 181 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 201 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -99520,65 +103281,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 191 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 194 /* ElementAccessExpression */: + case 153 /* ComputedPropertyName */: + case 174 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 110 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 203 /* TypeOfExpression */: + case 202 /* DeleteExpression */: + case 204 /* VoidExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -99710,7 +103471,7 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - return ts.firstDefined(n.getChildren(), function (child) { + return ts.firstDefined(n.getChildren(sourceFile), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -99757,7 +103518,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 288 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -99823,21 +103584,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 267 /* JsxClosingElement */) { return true; } return false; @@ -99859,7 +103620,7 @@ var ts; if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 28 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -99886,6 +103647,12 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; + function removeOptionality(type, isOptionalExpression, isOptionalChain) { + return isOptionalExpression ? type.getNonNullableType() : + isOptionalChain ? type.getNonOptionalType() : + type; + } + ts.removeOptionality = removeOptionality; function isPossiblyTypeArgumentPosition(token, sourceFile, checker) { var info = getPossibleTypeArgumentsInfo(token, sourceFile); return info !== undefined && (ts.isPartOfTypeNode(info.called) || @@ -99895,6 +103662,9 @@ var ts; ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; function getPossibleGenericSignatures(called, typeArgumentCount, checker) { var type = checker.getTypeAtLocation(called); + if (ts.isOptionalChain(called.parent)) { + type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true); + } var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; }); } @@ -99911,9 +103681,12 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); + if (token && token.kind === 28 /* QuestionDotToken */) { + token = findPrecedingToken(token.getFullStart(), sourceFile); + } if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { @@ -99921,13 +103694,13 @@ var ts; } remainingLessThanTokens--; break; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: remainingLessThanTokens++; break; case 19 /* CloseBraceToken */: @@ -99955,20 +103728,22 @@ var ts; case 27 /* CommaToken */: nTypeArguments++; break; - case 37 /* EqualsGreaterThanToken */: - case 73 /* Identifier */: + case 38 /* EqualsGreaterThanToken */: + // falls through + case 75 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 105 /* TypeOfKeyword */: - case 87 /* ExtendsKeyword */: - case 130 /* KeyOfKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + // falls through + case 107 /* TypeOfKeyword */: + case 89 /* ExtendsKeyword */: + case 133 /* KeyOfKeyword */: case 24 /* DotToken */: - case 50 /* BarToken */: - case 56 /* QuestionToken */: - case 57 /* ColonToken */: + case 51 /* BarToken */: + case 57 /* QuestionToken */: + case 58 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -100017,16 +103792,16 @@ var ts; result.push("abstract" /* abstractModifier */); if (flags & 1 /* Export */) result.push("export" /* exportedModifier */); - if (node.flags & 4194304 /* Ambient */) + if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 168 /* TypeReference */ || node.kind === 195 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 244 /* ClassDeclaration */ || node.kind === 245 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -100046,7 +103821,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 72 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 74 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -100056,9 +103831,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: return true; } return false; @@ -100071,18 +103846,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 191 /* ArrayLiteralExpression */ || + node.kind === 192 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 208 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 60 /* EqualsToken */) { + node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 231 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -100090,7 +103865,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 279 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -100134,23 +103909,23 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 121 /* AnyKeyword */, - 147 /* BigIntKeyword */, - 124 /* BooleanKeyword */, - 88 /* FalseKeyword */, - 130 /* KeyOfKeyword */, - 133 /* NeverKeyword */, - 97 /* NullKeyword */, - 136 /* NumberKeyword */, - 137 /* ObjectKeyword */, - 134 /* ReadonlyKeyword */, - 139 /* StringKeyword */, - 140 /* SymbolKeyword */, - 103 /* TrueKeyword */, - 107 /* VoidKeyword */, - 142 /* UndefinedKeyword */, - 143 /* UniqueKeyword */, - 144 /* UnknownKeyword */, + 124 /* AnyKeyword */, + 150 /* BigIntKeyword */, + 127 /* BooleanKeyword */, + 90 /* FalseKeyword */, + 133 /* KeyOfKeyword */, + 136 /* NeverKeyword */, + 99 /* NullKeyword */, + 139 /* NumberKeyword */, + 140 /* ObjectKeyword */, + 137 /* ReadonlyKeyword */, + 142 /* StringKeyword */, + 143 /* SymbolKeyword */, + 105 /* TrueKeyword */, + 109 /* VoidKeyword */, + 145 /* UndefinedKeyword */, + 146 /* UniqueKeyword */, + 147 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -100186,7 +103961,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 153 /* ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.getTextOfIdentifierOrLiteral(name); @@ -100262,7 +104037,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 73 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 75 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -100346,12 +104121,31 @@ var ts; return a.fileName === b.fileName && textSpansEqual(a.textSpan, b.textSpan); } ts.documentSpansEqual = documentSpansEqual; + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ + function forEachUnique(array, callback) { + if (array) { + for (var i = 0; i < array.length; i++) { + if (array.indexOf(array[i]) === i) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + } + return undefined; + } + ts.forEachUnique = forEachUnique; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 155 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -100392,6 +104186,8 @@ var ts; getColumn: function () { return 0; }, getLine: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingWhitespace: function () { return false; }, + hasTrailingComment: function () { return false; }, rawWrite: ts.notImplemented, getIndent: function () { return indent; }, increaseIndent: function () { indent++; }, @@ -100813,15 +104609,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 272 /* CaseClause */: + case 275 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100849,10 +104645,10 @@ var ts; ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: return true; default: return false; @@ -100863,8 +104659,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: return true; default: return false; @@ -100885,7 +104681,6 @@ var ts; var notAccessible = function () { typeIsAccessible = false; }; var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { trackSymbol: function (symbol, declaration, meaning) { - // TODO: GH#18217 typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; }, reportInaccessibleThisError: notAccessible, @@ -100903,28 +104698,90 @@ var ts; return typeIsAccessible ? res : undefined; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; - function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; - } - ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; + function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { + return kind === 164 /* CallSignature */ + || kind === 165 /* ConstructSignature */ + || kind === 166 /* IndexSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */; + } + ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; + function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { + return kind === 243 /* FunctionDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; + } + ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; + function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { + return kind === 248 /* ModuleDeclaration */; + } + ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; + function syntaxRequiresTrailingSemicolonOrASI(kind) { + return kind === 224 /* VariableStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 227 /* DoStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 233 /* BreakStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 158 /* PropertyDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 258 /* ExportAssignment */; + } + ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; + ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); + function isASICandidate(node, sourceFile) { + var lastToken = node.getLastToken(sourceFile); + if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + return false; + } + if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { + if (lastToken && lastToken.kind === 27 /* CommaToken */) { + return false; + } + } + else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isModuleBlock(lastChild)) { + return false; + } + } + else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isFunctionBlock(lastChild)) { + return false; + } + } + else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) { + return false; + } + // See comment in parser’s `parseDoStatement` + if (node.kind === 227 /* DoStatement */) { + return true; + } + var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); + var nextToken = ts.findNextToken(node, topNode, sourceFile); + if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + return true; + } + var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line; + return startLine !== endLine; + } + ts.isASICandidate = isASICandidate; function probablyUsesSemicolons(sourceFile) { var withSemicolon = 0; var withoutSemicolon = 0; var nStatementsToObserve = 5; ts.forEachChild(sourceFile, function visit(node) { - if (syntaxUsuallyHasTrailingSemicolon(node.kind)) { + if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { withSemicolon++; @@ -100947,6 +104804,150 @@ var ts; return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; } ts.probablyUsesSemicolons = probablyUsesSemicolons; + function tryGetDirectories(host, directoryName) { + return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; + } + ts.tryGetDirectories = tryGetDirectories; + function tryReadDirectory(host, path, extensions, exclude, include) { + return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || ts.emptyArray; + } + ts.tryReadDirectory = tryReadDirectory; + function tryFileExists(host, path) { + return tryIOAndConsumeErrors(host, host.fileExists, path); + } + ts.tryFileExists = tryFileExists; + function tryDirectoryExists(host, path) { + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; + } + ts.tryDirectoryExists = tryDirectoryExists; + function tryAndIgnoreErrors(cb) { + try { + return cb(); + } + catch (_a) { + return undefined; + } + } + ts.tryAndIgnoreErrors = tryAndIgnoreErrors; + function tryIOAndConsumeErrors(host, toApply) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + return tryAndIgnoreErrors(function () { return toApply && toApply.apply(host, args); }); + } + ts.tryIOAndConsumeErrors = tryIOAndConsumeErrors; + function findPackageJsons(startDirectory, host, stopDirectory) { + var paths = []; + ts.forEachAncestorDirectory(startDirectory, function (ancestor) { + if (ancestor === stopDirectory) { + return true; + } + var currentConfigPath = ts.combinePaths(ancestor, "package.json"); + if (tryFileExists(host, currentConfigPath)) { + paths.push(currentConfigPath); + } + }); + return paths; + } + ts.findPackageJsons = findPackageJsons; + function findPackageJson(directory, host) { + var packageJson; + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (ancestor === "node_modules") + return true; + packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); + if (packageJson) { + return true; // break out + } + }); + return packageJson; + } + ts.findPackageJson = findPackageJson; + function getPackageJsonsVisibleToFile(fileName, host) { + if (!host.fileExists) { + return []; + } + var packageJsons = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(fileName), function (ancestor) { + var packageJsonFileName = ts.combinePaths(ancestor, "package.json"); + if (host.fileExists(packageJsonFileName)) { + var info = createPackageJsonInfo(packageJsonFileName, host); + if (info) { + packageJsons.push(info); + } + } + }); + return packageJsons; + } + ts.getPackageJsonsVisibleToFile = getPackageJsonsVisibleToFile; + function createPackageJsonInfo(fileName, host) { + if (!host.readFile) { + return undefined; + } + var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]; + var stringContent = host.readFile(fileName); + var content = stringContent && tryParseJson(stringContent); + if (!content) { + return undefined; + } + var info = {}; + for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) { + var key = dependencyKeys_1[_i]; + var dependencies = content[key]; + if (!dependencies) { + continue; + } + var dependencyMap = ts.createMap(); + for (var packageName in dependencies) { + dependencyMap.set(packageName, dependencies[packageName]); + } + info[key] = dependencyMap; + } + var dependencyGroups = [ + [1 /* Dependencies */, info.dependencies], + [2 /* DevDependencies */, info.devDependencies], + [8 /* OptionalDependencies */, info.optionalDependencies], + [4 /* PeerDependencies */, info.peerDependencies], + ]; + return __assign(__assign({}, info), { fileName: fileName, + get: get, + has: function (dependencyName, inGroups) { + return !!get(dependencyName, inGroups); + } }); + function get(dependencyName, inGroups) { + if (inGroups === void 0) { inGroups = 15 /* All */; } + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; + if (deps && (inGroups & group_1)) { + var dep = deps.get(dependencyName); + if (dep !== undefined) { + return dep; + } + } + } + } + } + ts.createPackageJsonInfo = createPackageJsonInfo; + function tryParseJson(text) { + try { + return JSON.parse(text); + } + catch (_a) { + return undefined; + } + } + function consumesNodeCoreModules(sourceFile) { + return ts.some(sourceFile.imports, function (_a) { + var text = _a.text; + return ts.JsTyping.nodeCoreModules.has(text); + }); + } + ts.consumesNodeCoreModules = consumesNodeCoreModules; + function isInsideNodeModules(fileOrDirectory) { + return ts.contains(ts.getPathComponents(fileOrDirectory), "node_modules"); + } + ts.isInsideNodeModules = isInsideNodeModules; })(ts || (ts = {})); var ts; (function (ts) { @@ -101028,36 +105029,36 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; - case 28 /* LessThanToken */: - if (lastNonTriviaToken === 73 /* Identifier */) { + case 29 /* LessThanToken */: + if (lastNonTriviaToken === 75 /* Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 121 /* AnyKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: + case 124 /* AnyKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 73 /* Identifier */; + token = 75 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -101096,14 +105097,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 73 /* Identifier */; + token = 75 /* Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 73 /* Identifier */; + token = 75 /* Identifier */; } } } @@ -101117,19 +105118,19 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 73 /* Identifier */, + 75 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 101 /* ThisKeyword */, - 44 /* PlusPlusToken */, - 45 /* MinusMinusToken */, + 103 /* ThisKeyword */, + 45 /* PlusPlusToken */, + 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 103 /* TrueKeyword */, - 88 /* FalseKeyword */, + 105 /* TrueKeyword */, + 90 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -101241,10 +105242,10 @@ var ts; return true; } switch (keyword2) { - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 125 /* ConstructorKeyword */: - case 117 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 128 /* ConstructorKeyword */: + case 119 /* StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -101277,43 +105278,44 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 49 /* AmpersandToken */: - case 51 /* CaretToken */: - case 50 /* BarToken */: - case 54 /* AmpersandAmpersandToken */: - case 55 /* BarBarToken */: - case 71 /* BarEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 60 /* EqualsToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 50 /* AmpersandToken */: + case 52 /* CaretToken */: + case 51 /* BarToken */: + case 55 /* AmpersandAmpersandToken */: + case 56 /* BarBarToken */: + case 73 /* BarEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: + case 60 /* QuestionQuestionToken */: return true; default: return false; @@ -101321,12 +105323,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: return true; default: return false; @@ -101339,7 +105341,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 72 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 74 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -101358,7 +105360,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 73 /* Identifier */: + case 75 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -101383,10 +105385,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -101413,8 +105415,10 @@ var ts; }); return { spans: spans, endOfLineState: 0 /* None */ }; function pushClassification(start, end, type) { + var length = end - start; + ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); spans.push(start); - spans.push(end - start); + spans.push(length); spans.push(type); } } @@ -101604,18 +105608,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 307 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 308 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -101656,6 +105660,7 @@ var ts; // defined in `ts.commentPragmas` would be excessive, but we can avoid // some obvious false positives (e.g. in XML-like doc comments) by // checking the element name. + // eslint-disable-next-line no-in-operator if (!match[3] || !(match[3] in ts.commentPragmas)) { return false; } @@ -101765,22 +105770,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -101797,7 +105802,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* GreaterThanToken */) { + if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -101807,19 +105812,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 60 /* EqualsToken */) { + if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 241 /* VariableDeclaration */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 155 /* Parameter */ || + parent.kind === 271 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 208 /* BinaryExpression */ || + parent.kind === 206 /* PrefixUnaryExpression */ || + parent.kind === 207 /* PostfixUnaryExpression */ || + parent.kind === 209 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -101832,8 +105837,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 271 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -101846,35 +105850,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 73 /* Identifier */) { + else if (tokenKind === 75 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 155 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -101997,11 +106001,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -102009,9 +106013,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 187 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 177 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -102021,7 +106025,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -102038,7 +106042,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -102051,8 +106055,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -102061,9 +106065,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 263 /* ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); @@ -102091,7 +106095,7 @@ var ts; var candidates = []; checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); var types = ts.flatMap(candidates, function (candidate) { - if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) + if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length) return; var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); @@ -102107,11 +106111,8 @@ var ts; if (!type) return ts.emptyArray; type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; + return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : + type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; @@ -102201,10 +106202,10 @@ var ts; var absolutePath = ts.resolvePath(scriptPath, fragment); var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (!tryDirectoryExists(host, baseDirectory)) + if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { /** * Multiple file entries might map to the same truncated name once we remove extensions @@ -102227,7 +106228,7 @@ var ts; }); } // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); + var directories = ts.tryGetDirectories(host, baseDirectory); if (directories) { for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var directory = directories_1[_b]; @@ -102238,7 +106239,7 @@ var ts; } } // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); + var packageJsonPath = ts.findPackageJson(baseDirectory, host); if (packageJsonPath) { var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; @@ -102316,7 +106317,7 @@ var ts; if (!foundGlobal) { ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); - if (tryDirectoryExists(host, nodeModules)) { + if (ts.tryDirectoryExists(host, nodeModules)) { getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); @@ -102366,12 +106367,12 @@ var ts; // that encodes the suffix, but we would have to escape the character "?" which readDirectory // doesn't support. For now, this is safer but slower var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = ts.mapDefined(tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); }); - var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { var name = trimPrefixAndSuffix(dir); return name === undefined ? undefined : directoryResult(name); }); @@ -102423,22 +106424,22 @@ var ts; if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { var root = typeRoots_1[_i]; getCompletionEntriesFromDirectories(root); } // Also get all @types typings installed in visible node_modules directories - for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + for (var _a = 0, _b = ts.findPackageJsons(scriptPath, host); _a < _b.length; _a++) { var packageJson = _b[_a]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); getCompletionEntriesFromDirectories(typesDir); } return result; function getCompletionEntriesFromDirectories(directory) { - if (!tryDirectoryExists(host, directory)) + if (!ts.tryDirectoryExists(host, directory)) return; - for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.tryGetDirectories(host, directory); _i < _a.length; _i++) { var typeDirectoryName = _a[_i]; var packageName = ts.unmangleScopedPackageName(typeDirectoryName); if (options.types && !ts.contains(options.types, packageName)) @@ -102459,34 +106460,11 @@ var ts; } } } - function findPackageJsons(directory, host) { - var paths = []; - ts.forEachAncestorDirectory(directory, function (ancestor) { - var currentConfigPath = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (!currentConfigPath) { - return true; // break out - } - paths.push(currentConfigPath); - }); - return paths; - } - function findPackageJson(directory, host) { - var packageJson; - ts.forEachAncestorDirectory(directory, function (ancestor) { - if (ancestor === "node_modules") - return true; - packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (packageJson) { - return true; // break out - } - }); - return packageJson; - } function enumerateNodeModulesVisibleToScript(host, scriptPath) { if (!host.readFile || !host.fileExists) return ts.emptyArray; var result = []; - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.findPackageJsons(scriptPath, host); _i < _a.length; _i++) { var packageJson = _a[_i]; var contents = ts.readJson(packageJson, host); // Cast to assert that readFile is defined // Provide completions for all non @types dependencies @@ -102535,33 +106513,6 @@ var ts; */ var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*" with type any // And at `
` (with a closing `>`), the completion list will contain "div". var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 30 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -102734,14 +106744,25 @@ var ts; function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; var replacementSpan; - if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; + var insertQuestionDot = origin && originIsNullableMember(origin); + var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; + if (origin && originIsThisType(origin)) { + insertText = needsConvertPropertyAccess + ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]" + : "this" + (insertQuestionDot ? "?." : ".") + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. - else if ((origin && originIsSymbolMember(origin) || needsConvertPropertyAccess) && propertyAccessToConvert) { - insertText = needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); + else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { + insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name; + if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { + insertText = "?." + insertText; + } + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + if (!dot) { + return undefined; + } // If the text after the '.' starts with this name, write over it. Else, add new text. var end = ts.startsWith(name, propertyAccessToConvert.name.text) ? propertyAccessToConvert.name.end : dot.end; replacementSpan = ts.createTextSpanFromBounds(dot.getStart(sourceFile), end); @@ -102754,6 +106775,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -102848,9 +106876,9 @@ var ts; } return entries; } - function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { + function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) { var compilerOptions = program.getCompilerOptions(); - var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { return { type: "none" }; } @@ -102890,7 +106918,7 @@ var ts; return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); } // Compute all the completion symbols again. - var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); switch (symbolCompletion.type) { case "request": { var request = symbolCompletion.request; @@ -102946,8 +106974,8 @@ var ts; var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } - function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { - var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) { + var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); return completion.type === "symbol" ? completion.symbol : undefined; } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; @@ -102980,34 +107008,34 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return checker.getContextualType(parent); - case 75 /* CaseKeyword */: + case 77 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 264 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side - ? checker.getTypeAtLocation(parent.left) - : checker.getContextualType(previousToken); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -103017,9 +107045,9 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 288 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 @@ -103068,11 +107096,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 313 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 316 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -103108,6 +107136,7 @@ var ts; var node = currentToken; var propertyAccessToConvert; var isRightOfDot = false; + var isRightOfQuestionDot = false; var isRightOfOpenTag = false; var isStartingCloseTag = false; var isJsxInitializer = false; @@ -103119,10 +107148,11 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */) { - isRightOfDot = true; + if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -103134,14 +107164,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 187 /* ImportType */: + case 218 /* MetaProperty */: node = parent; break; default: @@ -103154,56 +107184,56 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 193 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + case 31 /* GreaterThanToken */: + if (currentToken.parent.kind === 264 /* JsxElement */ || currentToken.parent.kind === 266 /* JsxOpeningElement */) { location = currentToken; } break; - case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + case 43 /* SlashToken */: + if (currentToken.parent.kind === 265 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: - if (contextToken.kind === 42 /* SlashToken */) { + case 267 /* JsxClosingElement */: + if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: - if (contextToken.kind === 28 /* LessThanToken */) { + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: + case 266 /* JsxOpeningElement */: + if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: switch (previousToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: isJsxInitializer = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 60 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 62 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -103215,10 +107245,12 @@ var ts; var completionKind = 5 /* None */; var isNewIdentifierLocation = false; var keywordFilters = 0 /* None */; + // This also gets mutated in nested-functions after the return var symbols = []; var symbolToOriginInfoMap = []; var symbolToSortTextMap = []; - if (isRightOfDot) { + var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { @@ -103268,11 +107300,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 312 /* JSDocTypedefTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 315 /* JSDocTypedefTag */: return true; default: return false; @@ -103316,24 +107348,54 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 288 /* SourceFile */ && d.kind !== 248 /* ModuleDeclaration */ && d.kind !== 247 /* EnumDeclaration */; })) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + var canCorrectToQuestionDot = isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 96 /* NewKeyword */ || node.keywordToken === 93 /* ImportKeyword */)) { - var completion = (node.keywordToken === 96 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 98 /* NewKeyword */ || node.keywordToken === 95 /* ImportKeyword */)) { + var completion = (node.keywordToken === 98 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + var type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + var canCorrectToQuestionDot = isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait, insertQuestionDot) { isNewIdentifierLocation = !!type.getStringIndexType(); + if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { + isNewIdentifierLocation = true; + } + var propertyAccess = node.kind === 187 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -103345,13 +107407,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { - addPropertySymbol(symbol); + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { + addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); + } + } + } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true, insertQuestionDot); + } } } } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait, insertQuestionDot) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -103365,15 +107438,32 @@ var ts; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) + ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } + : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addSymbolOriginInfo(symbol); symbols.push(symbol); } + function addSymbolOriginInfo(symbol) { + if (preferences.includeCompletionsWithInsertText) { + if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + } + else if (insertQuestionDot) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + } + } + } + function getNullableSymbolOriginInfoKind(kind) { + return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -103406,6 +107496,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -103459,19 +107550,38 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 288 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ }; + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; } } } if (shouldOfferImportCompletions()) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && ts.isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target); + var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); + if (!detailsEntryId && importSuggestionsCache) { + importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); + } + autoImportSuggestions.forEach(function (_a) { + var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; + if (detailsEntryId) { + if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { + return; + } + } + else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { + return; + } + var symbolId = ts.getSymbolId(symbol); + symbols.push(symbol); + symbolToOriginInfoMap[symbolId] = origin; + symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; + }); } filterGlobalCompletion(symbols); } @@ -103493,10 +107603,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 210 /* TemplateExpression */: + case 274 /* JsxExpression */: + case 222 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -103541,28 +107651,28 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 107 /* TypeOfKeyword */ && + (contextToken.parent.kind === 171 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + case 58 /* ColonToken */: + return parentKind === 158 /* PropertyDeclaration */ || + parentKind === 157 /* PropertySignature */ || + parentKind === 155 /* Parameter */ || + parentKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; - case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; - case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; - case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + case 62 /* EqualsToken */: + return parentKind === 246 /* TypeAliasDeclaration */; + case 122 /* AsKeyword */: + return parentKind === 216 /* AsExpression */; + case 29 /* LessThanToken */: + return parentKind === 168 /* TypeReference */ || + parentKind === 198 /* TypeAssertionExpression */; + case 89 /* ExtendsKeyword */: + return parentKind === 154 /* TypeParameter */; } } return false; @@ -103576,10 +107686,71 @@ var ts; ts.addToSeen(seenModules, ts.getSymbolId(sym)) && typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); } - function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { - var tokenTextLowerCase = tokenText.toLowerCase(); + /** + * Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates" + * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but + * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, + * if and only if the the first can be imported (it may be excluded due to package.json filtering in + * `codefix.forEachExternalModuleToImportFrom`). + * + * Example. Imagine a chain of node_modules re-exporting one original symbol: + * + * ```js + * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js + * +-----------------------+ +--------------------------+ +--------------------------+ + * | | | | | | + * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | + * | | | | | | + * +-----------------------+ +--------------------------+ +--------------------------+ + * ``` + * + * Also imagine three buckets, which we’ll reference soon: + * + * ```md + * | | | | | | + * | **Bucket A** | | **Bucket B** | | **Bucket C** | + * | Symbols to | | Aliases to symbols | | Symbols to return | + * | definitely | | in Buckets A or C | | if nothing better | + * | return | | (don’t return these) | | comes along | + * |__________________| |______________________| |___________________| + * ``` + * + * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it + * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not + * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we + * may not be sure whether or not it should go in the list. So, we’ll take the following steps: + * + * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is + * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B + * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. + * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. + * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' + * should never be returned in the final list, so put it in Bucket B. + * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so + * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. + * Put this symbol in Bucket A. + * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t + * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move + * everything from Bucket C to Bucket A. + */ + function getSymbolsFromOtherSourceFileExports(target, host) { + var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); + if (cached) { + log("getSymbolsFromOtherSourceFileExports: Using cached list"); + return cached; + } + var startTime = ts.timestamp(); + log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); var seenResolvedModules = ts.createMap(); - ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + /** Bucket B */ + var aliasesToAlreadyIncludedSymbols = ts.createMap(); + /** Bucket C */ + var aliasesToReturnIfOriginalsAreMissing = ts.createMap(); + /** Bucket A */ + var results = []; + /** Ids present in `results` for faster lookup */ + var resultSymbolIds = ts.createMap(); + ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; @@ -103589,41 +107760,75 @@ var ts; if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { return; } + // Don't add another completion for `export =` of a symbol that's already global. + // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. if (resolvedModuleSymbol !== moduleSymbol && - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { - symbols.push(resolvedModuleSymbol); - symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator && !ts.findAncestor(d, ts.isGlobalScopeAugmentation); })) { + pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true); } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; - // Don't add a completion for a re-export, only for the original. - // The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details. - // This is just to avoid adding duplicate completion entries. - // - // If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols. - if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol - || ts.some(symbol.declarations, function (d) { - // If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion. - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - return ts.isExportSpecifier(d) && (d.propertyName ? ts.isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier); - })) { + // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. + if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { continue; } - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + var symbolId = ts.getSymbolId(symbol).toString(); + // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. + var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; + // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { + // Walk the export chain back one module (step 1 or 2 in diagrammed example). + // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. + var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); + if (!nearestExportSymbol) + continue; + var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); + var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); + if (!symbolHasBeenSeen) { + aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol }); + aliasesToAlreadyIncludedSymbols.set(symbolId, true); + } + else { + // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here + // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. + ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); + } } - var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; - if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { - symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin; + else { + // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.delete(symbolId); + pushSymbol(symbol, moduleSymbol); } } }); + // By this point, any potential duplicates that were actually duplicates have been + // removed, so the rest need to be added. (Step 4 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { + var alias = _a.alias, moduleSymbol = _a.moduleSymbol; + return pushSymbol(alias, moduleSymbol); + }); + log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); + return results; + function pushSymbol(symbol, moduleSymbol, skipFilter) { + if (skipFilter === void 0) { skipFilter = false; } + var isDefaultExport = symbol.escapedName === "default" /* Default */; + if (isDefaultExport) { + symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + } + ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); + var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; + results.push({ + symbol: symbol, + symbolName: getSymbolName(symbol, origin, target), + origin: origin, + skipFilter: skipFilter, + }); + } + } + function getNearestExportSymbol(fromSymbol) { + return findAlias(typeChecker, fromSymbol, function (alias) { + return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); + }); } /** * True if you could remove some characters in `a` to get `b`. @@ -103670,12 +107875,12 @@ var ts; if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 266 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 267 /* JsxClosingElement */ || contextToken.parent.kind === 265 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 264 /* JsxElement */; } } return false; @@ -103686,40 +107891,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 195 /* CallExpression */ // func( a, | + || containingNodeKind === 161 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 196 /* NewExpression */ // new C(a, | + || containingNodeKind === 191 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 208 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 169 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 195 /* CallExpression */ // func( | + || containingNodeKind === 161 /* Constructor */ // constructor( | + || containingNodeKind === 196 /* NewExpression */ // new C(a| + || containingNodeKind === 199 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 181 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 131 /* ModuleKeyword */: // module | - case 132 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 191 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 166 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 153 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 134 /* ModuleKeyword */: // module | + case 135 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 248 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | - case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 244 /* ClassDeclaration */; // class A{ | + case 62 /* EqualsToken */: + return containingNodeKind === 241 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 208 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 210 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 220 /* TemplateSpan */; // `aa ${10} dd ${| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -103746,8 +107951,8 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { - var typeForObject = typeChecker.getContextualType(objectLikeContainer); + if (objectLikeContainer.kind === 192 /* ObjectLiteralExpression */) { + var typeForObject = typeChecker.getContextualType(objectLikeContainer, 4 /* Completion */); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = ts.hasIndexSignature(typeForObject); @@ -103755,7 +107960,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 188 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -103766,12 +107971,12 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 231 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 155 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 160 /* MethodDeclaration */ || rootDeclaration.parent.kind === 163 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -103788,6 +107993,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -103813,7 +108019,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 256 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -103836,7 +108042,7 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) @@ -103844,7 +108050,7 @@ var ts; var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 75 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -103879,9 +108085,9 @@ var ts; return parent; } break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 73 /* Identifier */: + case 75 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -103931,23 +108137,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 30 /* GreaterThanToken */: // End of a type argument list - case 29 /* LessThanSlashToken */: - case 42 /* SlashToken */: - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { - if (contextToken.kind === 30 /* GreaterThanToken */) { + case 31 /* GreaterThanToken */: // End of a type argument list + case 30 /* LessThanSlashToken */: + case 43 /* SlashToken */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 272 /* JsxAttributes */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 265 /* JsxSelfClosingElement */ || parent.kind === 266 /* JsxOpeningElement */)) { + if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) break; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103959,7 +108165,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 271 /* JsxAttribute */) || (parent.kind === 273 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103969,8 +108175,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 274 /* JsxExpression */ && + parent.parent && parent.parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103978,7 +108184,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 273 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103998,64 +108204,64 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 241 /* VariableDeclaration */ || + containingNodeKind === 242 /* VariableDeclarationList */ || + containingNodeKind === 224 /* VariableStatement */ || + containingNodeKind === 247 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| - case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [.| + case 58 /* ColonToken */: + return containingNodeKind === 190 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 278 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | - case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 247 /* EnumDeclaration */; // enum a { | + case 29 /* LessThanToken */: + return containingNodeKind === 244 /* ClassDeclaration */ || // class A< | + containingNodeKind === 213 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 245 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 246 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 119 /* StaticKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + return containingNodeKind === 155 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 189 /* ArrayBindingPattern */); // var [...z| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 155 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 122 /* AsKeyword */: + return containingNodeKind === 257 /* ImportSpecifier */ || + containingNodeKind === 261 /* ExportSpecifier */ || + containingNodeKind === 255 /* NamespaceImport */; + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 111 /* InterfaceKeyword */: - case 91 /* FunctionKeyword */: - case 106 /* VarKeyword */: - case 93 /* ImportKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 118 /* YieldKeyword */: - case 141 /* TypeKeyword */: // type htm| + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 113 /* InterfaceKeyword */: + case 93 /* FunctionKeyword */: + case 108 /* VarKeyword */: + case 95 /* ImportKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 120 /* YieldKeyword */: + case 144 /* TypeKeyword */: // type htm| return true; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -104076,22 +108282,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 119 /* AbstractKeyword */: - case 77 /* ClassKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 91 /* FunctionKeyword */: - case 111 /* InterfaceKeyword */: - case 112 /* LetKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 117 /* StaticKeyword */: - case 106 /* VarKeyword */: - case 118 /* YieldKeyword */: + case 121 /* AbstractKeyword */: + case 79 /* ClassKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 93 /* FunctionKeyword */: + case 113 /* InterfaceKeyword */: + case 114 /* LetKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 119 /* StaticKeyword */: + case 108 /* VarKeyword */: + case 120 /* YieldKeyword */: return true; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -104101,7 +108307,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 161 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -104120,16 +108326,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 279 /* PropertyAssignment */ && + m.kind !== 280 /* ShorthandPropertyAssignment */ && + m.kind !== 190 /* BindingElement */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */ && + m.kind !== 281 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -104137,9 +108345,12 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 73 /* Identifier */) { + if (m.propertyName.kind === 75 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -104152,7 +108363,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -104164,10 +108408,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 158 /* PropertyDeclaration */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -104201,17 +108445,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 271 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -104222,7 +108472,7 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.startsWithQuote(name) + || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; @@ -104251,7 +108501,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 76 /* FirstKeyword */; i <= 151 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -104277,9 +108527,11 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 126 /* DeclareKeyword */ - || kind === 131 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 142 /* UndefinedKeyword */; + || kind === 129 /* DeclareKeyword */ + || kind === 134 /* ModuleKeyword */ + || kind === 144 /* TypeKeyword */ + || kind === 135 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 145 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -104289,7 +108541,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 78 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 80 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -104299,55 +108551,55 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 121 /* AnyKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 146 /* GlobalKeyword */: - case 110 /* ImplementsKeyword */: - case 128 /* InferKeyword */: - case 111 /* InterfaceKeyword */: - case 129 /* IsKeyword */: - case 130 /* KeyOfKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 133 /* NeverKeyword */: - case 136 /* NumberKeyword */: - case 137 /* ObjectKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: - case 139 /* StringKeyword */: - case 140 /* SymbolKeyword */: - case 141 /* TypeKeyword */: - case 143 /* UniqueKeyword */: - case 144 /* UnknownKeyword */: + case 121 /* AbstractKeyword */: + case 124 /* AnyKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 149 /* GlobalKeyword */: + case 112 /* ImplementsKeyword */: + case 131 /* InferKeyword */: + case 113 /* InterfaceKeyword */: + case 132 /* IsKeyword */: + case 133 /* KeyOfKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 136 /* NeverKeyword */: + case 139 /* NumberKeyword */: + case 140 /* ObjectKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: + case 142 /* StringKeyword */: + case 143 /* SymbolKeyword */: + case 144 /* TypeKeyword */: + case 146 /* UniqueKeyword */: + case 147 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 134 /* ReadonlyKeyword */; + return kind === 137 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 125 /* ConstructorKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 122 /* AsyncKeyword */: + case 121 /* AbstractKeyword */: + case 128 /* ConstructorKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 125 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 122 /* AsyncKeyword */ - || kind === 123 /* AwaitKeyword */ + return kind === 125 /* AsyncKeyword */ + || kind === 126 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -104385,7 +108637,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 314 /* SyntaxList */: + case 317 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -104393,7 +108645,7 @@ var ts; return cls; } break; - case 73 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } + case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return ts.findAncestor(location, ts.isObjectTypeDeclaration); } @@ -104419,7 +108671,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -104439,11 +108691,11 @@ var ts; return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -104452,6 +108704,14 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } + function findAlias(typeChecker, symbol, predicate) { + var currentAlias = symbol; + while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { + if (predicate(currentAlias)) { + return currentAlias; + } + } + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -104504,40 +108764,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 92 /* IfKeyword */: - case 84 /* ElseKeyword */: + case 94 /* IfKeyword */: + case 86 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 98 /* ReturnKeyword */: + case 100 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 104 /* TryKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: - var tryStatement = node.kind === 76 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 106 /* TryKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: + var tryStatement = node.kind === 78 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 75 /* CaseKeyword */: - case 81 /* DefaultKeyword */: + case 77 /* CaseKeyword */: + case 83 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 74 /* BreakKeyword */: - case 79 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 81 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 90 /* ForKeyword */: - case 108 /* WhileKeyword */: - case 83 /* DoKeyword */: + case 92 /* ForKeyword */: + case 110 /* WhileKeyword */: + case 85 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 125 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [125 /* ConstructorKeyword */]); - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [127 /* GetKeyword */, 138 /* SetKeyword */]); - case 123 /* AwaitKeyword */: + case 128 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [128 /* ConstructorKeyword */]); + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [130 /* GetKeyword */, 141 /* SetKeyword */]); + case 126 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 118 /* YieldKeyword */: + case 120 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -104580,7 +108840,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 288 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -104612,16 +108872,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 236 /* SwitchStatement */: + if (statement.kind === 232 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -104637,11 +108897,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 222 /* Block */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArrays(declaration.members, [declaration]); @@ -104649,14 +108909,14 @@ var ts; else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 172 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. @@ -104687,12 +108947,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 92 /* ForKeyword */, 110 /* WhileKeyword */, 85 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 227 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 110 /* WhileKeyword */)) { break; } } @@ -104700,7 +108960,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */, 79 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */, 81 /* ContinueKeyword */); } }); return keywords; @@ -104709,13 +108969,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -104723,13 +108983,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 100 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 102 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 75 /* CaseKeyword */, 81 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 77 /* CaseKeyword */, 83 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */); } }); }); @@ -104737,13 +108997,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 104 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 106 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 76 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 78 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 89 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 91 /* FinallyKeyword */); } return keywords; } @@ -104754,13 +109014,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -104772,11 +109032,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -104788,13 +109048,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 122 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 125 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 123 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 126 /* AwaitKeyword */); } }); }); @@ -104809,7 +109069,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 118 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 120 /* YieldKeyword */); } }); }); @@ -104828,7 +109088,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 84 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 86 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -104863,10 +109123,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 92 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 94 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 84 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 86 /* ElseKeyword */)) { break; } } @@ -105082,12 +109342,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 241 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { directImports.push(name); break; } @@ -105096,22 +109356,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 73 /* Identifier */: // for 'const x = require("y"); + case 75 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 255 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -105121,7 +109381,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 187 /* ImportType */: directImports.push(direct); break; default: @@ -105138,7 +109398,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 288 /* SourceFile */ || sourceFileLike.kind === 248 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -105193,17 +109453,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 252 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 73 /* Identifier */) { + if (decl.kind === 75 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 187 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -105218,17 +109478,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 259 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -105278,7 +109538,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 261 /* ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -105307,7 +109567,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 285 /* SourceFile */) { + if (searchSourceFile.kind === 288 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -105355,7 +109615,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 288 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -105370,15 +109630,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -105402,7 +109662,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 193 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -105536,13 +109796,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -105575,21 +109835,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 288 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 249 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 248 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 263 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -105638,7 +109898,7 @@ var ts; if (ts.isInJSFile(node)) { var binaryExpression = ts.isBinaryExpression(node.parent) ? node.parent : - ts.isPropertyAccessExpression(node.parent) && + ts.isAccessExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && node.parent.parent.left === node.parent ? node.parent.parent : @@ -105682,7 +109942,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 81 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 83 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -105691,7 +109951,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -105699,27 +109959,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -105763,18 +110023,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 99 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -105863,7 +110123,7 @@ var ts; return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 83 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -105918,13 +110178,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 213 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105953,7 +110213,7 @@ var ts; function getTextSpan(node, sourceFile, endNode) { var start = node.getStart(sourceFile); var end = (endNode || node).getEnd(); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { ts.Debug.assert(endNode === undefined); start += 1; end -= 1; @@ -105968,7 +110228,7 @@ var ts; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 81 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 83 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -105976,49 +110236,49 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 4194304 /* Ambient */)) + if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 208 /* BinaryExpression */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 83 /* DefaultKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 261 /* ExportSpecifier */: + case 254 /* ImportClause */: // default import + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 245 /* InterfaceDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 271 /* JsxAttribute */: + case 248 /* ModuleDeclaration */: + case 251 /* NamespaceExportDeclaration */: + case 255 /* NamespaceImport */: + case 155 /* Parameter */: + case 280 /* ShorthandPropertyAssignment */: + case 246 /* TypeAliasDeclaration */: + case 154 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: + case 159 /* MethodSignature */: + case 157 /* PropertySignature */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -106178,10 +110438,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -106198,11 +110458,9 @@ var ts; var sourceFile = decl.getSourceFile(); if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` - var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) - ? decl.left.expression - : ts.isExportAssignment(decl) - ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 88 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } @@ -106211,21 +110469,21 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 134 /* ReadonlyKeyword */ + return node.kind === 137 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 134 /* ReadonlyKeyword */; + && node.parent.operator === 137 /* ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 134 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 137 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 134 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 137 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -106241,7 +110499,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -106258,7 +110516,7 @@ var ts; // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 81 /* DefaultKeyword */) { + else if (node && node.kind === 83 /* DefaultKeyword */) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } @@ -106286,9 +110544,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: return 1 /* Constructor */; - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -106524,7 +110782,7 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 200 /* FunctionExpression */ || valueDeclaration.kind === 213 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -106534,7 +110792,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 244 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -106563,7 +110821,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -106671,8 +110929,9 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.text.length === searchSymbolName.length; + case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && @@ -106680,7 +110939,7 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 81 /* DefaultKeyword */: + case 83 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -106746,7 +111005,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 73 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 75 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -106802,12 +111061,14 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 81 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 81 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 83 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 83 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol); - var exportInfo = ts.Debug.assertDefined(FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker)); - searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); + var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); + if (exportInfo) { + searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); + } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { @@ -106866,7 +111127,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -106882,7 +111143,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 81 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 83 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -106909,7 +111170,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 101 /* ThisKeyword */) { + if (node.kind === 103 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -106928,18 +111189,18 @@ var ts; if (constructorSymbol) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 128 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 161 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 160 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 103 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -106960,10 +111221,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 161 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 101 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -106987,10 +111248,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 73 /* Identifier */) { + if (refNode.kind !== 75 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 280 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -107010,7 +111271,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 222 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -107038,13 +111299,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 191 /* ArrayLiteralExpression */: return true; default: return false; @@ -107097,13 +111358,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -107112,7 +111373,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 99 /* SuperKeyword */) { + if (node.kind !== 101 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -107124,41 +111385,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 75 /* Identifier */ && node.parent.kind === 155 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 288 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -107166,19 +111427,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 288 /* SourceFile */: + return container.kind === 288 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -107297,7 +111558,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 190 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -107347,11 +111608,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -107401,12 +111661,12 @@ var ts; /* @internal */ var ts; (function (ts) { - function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, _preferences, sourceMapper) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences, sourceMapper) { var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); - return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, function (changeTracker) { updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); @@ -107654,9 +111914,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); + return node.kind === 101 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -107664,7 +111924,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -107817,31 +112077,32 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 73 /* Identifier */) { + if (node.kind !== 75 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 257 /* ImportSpecifier */: + return declaration.parent.kind === 256 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { // There are cases when you extend a function by adding properties to it afterwards, - // we want to strip those extra properties - var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return !ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration; }) || undefined; + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 128 /* ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -107856,8 +112117,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -107910,9 +112175,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return true; default: return false; @@ -108014,7 +112279,7 @@ var ts; // The property length will have two declarations of property length coming // from Array - Array and Array var documentationComment = []; - forEachUnique(declarations, function (declaration) { + ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var comment = _a[_i].comment; if (comment === undefined) @@ -108030,11 +112295,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return [declaration]; - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -108043,7 +112308,7 @@ var ts; function getJsDocTagsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once. var tags = []; - forEachUnique(declarations, function (declaration) { + ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { var tag = _a[_i]; tags.push({ name: tag.tagName.text, text: getCommentText(tag) }); @@ -108055,16 +112320,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return withNode(tag.class); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -108080,24 +112345,6 @@ var ts; return comment === undefined ? s : s + " " + comment; } } - /** - * Iterates through 'array' by index and performs the callback on each element of array until the callback - * returns a truthy value, then returns that value. - * If no such value is found, the callback is applied to each element of array and undefined is returned. - */ - function forEachUnique(array, callback) { - if (array) { - for (var i = 0; i < array.length; i++) { - if (array.indexOf(array[i]) === i) { - var result = callback(array[i], i); - if (result) { - return result; - } - } - } - } - return undefined; - } function getJSDocTagNameCompletions() { return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { @@ -108241,7 +112488,7 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 73 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 75 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -108251,23 +112498,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 159 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 157 /* PropertySignature */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 246 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -108275,14 +112522,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 288 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 248 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 208 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -108301,14 +112548,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 199 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 213 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -108370,9 +112617,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -108382,7 +112629,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 153 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -108399,7 +112646,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 153 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -108443,6 +112690,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -108457,6 +112705,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -108467,13 +112720,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -108499,7 +112754,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -108524,28 +112779,56 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isPropertyNameLiteral(entityName)) { + var name = ts.getNameOrArgument(entityName); + var nameText = ts.getElementOrPropertyAccessName(entityName); + entityName = entityName.expression; + if (nameText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -108555,46 +112838,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 159 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -108606,90 +112891,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 280 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 281 /* SpreadAssignment */: + var expression = node.expression; + // Use the expression as the name of the SpreadAssignment, otherwise show as . + ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); + break; + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: + case 241 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + addNodeWithRecursiveChild(node, node.body); + break; + case 247 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 261 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 166 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 246 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && ts.getElementOrPropertyAccessName(assignmentTarget) !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else if (ts.isBindableStaticAccessExpression(assignmentTarget)) { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, ts.getNameOrArgument(assignmentTarget)); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -108712,8 +113075,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -108727,7 +113090,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -108736,7 +113099,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -108744,7 +113107,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -108757,12 +113213,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -108778,7 +113234,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 248 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -108808,43 +113264,46 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 248 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); if (declName && ts.isPropertyName(declName)) { - return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 + var propertyName = ts.getPropertyNameForPropertyNameNode(declName); + return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 248 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text + : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -108852,24 +113311,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 164 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -108879,28 +113341,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 246 /* TypeAliasDeclaration */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -108910,21 +113372,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -108937,18 +113393,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108979,7 +113435,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -108993,13 +113449,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 153 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 288 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 241 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -109007,14 +113463,14 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -109031,7 +113487,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -109052,14 +113512,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -109073,8 +113543,8 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, _preferences) { - var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext }); + function organizeImports(sourceFile, formatContext, host, program, preferences) { + var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); var coalesceAndOrganizeImports = function (importGroup) { return coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); @@ -109402,7 +113872,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 93 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 95 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -109519,7 +113989,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -109527,23 +113997,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 227 /* DoStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 278 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - return spanForNode(ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -109551,24 +114021,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 250 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -109610,7 +114080,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 201 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -110145,10 +114615,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 126 /* DeclareKeyword */) { + if (token === 129 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 131 /* ModuleKeyword */) { + if (token === 134 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -110166,7 +114636,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 93 /* ImportKeyword */) { + if (token === 95 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -110182,9 +114652,9 @@ var ts; return true; } else { - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -110192,7 +114662,7 @@ var ts; return true; } } - else if (token === 60 /* EqualsToken */) { + else if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -110215,7 +114685,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -110225,13 +114695,13 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 120 /* AsKeyword */) { + if (token === 122 /* AsKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -110249,7 +114719,7 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 86 /* ExportKeyword */) { + if (token === 88 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); if (token === 18 /* OpenBraceToken */) { @@ -110261,7 +114731,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -110271,9 +114741,9 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -110281,11 +114751,11 @@ var ts; } } } - else if (token === 93 /* ImportKeyword */) { + else if (token === 95 /* ImportKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 60 /* EqualsToken */) { + if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -110298,7 +114768,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 135 /* RequireKeyword */) { + if (token === 138 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -110313,7 +114783,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 73 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 75 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -110447,14 +114917,14 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 81 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 83 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 153 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -110501,7 +114971,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { // Exclude the quotes start += 1; width -= 2; @@ -110510,9 +114980,10 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -110552,7 +115023,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -110664,14 +115135,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 134 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 56 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 137 /* ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 154 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -110679,7 +115150,7 @@ var ts; // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; })), closeBraceToken, ]; @@ -110691,7 +115162,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -110704,14 +115175,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } return node.getChildren(); @@ -110778,7 +115249,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(314 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(317 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -110787,14 +115258,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 266 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 267 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -110887,7 +115358,7 @@ var ts; var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -110946,7 +115417,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -110999,10 +115470,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 197 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 210 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -111069,17 +115540,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 199 /* ParenthesizedExpression */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -111150,11 +115621,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -111203,7 +115674,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -111268,8 +115739,8 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(); - var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(28 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(29 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { @@ -111302,7 +115773,7 @@ var ts; var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(30 /* GreaterThanToken */)], parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -111378,6 +115849,10 @@ var ts; if (!sourceFile) return undefined; var program = host.getProgram(); + // If this is source file of project reference source (instead of redirect) there is no generated position + if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) { + return undefined; + } var options = program.getCompilerOptions(); var outPath = options.outFile || options.out; var declarationPath = outPath ? @@ -111515,7 +115990,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -111525,7 +116000,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -111558,11 +116033,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -111579,12 +116054,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 255 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -111642,13 +116117,13 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ - case 97 /* NullKeyword */: - case 73 /* Identifier */: // identifier includes undefined + // falls through + case 99 /* NullKeyword */: + case 75 /* Identifier */: // identifier includes undefined return true; default: return false; @@ -111671,7 +116146,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -111708,7 +116183,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 101 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 103 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -111759,11 +116234,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + return location.kind === 75 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 271 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -111790,13 +116265,13 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 101 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 103 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 101 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(101 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 103 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(103 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { @@ -111806,7 +116281,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 193 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -111826,7 +116301,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 196 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 101 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -111844,7 +116319,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -111861,14 +116336,14 @@ var ts; case "parameter" /* parameterElement */: case "local var" /* localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -111881,29 +116356,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 128 /* ConstructorKeyword */ && location.parent.kind === 161 /* Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration - var locationIsSymbolDeclaration = ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { + return declaration === (location.kind === 128 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 161 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 161 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 164 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -111913,7 +116388,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -111921,7 +116396,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(77 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(79 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -111929,37 +116404,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(111 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(113 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(78 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(80 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(85 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(87 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 248 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 75 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 135 /* NamespaceKeyword */ : 134 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -111978,7 +116453,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 154 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111986,21 +116461,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + if (declaration.kind === 165 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 164 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 246 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -112012,11 +116487,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 282 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -112042,32 +116517,32 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 251 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(135 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 258 /* ExportAssignment */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 83 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 261 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(93 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(95 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 252 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(135 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(138 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -112076,7 +116551,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -112090,7 +116565,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(101 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(103 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -112101,7 +116576,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -112139,10 +116614,10 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 288 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 208 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -112185,7 +116660,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(94 /* InKeyword */)); + displayParts.push(ts.keywordPart(96 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -112195,7 +116670,7 @@ var ts; var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(56 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -112230,7 +116705,7 @@ var ts; if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(38 /* PlusToken */)); + displayParts.push(ts.operatorPart(39 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); @@ -112255,16 +116730,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 200 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 241 /* VariableDeclaration */ && declaration.kind !== 243 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 288 /* SourceFile */ || parent.kind === 249 /* ModuleBlock */) { return false; } } @@ -112509,7 +116984,9 @@ var ts; var res = cb({ advance: advance, readTokenInfo: readTokenInfo, + readEOFTokenRange: readEOFTokenRange, isOnToken: isOnToken, + isOnEOF: isOnEOF, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, @@ -112549,11 +117026,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 32 /* GreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -112561,12 +117038,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 271 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 73 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 75 /* Identifier */; } } return false; @@ -112582,23 +117059,18 @@ var ts; container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 42 /* SlashToken */ || t === 65 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -112615,11 +117087,7 @@ var ts; scanner.scan(); } var currentToken = getNextToken(n, expectedScanAction); - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var token = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); // consume trailing trivia if (trailingTrivia) { trailingTrivia = undefined; @@ -112629,11 +117097,7 @@ var ts; if (!ts.isTrivia(currentToken)) { break; } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var trivia = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); if (!trailingTrivia) { trailingTrivia = []; } @@ -112652,7 +117116,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -112686,11 +117150,19 @@ var ts; } return token; } + function readEOFTokenRange() { + ts.Debug.assert(isOnEOF()); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } + function isOnEOF() { + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + return current === 1 /* EndOfFileToken */; + } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, // then kind needs to be fixed. This might happen in cases @@ -112722,10 +117194,16 @@ var ts; formatting.anyContext = ts.emptyArray; var RuleAction; (function (RuleAction) { - RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; - RuleAction[RuleAction["Space"] = 2] = "Space"; - RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; - RuleAction[RuleAction["Delete"] = 8] = "Delete"; + RuleAction[RuleAction["StopProcessingSpaceActions"] = 1] = "StopProcessingSpaceActions"; + RuleAction[RuleAction["StopProcessingTokenActions"] = 2] = "StopProcessingTokenActions"; + RuleAction[RuleAction["InsertSpace"] = 4] = "InsertSpace"; + RuleAction[RuleAction["InsertNewLine"] = 8] = "InsertNewLine"; + RuleAction[RuleAction["DeleteSpace"] = 16] = "DeleteSpace"; + RuleAction[RuleAction["DeleteToken"] = 32] = "DeleteToken"; + RuleAction[RuleAction["InsertTrailingSemicolon"] = 64] = "InsertTrailingSemicolon"; + RuleAction[RuleAction["StopAction"] = 3] = "StopAction"; + RuleAction[RuleAction["ModifySpaceAction"] = 28] = "ModifySpaceAction"; + RuleAction[RuleAction["ModifyTokenAction"] = 96] = "ModifyTokenAction"; })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); var RuleFlags; (function (RuleFlags) { @@ -112741,8 +117219,10 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { - allTokens.push(token); + for (var token = 0 /* FirstToken */; token <= 151 /* LastToken */; token++) { + if (token !== 1 /* EndOfFileToken */) { + allTokens.push(token); + } } function anyTokenExcept() { var tokens = []; @@ -112753,256 +117233,259 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; - var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArrays(allTokens, [1 /* EndOfFileToken */])); + var keywords = tokenRangeFromRange(76 /* FirstKeyword */, 151 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 74 /* LastBinaryOperator */); + var binaryKeywordOperators = [96 /* InKeyword */, 97 /* InstanceOfKeyword */, 151 /* OfKeyword */, 122 /* AsKeyword */, 132 /* IsKeyword */]; + var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 75 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostincrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; - var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; + var unaryPreincrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostincrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; + var unaryPredecrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostdecrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArrays([73 /* Identifier */], ts.typeKeywords); + var typeNames = __spreadArrays([75 /* Identifier */], ts.typeKeywords); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([73 /* Identifier */, 3 /* MultiLineCommentTrivia */, 77 /* ClassKeyword */, 86 /* ExportKeyword */, 93 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([75 /* Identifier */, 3 /* MultiLineCommentTrivia */, 79 /* ClassKeyword */, 88 /* ExportKeyword */, 95 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 83 /* DoKeyword */, 104 /* TryKeyword */, 89 /* FinallyKeyword */, 84 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 85 /* DoKeyword */, 106 /* TryKeyword */, 91 /* FinallyKeyword */, 86 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* Ignore */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* Ignore */), - rule("NotSpaceBeforeColon", anyToken, 57 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), - rule("SpaceAfterColon", 57 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeQuestionMark", anyToken, 56 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBetweenImportParenInImportType", 93 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 95 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPreincrementOperator", 44 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPredecrementOperator", 45 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 44 /* PlusPlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 38 /* PlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 38 /* PlusToken */, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 45 /* MinusMinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 39 /* MinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 39 /* MinusToken */, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 84 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 108 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 86 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 110 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 91 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, 73 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 91 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 93 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 75 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 93 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [127 /* GetKeyword */, 138 /* SetKeyword */], 73 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 118 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [118 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 98 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [106 /* VarKeyword */, 102 /* ThrowKeyword */, 96 /* NewKeyword */, 82 /* DeleteKeyword */, 98 /* ReturnKeyword */, 105 /* TypeOfKeyword */, 123 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [112 /* LetKeyword */, 78 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [130 /* GetKeyword */, 141 /* SetKeyword */], 75 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 120 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [120 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 100 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterCertainKeywords", [108 /* VarKeyword */, 104 /* ThrowKeyword */, 98 /* NewKeyword */, 84 /* DeleteKeyword */, 100 /* ReturnKeyword */, 107 /* TypeOfKeyword */, 126 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [114 /* LetKeyword */, 80 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 107 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 109 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 122 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 122 /* AsyncKeyword */, 91 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 125 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 125 /* AsyncKeyword */, 93 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [73 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 73 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 42 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 42 /* SlashToken */, 30 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 60 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 60 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 75 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [131 /* ModuleKeyword */, 135 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [134 /* ModuleKeyword */, 138 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 119 /* AbstractKeyword */, - 77 /* ClassKeyword */, - 126 /* DeclareKeyword */, - 81 /* DefaultKeyword */, - 85 /* EnumKeyword */, - 86 /* ExportKeyword */, - 87 /* ExtendsKeyword */, - 127 /* GetKeyword */, - 110 /* ImplementsKeyword */, - 93 /* ImportKeyword */, - 111 /* InterfaceKeyword */, - 131 /* ModuleKeyword */, - 132 /* NamespaceKeyword */, - 114 /* PrivateKeyword */, - 116 /* PublicKeyword */, - 115 /* ProtectedKeyword */, - 134 /* ReadonlyKeyword */, - 138 /* SetKeyword */, - 117 /* StaticKeyword */, - 141 /* TypeKeyword */, - 145 /* FromKeyword */, - 130 /* KeyOfKeyword */, - 128 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [87 /* ExtendsKeyword */, 110 /* ImplementsKeyword */, 145 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + 121 /* AbstractKeyword */, + 79 /* ClassKeyword */, + 129 /* DeclareKeyword */, + 83 /* DefaultKeyword */, + 87 /* EnumKeyword */, + 88 /* ExportKeyword */, + 89 /* ExtendsKeyword */, + 130 /* GetKeyword */, + 112 /* ImplementsKeyword */, + 95 /* ImportKeyword */, + 113 /* InterfaceKeyword */, + 134 /* ModuleKeyword */, + 135 /* NamespaceKeyword */, + 116 /* PrivateKeyword */, + 118 /* PublicKeyword */, + 117 /* ProtectedKeyword */, + 137 /* ReadonlyKeyword */, + 141 /* SetKeyword */, + 119 /* StaticKeyword */, + 144 /* TypeKeyword */, + 148 /* FromKeyword */, + 133 /* KeyOfKeyword */, + 131 /* InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [89 /* ExtendsKeyword */, 112 /* ImplementsKeyword */, 148 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 73 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 75 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterOpenAngularBracket", 28 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 30 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterCloseAngularBracket", 30 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 30 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 73 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 75 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 119 /* AbstractKeyword */, - 73 /* Identifier */, - 86 /* ExportKeyword */, - 81 /* DefaultKeyword */, - 77 /* ClassKeyword */, - 117 /* StaticKeyword */, - 116 /* PublicKeyword */, - 114 /* PrivateKeyword */, - 115 /* ProtectedKeyword */, - 127 /* GetKeyword */, - 138 /* SetKeyword */, + 121 /* AbstractKeyword */, + 75 /* Identifier */, + 88 /* ExportKeyword */, + 83 /* DefaultKeyword */, + 79 /* ClassKeyword */, + 119 /* StaticKeyword */, + 118 /* PublicKeyword */, + 116 /* PrivateKeyword */, + 117 /* ProtectedKeyword */, + 130 /* GetKeyword */, + 141 /* SetKeyword */, 22 /* OpenBracketToken */, - 40 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 96 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 28 /* LessThanToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + 41 /* AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 98 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), + rule("SpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), - rule("NoSpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), - rule("SpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(122 /* AsyncKeyword */, 75 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(125 /* AsyncKeyword */, 77 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 90 /* ForKeyword */, 123 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 92 /* ForKeyword */, 126 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 83 /* DoKeyword */, 84 /* ElseKeyword */, 75 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 85 /* DoKeyword */, 86 /* ElseKeyword */, 77 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [106 /* TryKeyword */, 91 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } @@ -113042,6 +117525,9 @@ var ts; /// /// Contexts /// + function optionEquals(optionName, optionValue) { + return function (context) { return context.options && context.options[optionName] === optionValue; }; + } function isOptionEnabled(optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; } @@ -113058,45 +117544,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 229 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 179 /* ConditionalType */: + case 216 /* AsExpression */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 167 /* TypePredicate */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 190 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 252 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 241 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 155 /* Parameter */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: - return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 154 /* TypeParameter */: + return context.currentTokenSpan.kind === 96 /* InKeyword */ || context.nextTokenSpan.kind === 96 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 231 /* ForOfStatement */: + return context.currentTokenSpan.kind === 151 /* OfKeyword */ || context.nextTokenSpan.kind === 151 /* OfKeyword */; } return false; } @@ -113108,22 +117599,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 158 /* PropertyDeclaration */ || + contextKind === 157 /* PropertySignature */ || + contextKind === 155 /* Parameter */ || + contextKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 209 /* ConditionalExpression */ || + context.contextNode.kind === 179 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 188 /* ObjectBindingPattern */ || + context.contextNode.kind === 185 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -113149,31 +117640,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 192 /* ObjectLiteralExpression */: + case 249 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 164 /* CallSignature */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 201 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 245 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -113182,40 +117676,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 243 /* FunctionDeclaration */ || context.contextNode.kind === 200 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 172 /* TypeLiteral */: + case 248 /* ModuleDeclaration */: + case 259 /* ExportDeclaration */: + case 260 /* NamedExports */: + case 253 /* ImportDeclaration */: + case 256 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 278 /* CatchClause */: + case 249 /* ModuleBlock */: + case 236 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 222 /* Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 201 /* ArrowFunction */ && blockParent.kind !== 200 /* FunctionExpression */) { return true; } } @@ -113224,31 +117718,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 235 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 278 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 192 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 195 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 196 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -113260,28 +117755,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 201 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 187 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 264 /* JsxElement */ && context.contextNode.kind !== 268 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 274 /* JsxExpression */ || context.contextNode.kind === 273 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 271 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 271 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 265 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -113296,45 +117791,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 242 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 248 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 172 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 165 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { + if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 198 /* TypeAssertionExpression */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -113345,16 +117840,78 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 198 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 109 /* VoidKeyword */ && context.currentTokenParent.kind === 204 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 211 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 217 /* NonNullExpression */; + } + function isSemicolonDeletionContext(context) { + var nextTokenKind = context.nextTokenSpan.kind; + var nextTokenStart = context.nextTokenSpan.pos; + if (ts.isTrivia(nextTokenKind)) { + var nextRealToken = context.nextTokenParent === context.currentTokenParent + ? ts.findNextToken(context.currentTokenParent, ts.findAncestor(context.currentTokenParent, function (a) { return !a.parent; }), context.sourceFile) + : context.nextTokenParent.getFirstToken(context.sourceFile); + if (!nextRealToken) { + return true; + } + nextTokenKind = nextRealToken.kind; + nextTokenStart = nextRealToken.getStart(context.sourceFile); + } + var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; + var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; + if (startLine === endLine) { + return nextTokenKind === 19 /* CloseBraceToken */ + || nextTokenKind === 1 /* EndOfFileToken */; + } + if (nextTokenKind === 221 /* SemicolonClassElement */ || + nextTokenKind === 26 /* SemicolonToken */) { + return false; + } + if (context.contextNode.kind === 245 /* InterfaceDeclaration */ || + context.contextNode.kind === 246 /* TypeAliasDeclaration */) { + // Can’t remove semicolon after `foo`; it would parse as a method declaration: + // + // interface I { + // foo; + // (): void + // } + return !ts.isPropertySignature(context.currentTokenParent) + || !!context.currentTokenParent.type + || nextTokenKind !== 20 /* OpenParenToken */; + } + if (ts.isPropertyDeclaration(context.currentTokenParent)) { + return !context.currentTokenParent.initializer; + } + return context.currentTokenParent.kind !== 229 /* ForStatement */ + && context.currentTokenParent.kind !== 223 /* EmptyStatement */ + && context.currentTokenParent.kind !== 221 /* SemicolonClassElement */ + && nextTokenKind !== 22 /* OpenBracketToken */ + && nextTokenKind !== 20 /* OpenParenToken */ + && nextTokenKind !== 39 /* PlusToken */ + && nextTokenKind !== 40 /* MinusToken */ + && nextTokenKind !== 43 /* SlashToken */ + && nextTokenKind !== 13 /* RegularExpressionLiteral */ + && nextTokenKind !== 27 /* CommaToken */ + && nextTokenKind !== 210 /* TemplateExpression */ + && nextTokenKind !== 15 /* TemplateHead */ + && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* DotToken */; + } + function isSemicolonInsertionContext(context) { + var contextAncestor = ts.findAncestor(context.currentTokenParent, function (ancestor) { + if (ancestor.end !== context.currentTokenSpan.end) { + return "quit"; + } + return ts.syntaxMayBeASICandidate(ancestor.kind); + }); + return !!contextAncestor && ts.isASICandidate(contextAncestor, context.sourceFile); } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -113364,7 +117921,7 @@ var ts; var formatting; (function (formatting) { function getFormatContext(options) { - return { options: options, getRule: getRulesMap() }; + return { options: options, getRules: getRulesMap() }; } formatting.getFormatContext = getFormatContext; var rulesMapCache; @@ -113374,11 +117931,45 @@ var ts; } return rulesMapCache; } + /** + * For a given rule action, gets a mask of other rule actions that + * cannot be applied at the same position. + */ + function getRuleActionExclusion(ruleAction) { + var mask = 0; + if (ruleAction & 1 /* StopProcessingSpaceActions */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 2 /* StopProcessingTokenActions */) { + mask |= 96 /* ModifyTokenAction */; + } + if (ruleAction & 28 /* ModifySpaceAction */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 96 /* ModifyTokenAction */) { + mask |= 96 /* ModifyTokenAction */; + } + return mask; + } function createRulesMap(rules) { var map = buildMap(rules); return function (context) { var bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)]; - return bucket && ts.find(bucket, function (rule) { return ts.every(rule.context, function (c) { return c(context); }); }); + if (bucket) { + var rules_1 = []; + var ruleActionMask = 0; + for (var _i = 0, bucket_1 = bucket; _i < bucket_1.length; _i++) { + var rule = bucket_1[_i]; + var acceptRuleActions = ~getRuleActionExclusion(ruleActionMask); + if (rule.action & acceptRuleActions && ts.every(rule.context, function (c) { return c(context); })) { + rules_1.push(rule); + ruleActionMask |= rule.action; + } + } + if (rules_1.length) { + return rules_1; + } + } }; } function buildMap(rules) { @@ -113386,8 +117977,8 @@ var ts; var map = new Array(mapRowLength * mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(map.length); - for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) { - var rule = rules_1[_i]; + for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) { + var rule = rules_2[_i]; var specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific; for (var _a = 0, _b = rule.leftTokenRange.tokens; _a < _b.length; _a++) { var left = _b[_a]; @@ -113405,16 +117996,16 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 151 /* LastKeyword */ && column <= 151 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 151 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = maskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; + RulesPosition[RulesPosition["StopRulesAny"] = maskBitSize * 1] = "StopRulesAny"; RulesPosition[RulesPosition["ContextRulesSpecific"] = maskBitSize * 2] = "ContextRulesSpecific"; RulesPosition[RulesPosition["ContextRulesAny"] = maskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = maskBitSize * 4] = "NoContextRulesSpecific"; @@ -113436,11 +118027,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action & 3 /* StopAction */ ? + specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -113465,6 +118056,16 @@ var ts; (function (ts) { var formatting; (function (formatting) { + function createTextRangeWithKind(pos, end, kind) { + var textRangeWithKind = { pos: pos, end: end, kind: kind }; + if (ts.Debug.isDebugging) { + Object.defineProperty(textRangeWithKind, "__debugKind", { + get: function () { return ts.Debug.formatSyntaxKind(kind); }, + }); + } + return textRangeWithKind; + } + formatting.createTextRangeWithKind = createTextRangeWithKind; var Constants; (function (Constants) { Constants[Constants["Unknown"] = -1] = "Unknown"; @@ -113588,17 +118189,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 249 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 288 /* SourceFile */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -113733,7 +118334,7 @@ var ts; return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) { - var options = _a.options, getRule = _a.getRule; + var options = _a.options, getRules = _a.getRules; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); var previousRange; @@ -113823,19 +118424,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: return 79 /* ClassKeyword */; + case 245 /* InterfaceDeclaration */: return 113 /* InterfaceKeyword */; + case 243 /* FunctionDeclaration */: return 93 /* FunctionKeyword */; + case 247 /* EnumDeclaration */: return 247 /* EnumDeclaration */; + case 162 /* GetAccessor */: return 130 /* GetKeyword */; + case 163 /* SetAccessor */: return 141 /* SetKeyword */; + case 160 /* MethodDeclaration */: if (node.asteriskToken) { - return 40 /* AsteriskToken */; + return 41 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -113885,22 +118486,22 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 84 /* ElseKeyword */: - case 108 /* WhileKeyword */: - case 58 /* AtToken */: + case 86 /* ElseKeyword */: + case 110 /* WhileKeyword */: + case 59 /* AtToken */: return false; - case 42 /* SlashToken */: - case 30 /* GreaterThanToken */: + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 185 /* MappedType */) { return false; } break; @@ -113947,6 +118548,12 @@ var ts; } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } + if (!node.parent && formattingScanner.isOnEOF()) { + var token = formattingScanner.readEOFTokenRange(); + if (token.end <= node.end && previousRange) { + processPair(token, sourceFile.getLineAndCharacterOfPosition(token.pos).line, node, previousRange, previousRangeStartLine, previousParent, contextNode, nodeDynamicIndentation); + } + } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; @@ -113992,7 +118599,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 156 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 11 /* JsxText */) { @@ -114000,7 +118607,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 191 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -114168,35 +118775,39 @@ var ts; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = getRule(formattingContext); - var trimTrailingWhitespaces; + var rules = getRules(formattingContext); + var trimTrailingWhitespaces = false; var lineAction = 0 /* None */; - if (rule) { - lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - switch (lineAction) { - case 2 /* LineRemoved */: - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); - } - break; - case 1 /* LineAdded */: - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); - } - break; - default: - ts.Debug.assert(lineAction === 0 /* None */); - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & 8 /* Delete */) && rule.flags !== 1 /* CanDeleteNewLines */; + if (rules) { + // Apply rules in reverse order so that higher priority rules (which are first in the array) + // win in a conflict with lower priority rules. + ts.forEachRight(rules, function (rule) { + lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + switch (lineAction) { + case 2 /* LineRemoved */: + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + } + break; + case 1 /* LineAdded */: + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + } + break; + default: + ts.Debug.assert(lineAction === 0 /* None */); + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + }); } else { - trimTrailingWhitespaces = true; + trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -114333,20 +118944,28 @@ var ts; edits.push(ts.createTextChangeFromStartLength(start, len, newText)); } } + function recordInsert(start, text) { + if (text) { + edits.push(ts.createTextChangeFromStartLength(start, 0, text)); + } + } function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* Ignore */: + case 1 /* StopProcessingSpaceActions */: // no action required return 0 /* None */; - case 8 /* Delete */: + case 16 /* DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } break; - case 4 /* NewLine */: + case 32 /* DeleteToken */: + recordDelete(previousRange.pos, previousRange.end - previousRange.pos); + break; + case 8 /* InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines @@ -114360,7 +118979,7 @@ var ts; return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; } break; - case 2 /* Space */: + case 4 /* InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { return 0 /* None */; @@ -114370,6 +118989,9 @@ var ts; recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } + break; + case 64 /* InsertTrailingSemicolon */: + recordInsert(previousRange.end, ";"); } return 0 /* None */; } @@ -114383,8 +119005,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -114393,6 +119014,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -114418,34 +119040,34 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 201 /* ArrowFunction */: if (node.typeParameters === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.parameters === list) { return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.arguments === list) { return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 168 /* TypeReference */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -114454,8 +119076,8 @@ var ts; switch (kind) { case 20 /* OpenParenToken */: return 21 /* CloseParenToken */; - case 28 /* LessThanToken */: - return 30 /* GreaterThanToken */; + case 29 /* LessThanToken */: + return 31 /* GreaterThanToken */; case 18 /* OpenBraceToken */: return 19 /* CloseBraceToken */; } @@ -114543,7 +119165,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -114562,7 +119185,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 208 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -114716,7 +119339,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 288 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -114764,8 +119387,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); + if (parent.kind === 226 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 86 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -114777,7 +119400,10 @@ var ts; if (ts.isCallOrNewExpression(parent)) { if (!parent.arguments) return false; - var currentNode = ts.Debug.assertDefined(ts.find(parent.arguments, function (arg) { return arg.pos === child.pos; })); + var currentNode = ts.find(parent.arguments, function (arg) { return arg.pos === child.pos; }); + // If it's not one of the arguments, don't look past this + if (!currentNode) + return false; var currentIndex = parent.arguments.indexOf(currentNode); if (currentIndex === 0) return false; // Can't look at previous node if first @@ -114799,40 +119425,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -114855,7 +119481,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 242 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114928,83 +119554,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 225 /* ExpressionStatement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 191 /* ArrayLiteralExpression */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 185 /* MappedType */: + case 174 /* TupleType */: + case 250 /* CaseBlock */: + case 276 /* DefaultClause */: + case 275 /* CaseClause */: + case 199 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 224 /* VariableStatement */: + case 258 /* ExportAssignment */: + case 234 /* ReturnStatement */: + case 209 /* ConditionalExpression */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: + case 265 /* JsxSelfClosingElement */: + case 274 /* JsxExpression */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 155 /* Parameter */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 181 /* ParenthesizedType */: + case 197 /* TaggedTemplateExpression */: + case 205 /* AwaitExpression */: + case 260 /* NamedExports */: + case 256 /* NamedImports */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 158 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 241 /* VariableDeclaration */: + case 279 /* PropertyAssignment */: + case 208 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 192 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 208 /* BinaryExpression */) { + return true; + } + break; + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return childKind !== 222 /* Block */; + case 259 /* ExportDeclaration */: + return childKind !== 260 /* NamedExports */; + case 253 /* ImportDeclaration */: + return childKind !== 254 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 256 /* NamedImports */); + case 264 /* JsxElement */: + return childKind !== 267 /* JsxClosingElement */; + case 268 /* JsxFragment */: + return childKind !== 270 /* JsxClosingFragment */; + case 178 /* IntersectionType */: + case 177 /* UnionType */: + if (childKind === 172 /* TypeLiteral */) { return false; } // falls through @@ -115015,11 +119645,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: + return parent.kind !== 222 /* Block */; default: return false; } @@ -115161,7 +119791,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 192 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -115192,6 +119822,18 @@ var ts; cb(tracker); return tracker.getChanges(); }; + ChangeTracker.prototype.pushRaw = function (sourceFile, change) { + ts.Debug.assertEqual(sourceFile.fileName, change.fileName); + for (var _i = 0, _a = change.textChanges; _i < _a.length; _i++) { + var c = _a[_i]; + this.changes.push({ + kind: ChangeKind.Text, + sourceFile: sourceFile, + text: c.newText, + range: ts.createTextRangeFromSpan(c.span), + }); + } + }; ChangeTracker.prototype.deleteRange = function (sourceFile, range) { this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); }; @@ -115320,15 +119962,16 @@ var ts; endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) - return; // Function missing parentheses, give up + return false; // Function missing parentheses, give up // If no `)`, is an arrow function `x => x`, so use the end of the first parameter endNode = ts.first(node.parameters); } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 241 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); + return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; @@ -115443,18 +120086,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 155 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -115463,12 +120106,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + if (node.kind === 201 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(91 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(93 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -115477,14 +120120,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 222 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(100 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 200 /* FunctionExpression */ ? 93 /* FunctionKeyword */ : 79 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -115735,29 +120378,34 @@ var ts; var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + noIndent + (options.suffix || ""); } + function getFormatCodeSettingsForWriting(_a, sourceFile) { + var options = _a.options; + var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore; + var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile); + return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore }); + } /** Note: this may mutate `nodeIn`. */ function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) { var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta; var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text; if (validate) validate(node, text); - var formatOptions = formatContext.options; + var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile); var initialIndentation = indentation !== undefined ? indentation : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos); if (delta === undefined) { - delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatContext.options, nodeIn) ? (formatOptions.indentSize || 0) : 0; + delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } var file = { text: text, getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); } }; - var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, formatContext); + var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, __assign(__assign({}, formatContext), { options: formatOptions })); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ function getNonformattedText(node, sourceFile, newLineCharacter) { - var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); - var writer = createWriter(newLineCharacter, omitTrailingSemicolon); + var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -115792,9 +120440,9 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - function createWriter(newLine, omitTrailingSemicolon) { + function createWriter(newLine) { var lastNonTriviaPosition = 0; - var writer = omitTrailingSemicolon ? ts.getTrailingSemicolonOmittingWriter(ts.createTextWriter(newLine)) : ts.createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var onEmitNode = function (hint, node, printCallback) { if (node) { setPos(node, lastNonTriviaPosition); @@ -115945,6 +120593,8 @@ var ts; getColumn: getColumn, getIndent: getIndent, isAtStartOfLine: isAtStartOfLine, + hasTrailingComment: function () { return writer.hasTrailingComment(); }, + hasTrailingWhitespace: function () { return writer.hasTrailingWhitespace(); }, clear: clear }; } @@ -116009,14 +120659,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 153 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 152 /* Parameter */: { + case 155 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -116031,14 +120681,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 189 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -116046,13 +120696,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -116061,7 +120711,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -116108,13 +120758,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 253 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 278 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -116125,14 +120775,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -116293,10 +120943,10 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) - : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(147 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(147 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -116334,7 +120984,7 @@ var ts; errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -116348,27 +120998,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -116382,7 +121043,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -116395,64 +121056,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = function (identifier) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return "continue"; + } + var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); + var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); + var variableStatement = ts.getAncestor(declaration, 224 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; + } + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); }); - if (isUsedElsewhere) { - return; - } - return declaration.initializer; + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { - return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 243 /* FunctionDeclaration */ || + ancestor.parent.kind === 200 /* FunctionExpression */ || + ancestor.parent.kind === 201 /* ArrowFunction */ || + ancestor.parent.kind === 160 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -116515,16 +121258,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || fixedNodes.tryAdd(initializer)) { - changeTracker.insertModifierBefore(sourceFile, 78 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 80 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 75 /* Identifier */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -116538,8 +121281,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 75 /* Identifier */: + case 208 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -116559,6 +121302,42 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addMissingDeclareProperty"; + var errorCodes = [ + ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Prefix_with_declare, fixId, ts.Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var fixedNodes = new ts.NodeSet(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start, fixedNodes); }); + }, + }); + function makeChange(changeTracker, sourceFile, pos, fixedNodes) { + var token = ts.getTokenAtPosition(sourceFile, pos); + if (!ts.isIdentifier(token)) { + return; + } + var declaration = token.parent; + if (declaration.kind === 158 /* PropertyDeclaration */ && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, 129 /* DeclareKeyword */, declaration); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -116680,33 +121459,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 241 /* VariableDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 158 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -116728,7 +121507,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 299 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -116768,8 +121547,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -116819,20 +121598,20 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; + var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; var token = ts.getTokenAtPosition(sourceFile, start); var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, formatContext, preferences); }); var name = declaration && ts.getNameOfDeclaration(declaration); return !name || changes.length === 0 ? undefined : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, formatContext, preferences); }); }, }); @@ -116872,8 +121651,8 @@ var ts; } return errorCode; } - function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 73 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 101 /* ThisKeyword */) { + function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, formatContext, preferences) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 103 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -116883,7 +121662,7 @@ var ts; case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location - annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); + annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken, formatContext, preferences); return parent; } if (ts.isPropertyAccessExpression(parent)) { @@ -116900,7 +121679,7 @@ var ts; case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { var symbol = program.getTypeChecker().getSymbolAtLocation(token); if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { - annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); + annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken, formatContext, preferences); return symbol.valueDeclaration; } return undefined; @@ -116914,14 +121693,14 @@ var ts; // Parameter declarations case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); return containingFunction; } // falls through case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: if (markSeen(containingFunction)) { var param = ts.cast(parent, ts.isParameter); - annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken); + annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken, formatContext, preferences); return param; } return undefined; @@ -116929,14 +121708,14 @@ var ts; case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { - annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); + annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host, formatContext, preferences); return containingFunction; } return undefined; // Set Accessor declarations case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); return containingFunction; } return undefined; @@ -116951,22 +121730,17 @@ var ts; return ts.Debug.fail(String(errorCode)); } } - function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { + function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken, formatContext, preferences) { if (ts.isIdentifier(declaration.name)) { - annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); + annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host, formatContext, preferences); } } - function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { + function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken, formatContext, preferences) { if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116977,7 +121751,7 @@ var ts; for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { - annotate(changes, sourceFile, declaration, type, program, host); + annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences); } } if (needParens) @@ -116985,14 +121759,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -117009,7 +121780,7 @@ var ts; ts.createJSDocThisTag(ts.createJSDocTypeExpression(typeNode)), ]); } - function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { + function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken, formatContext, preferences) { var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); @@ -117020,14 +121791,14 @@ var ts; annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); } else { - annotate(changes, sourceFile, param, type, program, host); + annotate(changes, sourceFile, param, type, program, host, formatContext, preferences); } } } - function annotate(changes, sourceFile, declaration, type, program, host) { + function annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 157 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -117036,11 +121807,32 @@ var ts; var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); addJSDocTags(changes, sourceFile, parent, [typeTag]); } - else { + else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences)) { changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); } } } + function tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences) { + var _a; + if (ts.isLiteralImportTypeNode(typeNode) && typeNode.qualifier && type.symbol) { + // Replace 'import("./a").SomeType' with 'SomeType' and an actual import if possible + var moduleSymbol = (_a = ts.find(type.symbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) === null || _a === void 0 ? void 0 : _a.getSourceFile().symbol; + // Symbol for the left-most thing after the dot + if (moduleSymbol) { + var symbol = ts.getFirstIdentifier(typeNode.qualifier).symbol; + var action = codefix.getImportCompletionAction(symbol, moduleSymbol, sourceFile, symbol.name, host, program, formatContext, declaration.pos, preferences); + if (action.codeAction.changes.length && changes.tryInsertTypeAnnotation(sourceFile, declaration, ts.createTypeReferenceNode(typeNode.qualifier, typeNode.typeArguments))) { + for (var _i = 0, _b = action.codeAction.changes; _i < _b.length; _i++) { + var change = _b[_i]; + var file = sourceFile.fileName === change.fileName ? sourceFile : ts.Debug.assertDefined(program.getSourceFile(change.fileName)); + changes.pushRaw(file, change); + } + return true; + } + } + } + return false; + } function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { var signature = parameterInferences.length && parameterInferences[0].declaration.parent; if (!signature) { @@ -117068,13 +121860,13 @@ var ts; return !!merged; }); }); var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var jsDocNode = parent.kind === 201 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 158 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -117084,14 +121876,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 307 /* JSDocParameterTag */: { + case 310 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 308 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -117103,25 +121895,31 @@ var ts; } function inferTypeForVariableFromUsage(token, program, cancellationToken) { var references = getReferences(token, program, cancellationToken); - var checker = program.getTypeChecker(); - var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); - return InferFromReference.unifyFromContext(types, checker); + return inferTypeFromReferences(program, references, cancellationToken).single(); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + } + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); + case 161 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 128 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -117130,54 +121928,109 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + var builtinConstructors = { + string: function () { return checker.getStringType(); }, + number: function () { return checker.getNumberType(); }, + Array: function (t) { return checker.createArrayType(t); }, + Promise: function (t) { return checker.createPromiseType(t); }, + }; + var builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function createEmptyUsage() { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + function combineUsages(usages) { + var combinedProperties = ts.createUnderscoreEscapedMap(); + for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { + var u = usages_1[_i]; + if (u.properties) { + u.properties.forEach(function (p, name) { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name).push(p); + }); + } } - return inferFromContext(usageContext, checker); + var properties = ts.createUnderscoreEscapedMap(); + combinedProperties.forEach(function (ps, name) { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(function (u) { return u.isNumber; }), + isString: usages.some(function (u) { return u.isString; }), + isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), + candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), + properties: properties, + calls: ts.flatMap(usages, function (u) { return u.calls; }), + constructs: ts.flatMap(usages, function (u) { return u.constructs; }), + numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), + stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), + candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), + inferredTypes: undefined, + }; + } + function single() { + return combineTypes(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = createEmptyUsage(); + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = __spreadArrays(usageContext.constructContexts || [], usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return declaration.parameters.map(function (parameter, parameterIndex) { var types = []; var isRest = ts.isRestParameter(parameter); var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.argumentTypes.length <= parameterIndex) { isOptional = ts.isInJSFile(declaration); types.push(checker.getUndefinedType()); } else if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = combineTypes(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -117185,242 +122038,255 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = createEmptyUsage(); + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return combineTypes(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = createEmptyUsage(); for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferTypes(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 225 /* ExpressionStatement */: + addCandidateType(usage, checker.getVoidType()); + break; + case 207 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 206 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 208 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 193 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 194 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 158 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - usageContext.isNumber = true; + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + usage.isNumber = true; break; - case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + case 39 /* PlusToken */: + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: // MultiplicativeOperator - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + // falls through + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: // ShiftOperator - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // falls through + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator - case 49 /* AmpersandToken */: - case 50 /* BarToken */: - case 51 /* CaretToken */: + // falls through + case 50 /* AmpersandToken */: + case 51 /* BarToken */: + case 52 /* CaretToken */: // CompoundAssignmentOperator - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 71 /* BarEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: + // falls through + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 73 /* BarEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator - case 39 /* MinusToken */: + // falls through + case 40 /* MinusToken */: // RelationalOperator - case 28 /* LessThanToken */: - case 31 /* LessThanEqualsToken */: - case 30 /* GreaterThanToken */: - case 32 /* GreaterThanEqualsToken */: + // falls through + case 29 /* LessThanToken */: + case 32 /* LessThanEqualsToken */: + case 31 /* GreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; - case 61 /* PlusEqualsToken */: - case 38 /* PlusToken */: + case 63 /* PlusEqualsToken */: + case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; + } + else if (otherOperandType.flags & 1 /* Any */) { + // do nothing, maybe we'll learn something elsewhere } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators - case 60 /* EqualsToken */: - case 33 /* EqualsEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + case 62 /* EqualsToken */: + case 34 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 94 /* InKeyword */: + case 96 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; - // LogicalOperator - case 55 /* BarBarToken */: + // LogicalOperator Or NullishCoalescing + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 241 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: // nothing to infer here break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], - returnType: {} + return_: createEmptyUsage() }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.return_); + if (parent.kind === 195 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || createEmptyUsage(); + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = createEmptyUsage(); + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -117429,17 +122295,19 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { - if (fallback === void 0) { fallback = checker.getAnyType(); } + function combineFromUsage(usage) { + return combineTypes(inferTypes(usage)); + } + function combineTypes(inferences) { if (!inferences.length) - return fallback; + return checker.getAnyType(); // 1. string or number individually override string | number // 2. non-any, non-void overrides any or void // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types @@ -117462,12 +122330,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function combineAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -117503,109 +122370,173 @@ var ts; }); return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); } - function inferFromContext(usageContext, checker) { + function inferTypes(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); - if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types_1 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); - types_1.push(checker.createPromiseType(types_1.length ? checker.getUnionType(types_1, 2 /* Subtype */) : checker.getAnyType())); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); - } - if (usageContext.numberIndexContext) { - types.push(checker.createArrayType(recur(usageContext.numberIndexContext))); - } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_1 = ts.createUnderscoreEscapedMap(); - var callSignatures = []; - var constructSignatures = []; - var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { - var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); - members_1.set(name, symbol); - }); - } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); - } - } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); - } - } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); - } - types.push(checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); } + if (usage.properties && usage.properties.size + || usage.calls && usage.calls.length + || usage.constructs && usage.constructs.length + || usage.stringIndex) { + types.push(inferStructuralType(usage)); + } + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + types.push.apply(types, inferNamedTypesFromProperties(usage)); return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + function inferStructuralType(usage) { + var members = ts.createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach(function (u, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); + } + var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + } + function inferNamedTypesFromProperties(usage) { + if (!usage.properties || !usage.properties.size) + return []; + var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); + if (0 < types.length && types.length < 3) { + return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); } + return []; + } + function allPropertiesAreAssignableToUsage(type, usage) { + if (!usage.properties) + return false; + return !ts.forEachEntry(usage.properties, function (propUsage, name) { + var source = checker.getTypeOfPropertyOfType(type, name); + if (!source) { + return true; + } + if (propUsage.calls) { + var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type, usage) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + return type; + } + var generic = type.target; + var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) + return type; var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + usage.properties.forEach(function (propUsage, name) { + var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); + ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName](combineTypes(types)); + } + function inferTypeParameters(genericType, usageType, typeParameter) { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); + } + else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + var genericArgs = checker.getTypeArguments(genericType); + var usageArgs = checker.getTypeArguments(usageType); + var types = []; + if (genericArgs && usageArgs) { + for (var i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); } } } + return types; } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } - return undefined; + return []; + } + function inferFromSignatures(genericSig, usageSig, typeParameter) { + var types = []; + for (var i = 0; i < genericSig.parameters.length; i++) { + var genericParam = genericSig.parameters[i]; + var usageParam = usageSig.parameters[i]; + var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); + } + var genericReturn = checker.getReturnTypeOfSignature(genericSig); + var usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; } - function getSignatureFromCallContext(callContext, checker) { + function getFunctionFromCalls(calls) { + return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + function getSignatureFromCalls(calls) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); + var _loop_12 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); + if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { + symbol.flags |= 16777216 /* Optional */; + } parameters.push(symbol); + }; + for (var i = 0; i < length; i++) { + _loop_12(i); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -117634,12 +122565,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -117671,7 +122602,7 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(117 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(119 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -117694,7 +122625,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 225 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -117702,27 +122633,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 201 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 222 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -117743,17 +122674,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 200 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 73 /* Identifier */) { + if (node.name.kind !== 75 /* Identifier */) { return undefined; } var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(precedingNode, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 88 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -117764,7 +122695,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 88 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -117827,12 +122758,12 @@ var ts; return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 122 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 125 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_13 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -117844,7 +122775,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_13(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -118138,10 +123069,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 73 /* Identifier */: // identifier includes undefined + case 75 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -118163,8 +123094,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -118276,6 +123207,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -118367,10 +123299,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -118416,29 +123348,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 60 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 62 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 195 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -118478,8 +123410,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -118487,11 +123419,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -118530,18 +123462,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); + case 160 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(88 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -118570,12 +123503,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -118588,7 +123519,7 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(86 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(88 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -118597,14 +123528,14 @@ var ts; } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(86 /* ExportKeyword */), ts.createToken(78 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(88 /* ExportKeyword */), ts.createToken(80 /* ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported) { - var modifiers = [ts.createToken(86 /* ExportKeyword */)]; + var modifiers = [ts.createToken(88 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -118612,10 +123543,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -118633,18 +123564,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 188 /* ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 189 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -118655,10 +123588,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -118680,7 +123613,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` var idName = namedBindingsNames.get(propertyName); if (idName === undefined) { idName = makeUniqueName(propertyName, identifiers); @@ -118727,11 +123660,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -118806,8 +123739,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -118834,7 +123769,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118932,7 +123867,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118945,7 +123880,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118953,14 +123888,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -119001,11 +123936,11 @@ var ts; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function codeFixActionToCodeAction(_a) { @@ -119071,21 +124006,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 253 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 256 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 253 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 255 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -119096,22 +124031,35 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 253 /* ImportDeclaration */ || i.kind === 252 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); + var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); - // Sort to keep the shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + // Sort by presence in package.json, then shortest paths first + return ts.sort(choicesForEachExportingModule, function (a, b) { + var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); + var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); + if (allowsImportingA && !allowsImportingB) { + return -1; + } + if (allowsImportingB && !allowsImportingA) { + return 1; + } + return a.moduleSpecifier.length - b.moduleSpecifier.length; + }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -119119,9 +124067,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 253 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 263 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -119178,7 +124126,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -119191,22 +124139,23 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default" /* Default */); - var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host); + var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, host) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); function addSymbol(moduleSymbol, exportedSymbol, importKind) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { @@ -119265,7 +124214,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -119281,7 +124230,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -119315,12 +124264,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -119338,7 +124287,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -119378,12 +124327,34 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(checker, from, allSourceFiles, cb) { - forEachExternalModule(checker, allSourceFiles, function (module, sourceFile) { - if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { - cb(module); + function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) { + var filteredCount = 0; + var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host); + var allSourceFiles = program.getSourceFiles(); + var globalTypingsCache = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); + forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) { + if (sourceFile === undefined) { + if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } + } + else if (sourceFile && + sourceFile !== from && + isImportablePath(from.fileName, sourceFile.fileName, ts.hostGetCanonicalFileName(host), globalTypingsCache)) { + if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } } }); + if (host.log) { + host.log("forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); + } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; function forEachExternalModule(checker, allSourceFiles, cb) { @@ -119402,10 +124373,13 @@ var ts; * Don't include something from a `node_modules` that isn't actually reachable by a global import. * A relative import to node_modules is usually a bad idea. */ - function isImportablePath(fromPath, toPath) { + function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); - return toNodeModules === undefined || ts.startsWith(fromPath, ts.getDirectoryPath(toNodeModules)); + var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); + return toNodeModulesParent === undefined + || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) + || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); @@ -119438,6 +124412,110 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; + function createAutoImportFilter(fromFile, program, host) { + var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host); + var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */; + // Mix in `getProbablySymlinks` from Program when host doesn't have it + // in order for non-Project hosts to have a symlinks cache. + var moduleSpecifierResolutionHost = { + directoryExists: ts.maybeBind(host, host.directoryExists), + fileExists: ts.maybeBind(host, host.fileExists), + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + readFile: ts.maybeBind(host, host.readFile), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks, + getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), + }; + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName, dependencyGroups) || packageJson.has(ts.getTypesPackageName(packageName), dependencyGroups)) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + /** + * Use for a specific module specifier that has already been resolved. + * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve + * the best module specifier for a given module _and_ determine if it’s importable. + */ + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -119481,12 +124559,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -119589,7 +124667,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -119616,7 +124694,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_14(info); } }); })); @@ -119677,7 +124755,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 213 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -119703,7 +124781,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 208 /* BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); @@ -119713,7 +124791,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; } - return typeNode || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return typeNode || ts.createKeywordTypeNode(124 /* AnyKeyword */); } function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); }); @@ -119722,7 +124800,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -119746,7 +124824,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(139 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(142 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -119766,7 +124844,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 160 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119974,7 +125052,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 101 /* ThisKeyword */) + if (token.kind !== 103 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -120013,7 +125091,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 128 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -120057,6 +125135,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120084,14 +125199,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 87 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 89 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(110 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(112 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 87 /* ExtendsKeyword */ && - heritageClauses[1].token === 110 /* ImplementsKeyword */) { + heritageClauses[0].token === 89 /* ExtendsKeyword */ && + heritageClauses[1].token === 112 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* CommaToken */)); @@ -120178,7 +125293,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 28 /* LessThanToken */) { + if (token.kind === 29 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -120198,7 +125313,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -120230,7 +125345,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 128 /* InferKeyword */) + if (token.kind === 131 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -120239,7 +125354,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 28 /* LessThanToken */) { + else if (token.kind === 29 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -120249,7 +125364,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -120260,23 +125375,23 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(144 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(147 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 93 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 95 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 155 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -120287,7 +125402,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -120296,7 +125411,7 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -120305,14 +125420,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 155 /* Parameter */: + case 154 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return true; } } @@ -120359,26 +125474,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); - ts.Debug.assert(index !== -1); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 75 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -120414,11 +125529,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -120429,15 +125544,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -120479,7 +125594,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -120503,7 +125618,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 292 /* JSDocNullableType */) { + if (typeNode.kind === 295 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -120523,7 +125638,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 295 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -120540,22 +125655,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 216 /* AsExpression */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 162 /* GetAccessor */: + case 166 /* IndexSignature */: + case 185 /* MappedType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 198 /* TypeAssertionExpression */: + case 241 /* VariableDeclaration */: return true; default: return false; @@ -120584,12 +125699,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -120609,14 +125727,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 93 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -120631,11 +125749,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 73 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 75 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 122 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 125 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -120743,17 +125861,17 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 4194304 /* Ambient */); + var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); switch (declaration.kind) { - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 158 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: { + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: { var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var orderedAccessors = allAccessors.secondAccessor @@ -120766,7 +125884,7 @@ var ts; /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); } else { - ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration); + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); var parameter = ts.getSetAccessorValueParameter(accessor); var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; out(ts.createSetAccessor( @@ -120775,8 +125893,8 @@ var ts; } break; } - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 160 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -120789,7 +125907,7 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; @@ -120805,7 +125923,7 @@ var ts; outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); } else { - ts.Debug.assert(declarations.length === signatures.length); + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); } } @@ -120819,14 +125937,14 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 160 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(57 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -120840,15 +125958,14 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(41 /* AsteriskToken */) : undefined, methodName, /*questionToken*/ undefined, /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); @@ -120865,8 +125982,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(121 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(124 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -120883,22 +126000,22 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - if (sig.hasRestParameter) { + if (ts.signatureHasRestParameter(sig)) { someSigHasRestParameter = true; } - if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!ts.signatureHasRestParameter(sig) || ts.signatureHasRestParameter(maxArgsSignature))) { maxArgsSignature = sig; } } - var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + var maxNonRestArgs = maxArgsSignature.parameters.length - (ts.signatureHasRestParameter(maxArgsSignature) ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { - var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(121 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(124 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -120909,7 +126026,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -120920,10 +126037,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(116 /* PublicKeyword */); + return ts.createToken(118 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(115 /* ProtectedKeyword */); + return ts.createToken(117 /* ProtectedKeyword */); } return undefined; } @@ -120995,7 +126112,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 195 /* CallExpression */ : 196 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -121106,7 +126223,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties); } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -121114,7 +126231,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(145 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); @@ -121235,6 +126352,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -121256,8 +126406,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 95 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 187 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -121309,7 +126459,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(137 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); @@ -121340,7 +126490,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 123 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 126 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -121351,7 +126501,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 96 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 98 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -121362,6 +126512,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -121378,8 +126562,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -121399,16 +126583,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -121417,7 +126601,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + ts.Debug.assert(!wasDefault, "Can't have a default flag here"); return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } default: @@ -121431,40 +126615,40 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 83 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 88 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(83 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -121478,27 +126662,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 251 /* ImportClause */: { + case 254 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 255 /* NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; @@ -121519,11 +126703,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 257 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.createIdentifier(parent.name.text); @@ -121536,7 +126720,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 261 /* ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -121545,7 +126729,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -121569,13 +126753,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 255 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 255 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -121592,7 +126776,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 255 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -121613,7 +126797,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -121652,7 +126836,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -121671,7 +126855,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -121792,6 +126976,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -121883,6 +127068,9 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -121935,20 +127123,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 158 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 155 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 161 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 160 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -121966,13 +127154,13 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 4194304 /* Ambient */) { + if (nodeToCheck.flags & 8388608 /* Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -121991,7 +127179,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 241 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! @@ -122003,13 +127191,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 192 /* CallExpression */) { + if (node.parent.kind === 195 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -122024,8 +127212,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -122037,20 +127225,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 222 /* Block */: + if (node.parent && node.parent.kind === 239 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -122062,19 +127250,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 182 /* ThisType */: + case 103 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -122083,20 +127271,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 233 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -122150,7 +127338,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 152 /* Parameter */) { + if (current.kind === 155 /* Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -122161,7 +127349,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 288 /* SourceFile */) { return scopes; } } @@ -122251,32 +127439,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 244 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 246 /* ModuleBlock */ + return scope.kind === 249 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -122342,20 +127530,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(114 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(116 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(122 /* AsyncKeyword */)); + modifiers.push(ts.createToken(125 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(122 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(125 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -122372,7 +127560,7 @@ var ts; var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.createYield(ts.createToken(40 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(41 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -122380,8 +127568,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -122449,7 +127637,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -122496,9 +127684,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 142 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 145 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(142 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); } } /** @@ -122506,6 +127694,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -122516,16 +127705,17 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(114 /* PrivateKeyword */)); + modifiers.push(ts.createToken(116 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } - modifiers.push(ts.createToken(134 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(137 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -122554,7 +127744,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 225 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.createVariableStatement( @@ -122573,7 +127763,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 225 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -122587,6 +127777,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -122660,7 +127907,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 234 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -122723,11 +127970,11 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { - var member = members_2[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -122765,11 +128012,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -122838,7 +128085,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 243 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -122891,7 +128138,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -122901,7 +128148,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -122923,7 +128170,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -122941,7 +128188,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -123154,30 +128401,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 282 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 253 /* ImportDeclaration */ && + parent.kind !== 257 /* ImportSpecifier */; + case 212 /* SpreadElement */: + case 188 /* ObjectBindingPattern */: + case 190 /* BindingElement */: return false; - case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + case 75 /* Identifier */: + return parent.kind !== 190 /* BindingElement */ && + parent.kind !== 257 /* ImportSpecifier */ && + parent.kind !== 261 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 222 /* Block */: + case 288 /* SourceFile */: + case 249 /* ModuleBlock */: + case 275 /* CaseClause */: return true; default: return false; @@ -123193,6 +128440,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -123202,22 +128450,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -123232,14 +128492,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; } - function isStatementAndHasJSDoc(n) { - return ts.isStatement(n) && ts.hasJSDocNodes(n); + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function rangeContainsSkipTrivia(r1, node, file) { return ts.rangeContainsStartEnd(r1, ts.skipTrivia(file.text, node.pos), node.end); @@ -123287,15 +128569,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(312 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(315 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -123303,10 +128596,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(311 /* JSDocTemplateTag */); + var template = ts.createNode(314 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(154 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -123356,10 +128649,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 116 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 118 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 114 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 116 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -123397,7 +128690,7 @@ var ts; return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { - var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(117 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(119 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -123420,7 +128713,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 155 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -123466,24 +128759,22 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration, declaration.parent) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 101 /* ThisKeyword */ && + node.expression.kind === 103 /* ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 103 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -123508,7 +128799,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -123565,11 +128856,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -123622,10 +128913,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -123647,25 +128938,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 253 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 255 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -123693,20 +128984,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 253 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 252 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -123748,7 +129039,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -123776,19 +129067,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -123797,7 +129088,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 255 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -123809,7 +129100,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 256 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -123822,14 +129113,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -123903,7 +129194,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -123956,13 +129247,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -123974,7 +129265,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123984,18 +129275,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -124005,11 +129296,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 188 /* ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.createObjectBindingPattern(newElements) : undefined; @@ -124061,18 +129352,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -124080,17 +129371,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -124100,13 +129391,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -124114,9 +129405,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -124147,28 +129438,28 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(88 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { @@ -124176,26 +129467,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 225 /* ExpressionStatement */: + return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 60 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 62 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -124318,7 +129609,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -124457,15 +129748,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -124475,7 +129766,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -124494,14 +129785,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -124543,11 +129834,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 161 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -124555,8 +129846,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -124566,7 +129857,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 81 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 83 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -124681,7 +129972,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(56 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); ts.suppressLeadingAndTrailingTrivia(propertySignature); copyComments(parameterDeclaration.name, propertySignature.name); @@ -124727,15 +130018,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 83 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -124746,30 +130037,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 83 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: - var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + case 161 /* Constructor */: + var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 128 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 213 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -124781,10 +130072,10 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 73 /* Identifier */ ? new IdentifierObject(73 /* Identifier */, pos, end) : + kind === 75 /* Identifier */ ? new IdentifierObject(75 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 12679168 /* ContextFlags */; + node.flags = parent.flags & 25358336 /* ContextFlags */; return node; } var NodeObject = /** @class */ (function () { @@ -124798,7 +130089,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -124855,8 +130146,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 313 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 292 /* FirstJSDocNode */ || kid.kind > 316 /* LastJSDocNode */; }); + return child.kind < 152 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -124867,7 +130158,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 152 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -124913,7 +130204,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 73 /* Identifier */) { + if (token === 75 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -124925,7 +130216,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(314 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(317 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -125048,7 +130339,9 @@ var ts; var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { - return _super.call(this, pos, end) || this; + var _this = _super.call(this, pos, end) || this; + _this.kind = 75 /* Identifier */; + return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { get: function () { @@ -125059,7 +130352,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 73 /* Identifier */; + IdentifierObject.prototype.kind = 75 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -125095,9 +130388,15 @@ var ts; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; }; + TypeObject.prototype.isNullableType = function () { + return this.checker.isNullableType(this); + }; TypeObject.prototype.getNonNullableType = function () { return this.checker.getNonNullableType(this); }; + TypeObject.prototype.getNonOptionalType = function () { + return this.checker.getNonOptionalType(this); + }; TypeObject.prototype.getConstraint = function () { return this.checker.getBaseConstraintOfType(this); }; @@ -125131,11 +130430,25 @@ var ts; TypeObject.prototype.isClass = function () { return !!(ts.getObjectFlags(this) & 1 /* Class */); }; + Object.defineProperty(TypeObject.prototype, "typeArguments", { + /** + * This polyfills `referenceType.typeArguments` for API consumers + */ + get: function () { + if (ts.getObjectFlags(this) & 4 /* Reference */) { + return this.checker.getTypeArguments(this); + } + return undefined; + }, + enumerable: true, + configurable: true + }); return TypeObject; }()); var SignatureObject = /** @class */ (function () { - function SignatureObject(checker) { + function SignatureObject(checker, flags) { this.checker = checker; + this.flags = flags; } SignatureObject.prototype.getDeclaration = function () { return this.declaration; @@ -125173,13 +130486,12 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var declaration = declarations_4[_i]; + ts.forEachUnique(declarations, function (declaration) { var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); - } + }); } return doc; } @@ -125202,7 +130514,9 @@ var ts; var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - return _super.call(this, kind, pos, end) || this; + var _this = _super.call(this, kind, pos, end) || this; + _this.kind = 288 /* SourceFile */; + return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -125260,10 +130574,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -125283,31 +130597,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 172 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -125318,19 +130632,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -125342,7 +130656,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -125351,7 +130665,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -125548,7 +130862,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -125668,10 +130982,10 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; }, getCurrentDirectory: function () { return currentDirectory; }, getProgram: getProgram, - fileExists: host.fileExists && (function (f) { return host.fileExists(f); }), - readFile: host.readFile && (function (f, encoding) { return host.readFile(f, encoding); }), - getDocumentPositionMapper: host.getDocumentPositionMapper && (function (generatedFileName, sourceFileName) { return host.getDocumentPositionMapper(generatedFileName, sourceFileName); }), - getSourceFileLike: host.getSourceFileLike && (function (f) { return host.getSourceFileLike(f); }), + fileExists: ts.maybeBind(host, host.fileExists), + readFile: ts.maybeBind(host, host.readFile), + getDocumentPositionMapper: ts.maybeBind(host, host.getDocumentPositionMapper), + getSourceFileLike: ts.maybeBind(host, host.getSourceFileLike), log: log }); function getValidSourceFile(fileName) { @@ -125767,6 +131081,12 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }; } + if (host.setResolvedProjectReferenceCallbacks) { + compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); }; + } + if (host.useSourceOfProjectReferenceRedirect) { + compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); }; + } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -125927,7 +131247,7 @@ var ts; } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }); + return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host); } function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); @@ -125971,15 +131291,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 99 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 101 /* SuperKeyword */: return true; default: return false; @@ -126052,12 +131372,11 @@ var ts; var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } - function getEmitOutput(fileName, emitOnlyDtsFiles) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function getEmitOutput(fileName, emitOnlyDtsFiles, forceDtsEmit) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); - return ts.getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers); + return ts.getFileEmitOutput(program, sourceFile, !!emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit); } // Signature help /** @@ -126081,16 +131400,16 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: case 10 /* StringLiteral */: - case 88 /* FalseKeyword */: - case 103 /* TrueKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 73 /* Identifier */: + case 90 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 75 /* Identifier */: break; // Cant create the text span default: @@ -126106,7 +131425,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 248 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -126171,7 +131490,7 @@ var ts; _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, + _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -126295,7 +131614,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -126558,7 +131877,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 263 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -126574,14 +131893,15 @@ var ts; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 153 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 192 /* ObjectLiteralExpression */ || node.parent.parent.kind === 272 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -126623,7 +131943,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -126670,7 +131990,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 4194304 /* Ambient */) { + if (tokenAtLocation.flags & 8388608 /* Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -126703,114 +132023,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 190 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 156 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -126828,19 +132148,19 @@ var ts; return spanInOpenParenToken(node); case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 57 /* ColonToken */: + case 58 /* ColonToken */: return spanInColonToken(node); - case 30 /* GreaterThanToken */: - case 28 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return spanInWhileKeyword(node); - case 84 /* ElseKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + case 86 /* ElseKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 151 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -126852,14 +132172,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + if ((node.kind === 75 /* Identifier */ || + node.kind === 212 /* SpreadElement */ || + node.kind === 279 /* PropertyAssignment */ || + node.kind === 280 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 208 /* BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -126868,7 +132188,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 60 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -126881,22 +132201,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 156 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -126905,21 +132225,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -126927,7 +132247,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -126957,7 +132277,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 230 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -126969,7 +132289,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 231 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -127010,7 +132330,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 244 /* ClassDeclaration */ && functionDeclaration.kind !== 161 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -127033,26 +132353,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 230 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 242 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -127077,21 +132397,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 190 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 189 /* ArrayBindingPattern */ && node.kind !== 188 /* ObjectBindingPattern */); + var elements = node.kind === 191 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -127099,18 +132419,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 208 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -127118,25 +132438,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -127144,7 +132464,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -127160,7 +132480,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -127175,12 +132495,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 227 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 195 /* CallExpression */ || + node.parent.kind === 196 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 199 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -127189,21 +132509,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 199 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -127213,20 +132533,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 279 /* PropertyAssignment */ || + node.parent.kind === 155 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 198 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 227 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -127234,7 +132554,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 231 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -127279,10 +132599,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -127304,9 +132623,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -127377,6 +132698,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -127405,6 +132727,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -127416,6 +132739,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -127559,13 +132883,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -127573,13 +132897,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -128037,8 +133362,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; diff --git a/node_modules/typescript/lib/typescriptServices.d.ts b/node_modules/typescript/lib/typescriptServices.d.ts index c98678ae3..5b5dfd4e1 100644 --- a/node_modules/typescript/lib/typescriptServices.d.ts +++ b/node_modules/typescript/lib/typescriptServices.d.ts @@ -14,7 +14,7 @@ and limitations under the License. ***************************************************************************** */ declare namespace ts { - const versionMajorMinor = "3.6"; + const versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ const version: string; } @@ -73,7 +73,7 @@ declare namespace ts { end: number; } export type JSDocSyntaxKind = SyntaxKind.EndOfFileToken | SyntaxKind.WhitespaceTrivia | SyntaxKind.AtToken | SyntaxKind.NewLineTrivia | SyntaxKind.AsteriskToken | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.LessThanToken | SyntaxKind.GreaterThanToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.EqualsToken | SyntaxKind.CommaToken | SyntaxKind.DotToken | SyntaxKind.Identifier | SyntaxKind.BacktickToken | SyntaxKind.Unknown | KeywordSyntaxKind; - export type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.BigIntKeyword | 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 KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.BigIntKeyword | 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 | SyntaxKind.EndOfFileToken | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.OpenBraceToken | SyntaxKind.LessThanToken; export enum SyntaxKind { Unknown = 0, @@ -104,329 +104,335 @@ declare namespace ts { DotDotDotToken = 25, SemicolonToken = 26, CommaToken = 27, - LessThanToken = 28, - LessThanSlashToken = 29, - GreaterThanToken = 30, - LessThanEqualsToken = 31, - GreaterThanEqualsToken = 32, - EqualsEqualsToken = 33, - ExclamationEqualsToken = 34, - EqualsEqualsEqualsToken = 35, - ExclamationEqualsEqualsToken = 36, - EqualsGreaterThanToken = 37, - PlusToken = 38, - MinusToken = 39, - AsteriskToken = 40, - AsteriskAsteriskToken = 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 = 57, - AtToken = 58, + QuestionDotToken = 28, + LessThanToken = 29, + LessThanSlashToken = 30, + GreaterThanToken = 31, + LessThanEqualsToken = 32, + GreaterThanEqualsToken = 33, + EqualsEqualsToken = 34, + ExclamationEqualsToken = 35, + EqualsEqualsEqualsToken = 36, + ExclamationEqualsEqualsToken = 37, + EqualsGreaterThanToken = 38, + PlusToken = 39, + MinusToken = 40, + AsteriskToken = 41, + AsteriskAsteriskToken = 42, + SlashToken = 43, + PercentToken = 44, + PlusPlusToken = 45, + MinusMinusToken = 46, + LessThanLessThanToken = 47, + GreaterThanGreaterThanToken = 48, + GreaterThanGreaterThanGreaterThanToken = 49, + AmpersandToken = 50, + BarToken = 51, + CaretToken = 52, + ExclamationToken = 53, + TildeToken = 54, + AmpersandAmpersandToken = 55, + BarBarToken = 56, + QuestionToken = 57, + ColonToken = 58, + AtToken = 59, + QuestionQuestionToken = 60, /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - BacktickToken = 59, - EqualsToken = 60, - PlusEqualsToken = 61, - MinusEqualsToken = 62, - AsteriskEqualsToken = 63, - AsteriskAsteriskEqualsToken = 64, - SlashEqualsToken = 65, - PercentEqualsToken = 66, - LessThanLessThanEqualsToken = 67, - GreaterThanGreaterThanEqualsToken = 68, - GreaterThanGreaterThanGreaterThanEqualsToken = 69, - AmpersandEqualsToken = 70, - BarEqualsToken = 71, - CaretEqualsToken = 72, - Identifier = 73, - BreakKeyword = 74, - CaseKeyword = 75, - CatchKeyword = 76, - ClassKeyword = 77, - ConstKeyword = 78, - ContinueKeyword = 79, - DebuggerKeyword = 80, - DefaultKeyword = 81, - DeleteKeyword = 82, - DoKeyword = 83, - ElseKeyword = 84, - EnumKeyword = 85, - ExportKeyword = 86, - ExtendsKeyword = 87, - FalseKeyword = 88, - FinallyKeyword = 89, - ForKeyword = 90, - FunctionKeyword = 91, - IfKeyword = 92, - ImportKeyword = 93, - InKeyword = 94, - InstanceOfKeyword = 95, - NewKeyword = 96, - NullKeyword = 97, - ReturnKeyword = 98, - SuperKeyword = 99, - SwitchKeyword = 100, - ThisKeyword = 101, - ThrowKeyword = 102, - TrueKeyword = 103, - TryKeyword = 104, - TypeOfKeyword = 105, - VarKeyword = 106, - VoidKeyword = 107, - WhileKeyword = 108, - WithKeyword = 109, - ImplementsKeyword = 110, - InterfaceKeyword = 111, - LetKeyword = 112, - PackageKeyword = 113, - PrivateKeyword = 114, - ProtectedKeyword = 115, - PublicKeyword = 116, - StaticKeyword = 117, - YieldKeyword = 118, - AbstractKeyword = 119, - AsKeyword = 120, - AnyKeyword = 121, - AsyncKeyword = 122, - AwaitKeyword = 123, - BooleanKeyword = 124, - ConstructorKeyword = 125, - DeclareKeyword = 126, - GetKeyword = 127, - InferKeyword = 128, - IsKeyword = 129, - KeyOfKeyword = 130, - ModuleKeyword = 131, - NamespaceKeyword = 132, - NeverKeyword = 133, - ReadonlyKeyword = 134, - RequireKeyword = 135, - NumberKeyword = 136, - ObjectKeyword = 137, - SetKeyword = 138, - StringKeyword = 139, - SymbolKeyword = 140, - TypeKeyword = 141, - UndefinedKeyword = 142, - UniqueKeyword = 143, - UnknownKeyword = 144, - FromKeyword = 145, - GlobalKeyword = 146, - BigIntKeyword = 147, - OfKeyword = 148, - QualifiedName = 149, - ComputedPropertyName = 150, - TypeParameter = 151, - Parameter = 152, - Decorator = 153, - PropertySignature = 154, - PropertyDeclaration = 155, - MethodSignature = 156, - MethodDeclaration = 157, - Constructor = 158, - GetAccessor = 159, - SetAccessor = 160, - CallSignature = 161, - ConstructSignature = 162, - IndexSignature = 163, - TypePredicate = 164, - TypeReference = 165, - FunctionType = 166, - ConstructorType = 167, - TypeQuery = 168, - TypeLiteral = 169, - ArrayType = 170, - TupleType = 171, - OptionalType = 172, - RestType = 173, - UnionType = 174, - IntersectionType = 175, - ConditionalType = 176, - InferType = 177, - ParenthesizedType = 178, - ThisType = 179, - TypeOperator = 180, - IndexedAccessType = 181, - MappedType = 182, - LiteralType = 183, - ImportType = 184, - ObjectBindingPattern = 185, - ArrayBindingPattern = 186, - BindingElement = 187, - ArrayLiteralExpression = 188, - ObjectLiteralExpression = 189, - PropertyAccessExpression = 190, - ElementAccessExpression = 191, - CallExpression = 192, - NewExpression = 193, - TaggedTemplateExpression = 194, - TypeAssertionExpression = 195, - ParenthesizedExpression = 196, - FunctionExpression = 197, - ArrowFunction = 198, - DeleteExpression = 199, - TypeOfExpression = 200, - VoidExpression = 201, - AwaitExpression = 202, - PrefixUnaryExpression = 203, - PostfixUnaryExpression = 204, - BinaryExpression = 205, - ConditionalExpression = 206, - TemplateExpression = 207, - YieldExpression = 208, - SpreadElement = 209, - ClassExpression = 210, - OmittedExpression = 211, - ExpressionWithTypeArguments = 212, - AsExpression = 213, - NonNullExpression = 214, - MetaProperty = 215, - SyntheticExpression = 216, - TemplateSpan = 217, - SemicolonClassElement = 218, - Block = 219, - VariableStatement = 220, - EmptyStatement = 221, - ExpressionStatement = 222, - IfStatement = 223, - DoStatement = 224, - WhileStatement = 225, - ForStatement = 226, - ForInStatement = 227, - ForOfStatement = 228, - ContinueStatement = 229, - BreakStatement = 230, - ReturnStatement = 231, - WithStatement = 232, - SwitchStatement = 233, - LabeledStatement = 234, - ThrowStatement = 235, - TryStatement = 236, - DebuggerStatement = 237, - VariableDeclaration = 238, - VariableDeclarationList = 239, - FunctionDeclaration = 240, - ClassDeclaration = 241, - InterfaceDeclaration = 242, - TypeAliasDeclaration = 243, - EnumDeclaration = 244, - ModuleDeclaration = 245, - ModuleBlock = 246, - CaseBlock = 247, - NamespaceExportDeclaration = 248, - ImportEqualsDeclaration = 249, - ImportDeclaration = 250, - ImportClause = 251, - NamespaceImport = 252, - NamedImports = 253, - ImportSpecifier = 254, - ExportAssignment = 255, - ExportDeclaration = 256, - NamedExports = 257, - ExportSpecifier = 258, - MissingDeclaration = 259, - ExternalModuleReference = 260, - JsxElement = 261, - JsxSelfClosingElement = 262, - JsxOpeningElement = 263, - JsxClosingElement = 264, - JsxFragment = 265, - JsxOpeningFragment = 266, - JsxClosingFragment = 267, - JsxAttribute = 268, - JsxAttributes = 269, - JsxSpreadAttribute = 270, - JsxExpression = 271, - CaseClause = 272, - DefaultClause = 273, - HeritageClause = 274, - CatchClause = 275, - PropertyAssignment = 276, - ShorthandPropertyAssignment = 277, - SpreadAssignment = 278, - EnumMember = 279, - UnparsedPrologue = 280, - UnparsedPrepend = 281, - UnparsedText = 282, - UnparsedInternalText = 283, - UnparsedSyntheticReference = 284, - SourceFile = 285, - Bundle = 286, - UnparsedSource = 287, - InputFiles = 288, - JSDocTypeExpression = 289, - JSDocAllType = 290, - JSDocUnknownType = 291, - JSDocNullableType = 292, - JSDocNonNullableType = 293, - JSDocOptionalType = 294, - JSDocFunctionType = 295, - JSDocVariadicType = 296, - JSDocNamepathType = 297, - JSDocComment = 298, - JSDocTypeLiteral = 299, - JSDocSignature = 300, - JSDocTag = 301, - JSDocAugmentsTag = 302, - JSDocAuthorTag = 303, - JSDocClassTag = 304, - JSDocCallbackTag = 305, - JSDocEnumTag = 306, - JSDocParameterTag = 307, - JSDocReturnTag = 308, - JSDocThisTag = 309, - JSDocTypeTag = 310, - JSDocTemplateTag = 311, - JSDocTypedefTag = 312, - JSDocPropertyTag = 313, - SyntaxList = 314, - NotEmittedStatement = 315, - PartiallyEmittedExpression = 316, - CommaListExpression = 317, - MergeDeclarationMarker = 318, - EndOfDeclarationMarker = 319, - Count = 320, - FirstAssignment = 60, - LastAssignment = 72, - FirstCompoundAssignment = 61, - LastCompoundAssignment = 72, - FirstReservedWord = 74, - LastReservedWord = 109, - FirstKeyword = 74, - LastKeyword = 148, - FirstFutureReservedWord = 110, - LastFutureReservedWord = 118, - FirstTypeNode = 164, - LastTypeNode = 184, + BacktickToken = 61, + EqualsToken = 62, + PlusEqualsToken = 63, + MinusEqualsToken = 64, + AsteriskEqualsToken = 65, + AsteriskAsteriskEqualsToken = 66, + SlashEqualsToken = 67, + PercentEqualsToken = 68, + LessThanLessThanEqualsToken = 69, + GreaterThanGreaterThanEqualsToken = 70, + GreaterThanGreaterThanGreaterThanEqualsToken = 71, + AmpersandEqualsToken = 72, + BarEqualsToken = 73, + CaretEqualsToken = 74, + Identifier = 75, + BreakKeyword = 76, + CaseKeyword = 77, + CatchKeyword = 78, + ClassKeyword = 79, + ConstKeyword = 80, + ContinueKeyword = 81, + DebuggerKeyword = 82, + DefaultKeyword = 83, + DeleteKeyword = 84, + DoKeyword = 85, + ElseKeyword = 86, + EnumKeyword = 87, + ExportKeyword = 88, + ExtendsKeyword = 89, + FalseKeyword = 90, + FinallyKeyword = 91, + ForKeyword = 92, + FunctionKeyword = 93, + IfKeyword = 94, + ImportKeyword = 95, + InKeyword = 96, + InstanceOfKeyword = 97, + NewKeyword = 98, + NullKeyword = 99, + ReturnKeyword = 100, + SuperKeyword = 101, + SwitchKeyword = 102, + ThisKeyword = 103, + ThrowKeyword = 104, + TrueKeyword = 105, + TryKeyword = 106, + TypeOfKeyword = 107, + VarKeyword = 108, + VoidKeyword = 109, + WhileKeyword = 110, + WithKeyword = 111, + ImplementsKeyword = 112, + InterfaceKeyword = 113, + LetKeyword = 114, + PackageKeyword = 115, + PrivateKeyword = 116, + ProtectedKeyword = 117, + PublicKeyword = 118, + StaticKeyword = 119, + YieldKeyword = 120, + AbstractKeyword = 121, + AsKeyword = 122, + AssertsKeyword = 123, + AnyKeyword = 124, + AsyncKeyword = 125, + AwaitKeyword = 126, + BooleanKeyword = 127, + ConstructorKeyword = 128, + DeclareKeyword = 129, + GetKeyword = 130, + InferKeyword = 131, + IsKeyword = 132, + KeyOfKeyword = 133, + ModuleKeyword = 134, + NamespaceKeyword = 135, + NeverKeyword = 136, + ReadonlyKeyword = 137, + RequireKeyword = 138, + NumberKeyword = 139, + ObjectKeyword = 140, + SetKeyword = 141, + StringKeyword = 142, + SymbolKeyword = 143, + TypeKeyword = 144, + UndefinedKeyword = 145, + UniqueKeyword = 146, + UnknownKeyword = 147, + FromKeyword = 148, + GlobalKeyword = 149, + BigIntKeyword = 150, + OfKeyword = 151, + QualifiedName = 152, + ComputedPropertyName = 153, + TypeParameter = 154, + Parameter = 155, + Decorator = 156, + PropertySignature = 157, + PropertyDeclaration = 158, + MethodSignature = 159, + MethodDeclaration = 160, + Constructor = 161, + GetAccessor = 162, + SetAccessor = 163, + CallSignature = 164, + ConstructSignature = 165, + IndexSignature = 166, + TypePredicate = 167, + TypeReference = 168, + FunctionType = 169, + ConstructorType = 170, + TypeQuery = 171, + TypeLiteral = 172, + ArrayType = 173, + TupleType = 174, + OptionalType = 175, + RestType = 176, + UnionType = 177, + IntersectionType = 178, + ConditionalType = 179, + InferType = 180, + ParenthesizedType = 181, + ThisType = 182, + TypeOperator = 183, + IndexedAccessType = 184, + MappedType = 185, + LiteralType = 186, + ImportType = 187, + ObjectBindingPattern = 188, + ArrayBindingPattern = 189, + BindingElement = 190, + ArrayLiteralExpression = 191, + ObjectLiteralExpression = 192, + PropertyAccessExpression = 193, + ElementAccessExpression = 194, + CallExpression = 195, + NewExpression = 196, + TaggedTemplateExpression = 197, + TypeAssertionExpression = 198, + ParenthesizedExpression = 199, + FunctionExpression = 200, + ArrowFunction = 201, + DeleteExpression = 202, + TypeOfExpression = 203, + VoidExpression = 204, + AwaitExpression = 205, + PrefixUnaryExpression = 206, + PostfixUnaryExpression = 207, + BinaryExpression = 208, + ConditionalExpression = 209, + TemplateExpression = 210, + YieldExpression = 211, + SpreadElement = 212, + ClassExpression = 213, + OmittedExpression = 214, + ExpressionWithTypeArguments = 215, + AsExpression = 216, + NonNullExpression = 217, + MetaProperty = 218, + SyntheticExpression = 219, + TemplateSpan = 220, + SemicolonClassElement = 221, + Block = 222, + EmptyStatement = 223, + VariableStatement = 224, + ExpressionStatement = 225, + IfStatement = 226, + DoStatement = 227, + WhileStatement = 228, + ForStatement = 229, + ForInStatement = 230, + ForOfStatement = 231, + ContinueStatement = 232, + BreakStatement = 233, + ReturnStatement = 234, + WithStatement = 235, + SwitchStatement = 236, + LabeledStatement = 237, + ThrowStatement = 238, + TryStatement = 239, + DebuggerStatement = 240, + VariableDeclaration = 241, + VariableDeclarationList = 242, + FunctionDeclaration = 243, + ClassDeclaration = 244, + InterfaceDeclaration = 245, + TypeAliasDeclaration = 246, + EnumDeclaration = 247, + ModuleDeclaration = 248, + ModuleBlock = 249, + CaseBlock = 250, + NamespaceExportDeclaration = 251, + ImportEqualsDeclaration = 252, + ImportDeclaration = 253, + ImportClause = 254, + NamespaceImport = 255, + NamedImports = 256, + ImportSpecifier = 257, + ExportAssignment = 258, + ExportDeclaration = 259, + NamedExports = 260, + ExportSpecifier = 261, + MissingDeclaration = 262, + ExternalModuleReference = 263, + JsxElement = 264, + JsxSelfClosingElement = 265, + JsxOpeningElement = 266, + JsxClosingElement = 267, + JsxFragment = 268, + JsxOpeningFragment = 269, + JsxClosingFragment = 270, + JsxAttribute = 271, + JsxAttributes = 272, + JsxSpreadAttribute = 273, + JsxExpression = 274, + CaseClause = 275, + DefaultClause = 276, + HeritageClause = 277, + CatchClause = 278, + PropertyAssignment = 279, + ShorthandPropertyAssignment = 280, + SpreadAssignment = 281, + EnumMember = 282, + UnparsedPrologue = 283, + UnparsedPrepend = 284, + UnparsedText = 285, + UnparsedInternalText = 286, + UnparsedSyntheticReference = 287, + SourceFile = 288, + Bundle = 289, + UnparsedSource = 290, + InputFiles = 291, + JSDocTypeExpression = 292, + JSDocAllType = 293, + JSDocUnknownType = 294, + JSDocNullableType = 295, + JSDocNonNullableType = 296, + JSDocOptionalType = 297, + JSDocFunctionType = 298, + JSDocVariadicType = 299, + JSDocNamepathType = 300, + JSDocComment = 301, + JSDocTypeLiteral = 302, + JSDocSignature = 303, + JSDocTag = 304, + JSDocAugmentsTag = 305, + JSDocAuthorTag = 306, + JSDocClassTag = 307, + JSDocCallbackTag = 308, + JSDocEnumTag = 309, + JSDocParameterTag = 310, + JSDocReturnTag = 311, + JSDocThisTag = 312, + JSDocTypeTag = 313, + JSDocTemplateTag = 314, + JSDocTypedefTag = 315, + JSDocPropertyTag = 316, + SyntaxList = 317, + NotEmittedStatement = 318, + PartiallyEmittedExpression = 319, + CommaListExpression = 320, + MergeDeclarationMarker = 321, + EndOfDeclarationMarker = 322, + SyntheticReferenceExpression = 323, + Count = 324, + FirstAssignment = 62, + LastAssignment = 74, + FirstCompoundAssignment = 63, + LastCompoundAssignment = 74, + FirstReservedWord = 76, + LastReservedWord = 111, + FirstKeyword = 76, + LastKeyword = 151, + FirstFutureReservedWord = 112, + LastFutureReservedWord = 120, + FirstTypeNode = 167, + LastTypeNode = 187, FirstPunctuation = 18, - LastPunctuation = 72, + LastPunctuation = 74, FirstToken = 0, - LastToken = 148, + LastToken = 151, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, LastLiteralToken = 14, FirstTemplateToken = 14, LastTemplateToken = 17, - FirstBinaryOperator = 28, - LastBinaryOperator = 72, - FirstNode = 149, - FirstJSDocNode = 289, - LastJSDocNode = 313, - FirstJSDocTagNode = 301, - LastJSDocTagNode = 313, + FirstBinaryOperator = 29, + LastBinaryOperator = 74, + FirstStatement = 224, + LastStatement = 240, + FirstNode = 152, + FirstJSDocNode = 292, + LastJSDocNode = 316, + FirstJSDocTagNode = 304, + LastJSDocTagNode = 316, } export enum NodeFlags { None = 0, @@ -435,27 +441,28 @@ declare namespace ts { NestedNamespace = 4, Synthesized = 8, Namespace = 16, - ExportContext = 32, - ContainsThis = 64, - HasImplicitReturn = 128, - HasExplicitReturn = 256, - GlobalAugmentation = 512, - HasAsyncFunctions = 1024, - DisallowInContext = 2048, - YieldContext = 4096, - DecoratorContext = 8192, - AwaitContext = 16384, - ThisNodeHasError = 32768, - JavaScriptFile = 65536, - ThisNodeOrAnySubNodesHasError = 131072, - HasAggregatedChildData = 262144, - JSDoc = 2097152, - JsonFile = 16777216, + OptionalChain = 32, + ExportContext = 64, + ContainsThis = 128, + HasImplicitReturn = 256, + HasExplicitReturn = 512, + GlobalAugmentation = 1024, + HasAsyncFunctions = 2048, + DisallowInContext = 4096, + YieldContext = 8192, + DecoratorContext = 16384, + AwaitContext = 32768, + ThisNodeHasError = 65536, + JavaScriptFile = 131072, + ThisNodeOrAnySubNodesHasError = 262144, + HasAggregatedChildData = 524288, + JSDoc = 4194304, + JsonFile = 33554432, BlockScoped = 3, - ReachabilityCheckFlags = 384, - ReachabilityAndEmitFlags = 1408, - ContextFlags = 12679168, - TypeExcludesFlags = 20480, + ReachabilityCheckFlags = 768, + ReachabilityAndEmitFlags = 2816, + ContextFlags = 25358336, + TypeExcludesFlags = 40960, } export enum ModifierFlags { None = 0, @@ -505,8 +512,10 @@ declare namespace ts { export interface Token extends Node { kind: TKind; } + export type DotToken = Token; export type DotDotDotToken = Token; export type QuestionToken = Token; + export type QuestionDotToken = Token; export type ExclamationToken = Token; export type ColonToken = Token; export type EqualsToken = Token; @@ -517,6 +526,7 @@ declare namespace ts { export type AwaitKeywordToken = Token; export type PlusToken = Token; export type MinusToken = Token; + export type AssertsToken = Token; export type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; export type ModifiersArray = NodeArray; export interface Identifier extends PrimaryExpression, Declaration { @@ -539,7 +549,7 @@ declare namespace ts { } export type EntityName = Identifier | QualifiedName; export type PropertyName = Identifier | StringLiteral | NumericLiteral | ComputedPropertyName; - export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern; + export type DeclarationName = Identifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | ElementAccessExpression | BindingPattern | EntityNameExpression; export interface Declaration extends Node { _declarationBrand: any; } @@ -770,8 +780,9 @@ declare namespace ts { export interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; parent: SignatureDeclaration | JSDocTypeExpression; + assertsModifier?: AssertsToken; parameterName: Identifier | ThisTypeNode; - type: TypeNode; + type?: TypeNode; } export interface TypeQueryNode extends TypeNode { kind: SyntaxKind.TypeQuery; @@ -842,7 +853,7 @@ declare namespace ts { kind: SyntaxKind.LiteralType; literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } - export interface StringLiteral extends LiteralExpression { + export interface StringLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.StringLiteral; } export type StringLiteralLike = StringLiteral | NoSubstitutionTemplateLiteral; @@ -943,7 +954,7 @@ declare namespace ts { export type LogicalOperatorOrHigher = BitwiseOperatorOrHigher | LogicalOperator; export type CompoundAssignmentOperator = SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken; export type AssignmentOperator = SyntaxKind.EqualsToken | CompoundAssignmentOperator; - export type AssignmentOperatorOrHigher = LogicalOperatorOrHigher | AssignmentOperator; + export type AssignmentOperatorOrHigher = SyntaxKind.QuestionQuestionToken | LogicalOperatorOrHigher | AssignmentOperator; export type BinaryOperator = AssignmentOperatorOrHigher | SyntaxKind.CommaToken; export type BinaryOperatorToken = Token; export interface BinaryExpression extends Expression, Declaration { @@ -1006,7 +1017,7 @@ declare namespace ts { export interface RegularExpressionLiteral extends LiteralExpression { kind: SyntaxKind.RegularExpressionLiteral; } - export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode { + export interface NoSubstitutionTemplateLiteral extends LiteralExpression, TemplateLiteralLikeNode, Declaration { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } export enum TokenFlags { @@ -1017,7 +1028,7 @@ declare namespace ts { BinarySpecifier = 128, OctalSpecifier = 256, } - export interface NumericLiteral extends LiteralExpression { + export interface NumericLiteral extends LiteralExpression, Declaration { kind: SyntaxKind.NumericLiteral; } export interface BigIntLiteral extends LiteralExpression { @@ -1077,8 +1088,12 @@ declare namespace ts { export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; name: Identifier; } + export interface PropertyAccessChain extends PropertyAccessExpression { + _optionalChainBrand: any; + } export interface SuperPropertyAccessExpression extends PropertyAccessExpression { expression: SuperExpression; } @@ -1090,8 +1105,12 @@ declare namespace ts { export interface ElementAccessExpression extends MemberExpression { kind: SyntaxKind.ElementAccessExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; argumentExpression: Expression; } + export interface ElementAccessChain extends ElementAccessExpression { + _optionalChainBrand: any; + } export interface SuperElementAccessExpression extends ElementAccessExpression { expression: SuperExpression; } @@ -1099,9 +1118,14 @@ declare namespace ts { export interface CallExpression extends LeftHandSideExpression, Declaration { kind: SyntaxKind.CallExpression; expression: LeftHandSideExpression; + questionDotToken?: QuestionDotToken; typeArguments?: NodeArray; arguments: NodeArray; } + export interface CallChain extends CallExpression { + _optionalChainBrand: any; + } + export type OptionalChain = PropertyAccessChain | ElementAccessChain | CallChain; export interface SuperCall extends CallExpression { expression: SuperExpression; } @@ -1635,8 +1659,8 @@ declare namespace ts { } export interface JSDocSignature extends JSDocType, Declaration { kind: SyntaxKind.JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly JSDocTemplateTag[]; + parameters: readonly JSDocParameterTag[]; type: JSDocReturnTag | undefined; } export interface JSDocPropertyLikeTag extends JSDocTag, Declaration { @@ -1655,7 +1679,7 @@ declare namespace ts { } export interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; - jsDocPropertyTags?: ReadonlyArray; + jsDocPropertyTags?: readonly JSDocPropertyLikeTag[]; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } @@ -1669,13 +1693,19 @@ declare namespace ts { FalseCondition = 64, SwitchClause = 128, ArrayMutation = 256, - Referenced = 512, - Shared = 1024, - PreFinally = 2048, - AfterFinally = 4096, + Call = 512, + Referenced = 1024, + Shared = 2048, + PreFinally = 4096, + AfterFinally = 8192, Label = 12, Condition = 96 } + export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCall | FlowCondition | FlowSwitchClause | FlowArrayMutation; + export interface FlowNodeBase { + flags: FlowFlags; + id?: number; + } export interface FlowLock { locked?: boolean; } @@ -1686,13 +1716,8 @@ declare namespace ts { antecedent: FlowNode; lock: FlowLock; } - export type FlowNode = AfterFinallyFlow | PreFinallyFlow | FlowStart | FlowLabel | FlowAssignment | FlowCondition | FlowSwitchClause | FlowArrayMutation; - export interface FlowNodeBase { - flags: FlowFlags; - id?: number; - } export interface FlowStart extends FlowNodeBase { - container?: FunctionExpression | ArrowFunction | MethodDeclaration; + node?: FunctionExpression | ArrowFunction | MethodDeclaration; } export interface FlowLabel extends FlowNodeBase { antecedents: FlowNode[] | undefined; @@ -1701,8 +1726,12 @@ declare namespace ts { node: Expression | VariableDeclaration | BindingElement; antecedent: FlowNode; } + export interface FlowCall extends FlowNodeBase { + node: CallExpression; + antecedent: FlowNode; + } export interface FlowCondition extends FlowNodeBase { - expression: Expression; + node: Expression; antecedent: FlowNode; } export interface FlowSwitchClause extends FlowNodeBase { @@ -1730,11 +1759,11 @@ declare namespace ts { endOfFileToken: Token; fileName: string; text: string; - amdDependencies: ReadonlyArray; + amdDependencies: readonly AmdDependency[]; moduleName?: string; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray; - libReferenceDirectives: ReadonlyArray; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly FileReference[]; + libReferenceDirectives: readonly FileReference[]; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1750,8 +1779,8 @@ declare namespace ts { } export interface Bundle extends Node { kind: SyntaxKind.Bundle; - prepends: ReadonlyArray; - sourceFiles: ReadonlyArray; + prepends: readonly (InputFiles | UnparsedSource)[]; + sourceFiles: readonly SourceFile[]; } export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; @@ -1768,16 +1797,16 @@ declare namespace ts { kind: SyntaxKind.UnparsedSource; fileName: string; text: string; - prologues: ReadonlyArray; - helpers: ReadonlyArray | undefined; - referencedFiles: ReadonlyArray; - typeReferenceDirectives: ReadonlyArray | undefined; - libReferenceDirectives: ReadonlyArray; + prologues: readonly UnparsedPrologue[]; + helpers: readonly UnscopedEmitHelper[] | undefined; + referencedFiles: readonly FileReference[]; + typeReferenceDirectives: readonly string[] | undefined; + libReferenceDirectives: readonly FileReference[]; hasNoDefaultLib?: boolean; sourceMapPath?: string; sourceMapText?: string; - syntheticReferences?: ReadonlyArray; - texts: ReadonlyArray; + syntheticReferences?: readonly UnparsedSyntheticReference[]; + texts: readonly UnparsedSourceText[]; } export type UnparsedSourceText = UnparsedPrepend | UnparsedTextLike; export type UnparsedNode = UnparsedPrologue | UnparsedSourceText | UnparsedSyntheticReference; @@ -1795,7 +1824,7 @@ declare namespace ts { kind: SyntaxKind.UnparsedPrepend; data: string; parent: UnparsedSource; - texts: ReadonlyArray; + texts: readonly UnparsedTextLike[]; } export interface UnparsedTextLike extends UnparsedSection { kind: SyntaxKind.UnparsedText | SyntaxKind.UnparsedInternalText; @@ -1827,7 +1856,7 @@ declare namespace ts { } export interface ParseConfigHost { useCaseSensitiveFileNames: boolean; - readDirectory(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): ReadonlyArray; + readDirectory(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): readonly string[]; /** * Gets a value indicating whether the specified path exists and is a file. * @param path The path to test. @@ -1844,7 +1873,7 @@ declare namespace ts { export type ResolvedConfigFileName = string & { _isResolvedConfigFileName: never; }; - export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray) => void; + export type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: readonly SourceFile[]) => void; export class OperationCanceledException { } export interface CancellationToken { @@ -1856,11 +1885,11 @@ declare namespace ts { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): ReadonlyArray; + getRootFileNames(): readonly string[]; /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1872,26 +1901,35 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** The first time this is called, it will return global diagnostics (no location). */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + getNodeCount(): number; + getIdentifierCount(): number; + getSymbolCount(): number; + getTypeCount(): number; + getRelationCacheSizes(): { + assignable: number; + identity: number; + subtype: number; + }; isSourceFileFromExternalLibrary(file: SourceFile): boolean; isSourceFileDefaultLibrary(file: SourceFile): boolean; - getProjectReferences(): ReadonlyArray | undefined; - getResolvedProjectReferences(): ReadonlyArray | undefined; + getProjectReferences(): readonly ProjectReference[] | undefined; + getResolvedProjectReferences(): readonly (ResolvedProjectReference | undefined)[] | undefined; } export interface ResolvedProjectReference { commandLine: ParsedCommandLine; sourceFile: SourceFile; - references?: ReadonlyArray; + references?: readonly (ResolvedProjectReference | undefined)[]; } export type CustomTransformerFactory = (context: TransformationContext) => CustomTransformer; export interface CustomTransformer { @@ -1925,12 +1963,15 @@ declare namespace ts { Success = 0, DiagnosticsPresent_OutputsSkipped = 1, DiagnosticsPresent_OutputsGenerated = 2, - InvalidProject_OutputsSkipped = 3 + InvalidProject_OutputsSkipped = 3, + ProjectReferenceCycle_OutputsSkipped = 4, + /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ + ProjectReferenceCycle_OutputsSkupped = 4 } export interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: ReadonlyArray; + diagnostics: readonly Diagnostic[]; emittedFiles?: string[]; } export interface TypeChecker { @@ -1939,7 +1980,7 @@ declare namespace ts { getPropertiesOfType(type: Type): Symbol[]; getPropertyOfType(type: Type, propertyName: string): Symbol | undefined; getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined; - getSignaturesOfType(type: Type, kind: SignatureKind): ReadonlyArray; + getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined; getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; @@ -1947,6 +1988,7 @@ declare namespace ts { getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; + getTypeArguments(type: TypeReference): readonly Type[]; /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -1993,7 +2035,7 @@ declare namespace ts { typePredicateToString(predicate: TypePredicate, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string; getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; - getRootSymbols(symbol: Symbol): ReadonlyArray; + getRootSymbols(symbol: Symbol): readonly Symbol[]; getContextualType(node: Expression): Type | undefined; /** * returns unknownSignature in the case of an error. @@ -2088,21 +2130,39 @@ declare namespace ts { } export enum TypePredicateKind { This = 0, - Identifier = 1 + Identifier = 1, + AssertsThis = 2, + AssertsIdentifier = 3 } export interface TypePredicateBase { kind: TypePredicateKind; - type: Type; + type: Type | undefined; } export interface ThisTypePredicate extends TypePredicateBase { kind: TypePredicateKind.This; + parameterName: undefined; + parameterIndex: undefined; + type: Type; } export interface IdentifierTypePredicate extends TypePredicateBase { kind: TypePredicateKind.Identifier; parameterName: string; parameterIndex: number; + type: Type; + } + export interface AssertsThisTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsThis; + parameterName: undefined; + parameterIndex: undefined; + type: Type | undefined; + } + export interface AssertsIdentifierTypePredicate extends TypePredicateBase { + kind: TypePredicateKind.AssertsIdentifier; + parameterName: string; + parameterIndex: number; + type: Type | undefined; } - export type TypePredicate = IdentifierTypePredicate | ThisTypePredicate; + export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate; export enum SymbolFlags { None = 0, FunctionScopedVariable = 1, @@ -2278,7 +2338,7 @@ declare namespace ts { symbol: Symbol; pattern?: DestructuringPattern; aliasSymbol?: Symbol; - aliasTypeArguments?: ReadonlyArray; + aliasTypeArguments?: readonly Type[]; } export interface LiteralType extends Type { value: string | number | PseudoBigInt; @@ -2330,7 +2390,7 @@ declare namespace ts { localTypeParameters: TypeParameter[] | undefined; thisType: TypeParameter | undefined; } - export type BaseType = ObjectType | IntersectionType; + export type BaseType = ObjectType | IntersectionType | TypeVariable; export interface InterfaceTypeWithDeclaredMembers extends InterfaceType { declaredProperties: Symbol[]; declaredCallSignatures: Signature[]; @@ -2350,7 +2410,9 @@ declare namespace ts { */ export interface TypeReference extends ObjectType { target: GenericType; - typeArguments?: ReadonlyArray; + node?: TypeReferenceNode | ArrayTypeNode | TupleTypeNode; + } + export interface DeferredTypeReference extends TypeReference { } export interface GenericType extends InterfaceType, TypeReference { } @@ -2420,8 +2482,8 @@ declare namespace ts { } export interface Signature { declaration?: SignatureDeclaration | JSDocSignature; - typeParameters?: ReadonlyArray; - parameters: ReadonlyArray; + typeParameters?: readonly TypeParameter[]; + parameters: readonly Symbol[]; } export enum IndexKind { String = 0, @@ -2529,6 +2591,7 @@ declare namespace ts { emitDeclarationOnly?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + disableSourceOfProjectReferenceRedirect?: boolean; downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; @@ -2595,9 +2658,14 @@ declare namespace ts { /** Paths used to compute primary types search locations */ typeRoots?: string[]; esModuleInterop?: boolean; + useDefineForClassFields?: boolean; [option: string]: CompilerOptionsValue | TsConfigSourceFile | undefined; } export interface TypeAcquisition { + /** + * @deprecated typingOptions.enableAutoDiscovery + * Use typeAcquisition.enable instead. + */ enableAutoDiscovery?: boolean; enable?: boolean; include?: string[]; @@ -2664,7 +2732,7 @@ declare namespace ts { options: CompilerOptions; typeAcquisition?: TypeAcquisition; fileNames: string[]; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; raw?: any; errors: Diagnostic[]; wildcardDirectories?: MapLike; @@ -2679,12 +2747,12 @@ declare namespace ts { wildcardDirectories: MapLike; } export interface CreateProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; oldProgram?: Program; - configFileParsingDiagnostics?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; } export interface ModuleResolutionHost { fileExists(fileName: string): boolean; @@ -2765,7 +2833,7 @@ declare namespace ts { } export interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { readonly resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective | undefined; - readonly failedLookupLocations: ReadonlyArray; + readonly failedLookupLocations: readonly string[]; } export interface CompilerHost extends ModuleResolutionHost { getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined; @@ -2778,7 +2846,7 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; useCaseSensitiveFileNames(): boolean; getNewLine(): string; - readDirectory?(rootDir: string, extensions: ReadonlyArray, excludes: ReadonlyArray | undefined, includes: ReadonlyArray, depth?: number): string[]; + readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files @@ -3016,6 +3084,11 @@ declare namespace ts { directoryExists?(directoryName: string): boolean; getCurrentDirectory?(): string; } + export interface ModuleSpecifierResolutionHost extends GetEffectiveTypeRootsHost { + useCaseSensitiveFileNames?(): boolean; + fileExists?(path: string): boolean; + readFile?(path: string): string | undefined; + } export interface TextSpan { start: number; length: number; @@ -3098,6 +3171,7 @@ declare namespace ts { readonly disableSuggestions?: boolean; readonly quotePreference?: "auto" | "double" | "single"; readonly includeCompletionsForModuleExports?: boolean; + readonly includeAutomaticOptionalChainCompletions?: boolean; readonly includeCompletionsWithInsertText?: boolean; readonly importModuleSpecifierPreference?: "relative" | "non-relative"; /** Determines whether we import `foo/index.ts` as "foo", "foo/index", or "foo/index.js" */ @@ -3144,7 +3218,7 @@ declare namespace ts { getExecutingFilePath(): string; getCurrentDirectory(): string; getDirectories(path: string): string[]; - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; getModifiedTime?(path: string): Date | undefined; setModifiedTime?(path: string, time: Date): void; deleteFile?(path: string): void; @@ -3192,6 +3266,7 @@ declare namespace ts { scanJsxAttributeValue(): SyntaxKind; reScanJsxToken(): JsxTokenSyntaxKind; reScanLessThanToken(): SyntaxKind; + reScanQuestionToken(): SyntaxKind; scanJsxToken(): JsxTokenSyntaxKind; scanJsDocToken(): JSDocSyntaxKind; scan(): SyntaxKind; @@ -3229,7 +3304,7 @@ declare namespace ts { } declare namespace ts { function isExternalModuleNameRelative(moduleName: string): boolean; - function sortAndDeduplicateDiagnostics(diagnostics: ReadonlyArray): SortedReadonlyArray; + function sortAndDeduplicateDiagnostics(diagnostics: readonly T[]): SortedReadonlyArray; } declare namespace ts { function getDefaultLibFileName(options: CompilerOptions): string; @@ -3258,7 +3333,7 @@ declare namespace ts { * This function will then merge those changes into a single change range valid between V1 and * Vn. */ - function collapseTextChangeRangesAcrossMultipleVersions(changes: ReadonlyArray): TextChangeRange; + function collapseTextChangeRangesAcrossMultipleVersions(changes: readonly TextChangeRange[]): TextChangeRange; function getTypeParameterOwner(d: Declaration): Declaration | undefined; type ParameterPropertyDeclaration = ParameterDeclaration & { parent: ConstructorDeclaration; @@ -3330,7 +3405,7 @@ declare namespace ts { * * For binding patterns, parameter tags are matched by position. */ - function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray; + function getJSDocParameterTags(param: ParameterDeclaration): readonly JSDocParameterTag[]; /** * Gets the JSDoc type parameter tags for the node if present. * @@ -3341,7 +3416,7 @@ declare namespace ts { * node are returned first, so in the previous example, the template * tag on the containing function expression would be first. */ - function getJSDocTypeParameterTags(param: TypeParameterDeclaration): ReadonlyArray; + function getJSDocTypeParameterTags(param: TypeParameterDeclaration): readonly JSDocTemplateTag[]; /** * Return true if the node has JSDoc parameter tags. * @@ -3383,14 +3458,14 @@ declare namespace ts { */ function getJSDocReturnType(node: Node): TypeNode | undefined; /** Get all JSDoc tags related to a node, including those on parent nodes. */ - function getJSDocTags(node: Node): ReadonlyArray; + function getJSDocTags(node: Node): readonly JSDocTag[]; /** Gets all JSDoc tags of a specified kind, or undefined if not present. */ - function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): ReadonlyArray; + function getAllJSDocTagsOfKind(node: Node, kind: SyntaxKind): readonly JSDocTag[]; /** * Gets the effective type parameters. If the node was parsed in a * JavaScript file, gets the type parameters from the `@template` tag from JSDoc. */ - function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): ReadonlyArray; + function getEffectiveTypeParameterDeclarations(node: DeclarationWithTypeParameters): readonly TypeParameterDeclaration[]; function getEffectiveConstraintOfTypeParameter(node: TypeParameterDeclaration): TypeNode | undefined; } declare namespace ts { @@ -3444,8 +3519,13 @@ declare namespace ts { function isArrayLiteralExpression(node: Node): node is ArrayLiteralExpression; function isObjectLiteralExpression(node: Node): node is ObjectLiteralExpression; function isPropertyAccessExpression(node: Node): node is PropertyAccessExpression; + function isPropertyAccessChain(node: Node): node is PropertyAccessChain; function isElementAccessExpression(node: Node): node is ElementAccessExpression; + function isElementAccessChain(node: Node): node is ElementAccessChain; function isCallExpression(node: Node): node is CallExpression; + function isCallChain(node: Node): node is CallChain; + function isOptionalChain(node: Node): node is PropertyAccessChain | ElementAccessChain | CallChain; + function isNullishCoalesce(node: Node): boolean; function isNewExpression(node: Node): node is NewExpression; function isTaggedTemplateExpression(node: Node): node is TaggedTemplateExpression; function isTypeAssertion(node: Node): node is TypeAssertion; @@ -3543,7 +3623,7 @@ declare namespace ts { function isUnparsedTextLike(node: Node): node is UnparsedTextLike; function isUnparsedNode(node: Node): node is UnparsedNode; function isJSDocTypeExpression(node: Node): node is JSDocTypeExpression; - function isJSDocAllType(node: JSDocAllType): node is JSDocAllType; + function isJSDocAllType(node: Node): node is JSDocAllType; function isJSDocUnknownType(node: Node): node is JSDocUnknownType; function isJSDocNullableType(node: Node): node is JSDocNullableType; function isJSDocNonNullableType(node: Node): node is JSDocNonNullableType; @@ -3643,7 +3723,7 @@ declare namespace ts { export {}; } declare namespace ts { - export function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; + export function parseCommandLine(commandLine: readonly string[], readFile?: (path: string) => string | undefined): ParsedCommandLine; export type DiagnosticReporter = (diagnostic: Diagnostic) => void; /** * Reports config file diagnostics @@ -3697,7 +3777,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; /** * Parse the contents of a config file (tsconfig.json). * @param jsonNode The contents of the config file to parse @@ -3705,7 +3785,7 @@ declare namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: ReadonlyArray, extendedConfigCache?: Map): ParsedCommandLine; + export function parseJsonSourceFileConfigFileContent(sourceFile: TsConfigSourceFile, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: readonly FileExtensionInfo[], extendedConfigCache?: Map): ParsedCommandLine; export interface ParsedTsconfig { raw: any; options?: CompilerOptions; @@ -3771,7 +3851,7 @@ declare namespace ts { function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; } declare namespace ts { - function createNodeArray(elements?: ReadonlyArray, hasTrailingComma?: boolean): NodeArray; + function createNodeArray(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; function createLiteral(value: number | PseudoBigInt): NumericLiteral; @@ -3809,62 +3889,64 @@ declare namespace ts { function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function createParameter(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + function createParameter(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createPropertySignature(modifiers: ReadonlyArray | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function updatePropertySignature(node: PropertySignature, modifiers: ReadonlyArray | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; - function createProperty(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - function createMethodSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createProperty(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + function createMethodSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; - function createMethod(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - function createConstructor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, body: Block | undefined): ConstructorDeclaration; - function createGetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - function createSetAccessor(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: PropertyName, parameters: ReadonlyArray, body: Block | undefined): SetAccessorDeclaration; - function createCallSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createMethod(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; - function createConstructSignature(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - function createIndexSignature(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; - function updateIndexSignature(node: IndexSignatureDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode): IndexSignatureDeclaration; + function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; - function createTypeReferenceNode(typeName: string | EntityName, typeArguments: ReadonlyArray | undefined): TypeReferenceNode; + function updateTypePredicateNodeWithModifier(node: TypePredicateNode, assertsModifier: AssertsToken | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: readonly TypeNode[] | undefined): TypeReferenceNode; function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; - function createFunctionTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): FunctionTypeNode; + function createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; - function createConstructorTypeNode(typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined): ConstructorTypeNode; + function createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; function createTypeQueryNode(exprName: EntityName): TypeQueryNode; function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; - function createTypeLiteralNode(members: ReadonlyArray | undefined): TypeLiteralNode; + function createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; - function createTupleTypeNode(elementTypes: ReadonlyArray): TupleTypeNode; - function updateTupleTypeNode(node: TupleTypeNode, elementTypes: ReadonlyArray): TupleTypeNode; + function createTupleTypeNode(elementTypes: readonly TypeNode[]): TupleTypeNode; + function updateTupleTypeNode(node: TupleTypeNode, elementTypes: readonly TypeNode[]): TupleTypeNode; function createOptionalTypeNode(type: TypeNode): OptionalTypeNode; function updateOptionalTypeNode(node: OptionalTypeNode, type: TypeNode): OptionalTypeNode; function createRestTypeNode(type: TypeNode): RestTypeNode; function updateRestTypeNode(node: RestTypeNode, type: TypeNode): RestTypeNode; - function createUnionTypeNode(types: ReadonlyArray): UnionTypeNode; + function createUnionTypeNode(types: readonly TypeNode[]): UnionTypeNode; function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray): UnionTypeNode; - function createIntersectionTypeNode(types: ReadonlyArray): IntersectionTypeNode; + function createIntersectionTypeNode(types: readonly TypeNode[]): IntersectionTypeNode; function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray): IntersectionTypeNode; - function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: ReadonlyArray): UnionOrIntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: readonly TypeNode[]): UnionOrIntersectionTypeNode; function createConditionalTypeNode(checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; function createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; function updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: ReadonlyArray, isTypeOf?: boolean): ImportTypeNode; + function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; function createThisTypeNode(): ThisTypeNode; @@ -3877,36 +3959,42 @@ declare namespace ts { function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | PlusToken | MinusToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | PlusToken | MinusToken | undefined, type: TypeNode | undefined): MappedTypeNode; function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; - function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; - function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; - function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; - function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ReadonlyArray): ArrayBindingPattern; + function createObjectBindingPattern(elements: readonly BindingElement[]): ObjectBindingPattern; + function updateObjectBindingPattern(node: ObjectBindingPattern, elements: readonly BindingElement[]): ObjectBindingPattern; + function createArrayBindingPattern(elements: readonly ArrayBindingElement[]): ArrayBindingPattern; + function updateArrayBindingPattern(node: ArrayBindingPattern, elements: readonly ArrayBindingElement[]): ArrayBindingPattern; function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; - function createArrayLiteral(elements?: ReadonlyArray, multiLine?: boolean): ArrayLiteralExpression; - function updateArrayLiteral(node: ArrayLiteralExpression, elements: ReadonlyArray): ArrayLiteralExpression; - function createObjectLiteral(properties?: ReadonlyArray, multiLine?: boolean): ObjectLiteralExpression; - function updateObjectLiteral(node: ObjectLiteralExpression, properties: ReadonlyArray): ObjectLiteralExpression; + function createArrayLiteral(elements?: readonly Expression[], multiLine?: boolean): ArrayLiteralExpression; + function updateArrayLiteral(node: ArrayLiteralExpression, elements: readonly Expression[]): ArrayLiteralExpression; + function createObjectLiteral(properties?: readonly ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; + function updateObjectLiteral(node: ObjectLiteralExpression, properties: readonly ObjectLiteralElementLike[]): ObjectLiteralExpression; function createPropertyAccess(expression: Expression, name: string | Identifier): PropertyAccessExpression; function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; + function createPropertyAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, name: string | Identifier): PropertyAccessChain; + function updatePropertyAccessChain(node: PropertyAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, name: Identifier): PropertyAccessChain; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray): CallExpression; - function createNew(expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: ReadonlyArray | undefined, argumentsArray: ReadonlyArray | undefined): NewExpression; + function createElementAccessChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, index: number | Expression): ElementAccessChain; + function updateElementAccessChain(node: ElementAccessChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, argumentExpression: Expression): ElementAccessChain; + function createCall(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallExpression; + function createCallChain(expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): CallChain; + function updateCallChain(node: CallChain, expression: Expression, questionDotToken: QuestionDotToken | undefined, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[]): CallChain; + function createNew(expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: readonly TypeNode[] | undefined, argumentsArray: readonly Expression[] | undefined): NewExpression; /** @deprecated */ function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function createTaggedTemplate(tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function createTaggedTemplate(tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; /** @deprecated */ function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: ReadonlyArray | undefined, template: TemplateLiteral): TaggedTemplateExpression; + function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; - function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3924,8 +4012,8 @@ declare namespace ts { /** @deprecated */ function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; - function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; - function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; + function createTemplateExpression(head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; + function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: readonly TemplateSpan[]): TemplateExpression; function createTemplateHead(text: string, rawText?: string): TemplateHead; function createTemplateMiddle(text: string, rawText?: string): TemplateMiddle; function createTemplateTail(text: string, rawText?: string): TemplateTail; @@ -3935,11 +4023,11 @@ declare namespace ts { function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassExpression; + function createClassExpression(modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; - function createExpressionWithTypeArguments(typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; - function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: ReadonlyArray | undefined, expression: Expression): ExpressionWithTypeArguments; + function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; + function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression): ExpressionWithTypeArguments; function createAsExpression(expression: Expression, type: TypeNode): AsExpression; function updateAsExpression(node: AsExpression, expression: Expression, type: TypeNode): AsExpression; function createNonNullExpression(expression: Expression): NonNullExpression; @@ -3949,10 +4037,10 @@ declare namespace ts { function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createSemicolonClassElement(): SemicolonClassElement; - function createBlock(statements: ReadonlyArray, multiLine?: boolean): Block; - function updateBlock(node: Block, statements: ReadonlyArray): Block; - function createVariableStatement(modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList | ReadonlyArray): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: ReadonlyArray | undefined, declarationList: VariableDeclarationList): VariableStatement; + function createBlock(statements: readonly Statement[], multiLine?: boolean): Block; + function updateBlock(node: Block, statements: readonly Statement[]): Block; + function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createEmptyStatement(): EmptyStatement; function createExpressionStatement(expression: Expression): ExpressionStatement; function updateExpressionStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; @@ -3991,76 +4079,76 @@ declare namespace ts { function createDebuggerStatement(): DebuggerStatement; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - function createVariableDeclarationList(declarations: ReadonlyArray, flags?: NodeFlags): VariableDeclarationList; - function updateVariableDeclarationList(node: VariableDeclarationList, declarations: ReadonlyArray): VariableDeclarationList; - function createFunctionDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - function createClassDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): ClassDeclaration; - function createInterfaceDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, heritageClauses: ReadonlyArray | undefined, members: ReadonlyArray): InterfaceDeclaration; - function createTypeAliasDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, typeParameters: ReadonlyArray | undefined, type: TypeNode): TypeAliasDeclaration; - function createEnumDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, members: ReadonlyArray): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, members: ReadonlyArray): EnumDeclaration; - function createModuleDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; - function createModuleBlock(statements: ReadonlyArray): ModuleBlock; - function updateModuleBlock(node: ModuleBlock, statements: ReadonlyArray): ModuleBlock; - function createCaseBlock(clauses: ReadonlyArray): CaseBlock; - function updateCaseBlock(node: CaseBlock, clauses: ReadonlyArray): CaseBlock; + function createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; + function updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; + function createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + function createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + function createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + function createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + function createModuleBlock(statements: readonly Statement[]): ModuleBlock; + function updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; + function createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; + function updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; function createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - function createImportEqualsDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression): ImportDeclaration; function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; - function createNamedImports(elements: ReadonlyArray): NamedImports; - function updateNamedImports(node: NamedImports, elements: ReadonlyArray): NamedImports; + function createNamedImports(elements: readonly ImportSpecifier[]): NamedImports; + function updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: ReadonlyArray | undefined, modifiers: ReadonlyArray | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; - function createNamedExports(elements: ReadonlyArray): NamedExports; - function updateNamedExports(node: NamedExports, elements: ReadonlyArray): NamedExports; + function createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; + function createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; + function updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; - function createJsxElement(openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: ReadonlyArray, closingElement: JsxClosingElement): JsxElement; - function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxSelfClosingElement; - function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; - function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: ReadonlyArray | undefined, attributes: JsxAttributes): JsxOpeningElement; + function createJsxElement(openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function updateJsxElement(node: JsxElement, openingElement: JsxOpeningElement, children: readonly JsxChild[], closingElement: JsxClosingElement): JsxElement; + function createJsxSelfClosingElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function updateJsxSelfClosingElement(node: JsxSelfClosingElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxSelfClosingElement; + function createJsxOpeningElement(tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; + function updateJsxOpeningElement(node: JsxOpeningElement, tagName: JsxTagNameExpression, typeArguments: readonly TypeNode[] | undefined, attributes: JsxAttributes): JsxOpeningElement; function createJsxClosingElement(tagName: JsxTagNameExpression): JsxClosingElement; function updateJsxClosingElement(node: JsxClosingElement, tagName: JsxTagNameExpression): JsxClosingElement; - function createJsxFragment(openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function createJsxFragment(openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxText(text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function updateJsxText(node: JsxText, text: string, containsOnlyTriviaWhiteSpaces?: boolean): JsxText; function createJsxOpeningFragment(): JsxOpeningFragment; function createJsxJsxClosingFragment(): JsxClosingFragment; - function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: ReadonlyArray, closingFragment: JsxClosingFragment): JsxFragment; + function updateJsxFragment(node: JsxFragment, openingFragment: JsxOpeningFragment, children: readonly JsxChild[], closingFragment: JsxClosingFragment): JsxFragment; function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; - function createJsxAttributes(properties: ReadonlyArray): JsxAttributes; - function updateJsxAttributes(node: JsxAttributes, properties: ReadonlyArray): JsxAttributes; + function createJsxAttributes(properties: readonly JsxAttributeLike[]): JsxAttributes; + function updateJsxAttributes(node: JsxAttributes, properties: readonly JsxAttributeLike[]): JsxAttributes; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; - function createCaseClause(expression: Expression, statements: ReadonlyArray): CaseClause; - function updateCaseClause(node: CaseClause, expression: Expression, statements: ReadonlyArray): CaseClause; - function createDefaultClause(statements: ReadonlyArray): DefaultClause; - function updateDefaultClause(node: DefaultClause, statements: ReadonlyArray): DefaultClause; - function createHeritageClause(token: HeritageClause["token"], types: ReadonlyArray): HeritageClause; - function updateHeritageClause(node: HeritageClause, types: ReadonlyArray): HeritageClause; + function createCaseClause(expression: Expression, statements: readonly Statement[]): CaseClause; + function updateCaseClause(node: CaseClause, expression: Expression, statements: readonly Statement[]): CaseClause; + function createDefaultClause(statements: readonly Statement[]): DefaultClause; + function updateDefaultClause(node: DefaultClause, statements: readonly Statement[]): DefaultClause; + function createHeritageClause(token: HeritageClause["token"], types: readonly ExpressionWithTypeArguments[]): HeritageClause; + function updateHeritageClause(node: HeritageClause, types: readonly ExpressionWithTypeArguments[]): HeritageClause; function createCatchClause(variableDeclaration: string | VariableDeclaration | undefined, block: Block): CatchClause; function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration | undefined, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; @@ -4071,7 +4159,7 @@ declare namespace ts { function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; - function updateSourceFileNode(node: SourceFile, statements: ReadonlyArray, isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; + function updateSourceFileNode(node: SourceFile, statements: readonly Statement[], isDeclarationFile?: boolean, referencedFiles?: SourceFile["referencedFiles"], typeReferences?: SourceFile["typeReferenceDirectives"], hasNoDefaultLib?: boolean, libReferences?: SourceFile["libReferenceDirectives"]): SourceFile; /** * Creates a shallow, memberwise clone of a node for mutation. */ @@ -4093,20 +4181,20 @@ declare namespace ts { */ function createPartiallyEmittedExpression(expression: Expression, original?: Node): PartiallyEmittedExpression; function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; - function createCommaList(elements: ReadonlyArray): CommaListExpression; - function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; + function createCommaList(elements: readonly Expression[]): CommaListExpression; + function updateCommaList(node: CommaListExpression, elements: readonly Expression[]): CommaListExpression; + function createBundle(sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; function createUnparsedSourceFile(text: string): UnparsedSource; function createUnparsedSourceFile(inputFile: InputFiles, type: "js" | "dts", stripInternal?: boolean): UnparsedSource; function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; function createInputFiles(javascriptText: string, declarationText: string): InputFiles; function createInputFiles(readFileText: (path: string) => string | undefined, javascriptPath: string, javascriptMapPath: string | undefined, declarationPath: string, declarationMapPath: string | undefined, buildInfoPath: string | undefined): InputFiles; function createInputFiles(javascriptText: string, declarationText: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; - function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; + function updateBundle(node: Bundle, sourceFiles: readonly SourceFile[], prepends?: readonly (UnparsedSource | InputFiles)[]): Bundle; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -4118,6 +4206,7 @@ declare namespace ts { function createPostfixIncrement(operand: Expression): PostfixUnaryExpression; function createLogicalAnd(left: Expression, right: Expression): BinaryExpression; function createLogicalOr(left: Expression, right: Expression): BinaryExpression; + function createNullishCoalesce(left: Expression, right: Expression): BinaryExpression; function createLogicalNot(operand: Expression): PrefixUnaryExpression; function createVoidZero(): VoidExpression; function createExportDefault(expression: Expression): ExportAssignment; @@ -4174,7 +4263,7 @@ declare namespace ts { /** * Sets the constant value to emit for an expression. */ - function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): PropertyAccessExpression | ElementAccessExpression; + function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: string | number): ElementAccessExpression | PropertyAccessExpression; /** * Adds an EmitHelper to a node. */ @@ -4279,23 +4368,25 @@ declare namespace ts { function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; } declare namespace ts { + function getTsBuildInfoEmitOutputFilePath(options: CompilerOptions): string | undefined; + function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName: string, ignoreCase: boolean): readonly string[]; function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } declare namespace ts { export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName?: string): string | undefined; export function resolveTripleslashReference(moduleName: string, containingFile: string): string; export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost; - export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; export interface FormatDiagnosticsHost { getCurrentDirectory(): string; getCanonicalFileName(fileName: string): string; getNewLine(): string; } - export function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; + export function formatDiagnostics(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; export function formatDiagnostic(diagnostic: Diagnostic, host: FormatDiagnosticsHost): string; - export function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; + export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; - export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): ReadonlyArray; + export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -4321,7 +4412,7 @@ declare namespace ts { * @param configFileParsingDiagnostics - error during config file parsing * @returns A 'Program' object. */ - export function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: ReadonlyArray): Program; + export function createProgram(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): Program; /** @deprecated */ export interface ResolveProjectReferencePathHost { fileExists(fileName: string): boolean; } @@ -4383,31 +4474,31 @@ declare namespace ts { /** * Get a list of files in the program */ - getSourceFiles(): ReadonlyArray; + getSourceFiles(): readonly SourceFile[]; /** * Get the diagnostics for compiler options */ - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics that dont belong to any file */ - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the diagnostics from config file parsing */ - getConfigFileParsingDiagnostics(): ReadonlyArray; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; /** * Get the syntax diagnostics, for all source files if source file is not supplied */ - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Get the declaration diagnostics, for all source files if source file is not supplied */ - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[]; /** * Get all the dependencies of the file */ - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; + getAllDependencies(sourceFile: SourceFile): readonly string[]; /** * Gets the semantic diagnostics from the program corresponding to this state of file (if provided) or whole program * The semantic diagnostics are cached and managed here @@ -4416,7 +4507,7 @@ declare namespace ts { * In case of SemanticDiagnosticsBuilderProgram if the source file is not provided, * it will iterate through all the affected files, to ensure that cache stays valid and yet provide a way to get all semantic diagnostics */ - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; /** * Emits the JavaScript and declaration files. * When targetSource file is specified, emits the files corresponding to that source file, @@ -4442,7 +4533,7 @@ declare namespace ts { * Gets the semantic diagnostics from the program for the next affected file and caches it * Returns undefined if the iteration is complete */ - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; } /** * The builder that can handle the changes in program and iterate through changed file to emit the files @@ -4459,19 +4550,19 @@ declare namespace ts { /** * Create the builder to manage semantic diagnostics and cache them */ - function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; - function createSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): SemanticDiagnosticsBuilderProgram; + function createSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: SemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): SemanticDiagnosticsBuilderProgram; /** * Create the builder that can handle the changes in program and iterate through changed files * to emit the those files and manage semantic diagnostics cache as well */ - function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; - function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(newProgram: Program, host: BuilderProgramHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): EmitAndSemanticDiagnosticsBuilderProgram; + function createEmitAndSemanticDiagnosticsBuilderProgram(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: EmitAndSemanticDiagnosticsBuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): EmitAndSemanticDiagnosticsBuilderProgram; /** * Creates a builder thats just abstraction over program and can be used with watch */ - function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray): BuilderProgram; - function createAbstractBuilder(rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray): BuilderProgram; + function createAbstractBuilder(newProgram: Program, host: BuilderProgramHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[]): BuilderProgram; + function createAbstractBuilder(rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: BuilderProgram, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[]): BuilderProgram; } declare namespace ts { interface ReadBuildProgramHost { @@ -4482,21 +4573,21 @@ declare namespace ts { function readBuilderProgram(compilerOptions: CompilerOptions, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram | undefined; function createIncrementalCompilerHost(options: CompilerOptions, system?: System): CompilerHost; interface IncrementalProgramOptions { - rootNames: ReadonlyArray; + rootNames: readonly string[]; options: CompilerOptions; - configFileParsingDiagnostics?: ReadonlyArray; - projectReferences?: ReadonlyArray; + configFileParsingDiagnostics?: readonly Diagnostic[]; + projectReferences?: readonly ProjectReference[]; host?: CompilerHost; createProgram?: CreateProgram; } function createIncrementalProgram({ rootNames, options, configFileParsingDiagnostics, projectReferences, host, createProgram }: IncrementalProgramOptions): T; - type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions) => void; + type WatchStatusReporter = (diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number) => void; /** Create the program with rootNames and options, if they are undefined, oldProgram and new configFile diagnostics create new program */ - type CreateProgram = (rootNames: ReadonlyArray | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: ReadonlyArray, projectReferences?: ReadonlyArray | undefined) => T; + type CreateProgram = (rootNames: readonly string[] | undefined, options: CompilerOptions | undefined, host?: CompilerHost, oldProgram?: T, configFileParsingDiagnostics?: readonly Diagnostic[], projectReferences?: readonly ProjectReference[] | undefined) => T; /** Host that has watch functionality used in --watch mode */ interface WatchHost { /** If provided, called with Diagnostic message that informs about change in watch status */ - onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions): void; + onWatchStatusChange?(diagnostic: Diagnostic, newLine: string, options: CompilerOptions, errorCount?: number): void; /** Used to watch changes in source files, missing files needed to update the program or config file */ watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number): FileWatcher; /** Used to watch resolved module's failed lookup locations, config file specs, type roots where auto type reference directives are added */ @@ -4532,7 +4623,7 @@ declare namespace ts { /** If provided, used in resolutions as well as handling directory structure */ getDirectories?(path: string): string[]; /** If provided, used to cache and handle directory structure modifications */ - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; /** Symbol links resolution */ realpath?(path: string): string; /** If provided would be used to write log about compilation */ @@ -4557,7 +4648,7 @@ declare namespace ts { /** Compiler options */ options: CompilerOptions; /** Project References */ - projectReferences?: ReadonlyArray; + projectReferences?: readonly ProjectReference[]; } /** * Host to create watch with config file @@ -4571,7 +4662,7 @@ declare namespace ts { * Used to generate source file names from the config file and its include, exclude, files rules * and also to cache the directory stucture */ - readDirectory(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; } interface Watch { /** Synchronize with host and get updated program */ @@ -4595,7 +4686,7 @@ declare namespace ts { * Create the watch compiler host for either configFile or fileNames and its options */ function createWatchCompilerHost(configFileName: string, optionsToExtend: CompilerOptions | undefined, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): WatchCompilerHostOfConfigFile; - function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: ReadonlyArray): WatchCompilerHostOfFilesAndCompilerOptions; + function createWatchCompilerHost(rootFiles: string[], options: CompilerOptions, system: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter, projectReferences?: readonly ProjectReference[]): WatchCompilerHostOfFilesAndCompilerOptions; /** * Creates the watch from the host for root files and compiler options */ @@ -4648,8 +4739,8 @@ declare namespace ts { function createBuilderStatusReporter(system: System, pretty?: boolean): DiagnosticReporter; function createSolutionBuilderHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportErrorSummary?: ReportEmitErrorSummary): SolutionBuilderHost; function createSolutionBuilderWithWatchHost(system?: System, createProgram?: CreateProgram, reportDiagnostic?: DiagnosticReporter, reportSolutionBuilderStatus?: DiagnosticReporter, reportWatchStatus?: WatchStatusReporter): SolutionBuilderWithWatchHost; - function createSolutionBuilder(host: SolutionBuilderHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; - function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: ReadonlyArray, defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilder(host: SolutionBuilderHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; + function createSolutionBuilderWithWatch(host: SolutionBuilderWithWatchHost, rootNames: readonly string[], defaultOptions: BuildOptions): SolutionBuilder; enum InvalidatedProjectKind { Build = 0, UpdateBundle = 1, @@ -4674,14 +4765,14 @@ declare namespace ts { getBuilderProgram(): T | undefined; getProgram(): Program | undefined; getSourceFile(fileName: string): SourceFile | undefined; - getSourceFiles(): ReadonlyArray; - getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; - getConfigFileParsingDiagnostics(): ReadonlyArray; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getAllDependencies(sourceFile: SourceFile): ReadonlyArray; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; - getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult>; + getSourceFiles(): readonly SourceFile[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[]; + getConfigFileParsingDiagnostics(): readonly Diagnostic[]; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getAllDependencies(sourceFile: SourceFile): readonly string[]; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[]; + getSemanticDiagnosticsOfNextAffectedFile(cancellationToken?: CancellationToken, ignoreSourceFile?: (sourceFile: SourceFile) => boolean): AffectedFileResult; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult | undefined; } interface UpdateBundleProject extends InvalidatedProjectBase { @@ -4744,7 +4835,7 @@ declare namespace ts.server { readonly kind: EventBeginInstallTypes | EventEndInstallTypes; readonly eventId: number; readonly typingsInstallerVersion: string; - readonly packagesToInstall: ReadonlyArray; + readonly packagesToInstall: readonly string[]; } interface BeginInstallTypes extends InstallTypes { readonly kind: EventBeginInstallTypes; @@ -4797,8 +4888,8 @@ declare namespace ts { getProperties(): Symbol[]; getProperty(propertyName: string): Symbol | undefined; getApparentProperties(): Symbol[]; - getCallSignatures(): ReadonlyArray; - getConstructSignatures(): ReadonlyArray; + getCallSignatures(): readonly Signature[]; + getConstructSignatures(): readonly Signature[]; getStringIndexType(): Type | undefined; getNumberIndexType(): Type | undefined; getBaseTypes(): BaseType[] | undefined; @@ -4815,6 +4906,9 @@ declare namespace ts { isClassOrInterface(): this is InterfaceType; isClass(): this is InterfaceType; } + interface TypeReference { + typeArguments?: readonly Type[]; + } interface Signature { getDeclaration(): SignatureDeclaration; getTypeParameters(): TypeParameter[] | undefined; @@ -4826,7 +4920,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): ReadonlyArray; + getLineStarts(): readonly number[]; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -4875,7 +4969,7 @@ declare namespace ts { fileName: Path; packageName: string; } - interface LanguageServiceHost extends GetEffectiveTypeRootsHost { + interface LanguageServiceHost extends ModuleSpecifierResolutionHost { getCompilationSettings(): CompilerOptions; getNewLine?(): string; getProjectVersion?(): string; @@ -4883,7 +4977,7 @@ declare namespace ts { getScriptKind?(fileName: string): ScriptKind; getScriptVersion(fileName: string): string; getScriptSnapshot(fileName: string): IScriptSnapshot | undefined; - getProjectReferences?(): ReadonlyArray | undefined; + getProjectReferences?(): readonly ProjectReference[] | undefined; getLocalizedDiagnosticMessages?(): any; getCancellationToken?(): HostCancellationToken; getCurrentDirectory(): string; @@ -4891,8 +4985,7 @@ declare namespace ts { log?(s: string): void; trace?(s: string): void; error?(s: string): void; - useCaseSensitiveFileNames?(): boolean; - readDirectory?(path: string, extensions?: ReadonlyArray, exclude?: ReadonlyArray, include?: ReadonlyArray, depth?: number): string[]; + readDirectory?(path: string, extensions?: readonly string[], exclude?: readonly string[], include?: readonly string[], depth?: number): string[]; readFile?(path: string, encoding?: string): string | undefined; realpath?(path: string): string; fileExists?(path: string): boolean; @@ -4937,17 +5030,17 @@ declare namespace ts { getBreakpointStatementAtPosition(fileName: string, position: number): TextSpan | undefined; getSignatureHelpItems(fileName: string, position: number, options: SignatureHelpItemsOptions | undefined): SignatureHelpItems | undefined; getRenameInfo(fileName: string, position: number, options?: RenameInfoOptions): RenameInfo; - findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): ReadonlyArray | undefined; + findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean, providePrefixAndSuffixTextForRename?: boolean): readonly RenameLocation[] | undefined; getSmartSelectionRange(fileName: string, position: number): SelectionRange; - getDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; getDefinitionAndBoundSpan(fileName: string, position: number): DefinitionInfoAndBoundSpan | undefined; - getTypeDefinitionAtPosition(fileName: string, position: number): ReadonlyArray | undefined; - getImplementationAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getTypeDefinitionAtPosition(fileName: string, position: number): readonly DefinitionInfo[] | undefined; + getImplementationAtPosition(fileName: string, position: number): readonly ImplementationLocation[] | undefined; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] | undefined; findReferences(fileName: string, position: number): ReferencedSymbol[] | undefined; getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): DocumentHighlights[] | undefined; /** @deprecated */ - getOccurrencesAtPosition(fileName: string, position: number): ReadonlyArray | undefined; + getOccurrencesAtPosition(fileName: string, position: number): readonly ReferenceEntry[] | undefined; getNavigateToItems(searchValue: string, maxResultCount?: number, fileName?: string, excludeDtsFiles?: boolean): NavigateToItem[]; getNavigationBarItems(fileName: string): NavigationBarItem[]; getNavigationTree(fileName: string): NavigationTree; @@ -4967,7 +5060,7 @@ declare namespace ts { getJsxClosingTagAtPosition(fileName: string, position: number): JsxClosingTagInfo | undefined; getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan | undefined; toLineColumnOffset?(fileName: string, position: number): LineAndCharacter; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: readonly number[], formatOptions: FormatCodeSettings, preferences: UserPreferences): readonly CodeFixAction[]; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -4980,9 +5073,9 @@ declare namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; - organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; - getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray; - getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; + organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEditsForFileRename(oldFilePath: string, newFilePath: string, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): readonly FileTextChanges[]; + getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean, forceDtsEmit?: boolean): EmitOutput; getProgram(): Program | undefined; dispose(): void; } @@ -5105,7 +5198,7 @@ declare namespace ts { } interface FileTextChanges { fileName: string; - textChanges: TextChange[]; + textChanges: readonly TextChange[]; isNewFile?: boolean; } interface CodeAction { @@ -5130,8 +5223,8 @@ declare namespace ts { fixAllDescription?: string; } interface CombinedCodeActions { - changes: ReadonlyArray; - commands?: ReadonlyArray; + changes: readonly FileTextChanges[]; + commands?: readonly CodeActionCommand[]; } type CodeActionCommand = InstallPackageAction; interface InstallPackageAction { @@ -5252,6 +5345,11 @@ declare namespace ts { Block = 1, Smart = 2 } + enum SemicolonPreference { + Ignore = "ignore", + Insert = "insert", + Remove = "remove" + } interface EditorOptions { BaseIndentSize?: number; IndentSize: number; @@ -5304,6 +5402,7 @@ declare namespace ts { readonly placeOpenBraceOnNewLineForControlBlocks?: boolean; readonly insertSpaceBeforeTypeAnnotation?: boolean; readonly indentMultiLineObjectLiteralBeginningOnBlankLine?: boolean; + readonly semicolons?: SemicolonPreference; } function getDefaultFormatCodeSettings(newLineCharacter?: string): FormatCodeSettings; interface DefinitionInfo extends DocumentSpan { @@ -5313,7 +5412,7 @@ declare namespace ts { containerName: string; } interface DefinitionInfoAndBoundSpan { - definitions?: ReadonlyArray; + definitions?: readonly DefinitionInfo[]; textSpan: TextSpan; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { diff --git a/node_modules/typescript/lib/typescriptServices.js b/node_modules/typescript/lib/typescriptServices.js index d41325d6b..cdab461b9 100644 --- a/node_modules/typescript/lib/typescriptServices.js +++ b/node_modules/typescript/lib/typescriptServices.js @@ -76,67 +76,20 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var ts; -(function (ts) { - // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. - // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; - /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; -})(ts || (ts = {})); -(function (ts) { - /* @internal */ - var Comparison; - (function (Comparison) { - Comparison[Comparison["LessThan"] = -1] = "LessThan"; - Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; - Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; - })(Comparison = ts.Comparison || (ts.Comparison = {})); -})(ts || (ts = {})); /* @internal */ +var ts; (function (ts) { - ts.emptyArray = []; - /** Create a MapLike with good performance. */ - function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map.__ = undefined; - delete map.__; - return map; - } - /** Create a new map. If a template object is provided, the map will copy entries from it. */ - function createMap() { - return new ts.MapCtr(); - } - ts.createMap = createMap; - function createMapFromEntries(entries) { - var map = createMap(); - for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { - var _a = entries_1[_i], key = _a[0], value = _a[1]; - map.set(key, value); - } - return map; - } - ts.createMapFromEntries = createMapFromEntries; - function createMapFromTemplate(template) { - var map = new ts.MapCtr(); - // Copies keys/values from template. Note that for..in will not throw if - // template is undefined, and instead will just exit the loop. - for (var key in template) { - if (hasOwnProperty.call(template, key)) { - map.set(key, template[key]); - } + function createMapShim() { + /** Create a MapLike with good performance. */ + function createDictionaryObject() { + var map = Object.create(/*prototype*/ null); // eslint-disable-line no-null/no-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; } - return map; - } - ts.createMapFromTemplate = createMapFromTemplate; - // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name - ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); - // Keep the class inside a function so it doesn't get compiled if it's not used. - function shimMap() { var MapIterator = /** @class */ (function () { function MapIterator(currentEntry, selector) { this.currentEntry = currentEntry; @@ -197,7 +150,7 @@ var ts; return this; }; class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator + // eslint-disable-next-line no-in-operator return key in this.data; }; class_1.prototype.delete = function (key) { @@ -272,7 +225,75 @@ var ts; return class_1; }()); } - ts.shimMap = shimMap; + ts.createMapShim = createMapShim; +})(ts || (ts = {})); +var ts; +(function (ts) { + // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. + // If changing the text in this section, be sure to test `configureNightly` too. + ts.versionMajorMinor = "3.7"; + /** The version of the TypeScript compiler release */ + ts.version = ts.versionMajorMinor + ".2"; +})(ts || (ts = {})); +(function (ts) { + /* @internal */ + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + /** + * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). + */ + function tryGetNativeMap() { + // Internet Explorer's Map doesn't support iteration, so don't use it. + // eslint-disable-next-line no-in-operator + return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined; + } + ts.tryGetNativeMap = tryGetNativeMap; +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + ts.emptyArray = []; + ts.Map = ts.tryGetNativeMap() || (function () { + // NOTE: createMapShim will be defined for typescriptServices.js but not for tsc.js, so we must test for it. + if (typeof ts.createMapShim === "function") { + return ts.createMapShim(); + } + throw new Error("TypeScript requires an environment that provides a compatible native Map implementation."); + })(); + /** Create a new map. */ + function createMap() { + return new ts.Map(); + } + ts.createMap = createMap; + /** Create a new map from an array of entries. */ + function createMapFromEntries(entries) { + var map = createMap(); + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var _a = entries_1[_i], key = _a[0], value = _a[1]; + map.set(key, value); + } + return map; + } + ts.createMapFromEntries = createMapFromEntries; + /** Create a new map from a template object is provided, the map will copy entries from it. */ + function createMapFromTemplate(template) { + var map = new ts.Map(); + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (var key in template) { + if (hasOwnProperty.call(template, key)) { + map.set(key, template[key]); + } + } + return map; + } + ts.createMapFromTemplate = createMapFromTemplate; function length(array) { return array ? array.length : 0; } @@ -294,6 +315,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -847,6 +883,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1387,6 +1424,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1446,7 +1489,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1480,7 +1523,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1832,20 +1875,6 @@ var ts; return str.indexOf(substring) !== -1; } ts.stringContains = stringContains; - function fileExtensionIs(path, extension) { - return path.length > extension.length && endsWith(path, extension); - } - ts.fileExtensionIs = fileExtensionIs; - function fileExtensionIsOneOf(path, extensions) { - for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { - var extension = extensions_1[_i]; - if (fileExtensionIs(path, extension)) { - return true; - } - } - return false; - } - ts.fileExtensionIsOneOf = fileExtensionIsOneOf; /** * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ @@ -1954,11 +1983,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2035,8 +2086,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2085,6 +2138,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2100,7 +2154,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2208,6 +2262,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2218,6 +2275,33 @@ var ts; ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); } : ts.noop; var isDebugInfoEnabled = false; + var extendedDebugModule; + function extendedDebug() { + enableDebugInfo(); + if (!extendedDebugModule) { + throw new Error("Debugging helpers could not be loaded."); + } + return extendedDebugModule; + } + function printControlFlowGraph(flowNode) { + return console.log(formatControlFlowGraph(flowNode)); + } + Debug.printControlFlowGraph = printControlFlowGraph; + function formatControlFlowGraph(flowNode) { + return extendedDebug().formatControlFlowGraph(flowNode); + } + Debug.formatControlFlowGraph = formatControlFlowGraph; + function attachFlowNodeDebugInfo(flowNode) { + if (isDebugInfoEnabled) { + if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line no-in-operator + Object.defineProperties(flowNode, { + __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, + __debugToString: { value: function () { return formatControlFlowGraph(this); } } + }); + } + } + } + Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo; /** * Injects debug information into frequently used types. */ @@ -2261,6 +2345,20 @@ var ts; }); } } + // attempt to load extended debugging information + try { + if (ts.sys && ts.sys.require) { + var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath())); + var result = ts.sys.require(basePath, "./compiler-debug"); + if (!result.error) { + result.module.init(ts); + extendedDebugModule = result.module; + } + } + } + catch (_a) { + // do nothing + } isDebugInfoEnabled = true; } Debug.enableDebugInfo = enableDebugInfo; @@ -2417,15 +2515,13 @@ var ts; try { // require() will throw an exception if the module is not installed // It may also return undefined if not installed properly - etwModule = require("@microsoft/typescript-etw"); // tslint:disable-line:no-implicit-dependencies + etwModule = require("@microsoft/typescript-etw"); } catch (e) { etwModule = undefined; } /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; - var args = typeof process === "undefined" ? [] : process.argv; - ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); })(ts || (ts = {})); /* @internal */ var ts; @@ -2827,360 +2923,366 @@ var ts; SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 297] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 298] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 299] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 300] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 301] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 302] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 303] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 304] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 305] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 306] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 307] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 308] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 309] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 310] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 311] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 312] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 313] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 314] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 315] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 316] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 317] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 318] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 319] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 320] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 313] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 301] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 313] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3190,20 +3292,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3213,23 +3316,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3268,7 +3371,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3310,6 +3416,7 @@ var ts; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; })(TokenFlags = ts.TokenFlags || (ts.TokenFlags = {})); + // NOTE: Ensure this is up-to-date with src/debug/debug.ts var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; @@ -3321,12 +3428,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3336,6 +3444,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3356,6 +3471,10 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped"; + /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3364,6 +3483,14 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + /* @internal */ + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + ContextFlags[ContextFlags["Completion"] = 4] = "Completion"; + })(ContextFlags = ts.ContextFlags || (ts.ContextFlags = {})); // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { @@ -3421,7 +3548,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3471,27 +3597,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3562,11 +3701,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3789,6 +3932,18 @@ var ts; SignatureKind[SignatureKind["Call"] = 0] = "Call"; SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + /* @internal */ + var SignatureFlags; + (function (SignatureFlags) { + SignatureFlags[SignatureFlags["None"] = 0] = "None"; + SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter"; + SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes"; + SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall"; + // We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us + // attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when + // instantiating the return type. + SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags"; + })(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {})); var IndexKind; (function (IndexKind) { IndexKind[IndexKind["String"] = 0] = "String"; @@ -4684,7 +4839,7 @@ var ts; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; /*@internal*/ - ts.sysLog = ts.noop; + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4789,6 +4944,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4805,12 +4986,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4822,6 +5005,8 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; @@ -4903,8 +5088,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4928,8 +5115,101 @@ var ts; bufferFrom: bufferFrom, base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); }, base64encode: function (input) { return bufferFrom(input).toString("base64"); }, + require: function (baseDir, moduleName) { + try { + var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem); + return { module: require(modulePath), modulePath: modulePath, error: undefined }; + } + catch (error) { + return { module: undefined, modulePath: undefined, error: error }; + } + } }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4982,6 +5262,7 @@ var ts; if (fsSupportsRecursive) { return watchDirectoryUsingFsWatch; } + // defer watchDirectoryRecursively as it depends on `ts.createMap()` which may not be usable yet. var watchDirectory = tscWatchDirectory === "RecursiveDirectoryUsingFsWatchFile" ? createWatchDirectoryUsing(fsWatchFile) : tscWatchDirectory === "RecursiveDirectoryUsingDynamicPriorityPolling" ? @@ -5401,16 +5682,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5422,14 +5693,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5443,311 +5707,985 @@ var ts; ts.Debug.isDebugging = true; } })(ts || (ts = {})); -// -// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + /** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + */ + ts.directorySeparator = "/"; + var altDirectorySeparator = "\\"; + var urlSchemeSeparator = "://"; + var backslashRegExp = /\\/g; + //// Path Tests + /** + * Determines whether a charCode corresponds to `/` or `\`. + */ + function isAnyDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; } - // tslint:disable-next-line variable-name - ts.Diagnostics = { - Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), - Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), - _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), - A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), - Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), - An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), - Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), - A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), - A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), - Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), - A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), - An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), - An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), - An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), - An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), - An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), - An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), - An_index_signature_parameter_type_must_be_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_or_number_1023", "An index signature parameter type must be 'string' or 'number'."), - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), - Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), - _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), - _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), - _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), - super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), - Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), - Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), - Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), - _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), - _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), - _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), - _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), - _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), - A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), - Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), - A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), - A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), - A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), - A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), - A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), - A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), - A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), - An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), - The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), - A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), - The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), - Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), - Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), - An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), - Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), - _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), - _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), - A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), - Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), - _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), - Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), - Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), - An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), - A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), - An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), - _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), - Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), - Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), - Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), - with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), - delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), - Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), - A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), - Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), - Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), - Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), - An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), - Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), - Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), - Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), - Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), - Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), - Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), - Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), - case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), - Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), - Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), - Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), - Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), - Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), - Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), - Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), - Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), - Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), - String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), - Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), - or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), - Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), - Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), - File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), - const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), - const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), - let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), - Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), - Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), - An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), - A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), - Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), - A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), - extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), - extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), - Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), - implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), - Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), - Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), - Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), - Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), - Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), - Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), - A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), - An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), - Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), - Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), - A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), - A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), - An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), - Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), - An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), - Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), - Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), - Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), - Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), - Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), - Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), - Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), - All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), - A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), - Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), - Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), - Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), - An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), - _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), - Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), - Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), - Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), - Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), - A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), - An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), - An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), - _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), - Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), - An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), - A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), - A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), - A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), - A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), - A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), - Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), - Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), - Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), - with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), - await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), - The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), - Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), - Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), - Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), - A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), - An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), - A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), - Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), - Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), - Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323", "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'."), - Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), - Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), - String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), - Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), - _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), - A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), - A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), - A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), - unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), - unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), - unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), - An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), - An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), - infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), - Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), - Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), - A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), - An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), - This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), - use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), - Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), - use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), - Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), - An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), - A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), - A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), - readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), - A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), - Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), - Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), - Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), - Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), - Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), - Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), - File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), - Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), - Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), - A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), - An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), - Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), - Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), - Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), - Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), - Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), - Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), - Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), - Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), - Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), - Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), - Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), - Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), - Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), - Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), - Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), - Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), - Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), - Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), - this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), - this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), - this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), - this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), + ts.isAnyDirectorySeparator = isAnyDirectorySeparator; + /** + * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.). + */ + function isUrl(path) { + return getEncodedRootLength(path) < 0; + } + ts.isUrl = isUrl; + /** + * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path + * like `c:`, `c:\` or `c:/`). + */ + function isRootedDiskPath(path) { + return getEncodedRootLength(path) > 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + /** + * Determines whether a path consists only of a path root. + */ + function isDiskPathRoot(path) { + var rootLength = getEncodedRootLength(path); + return rootLength > 0 && rootLength === path.length; + } + ts.isDiskPathRoot = isDiskPathRoot; + /** + * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.). + * + * ```ts + * // POSIX + * pathIsAbsolute("/path/to/file.ext") === true + * // DOS + * pathIsAbsolute("c:/path/to/file.ext") === true + * // URL + * pathIsAbsolute("file:///path/to/file.ext") === true + * // Non-absolute + * pathIsAbsolute("path/to/file.ext") === false + * pathIsAbsolute("./path/to/file.ext") === false + * ``` + */ + function pathIsAbsolute(path) { + return getEncodedRootLength(path) !== 0; + } + ts.pathIsAbsolute = pathIsAbsolute; + /** + * Determines whether a path starts with a relative path component (i.e. `.` or `..`). + */ + function pathIsRelative(path) { + return /^\.\.?($|[\\/])/.test(path); + } + ts.pathIsRelative = pathIsRelative; + function hasExtension(fileName) { + return ts.stringContains(getBaseFileName(fileName), "."); + } + ts.hasExtension = hasExtension; + function fileExtensionIs(path, extension) { + return path.length > extension.length && ts.endsWith(path, extension); + } + ts.fileExtensionIs = fileExtensionIs; + function fileExtensionIsOneOf(path, extensions) { + for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { + var extension = extensions_1[_i]; + if (fileExtensionIs(path, extension)) { + return true; + } + } + return false; + } + ts.fileExtensionIsOneOf = fileExtensionIsOneOf; + /** + * Determines whether a path has a trailing separator (`/` or `\\`). + */ + function hasTrailingDirectorySeparator(path) { + return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); + } + ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; + //// Path Parsing + function isVolumeCharacter(charCode) { + return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || + (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + } + function getFileUrlVolumeSeparatorEnd(url, start) { + var ch0 = url.charCodeAt(start); + if (ch0 === 58 /* colon */) + return start + 1; + if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + var ch2 = url.charCodeAt(start + 2); + if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + return start + 3; + } + return -1; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * If the root is part of a URL, the twos-complement of the root length is returned. + */ + function getEncodedRootLength(path) { + if (!path) + return 0; + var ch0 = path.charCodeAt(0); + // POSIX or UNC + if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (path.charCodeAt(1) !== ch0) + return 1; // POSIX: "/" (or non-normalized "\") + var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); + if (p1 < 0) + return path.length; // UNC: "//server" or "\\server" + return p1 + 1; // UNC: "//server/" or "\\server\" + } + // DOS + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + var ch2 = path.charCodeAt(2); + if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + return 3; // DOS: "c:/" or "c:\" + if (path.length === 2) + return 2; // DOS: "c:" (but not "c:d") + } + // URL + var schemeEnd = path.indexOf(urlSchemeSeparator); + if (schemeEnd !== -1) { + var authorityStart = schemeEnd + urlSchemeSeparator.length; + var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); + if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" + // For local "file" URLs, include the leading DOS volume (if present). + // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a + // special case interpreted as "the machine from which the URL is being interpreted". + var scheme = path.slice(0, schemeEnd); + var authority = path.slice(authorityStart, authorityEnd); + if (scheme === "file" && (authority === "" || authority === "localhost") && + isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { + var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); + if (volumeSeparatorEnd !== -1) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" + return ~(volumeSeparatorEnd + 1); + } + if (volumeSeparatorEnd === path.length) { + // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" + // but not "file:///c:d" or "file:///c%3ad" + return ~volumeSeparatorEnd; + } + } + } + return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" + } + return ~path.length; // URL: "file://server", "http://server" + } + // relative + return 0; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * + * For example: + * ```ts + * getRootLength("a") === 0 // "" + * getRootLength("/") === 1 // "/" + * getRootLength("c:") === 2 // "c:" + * getRootLength("c:d") === 0 // "" + * getRootLength("c:/") === 3 // "c:/" + * getRootLength("c:\\") === 3 // "c:\\" + * getRootLength("//server") === 7 // "//server" + * getRootLength("//server/share") === 8 // "//server/" + * getRootLength("\\\\server") === 7 // "\\\\server" + * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" + * getRootLength("file:///path") === 8 // "file:///" + * getRootLength("file:///c:") === 10 // "file:///c:" + * getRootLength("file:///c:d") === 8 // "file:///" + * getRootLength("file:///c:/path") === 11 // "file:///c:/" + * getRootLength("file://server") === 13 // "file://server" + * getRootLength("file://server/path") === 14 // "file://server/" + * getRootLength("http://server") === 13 // "http://server" + * getRootLength("http://server/path") === 14 // "http://server/" + * ``` + */ + function getRootLength(path) { + var rootLength = getEncodedRootLength(path); + return rootLength < 0 ? ~rootLength : rootLength; + } + ts.getRootLength = getRootLength; + function getDirectoryPath(path) { + path = normalizeSlashes(path); + // If the path provided is itself the root, then return it. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return path; + // return the leading portion of the path up to the last (non-terminal) directory separator + // but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function getBaseFileName(path, extensions, ignoreCase) { + path = normalizeSlashes(path); + // if the path provided is itself the root, then it has not file name. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return ""; + // return the trailing portion of the path starting after the last (non-terminal) directory + // separator but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); + var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; + return extension ? name.slice(0, name.length - extension.length) : name; + } + ts.getBaseFileName = getBaseFileName; + function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { + if (!ts.startsWith(extension, ".")) + extension = "." + extension; + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + var pathExtension = path.slice(path.length - extension.length); + if (stringEqualityComparer(pathExtension, extension)) { + return pathExtension; + } + } + } + function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { + if (typeof extensions === "string") { + return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || ""; + } + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer); + if (result) + return result; + } + return ""; + } + function getAnyExtensionFromPath(path, extensions, ignoreCase) { + // Retrieves any string from the final "." onwards from a base file name. + // Unlike extensionFromPath, which throws an exception on unrecognized extensions. + if (extensions) { + return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); + } + var baseFileName = getBaseFileName(path); + var extensionIndex = baseFileName.lastIndexOf("."); + if (extensionIndex >= 0) { + return baseFileName.substring(extensionIndex); + } + return ""; + } + ts.getAnyExtensionFromPath = getAnyExtensionFromPath; + function pathComponents(path, rootLength) { + var root = path.substring(0, rootLength); + var rest = path.substring(rootLength).split(ts.directorySeparator); + if (rest.length && !ts.lastOrUndefined(rest)) + rest.pop(); + return __spreadArrays([root], rest); + } + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is not normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * // POSIX + * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"] + * getPathComponents("/path/to/") === ["/", "path", "to"] + * getPathComponents("/") === ["/"] + * // DOS + * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"] + * getPathComponents("c:/path/to/") === ["c:/", "path", "to"] + * getPathComponents("c:/") === ["c:/"] + * getPathComponents("c:") === ["c:"] + * // URL + * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"] + * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"] + * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"] + * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"] + * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"] + * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"] + * getPathComponents("file://server/") === ["file://server/"] + * getPathComponents("file://server") === ["file://server"] + * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"] + * getPathComponents("file:///path/to/") === ["file:///", "path", "to"] + * getPathComponents("file:///") === ["file:///"] + * getPathComponents("file://") === ["file://"] + */ + function getPathComponents(path, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } + path = combinePaths(currentDirectory, path); + return pathComponents(path, getRootLength(path)); + } + ts.getPathComponents = getPathComponents; + //// Path Formatting + /** + * Formats a parsed path consisting of a root component (at index 0) and zero or more path + * segments (at indices > 0). + * + * ```ts + * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext" + * ``` + */ + function getPathFromPathComponents(pathComponents) { + if (pathComponents.length === 0) + return ""; + var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]); + return root + pathComponents.slice(1).join(ts.directorySeparator); + } + ts.getPathFromPathComponents = getPathFromPathComponents; + //// Path Normalization + /** + * Normalize path separators, converting `\` into `/`. + */ + function normalizeSlashes(path) { + return path.replace(backslashRegExp, ts.directorySeparator); + } + ts.normalizeSlashes = normalizeSlashes; + /** + * Reduce an array of path components to a more simplified path by navigating any + * `"."` or `".."` entries in the path. + */ + function reducePathComponents(components) { + if (!ts.some(components)) + return []; + var reduced = [components[0]]; + for (var i = 1; i < components.length; i++) { + var component = components[i]; + if (!component) + continue; + if (component === ".") + continue; + if (component === "..") { + if (reduced.length > 1) { + if (reduced[reduced.length - 1] !== "..") { + reduced.pop(); + continue; + } + } + else if (reduced[0]) + continue; + } + reduced.push(component); + } + return reduced; + } + ts.reducePathComponents = reducePathComponents; + /** + * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. + * + * ```ts + * // Non-rooted + * combinePaths("path", "to", "file.ext") === "path/to/file.ext" + * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext" + * // POSIX + * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext" + * combinePaths("/path", "/to", "file.ext") === "/to/file.ext" + * // DOS + * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext" + * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext" + * // URL + * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext" + * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext" + * ``` + */ + function combinePaths(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + if (path) + path = normalizeSlashes(path); + for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { + var relativePath = paths_1[_a]; + if (!relativePath) + continue; + relativePath = normalizeSlashes(relativePath); + if (!path || getRootLength(relativePath) !== 0) { + path = relativePath; + } + else { + path = ensureTrailingDirectorySeparator(path) + relativePath; + } + } + return path; + } + ts.combinePaths = combinePaths; + /** + * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any + * `.` and `..` path components are resolved. Trailing directory separators are preserved. + * + * ```ts + * resolvePath("/path", "to", "file.ext") === "path/to/file.ext" + * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/" + * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext" + * ``` + */ + function resolvePath(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path)); + } + ts.resolvePath = resolvePath; + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"] + */ + function getNormalizedPathComponents(path, currentDirectory) { + return reducePathComponents(getPathComponents(path, currentDirectory)); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function normalizePath(path) { + path = normalizeSlashes(path); + var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); + return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; + } + ts.normalizePath = normalizePath; + function getPathWithoutRoot(pathComponents) { + if (pathComponents.length === 0) + return ""; + return pathComponents.slice(1).join(ts.directorySeparator); + } + function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { + return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; + function normalizePathAndParts(path) { + path = normalizeSlashes(path); + var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; + } + else { + return { path: root, parts: parts }; + } + } + ts.normalizePathAndParts = normalizePathAndParts; + function removeTrailingDirectorySeparator(path) { + if (hasTrailingDirectorySeparator(path)) { + return path.substr(0, path.length - 1); + } + return path; + } + ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; + function ensureTrailingDirectorySeparator(path) { + if (!hasTrailingDirectorySeparator(path)) { + return path + ts.directorySeparator; + } + return path; + } + ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; + /** + * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed + * with `./` or `../`) so as not to be confused with an unprefixed module name. + * + * ```ts + * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext" + * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext" + * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext" + * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext" + * ``` + */ + function ensurePathIsNonModuleName(path) { + return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path; + } + ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; + function changeAnyExtension(path, ext, extensions, ignoreCase) { + var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); + return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; + } + ts.changeAnyExtension = changeAnyExtension; + //// Path Comparisons + // check path for these segments: '', '.'. '..' + var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + function comparePathsWorker(a, b, componentComparer) { + if (a === b) + return 0 /* EqualTo */; + if (a === undefined) + return -1 /* LessThan */; + if (b === undefined) + return 1 /* GreaterThan */; + // NOTE: Performance optimization - shortcut if the root segments differ as there would be no + // need to perform path reduction. + var aRoot = a.substring(0, getRootLength(a)); + var bRoot = b.substring(0, getRootLength(b)); + var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); + if (result !== 0 /* EqualTo */) { + return result; + } + // NOTE: Performance optimization - shortcut if there are no relative path segments in + // the non-root portion of the path + var aRest = a.substring(aRoot.length); + var bRest = b.substring(bRoot.length); + if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { + return componentComparer(aRest, bRest); + } + // The path contains a relative path segment. Normalize the paths and perform a slower component + // by component comparison. + var aComponents = reducePathComponents(getPathComponents(a)); + var bComponents = reducePathComponents(getPathComponents(b)); + var sharedLength = Math.min(aComponents.length, bComponents.length); + for (var i = 1; i < sharedLength; i++) { + var result_1 = componentComparer(aComponents[i], bComponents[i]); + if (result_1 !== 0 /* EqualTo */) { + return result_1; + } + } + return ts.compareValues(aComponents.length, bComponents.length); + } + /** + * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively. + */ + function comparePathsCaseSensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + } + ts.comparePathsCaseSensitive = comparePathsCaseSensitive; + /** + * Performs a case-insensitive comparison of two paths. + */ + function comparePathsCaseInsensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + } + ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; + function comparePaths(a, b, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + a = combinePaths(currentDirectory, a); + b = combinePaths(currentDirectory, b); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + } + ts.comparePaths = comparePaths; + function containsPath(parent, child, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + parent = combinePaths(currentDirectory, parent); + child = combinePaths(currentDirectory, child); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + if (parent === undefined || child === undefined) + return false; + if (parent === child) + return true; + var parentComponents = reducePathComponents(getPathComponents(parent)); + var childComponents = reducePathComponents(getPathComponents(child)); + if (childComponents.length < parentComponents.length) { + return false; + } + var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; + for (var i = 0; i < parentComponents.length; i++) { + var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; + if (!equalityComparer(parentComponents[i], childComponents[i])) { + return false; + } + } + return true; + } + ts.containsPath = containsPath; + /** + * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. + * Comparison is case-sensitive between the canonical paths. + * + * @deprecated Use `containsPath` if possible. + */ + function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { + var canonicalFileName = getCanonicalFileName(fileName); + var canonicalDirectoryName = getCanonicalFileName(directoryName); + return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); + } + ts.startsWithDirectory = startsWithDirectory; + //// Relative Paths + function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { + var fromComponents = reducePathComponents(getPathComponents(from)); + var toComponents = reducePathComponents(getPathComponents(to)); + var start; + for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { + var fromComponent = getCanonicalFileName(fromComponents[start]); + var toComponent = getCanonicalFileName(toComponents[start]); + var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; + if (!comparer(fromComponent, toComponent)) + break; + } + if (start === 0) { + return toComponents; + } + var components = toComponents.slice(start); + var relative = []; + for (; start < fromComponents.length; start++) { + relative.push(".."); + } + return __spreadArrays([""], relative, components); + } + ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; + function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { + ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); + var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; + var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; + var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathFromDirectory = getRelativePathFromDirectory; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + } + ts.convertToRelativePath = convertToRelativePath; + function getRelativePathFromFile(from, to, getCanonicalFileName) { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); + } + ts.getRelativePathFromFile = getRelativePathFromFile; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); + var firstComponent = pathComponents[0]; + if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) { + var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; + pathComponents[0] = prefix + firstComponent; + } + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } + ts.forEachAncestorDirectory = forEachAncestorDirectory; +})(ts || (ts = {})); +// +// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' +/* @internal */ +var ts; +(function (ts) { + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; + } + ts.Diagnostics = { + Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), + Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), + _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), + A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), + Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), + Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), + An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), + Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), + A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), + A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), + Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), + A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), + An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), + An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), + An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), + An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), + An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), + An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), + An_index_signature_parameter_type_must_be_either_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_either_string_or_number_1023", "An index signature parameter type must be either 'string' or 'number'."), + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), + Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), + _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), + _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), + _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), + super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), + Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), + Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), + Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), + _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), + _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), + _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), + _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), + _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), + A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), + Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), + A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), + A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), + A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), + A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), + A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), + A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), + A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), + An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), + A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), + Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), + An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), + _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), + _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), + A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), + Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), + _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), + _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), + Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), + Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), + An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), + A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), + An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), + _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), + Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), + Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), + Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), + with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), + delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), + A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), + Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), + Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), + Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), + An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), + Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), + Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), + Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), + Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), + Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), + Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), + Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), + Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), + case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), + Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), + Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), + Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), + Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), + Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), + Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), + Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), + Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), + Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), + String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), + Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), + or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), + Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), + Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), + Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), + File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), + const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), + const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), + let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), + Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), + Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), + An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), + A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), + Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), + A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), + extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), + extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), + Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), + implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), + Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), + Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), + Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), + Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), + Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), + Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), + A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), + An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), + Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), + Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), + A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), + A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), + An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), + Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), + An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), + Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), + Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), + Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), + Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), + Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), + Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), + Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), + All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), + A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), + Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), + Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), + Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), + An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), + _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), + Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), + Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), + Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), + Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), + A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), + An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), + An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), + _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), + Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), + An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), + A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), + A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), + A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), + _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), + A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), + A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), + Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), + with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), + await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), + The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), + Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), + Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), + Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), + A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), + An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd_1323", "Dynamic imports are only supported when the '--module' flag is set to 'esnext', 'commonjs', 'amd', 'system', or 'umd'."), + Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), + Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), + Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), + String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), + Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), + _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), + A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), + A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), + A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), + unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), + unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), + unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), + An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), + An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), + infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), + Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), + Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), + A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), + An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), + This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), + use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), + Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), + use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), + An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), + A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), + A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), + readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), + A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), + Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), + Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), + Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), + Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), + Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), + File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), + Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), + Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), + Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), + A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), + An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), + Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), + Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), + Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), + Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), + Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), + Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), + Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), + Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), + Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), + Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), + Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), + Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), + Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), + Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), + Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), + Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), + Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), + Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), + this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), + this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), + this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), + this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), @@ -5756,7 +6694,7 @@ var ts; Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), @@ -5834,7 +6772,6 @@ var ts; Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2424, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property."), Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."), Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."), Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."), @@ -6004,6 +6941,11 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(2613, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(2614, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -6126,6 +7068,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -6212,6 +7162,11 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), + Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), + Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6222,6 +7177,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6247,6 +7203,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6434,6 +7391,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6452,9 +7410,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), - Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6493,9 +7453,12 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), + Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -6579,6 +7542,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6608,6 +7573,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6725,6 +7691,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6735,94 +7709,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7086,6 +8061,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7438,7 +8414,7 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, @@ -7448,8 +8424,8 @@ var ts; hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7459,6 +8435,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7473,6 +8450,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7921,7 +8907,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7985,7 +8971,7 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; @@ -8056,12 +9042,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -8070,19 +9056,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -8091,13 +9077,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -8105,28 +9091,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8187,10 +9173,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8248,7 +9234,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8264,20 +9250,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8290,15 +9276,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8310,10 +9296,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8322,10 +9316,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8340,22 +9334,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { @@ -8401,29 +9395,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8485,12 +9479,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8500,10 +9499,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8579,7 +9578,7 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } @@ -8595,13 +9594,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8611,17 +9610,17 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; + return token = 61 /* BacktickToken */; case 92 /* backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -8643,7 +9642,7 @@ var ts; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion)) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); if (char === 92 /* backslash */) { @@ -8724,7 +9723,7 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -8795,7 +9794,7 @@ var ts; ts.getDeclarationOfKind = getDeclarationOfKind; /** Create a new escaped identifier map. */ function createUnderscoreEscapedMap() { - return new ts.MapCtr(); + return new ts.Map(); } ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap; function hasEntries(map) { @@ -8837,6 +9836,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8849,13 +9850,6 @@ var ts; reportPrivateInBaseOfClassExpression: ts.noop, }; } - function toPath(fileName, basePath, getCanonicalFileName) { - var nonCanonicalizedPath = ts.isRootedDiskPath(fileName) - ? ts.normalizePath(fileName) - : ts.getNormalizedAbsolutePath(fileName, basePath); - return getCanonicalFileName(nonCanonicalizedPath); - } - ts.toPath = toPath; function changesAffectModuleResolution(oldOptions, newOptions) { return oldOptions.configFilePath !== newOptions.configFilePath || optionsHaveModuleResolutionChanges(oldOptions, newOptions); @@ -8924,7 +9918,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -9012,28 +10006,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -9041,11 +10035,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -9213,7 +10207,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 314 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9232,7 +10226,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9300,10 +10294,8 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings return "`" + rawText + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings return "}" + rawText + "${"; case 17 /* TemplateTail */: return "}" + rawText + "`"; @@ -9334,7 +10326,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9366,16 +10358,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9387,9 +10379,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9442,22 +10434,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9467,9 +10459,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 300 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9479,25 +10471,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9507,8 +10499,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9517,15 +10509,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9555,13 +10547,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9572,11 +10564,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9621,7 +10613,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9635,7 +10627,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9644,32 +10636,38 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + var start = ts.skipTrivia(sourceFile.text, node.pos); + var end = node.statements.length > 0 ? node.statements[0].pos : node.end; + return ts.createTextSpanFromBounds(start, end); } if (errorNode === undefined) { // If we don't have a better node, then just set the error on the first token of // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9711,16 +10709,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 93 /* ImportKeyword */ + && n.keywordToken === 95 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -9729,7 +10727,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9738,11 +10736,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -9758,48 +10756,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9808,40 +10806,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9866,23 +10864,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9892,26 +10890,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -9934,10 +10932,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9947,12 +10945,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9960,14 +10958,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9979,8 +10977,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9991,13 +10989,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -10008,7 +11006,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -10016,17 +11014,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -10039,7 +11037,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -10080,14 +11078,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -10102,9 +11100,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10115,26 +11113,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -10144,9 +11142,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -10168,27 +11166,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10204,21 +11202,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -10227,8 +11225,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -10236,20 +11234,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -10257,10 +11255,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -10269,25 +11267,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10303,10 +11301,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10315,9 +11313,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10325,57 +11323,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10385,49 +11383,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10435,7 +11433,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10444,7 +11442,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10456,15 +11454,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10472,22 +11470,22 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; - function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + function isRequireCall(callExpression, requireStringLiteralLikeArgument) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { return false; } var arg = args[0]; - return !checkArgumentIsStringLiteralLike || ts.isStringLiteralLike(arg); + return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { @@ -10511,21 +11509,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { - if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { - name = node.parent.parent.name; - decl = node.parent.parent; - } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10535,13 +11537,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10555,14 +11558,20 @@ var ts; } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; function hasExpandoValueProperty(node, isPrototypeAssignment) { - return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + return ts.forEach(node.properties, function (p) { + return ts.isPropertyAssignment(p) && + ts.isIdentifier(p.name) && + p.name.escapedText === "value" && + p.initializer && + getExpandoInitializer(p.initializer, isPrototypeAssignment); + }); } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10588,11 +11597,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10609,14 +11618,16 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10624,8 +11635,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10644,19 +11655,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10671,10 +11683,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10689,60 +11704,129 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0], /*excludeThisKeyword*/ true); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + /** x.y OR x[0] */ + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + /** x[0] OR x['a'] OR x[Symbol.y] */ + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + /** Any series of property and element accesses. */ + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + /** Any series of property and element accesses, ending in a literal element access */ + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); + } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; - if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { - // exports.name = expr OR module.exports.name = expr + if ((id.escapedText === "exports" || + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") && + // ExportsProperty does not support binding with computed names + isBindableStaticAccessExpression(lhs)) { + // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... return 1 /* ExportsProperty */; } - // F.G...x = expr - return 5 /* Property */; + if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs) && lhs.expression.kind !== 103 /* ThisKeyword */)) { + // F.G...x = expr + return 5 /* Property */; + } } return 0 /* None */; } @@ -10760,7 +11844,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10769,7 +11854,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10778,14 +11863,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10795,12 +11880,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10809,11 +11894,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10821,19 +11906,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10847,7 +11932,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 312 /* JSDocTypedefTag */ || node.kind === 305 /* JSDocCallbackTag */ || node.kind === 306 /* JSDocEnumTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10857,7 +11942,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10866,18 +11951,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10888,7 +11973,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10903,11 +11988,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10918,12 +12003,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10934,7 +12019,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10957,7 +12042,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10982,7 +12067,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10992,7 +12077,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -11005,31 +12090,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -11056,22 +12141,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -11088,33 +12173,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -11136,11 +12221,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -11163,8 +12249,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -11172,32 +12258,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -11213,22 +12299,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -11242,24 +12345,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11286,11 +12389,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -11298,7 +12401,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -11306,6 +12409,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11329,14 +12437,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11350,10 +12458,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11366,7 +12474,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11386,10 +12494,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11403,12 +12514,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11424,7 +12535,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11435,11 +12546,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11454,7 +12565,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11463,11 +12574,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11475,15 +12586,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11502,38 +12613,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11542,15 +12653,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11560,73 +12671,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11635,41 +12746,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11787,22 +12900,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11853,6 +12967,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11864,7 +12979,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11874,17 +12989,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11898,6 +13025,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11917,6 +13045,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11931,12 +13061,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -12000,7 +13130,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -12018,7 +13148,7 @@ var ts; */ function getExternalModuleNameFromPath(host, fileName, referencePath) { var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = ts.removeFileExtension(relativePath); @@ -12141,11 +13271,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -12156,10 +13286,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -12179,10 +13309,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -12228,7 +13358,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 298 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12468,7 +13598,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12476,29 +13606,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12511,14 +13641,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12526,8 +13656,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12537,9 +13667,32 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function getFirstIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + node = node.expression; + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + ts.getFirstIdentifier = getFirstIdentifier; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12555,21 +13708,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12867,8 +14020,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12945,35 +14098,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && skipParenthesesUp(parent.parent).kind === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -13052,21 +14205,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ - function forEachAncestorDirectory(directory, callback) { - while (true) { - var result = callback(directory); - if (result !== undefined) { - return result; - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - return undefined; - } - directory = parentPath; - } - } - ts.forEachAncestorDirectory = forEachAncestorDirectory; // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { return !!(getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isAbstractConstructorSymbol(type.symbol); @@ -13093,7 +14231,7 @@ var ts; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { - return !!forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); + return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { @@ -13137,32 +14275,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -13175,6 +14313,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13282,7 +14424,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13399,9 +14541,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } @@ -13409,7 +14551,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13439,14 +14581,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13510,7 +14652,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13592,30 +14735,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 205 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13627,6 +14770,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13639,41 +14793,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 306 /* JSDocEnumTag */: + case 309 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13696,8 +14855,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13875,7 +15034,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 298 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13895,10 +15054,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13943,198 +15101,230 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + var kind = node.kind; + return !!(node.flags & 32 /* OptionalChain */) && + (kind === 193 /* PropertyAccessExpression */ + || kind === 194 /* ElementAccessExpression */ + || kind === 195 /* CallExpression */); + } + ts.isOptionalChain = isOptionalChain; + /** + * Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`). + */ + /* @internal */ + function isExpressionOfOptionalChainRoot(node) { + return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node; + } + ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot; + function isNullishCoalesce(node) { + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + } + ts.isNullishCoalesce = isNullishCoalesce; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -14143,376 +15333,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 316 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14521,105 +15711,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 298 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 303 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 302 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 304 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 306 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 309 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 307 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 308 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 310 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 311 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 312 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 313 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 313 /* JSDocPropertyTag */ || node.kind === 307 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 299 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 305 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 300 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14630,7 +15820,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 314 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14640,7 +15830,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14649,7 +15839,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14702,17 +15892,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14725,7 +15915,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14734,23 +15924,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14765,13 +15955,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14780,14 +15970,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14802,29 +15992,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14834,11 +16024,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14847,12 +16037,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14867,8 +16057,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14879,8 +16069,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14888,15 +16078,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14905,9 +16095,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14928,8 +16118,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14941,8 +16131,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14951,26 +16141,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14978,12 +16168,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14994,34 +16184,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -15034,13 +16224,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -15049,11 +16239,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -15070,15 +16260,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 317 /* CommaListExpression */: - case 316 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -15086,21 +16276,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 316 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 315 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -15108,21 +16303,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -15146,113 +16362,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 312 /* JSDocTypedefTag */ - || kind === 305 /* JSDocCallbackTag */ - || kind === 313 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 315 /* NotEmittedStatement */ - || kind === 319 /* EndOfDeclarationMarker */ - || kind === 318 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 311 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -15279,10 +16495,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -15292,83 +16508,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 313 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 298 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 301 /* FirstJSDocTagNode */ && node.kind <= 313 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; + } + ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; } - ts.isGetAccessor = isGetAccessor; + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15396,12 +16617,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15437,7 +16658,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15455,7 +16676,12 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature(checker, flags) { + this.flags = flags; + if (ts.Debug.isDebugging) { + this.checker = checker; + } + } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15469,759 +16695,303 @@ var ts; } function SourceMapSource(fileName, text, skipTrivia) { this.fileName = fileName; - this.text = text; - this.skipTrivia = skipTrivia || (function (pos) { return pos; }); - } - ts.objectAllocator = { - getNodeConstructor: function () { return Node; }, - getTokenConstructor: function () { return Node; }, - getIdentifierConstructor: function () { return Node; }, - getSourceFileConstructor: function () { return Node; }, - getSymbolConstructor: function () { return Symbol; }, - getTypeConstructor: function () { return Type; }, - getSignatureConstructor: function () { return Signature; }, - getSourceMapSourceConstructor: function () { return SourceMapSource; }, - }; - function formatStringFromArgs(text, args, baseIndex) { - if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); - } - ts.formatStringFromArgs = formatStringFromArgs; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - ts.Debug.assertGreaterThanOrEqual(start, 0); - ts.Debug.assertGreaterThanOrEqual(length, 0); - if (file) { - ts.Debug.assertLessThanOrEqual(start, file.text.length); - ts.Debug.assertLessThanOrEqual(start + length, file.text.length); - } - var text = getLocaleSpecificMessage(message); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(_dummy, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return text; - } - ts.formatMessage = formatMessage; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function createCompilerDiagnosticFromMessageChain(chain) { - return { - file: undefined, - start: undefined, - length: undefined, - code: chain.code, - category: chain.category, - messageText: chain.next ? chain : chain.messageText, - }; - } - ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details === undefined || Array.isArray(details) ? details : [details] - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - var lastChain = headChain; - while (lastChain.next) { - lastChain = lastChain.next[0]; - } - lastChain.next = [tailChain]; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function getDiagnosticFilePath(diagnostic) { - return diagnostic.file ? diagnostic.file.path : undefined; - } - function compareDiagnostics(d1, d2) { - return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; - } - ts.compareDiagnostics = compareDiagnostics; - function compareDiagnosticsSkipRelatedInformation(d1, d2) { - return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || - ts.compareValues(d1.start, d2.start) || - ts.compareValues(d1.length, d2.length) || - ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; - } - ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; - function compareRelatedInformation(d1, d2) { - if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; - } - if (d1.relatedInformation && d2.relatedInformation) { - return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { - var d2i = d2.relatedInformation[index]; - return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; - } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; - } - function compareMessageText(t1, t2) { - if (typeof t1 === "string" && typeof t2 === "string") { - return ts.compareStringsCaseSensitive(t1, t2); - } - else if (typeof t1 === "string") { - return -1 /* LessThan */; - } - else if (typeof t2 === "string") { - return 1 /* GreaterThan */; - } - var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); - if (res) { - return res; - } - if (!t1.next && !t2.next) { - return 0 /* EqualTo */; - } - if (!t1.next) { - return -1 /* LessThan */; - } - if (!t2.next) { - return 1 /* GreaterThan */; - } - var len = Math.min(t1.next.length, t2.next.length); - for (var i = 0; i < len; i++) { - res = compareMessageText(t1.next[i], t2.next[i]); - if (res) { - return res; - } - } - if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; - } - else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; - } - return 0 /* EqualTo */; - } - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0 /* ES3 */; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; - function getEmitModuleResolutionKind(compilerOptions) { - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - } - return moduleResolution; - } - ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; - function hasJsonModuleEmitEnabled(options) { - switch (getEmitModuleKind(options)) { - case ts.ModuleKind.CommonJS: - case ts.ModuleKind.AMD: - case ts.ModuleKind.ES2015: - case ts.ModuleKind.ESNext: - return true; - default: - return false; - } - } - ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; - function unreachableCodeIsError(options) { - return options.allowUnreachableCode === false; - } - ts.unreachableCodeIsError = unreachableCodeIsError; - function unusedLabelIsError(options) { - return options.allowUnusedLabels === false; - } - ts.unusedLabelIsError = unusedLabelIsError; - function getAreDeclarationMapsEnabled(options) { - return !!(getEmitDeclarations(options) && options.declarationMap); - } - ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; - function getAllowSyntheticDefaultImports(compilerOptions) { - var moduleKind = getEmitModuleKind(compilerOptions); - return compilerOptions.allowSyntheticDefaultImports !== undefined - ? compilerOptions.allowSyntheticDefaultImports - : compilerOptions.esModuleInterop || - moduleKind === ts.ModuleKind.System; - } - ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; - function getEmitDeclarations(compilerOptions) { - return !!(compilerOptions.declaration || compilerOptions.composite); - } - ts.getEmitDeclarations = getEmitDeclarations; - function isIncrementalCompilation(options) { - return !!(options.incremental || options.composite); - } - ts.isIncrementalCompilation = isIncrementalCompilation; - function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; - } - ts.getStrictOptionValue = getStrictOptionValue; - function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; - function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; - function getCompilerOptionValue(options, option) { - return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; - } - ts.getCompilerOptionValue = getCompilerOptionValue; - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - // have already seen asterisk - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - /** - * Internally, we represent paths as strings with '/' as the directory separator. - * When we make system calls (eg: LanguageServiceHost.getDirectory()), - * we expect the host to correctly handle paths in our specified format. - */ - ts.directorySeparator = "/"; - var altDirectorySeparator = "\\"; - var urlSchemeSeparator = "://"; - var backslashRegExp = /\\/g; - /** - * Normalize path separators. - */ - function normalizeSlashes(path) { - return path.replace(backslashRegExp, ts.directorySeparator); - } - ts.normalizeSlashes = normalizeSlashes; - function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); - } - function getFileUrlVolumeSeparatorEnd(url, start) { - var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) - return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { - var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) - return start + 3; - } - return -1; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * If the root is part of a URL, the twos-complement of the root length is returned. - */ - function getEncodedRootLength(path) { - if (!path) - return 0; - var ch0 = path.charCodeAt(0); - // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { - if (path.charCodeAt(1) !== ch0) - return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); - if (p1 < 0) - return path.length; // UNC: "//server" or "\\server" - return p1 + 1; // UNC: "//server/" or "\\server\" - } - // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { - var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) - return 3; // DOS: "c:/" or "c:\" - if (path.length === 2) - return 2; // DOS: "c:" (but not "c:d") - } - // URL - var schemeEnd = path.indexOf(urlSchemeSeparator); - if (schemeEnd !== -1) { - var authorityStart = schemeEnd + urlSchemeSeparator.length; - var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); - if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" - // For local "file" URLs, include the leading DOS volume (if present). - // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a - // special case interpreted as "the machine from which the URL is being interpreted". - var scheme = path.slice(0, schemeEnd); - var authority = path.slice(authorityStart, authorityEnd); - if (scheme === "file" && (authority === "" || authority === "localhost") && - isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { - var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); - if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { - // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" - return ~(volumeSeparatorEnd + 1); - } - if (volumeSeparatorEnd === path.length) { - // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" - // but not "file:///c:d" or "file:///c%3ad" - return ~volumeSeparatorEnd; - } - } - } - return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" - } - return ~path.length; // URL: "file://server", "http://server" - } - // relative - return 0; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * - * For example: - * ```ts - * getRootLength("a") === 0 // "" - * getRootLength("/") === 1 // "/" - * getRootLength("c:") === 2 // "c:" - * getRootLength("c:d") === 0 // "" - * getRootLength("c:/") === 3 // "c:/" - * getRootLength("c:\\") === 3 // "c:\\" - * getRootLength("//server") === 7 // "//server" - * getRootLength("//server/share") === 8 // "//server/" - * getRootLength("\\\\server") === 7 // "\\\\server" - * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" - * getRootLength("file:///path") === 8 // "file:///" - * getRootLength("file:///c:") === 10 // "file:///c:" - * getRootLength("file:///c:d") === 8 // "file:///" - * getRootLength("file:///c:/path") === 11 // "file:///c:/" - * getRootLength("file://server") === 13 // "file://server" - * getRootLength("file://server/path") === 14 // "file://server/" - * getRootLength("http://server") === 13 // "http://server" - * getRootLength("http://server/path") === 14 // "http://server/" - * ``` - */ - function getRootLength(path) { - var rootLength = getEncodedRootLength(path); - return rootLength < 0 ? ~rootLength : rootLength; - } - ts.getRootLength = getRootLength; - // TODO(rbuckton): replace references with `resolvePath` - function normalizePath(path) { - return ts.resolvePath(path); - } - ts.normalizePath = normalizePath; - function normalizePathAndParts(path) { - path = normalizeSlashes(path); - var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); - if (parts.length) { - var joinedParts = root + parts.join(ts.directorySeparator); - return { path: ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; - } - else { - return { path: root, parts: parts }; - } - } - ts.normalizePathAndParts = normalizePathAndParts; - function getDirectoryPath(path) { - path = normalizeSlashes(path); - // If the path provided is itself the root, then return it. - var rootLength = getRootLength(path); - if (rootLength === path.length) - return path; - // return the leading portion of the path up to the last (non-terminal) directory separator - // but not including any trailing directory separator. - path = ts.removeTrailingDirectorySeparator(path); - return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { - var canonicalFileName = getCanonicalFileName(fileName); - var canonicalDirectoryName = getCanonicalFileName(directoryName); - return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); - } - ts.startsWithDirectory = startsWithDirectory; - function isUrl(path) { - return getEncodedRootLength(path) < 0; - } - ts.isUrl = isUrl; - function pathIsRelative(path) { - return /^\.\.?($|[\\/])/.test(path); - } - ts.pathIsRelative = pathIsRelative; - /** - * Determines whether a path is an absolute path (e.g. starts with `/`, or a dos path - * like `c:`, `c:\` or `c:/`). - */ - function isRootedDiskPath(path) { - return getEncodedRootLength(path) > 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - /** - * Determines whether a path consists only of a path root. - */ - function isDiskPathRoot(path) { - var rootLength = getEncodedRootLength(path); - return rootLength > 0 && rootLength === path.length; - } - ts.isDiskPathRoot = isDiskPathRoot; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - } - ts.convertToRelativePath = convertToRelativePath; - function pathComponents(path, rootLength) { - var root = path.substring(0, rootLength); - var rest = path.substring(rootLength).split(ts.directorySeparator); - if (rest.length && !ts.lastOrUndefined(rest)) - rest.pop(); - return __spreadArrays([root], rest); - } - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is not normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getPathComponents(path, currentDirectory) { - if (currentDirectory === void 0) { currentDirectory = ""; } - path = ts.combinePaths(currentDirectory, path); - var rootLength = getRootLength(path); - return pathComponents(path, rootLength); - } - ts.getPathComponents = getPathComponents; - /** - * Reduce an array of path components to a more simplified path by navigating any - * `"."` or `".."` entries in the path. - */ - function reducePathComponents(components) { - if (!ts.some(components)) - return []; - var reduced = [components[0]]; - for (var i = 1; i < components.length; i++) { - var component = components[i]; - if (!component) - continue; - if (component === ".") - continue; - if (component === "..") { - if (reduced.length > 1) { - if (reduced[reduced.length - 1] !== "..") { - reduced.pop(); - continue; - } - } - else if (reduced[0]) - continue; - } - reduced.push(component); - } - return reduced; - } - ts.reducePathComponents = reducePathComponents; - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getNormalizedPathComponents(path, currentDirectory) { - return reducePathComponents(getPathComponents(path, currentDirectory)); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - /** - * Formats a parsed path consisting of a root component (at index 0) and zero or more path - * segments (at indices > 0). - */ - function getPathFromPathComponents(pathComponents) { - if (pathComponents.length === 0) - return ""; - var root = pathComponents[0] && ts.ensureTrailingDirectorySeparator(pathComponents[0]); - return root + pathComponents.slice(1).join(ts.directorySeparator); + this.text = text; + this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } - ts.getPathFromPathComponents = getPathFromPathComponents; - function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { - return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + // eslint-disable-next-line prefer-const + ts.objectAllocator = { + getNodeConstructor: function () { return Node; }, + getTokenConstructor: function () { return Node; }, + getIdentifierConstructor: function () { return Node; }, + getSourceFileConstructor: function () { return Node; }, + getSymbolConstructor: function () { return Symbol; }, + getTypeConstructor: function () { return Type; }, + getSignatureConstructor: function () { return Signature; }, + getSourceMapSourceConstructor: function () { return SourceMapSource; }, + }; + function formatStringFromArgs(text, args, baseIndex) { + if (baseIndex === void 0) { baseIndex = 0; } + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } - ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; - function getPathWithoutRoot(pathComponents) { - if (pathComponents.length === 0) - return ""; - return pathComponents.slice(1).join(ts.directorySeparator); + ts.formatStringFromArgs = formatStringFromArgs; + function getLocaleSpecificMessage(message) { + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; } -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { - var fromComponents = ts.reducePathComponents(ts.getPathComponents(from)); - var toComponents = ts.reducePathComponents(ts.getPathComponents(to)); - var start; - for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { - var fromComponent = getCanonicalFileName(fromComponents[start]); - var toComponent = getCanonicalFileName(toComponents[start]); - var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; - if (!comparer(fromComponent, toComponent)) - break; + ts.getLocaleSpecificMessage = getLocaleSpecificMessage; + function createFileDiagnostic(file, start, length, message) { + ts.Debug.assertGreaterThanOrEqual(start, 0); + ts.Debug.assertGreaterThanOrEqual(length, 0); + if (file) { + ts.Debug.assertLessThanOrEqual(start, file.text.length); + ts.Debug.assertLessThanOrEqual(start + length, file.text.length); } - if (start === 0) { - return toComponents; + var text = getLocaleSpecificMessage(message); + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); } - var components = toComponents.slice(start); - var relative = []; - for (; start < fromComponents.length; start++) { - relative.push(".."); + return { + file: file, + start: start, + length: length, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; + } + ts.createFileDiagnostic = createFileDiagnostic; + function formatMessage(_dummy, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return __spreadArrays([""], relative, components); + return text; } - ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; - function getRelativePathFromFile(from, to, getCanonicalFileName) { - return ensurePathIsNonModuleName(getRelativePathFromDirectory(ts.getDirectoryPath(from), to, getCanonicalFileName)); + ts.formatMessage = formatMessage; + function createCompilerDiagnostic(message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 1) { + text = formatStringFromArgs(text, arguments, 1); + } + return { + file: undefined, + start: undefined, + length: undefined, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; } - ts.getRelativePathFromFile = getRelativePathFromFile; - function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { - ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); - var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; - var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; - var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); - return ts.getPathFromPathComponents(pathComponents); + ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText, + }; } - ts.getRelativePathFromDirectory = getRelativePathFromDirectory; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); - var firstComponent = pathComponents[0]; - if (isAbsolutePathAnUrl && ts.isRootedDiskPath(firstComponent)) { - var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; - pathComponents[0] = prefix + firstComponent; + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; + function chainDiagnosticMessages(details, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return ts.getPathFromPathComponents(pathComponents); + return { + messageText: text, + category: message.category, + code: message.code, + next: details === undefined || Array.isArray(details) ? details : [details] + }; } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - /** - * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed - * with `./` or `../`) so as not to be confused with an unprefixed module name. - */ - function ensurePathIsNonModuleName(path) { - return ts.getRootLength(path) === 0 && !ts.pathIsRelative(path) ? "./" + path : path; + ts.chainDiagnosticMessages = chainDiagnosticMessages; + function concatenateDiagnosticMessageChains(headChain, tailChain) { + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next[0]; + } + lastChain.next = [tailChain]; } - ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; - function getBaseFileName(path, extensions, ignoreCase) { - path = ts.normalizeSlashes(path); - // if the path provided is itself the root, then it has not file name. - var rootLength = ts.getRootLength(path); - if (rootLength === path.length) - return ""; - // return the trailing portion of the path starting after the last (non-terminal) directory - // separator but not including any trailing directory separator. - path = removeTrailingDirectorySeparator(path); - var name = path.slice(Math.max(ts.getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); - var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; - return extension ? name.slice(0, name.length - extension.length) : name; + ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; + function getDiagnosticFilePath(diagnostic) { + return diagnostic.file ? diagnostic.file.path : undefined; } - ts.getBaseFileName = getBaseFileName; - /** - * Combines paths. If a path is absolute, it replaces any previous path. - */ - function combinePaths(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + function compareDiagnosticsSkipRelatedInformation(d1, d2) { + return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || + ts.compareValues(d1.start, d2.start) || + ts.compareValues(d1.length, d2.length) || + ts.compareValues(d1.code, d2.code) || + compareMessageText(d1.messageText, d2.messageText) || + 0 /* EqualTo */; + } + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; } - if (path) - path = ts.normalizeSlashes(path); - for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { - var relativePath = paths_1[_a]; - if (!relativePath) - continue; - relativePath = ts.normalizeSlashes(relativePath); - if (!path || ts.getRootLength(relativePath) !== 0) { - path = relativePath; - } - else { - path = ensureTrailingDirectorySeparator(path) + relativePath; - } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; } - return path; + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; } - ts.combinePaths = combinePaths; - /** - * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any - * `.` and `..` path components are resolved. - */ - function resolvePath(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareMessageText(t1, t2) { + if (typeof t1 === "string" && typeof t2 === "string") { + return ts.compareStringsCaseSensitive(t1, t2); } - var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); - var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); - return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; - } - ts.resolvePath = resolvePath; - /** - * Determines whether a path has a trailing separator (`/` or `\\`). - */ - function hasTrailingDirectorySeparator(path) { - if (path.length === 0) - return false; - var ch = path.charCodeAt(path.length - 1); - return ch === 47 /* slash */ || ch === 92 /* backslash */; - } - ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; - function removeTrailingDirectorySeparator(path) { - if (hasTrailingDirectorySeparator(path)) { - return path.substr(0, path.length - 1); + else if (typeof t1 === "string") { + return -1 /* LessThan */; } - return path; - } - ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; - function ensureTrailingDirectorySeparator(path) { - if (!hasTrailingDirectorySeparator(path)) { - return path + ts.directorySeparator; + else if (typeof t2 === "string") { + return 1 /* GreaterThan */; } - return path; - } - ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; - // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; - function comparePathsWorker(a, b, componentComparer) { - if (a === b) + var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); + if (res) { + return res; + } + if (!t1.next && !t2.next) { return 0 /* EqualTo */; - if (a === undefined) + } + if (!t1.next) { return -1 /* LessThan */; - if (b === undefined) - return 1 /* GreaterThan */; - // NOTE: Performance optimization - shortcut if the root segments differ as there would be no - // need to perform path reduction. - var aRoot = a.substring(0, ts.getRootLength(a)); - var bRoot = b.substring(0, ts.getRootLength(b)); - var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { - return result; } - // NOTE: Performance optimization - shortcut if there are no relative path segments in - // the non-root portion of the path - var aRest = a.substring(aRoot.length); - var bRest = b.substring(bRoot.length); - if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { - return componentComparer(aRest, bRest); + if (!t2.next) { + return 1 /* GreaterThan */; } - // The path contains a relative path segment. Normalize the paths and perform a slower component - // by component comparison. - var aComponents = ts.reducePathComponents(ts.getPathComponents(a)); - var bComponents = ts.reducePathComponents(ts.getPathComponents(b)); - var sharedLength = Math.min(aComponents.length, bComponents.length); - for (var i = 1; i < sharedLength; i++) { - var result_1 = componentComparer(aComponents[i], bComponents[i]); - if (result_1 !== 0 /* EqualTo */) { - return result_1; + var len = Math.min(t1.next.length, t2.next.length); + for (var i = 0; i < len; i++) { + res = compareMessageText(t1.next[i], t2.next[i]); + if (res) { + return res; } } - return ts.compareValues(aComponents.length, bComponents.length); + if (t1.next.length < t2.next.length) { + return -1 /* LessThan */; + } + else if (t1.next.length > t2.next.length) { + return 1 /* GreaterThan */; + } + return 0 /* EqualTo */; } - /** - * Performs a case-sensitive comparison of two paths. - */ - function comparePathsCaseSensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0 /* ES3 */; } - ts.comparePathsCaseSensitive = comparePathsCaseSensitive; - /** - * Performs a case-insensitive comparison of two paths. - */ - function comparePathsCaseInsensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } - ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; - function comparePaths(a, b, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - a = combinePaths(currentDirectory, a); - b = combinePaths(currentDirectory, b); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; + ts.getEmitModuleKind = getEmitModuleKind; + function getEmitModuleResolutionKind(compilerOptions) { + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; } - return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + return moduleResolution; } - ts.comparePaths = comparePaths; - function containsPath(parent, child, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - parent = combinePaths(currentDirectory, parent); - child = combinePaths(currentDirectory, child); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; - } - if (parent === undefined || child === undefined) - return false; - if (parent === child) - return true; - var parentComponents = ts.reducePathComponents(ts.getPathComponents(parent)); - var childComponents = ts.reducePathComponents(ts.getPathComponents(child)); - if (childComponents.length < parentComponents.length) { - return false; - } - var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; - for (var i = 0; i < parentComponents.length; i++) { - var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; - if (!equalityComparer(parentComponents[i], childComponents[i])) { + ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function hasJsonModuleEmitEnabled(options) { + switch (getEmitModuleKind(options)) { + case ts.ModuleKind.CommonJS: + case ts.ModuleKind.AMD: + case ts.ModuleKind.ES2015: + case ts.ModuleKind.ESNext: + return true; + default: return false; + } + } + ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; + function getAreDeclarationMapsEnabled(options) { + return !!(getEmitDeclarations(options) && options.declarationMap); + } + ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; + function getAllowSyntheticDefaultImports(compilerOptions) { + var moduleKind = getEmitModuleKind(compilerOptions); + return compilerOptions.allowSyntheticDefaultImports !== undefined + ? compilerOptions.allowSyntheticDefaultImports + : compilerOptions.esModuleInterop || + moduleKind === ts.ModuleKind.System; + } + ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; + function getEmitDeclarations(compilerOptions) { + return !!(compilerOptions.declaration || compilerOptions.composite); + } + ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; + function getStrictOptionValue(compilerOptions, flag) { + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; + } + ts.getStrictOptionValue = getStrictOptionValue; + function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; + function compilerOptionsAffectEmit(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; + function getCompilerOptionValue(options, option) { + return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; + } + ts.getCompilerOptionValue = getCompilerOptionValue; + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42 /* asterisk */) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + // have already seen asterisk + return false; + } } } return true; } - ts.containsPath = containsPath; - function isDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { function stripLeadingDirectorySeparator(s) { - return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; } function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); @@ -16240,10 +17010,6 @@ var ts; return "\\" + match; } var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; - function hasExtension(fileName) { - return ts.stringContains(getBaseFileName(fileName), "."); - } - ts.hasExtension = hasExtension; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; var filesMatcher = { @@ -16319,7 +17085,7 @@ var ts; } // getNormalizedPathComponents includes the separator for the root component. // We need to remove to create our regex correctly. - components[0] = removeTrailingDirectorySeparator(components[0]); + components[0] = ts.removeTrailingDirectorySeparator(components[0]); if (isImplicitGlob(lastComponent)) { components.push("**", "*"); } @@ -16381,7 +17147,7 @@ var ts; function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = ts.normalizePath(path); currentDirectory = ts.normalizePath(currentDirectory); - var absolutePath = combinePaths(currentDirectory, path); + var absolutePath = ts.combinePaths(currentDirectory, path); return { includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), @@ -16410,7 +17176,7 @@ var ts; var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; - visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth); + visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); } return ts.flatten(results); function visitDirectory(path, absolutePath, depth) { @@ -16420,8 +17186,8 @@ var ts; visited.set(canonicalPath, true); var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; var _loop_1 = function (current) { - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if (extensions && !ts.fileExtensionIsOneOf(name, extensions)) return "continue"; if (excludeRegex && excludeRegex.test(absoluteName)) @@ -16448,8 +17214,8 @@ var ts; } for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) { var current = _d[_c]; - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { visitDirectory(name, absoluteName, depth); @@ -16471,14 +17237,14 @@ var ts; var include = includes_1[_i]; // We also need to check the relative paths by converting them to absolute and normalizing // in case they escape the base path (e.g "..\somedirectory") - var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(combinePaths(path, include)); + var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include)); // Append the literal and canonical candidate base paths. includeBasePaths.push(getIncludeBasePath(absolute)); } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames)); var _loop_2 = function (includeBasePath) { - if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; @@ -16495,9 +17261,9 @@ var ts; var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes); if (wildcardOffset < 0) { // No "*" or "?" in the path - return !hasExtension(absolute) + return !ts.hasExtension(absolute) ? absolute - : removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); + : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); } return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); } @@ -16662,14 +17428,9 @@ var ts; } ts.removeExtension = removeExtension; function changeExtension(path, newExtension) { - return changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); + return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; - function changeAnyExtension(path, ext, extensions, ignoreCase) { - var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); - return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; - } - ts.changeAnyExtension = changeAnyExtension; function tryParsePattern(pattern) { // This should be verified outside of here and a proper error thrown. ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern)); @@ -16712,36 +17473,6 @@ var ts; return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); }); } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; - function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { - if (typeof extensions === "string") - extensions = [extensions]; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - if (!ts.startsWith(extension, ".")) - extension = "." + extension; - if (path.length >= extension.length && path.charAt(path.length - extension.length) === ".") { - var pathExtension = path.slice(path.length - extension.length); - if (stringEqualityComparer(pathExtension, extension)) { - return pathExtension; - } - } - } - return ""; - } - function getAnyExtensionFromPath(path, extensions, ignoreCase) { - // Retrieves any string from the final "." onwards from a base file name. - // Unlike extensionFromPath, which throws an exception on unrecognized extensions. - if (extensions) { - return getAnyExtensionFromPathWorker(path, extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); - } - var baseFileName = getBaseFileName(path); - var extensionIndex = baseFileName.lastIndexOf("."); - if (extensionIndex >= 0) { - return baseFileName.substring(extensionIndex); - } - return ""; - } - ts.getAnyExtensionFromPath = getAnyExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } @@ -16871,14 +17602,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16982,17 +17716,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -17041,19 +17773,19 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17061,9 +17793,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -17071,7 +17803,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17079,51 +17811,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -17135,345 +17867,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 303 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 301 /* JSDocTag */: - case 304 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17527,7 +18264,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17556,14 +18293,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17694,18 +18429,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17714,7 +18449,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17730,6 +18465,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17755,10 +18493,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17786,7 +18524,7 @@ var ts; function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17851,7 +18589,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17872,16 +18610,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17922,40 +18660,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -18070,20 +18808,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -18171,7 +18909,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -18201,7 +18939,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -18213,7 +18951,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -18234,9 +18972,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -18245,7 +18983,12 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var isReservedWord = scanner.isReservedWord(); + var msgArg = scanner.getTokenText(); + var defaultMessage = isReservedWord ? + ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : + ts.Diagnostics.Identifier_expected; + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -18276,7 +19019,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18297,20 +19040,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18323,16 +19066,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18352,7 +19095,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18368,7 +19111,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18438,7 +19181,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18455,8 +19198,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18486,14 +19229,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18512,9 +19255,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18534,7 +19277,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18609,7 +19352,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18710,20 +19453,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18732,8 +19475,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18742,58 +19485,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18814,7 +19557,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18881,7 +19624,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18919,6 +19662,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18939,7 +19685,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18950,7 +19696,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18981,13 +19727,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -18999,7 +19745,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -19059,24 +19805,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -19084,20 +19830,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -19105,7 +19851,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -19126,43 +19872,43 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); if (moduleSpecifier) { - var moduleTag = createNode(297 /* JSDocNamepathType */, moduleSpecifier.pos); + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); terminate: while (true) { switch (token()) { case 19 /* CloseBraceToken */: @@ -19181,25 +19927,25 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -19218,18 +19964,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -19238,12 +19984,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -19265,7 +20011,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -19287,16 +20033,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -19343,10 +20089,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19390,21 +20136,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 56 /* QuestionToken */) { + if (token() !== 57 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19412,17 +20158,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -19434,7 +20180,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19456,20 +20202,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19480,7 +20226,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19488,14 +20234,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19512,37 +20258,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19553,23 +20299,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19577,9 +20323,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19587,14 +20333,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19607,23 +20353,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19633,50 +20379,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19684,51 +20434,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19746,27 +20499,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19785,16 +20538,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19802,11 +20555,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19827,13 +20580,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19843,7 +20596,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19865,8 +20618,8 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19875,7 +20628,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19887,7 +20640,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19898,45 +20652,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19945,14 +20706,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19963,18 +20724,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -19993,9 +20754,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -20018,7 +20779,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -20063,7 +20824,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -20079,7 +20840,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -20108,15 +20869,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -20127,20 +20888,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -20165,8 +20926,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -20176,10 +20937,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -20189,12 +20950,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -20208,8 +20969,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -20233,30 +20994,30 @@ var ts; // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -20265,7 +21026,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -20275,11 +21036,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -20312,7 +21073,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -20325,23 +21086,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20351,7 +21112,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20364,7 +21125,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20375,8 +21136,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20401,20 +21162,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20422,7 +21183,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20451,16 +21212,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20481,51 +21242,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20535,7 +21296,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20559,7 +21320,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20576,10 +21337,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -20604,23 +21365,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20643,16 +21404,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20675,21 +21436,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20730,14 +21491,14 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20745,21 +21506,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a - // CallExpression. As such, we need to consume the rest of it here to be complete. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20811,11 +21573,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20827,7 +21589,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20836,8 +21598,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20846,15 +21608,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20865,11 +21627,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20899,7 +21661,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20907,7 +21669,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20928,16 +21690,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20945,23 +21707,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20975,10 +21737,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20986,7 +21748,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -21012,9 +21774,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -21027,7 +21789,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -21035,78 +21797,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -21115,48 +21909,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -21165,12 +21981,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -21187,21 +22003,23 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* ColonToken */: // foo: case 26 /* SemicolonToken */: // foo; - case 56 /* QuestionToken */: // foo? - case 33 /* EqualsEqualsToken */: // foo == - case 35 /* EqualsEqualsEqualsToken */: // foo === - case 34 /* ExclamationEqualsToken */: // foo != - case 36 /* ExclamationEqualsEqualsToken */: // foo !== - case 54 /* AmpersandAmpersandToken */: // foo && - case 55 /* BarBarToken */: // foo || - case 51 /* CaretToken */: // foo ^ - case 49 /* AmpersandToken */: // foo & - case 50 /* BarToken */: // foo | + case 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // these cases can't legally follow a type arg list. However, they're not legal @@ -21213,6 +22031,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -21225,11 +22044,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -21237,7 +22056,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -21245,14 +22064,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -21263,28 +22082,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21296,25 +22115,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -21322,24 +22141,24 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21358,10 +22177,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21369,7 +22188,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21381,26 +22200,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21410,7 +22229,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21443,25 +22262,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21473,8 +22292,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21483,12 +22302,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21496,23 +22315,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21530,7 +22349,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21538,8 +22357,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21547,39 +22366,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21594,29 +22413,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21629,8 +22448,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21640,13 +22459,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21658,11 +22477,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21671,12 +22490,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -21699,41 +22518,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21746,50 +22565,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -21812,63 +22632,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21877,52 +22698,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21931,7 +22771,7 @@ var ts; if (node.decorators || node.modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21954,24 +22794,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21979,14 +22819,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -22008,10 +22848,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22021,14 +22861,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -22044,7 +22884,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -22059,25 +22899,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -22089,25 +22929,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22122,17 +22962,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -22140,13 +22980,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -22163,7 +23003,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -22179,18 +23019,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -22208,10 +23048,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -22231,7 +23071,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -22250,7 +23090,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -22261,20 +23101,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -22288,27 +23128,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22334,7 +23184,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -22346,33 +23196,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22380,11 +23229,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22394,14 +23243,14 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22413,7 +23262,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22424,7 +23273,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22436,11 +23285,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22456,15 +23305,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22472,52 +23321,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22529,7 +23378,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22539,7 +23388,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22549,8 +23398,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22572,9 +23421,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22587,14 +23436,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22608,9 +23457,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22619,24 +23468,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22644,12 +23493,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22664,15 +23513,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22680,7 +23527,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22731,9 +23578,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22743,8 +23590,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22755,11 +23602,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22824,7 +23671,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22843,7 +23690,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -22894,7 +23741,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(298 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22930,14 +23777,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22945,7 +23792,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -23029,7 +23876,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -23054,7 +23901,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -23062,7 +23909,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -23071,7 +23918,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -23094,7 +23941,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(301 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -23122,15 +23969,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -23139,9 +23986,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -23157,8 +24004,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(313 /* JSDocPropertyTag */, start) : - createNode(307 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -23175,20 +24022,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -23200,7 +24047,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(308 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -23209,13 +24056,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(310 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(303 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -23237,20 +24084,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -23269,14 +24116,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(302 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -23288,7 +24135,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -23296,19 +24143,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(304 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(309 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(306 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -23317,7 +24164,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(312 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -23331,9 +24178,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 310 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -23346,7 +24193,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23365,7 +24212,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23379,22 +24226,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(305 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(300 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 308 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23436,10 +24283,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23452,13 +24299,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23467,7 +24314,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23503,13 +24350,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(311 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23542,13 +24389,13 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - if (token() !== 73 /* Identifier */) { + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { result.originalKeywordKind = token(); } result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -23677,7 +24524,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -24243,10 +25090,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24396,6 +25243,14 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", @@ -24460,6 +25315,15 @@ var ts; isCommandLineOnly: true, description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, + { + name: "listFilesOnly", + type: "boolean", + category: ts.Diagnostics.Command_line_Options, + affectsSemanticDiagnostics: true, + affectsEmit: true, + isCommandLineOnly: true, + description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing + }, // Basic { name: "target", @@ -25016,6 +25880,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -25111,6 +25981,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -25208,7 +26085,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25438,6 +26316,7 @@ var ts; return { buildOptions: buildOptions, projects: projects, errors: errors }; } ts.parseBuildCommand = parseBuildCommand; + /* @internal */ function getDiagnosticText(_message) { var _args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -25446,104 +26325,7 @@ var ts; var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } - /* @internal */ - function printVersion() { - ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); - } - ts.printVersion = printVersion; - /* @internal */ - function printHelp(optionsList, syntaxPrefix) { - if (syntaxPrefix === void 0) { syntaxPrefix = ""; } - var output = []; - // We want to align our "syntax" and "examples" commands to a certain margin. - var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; - var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; - var marginLength = Math.max(syntaxLength, examplesLength); - // Build up the syntactic skeleton. - var syntax = makePadding(marginLength - syntaxLength); - syntax += "tsc " + syntaxPrefix + "[" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + "...]"; - output.push(getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax)); - output.push(ts.sys.newLine + ts.sys.newLine); - // Build up the list of examples. - var padding = makePadding(marginLength); - output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine); - output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine); - output.push(padding + "tsc @args.txt" + ts.sys.newLine); - output.push(padding + "tsc --build tsconfig.json" + ts.sys.newLine); - output.push(ts.sys.newLine); - output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); - // We want our descriptions to align at the same column in our output, - // so we keep track of the longest option usage string. - marginLength = 0; - var usageColumn = []; // Things like "-d, --declaration" go in here. - var descriptionColumn = []; - var optionsDescriptionMap = ts.createMap(); // Map between option.description and list of option.type if it is a kind - for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) { - var option = optionsList_1[_i]; - // If an option lacks a description, - // it is not officially supported. - if (!option.description) { - continue; - } - var usageText_1 = " "; - if (option.shortName) { - usageText_1 += "-" + option.shortName; - usageText_1 += getParamType(option); - usageText_1 += ", "; - } - usageText_1 += "--" + option.name; - usageText_1 += getParamType(option); - usageColumn.push(usageText_1); - var description = void 0; - if (option.name === "lib") { - description = getDiagnosticText(option.description); - var element = option.element; - var typeMap = element.type; - optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; })); - } - else { - description = getDiagnosticText(option.description); - } - descriptionColumn.push(description); - // Set the new margin for the description column if necessary. - marginLength = Math.max(usageText_1.length, marginLength); - } - // Special case that can't fit in the loop. - var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; - usageColumn.push(usageText); - descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); - marginLength = Math.max(usageText.length, marginLength); - // Print out each row, aligning all the descriptions on the same column. - for (var i = 0; i < usageColumn.length; i++) { - var usage = usageColumn[i]; - var description = descriptionColumn[i]; - var kindsList = optionsDescriptionMap.get(description); - output.push(usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine); - if (kindsList) { - output.push(makePadding(marginLength + 4)); - for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) { - var kind = kindsList_1[_a]; - output.push(kind + " "); - } - output.push(ts.sys.newLine); - } - } - for (var _b = 0, output_1 = output; _b < output_1.length; _b++) { - var line = output_1[_b]; - ts.sys.write(line); - } - return; - function getParamType(option) { - if (option.paramType !== undefined) { - return " " + getDiagnosticText(option.paramType); - } - return ""; - } - function makePadding(paddingLength) { - return Array(paddingLength + 1).join(" "); - } - } - ts.printHelp = printHelp; + ts.getDiagnosticText = getDiagnosticText; /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ @@ -25708,7 +26490,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25764,15 +26546,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25790,13 +26572,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25813,7 +26595,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25862,7 +26644,7 @@ var ts; /** @internal */ function convertToTSConfig(configParseResult, configFileName, host) { var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); + var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs, host)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; @@ -25883,12 +26665,12 @@ var ts; return undefined; return specs; } - function matchesSpecs(path, includeSpecs, excludeSpecs) { + function matchesSpecs(path, includeSpecs, excludeSpecs, host) { if (!includeSpecs) return function (_) { return true; }; - var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); - var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); - var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames); if (includeRe) { if (excludeRe) { return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); }; @@ -26065,6 +26847,35 @@ var ts; } } ts.generateTSConfig = generateTSConfig; + /* @internal */ + function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) { + var result = {}; + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name in options) { + if (ts.hasProperty(options, name)) { + result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); + } + } + if (result.configFilePath) { + result.configFilePath = toAbsolutePath(result.configFilePath); + } + return result; + } + ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; + function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { + if (option) { + if (option.type === "list") { + var values = value; + if (option.element.isFilePath && values.length) { + return values.map(toAbsolutePath); + } + } + else if (option.isFilePath) { + return toAbsolutePath(value); + } + } + return value; + } /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -26095,8 +26906,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -26516,7 +27326,7 @@ var ts; } function normalizeNonListOptionValue(option, basePath, value) { if (option.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + value = ts.getNormalizedAbsolutePath(value, basePath); if (value === "") { value = "."; } @@ -26951,8 +27761,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -27211,7 +28022,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27675,7 +28486,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -28155,35 +28966,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -28202,9 +29045,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -28213,6 +29056,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -28237,7 +29110,11 @@ var ts; ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; })(ContainerFlags || (ContainerFlags = {})); - var flowNodeCreated = ts.identity; + function initFlowNode(node) { + ts.Debug.attachFlowNodeDebugInfo(node); + return node; + } + var flowNodeCreated = initFlowNode; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -28277,7 +29154,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -28301,6 +29178,9 @@ var ts; symbolCount = 0; skipTransformFlagAggregation = file.isDeclarationFile; Symbol = ts.objectAllocator.getSymbolConstructor(); + // Attach debugging information if necessary + ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); + ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { bind(file); file.symbolCount = symbolCount; @@ -28345,7 +29225,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -28372,7 +29252,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -28381,7 +29261,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28393,39 +29273,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 295 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 298 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -28525,7 +29408,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28560,7 +29443,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28584,7 +29467,7 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } @@ -28627,7 +29510,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28653,34 +29536,35 @@ var ts; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isIIFE) { - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; hasExplicitReturn = false; - flowNodeCreated = ts.identity; + flowNodeCreated = initFlowNode; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28697,7 +29581,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28724,8 +29608,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28757,80 +29641,90 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28841,30 +29735,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && - isNarrowableReference(expr.expression); + ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || + ts.isOptionalChain(expr); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -28875,7 +29768,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28889,17 +29782,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28908,11 +29801,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28921,20 +29814,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28949,31 +29836,35 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if ((expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -28988,47 +29879,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -29056,7 +29952,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -29088,15 +29984,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -29118,7 +30014,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -29138,7 +30034,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -29166,7 +30062,7 @@ var ts; // as possible antecedents of the start of the `catch` or `finally` blocks. // Don't bother intercepting the call if there's no finally or catch block that needs the information if (node.catchClause || node.finallyBlock) { - flowNodeCreated = function (node) { return (tryPriors.push(node), node); }; + flowNodeCreated = function (node) { return (tryPriors.push(node), initFlowNode(node)); }; } bind(node.tryBlock); flowNodeCreated = oldFlowNodeCreated; @@ -29230,7 +30126,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = initFlowNode({ flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }); addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -29248,7 +30144,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -29266,9 +30162,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all - // case clauses have unreachable end points (e.g. they all return). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -29296,7 +30193,7 @@ var ts; bind(clause); fallthroughFlow = currentFlow; if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { - errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + clause.fallthroughFlowNode = currentFlow; } } clauses.transformFlags = subtreeTransformFlags | 536870912 /* HasComputedFlags */; @@ -29322,6 +30219,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -29333,14 +30241,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -29351,10 +30259,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -29362,16 +30270,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29379,7 +30287,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29390,7 +30298,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29400,20 +30308,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29427,7 +30335,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29438,7 +30346,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29477,27 +30385,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.kind !== 306 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // an immediately invoked function expression (IIFE). Initialize the flowNode property to - // the current control flow (which includes evaluation of the IIFE arguments). - var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29506,54 +30489,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -29586,45 +30569,45 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 300 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -29651,11 +30634,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29725,7 +30708,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29737,7 +30720,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29769,10 +30752,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29800,7 +30783,7 @@ var ts; var host = ts.getJSDocHost(typeAlias); container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -29808,12 +30791,17 @@ var ts; // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); if (isTopLevel) { - bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; })); + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - container = file; + if (!ts.isExternalOrCommonJsModule(file)) { + container = undefined; + } + else { + container = file; + } break; case 4 /* ThisProperty */: container = declName.parent.expression; @@ -29827,11 +30815,13 @@ var ts; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + if (container) { + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -29849,11 +30839,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */) && - !(node.flags & 2097152 /* JSDoc */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29887,7 +30877,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -29898,7 +30888,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29939,8 +30929,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -29966,7 +30956,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -30035,7 +31025,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -30075,8 +31065,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -30097,7 +31087,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -30110,27 +31100,28 @@ var ts; break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -30158,76 +31149,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 307 /* JSDocClassTag */: + return bindJSDocClassTag(node); + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -30246,65 +31239,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 307 /* JSDocParameterTag */: - if (node.parent.kind === 300 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 299 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 313 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30412,8 +31405,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30423,7 +31415,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30442,41 +31434,53 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + setValueDeclaration(symbol, node); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } - if (constructorSymbol) { + if (constructorSymbol && constructorSymbol.valueDeclaration) { // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -30489,11 +31493,21 @@ var ts; ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30506,11 +31520,14 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + if (namespaceSymbol) { + // Ensure the namespace symbol becomes class-like + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } /** @@ -30526,32 +31543,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30560,9 +31583,9 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; @@ -30579,6 +31602,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30589,20 +31615,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30631,7 +31684,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30648,7 +31701,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30660,7 +31713,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30671,7 +31724,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { + if (node.kind === 244 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -30734,10 +31787,10 @@ var ts; } } function bindParameter(node) { - if (node.kind === 307 /* JSDocParameterTag */ && container.kind !== 300 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30756,9 +31809,9 @@ var ts; } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); @@ -30771,9 +31824,9 @@ var ts; } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30784,8 +31837,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30811,7 +31864,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -30839,11 +31892,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30857,7 +31910,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30887,12 +31940,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30904,7 +31957,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30941,58 +31994,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -31003,6 +32056,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -31014,7 +32070,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31037,17 +32093,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -31090,8 +32149,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31131,11 +32190,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -31326,9 +32385,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31338,9 +32400,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31428,43 +32493,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31472,11 +32537,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31493,103 +32558,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31602,26 +32667,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31639,67 +32704,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31718,7 +32783,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31791,7 +32856,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31874,7 +32939,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -32028,6 +33093,7 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 7] = "ResolvedTypeArguments"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var CheckMode; (function (CheckMode) { @@ -32038,11 +33104,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); var AccessFlags; (function (AccessFlags) { AccessFlags[AccessFlags["None"] = 0] = "None"; @@ -32145,11 +33206,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -32231,8 +33290,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -32298,9 +33360,9 @@ var ts; }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (nodeIn) { + getContextualType: function (nodeIn, contextFlags) { var node = ts.getParseTreeNode(nodeIn, ts.isExpression); - return node ? getContextualType(node) : undefined; + return node ? getContextualType(node, contextFlags) : undefined; }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); @@ -32349,7 +33411,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -32365,6 +33427,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -32383,6 +33448,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -32411,7 +33477,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -32475,6 +33541,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -32504,6 +33571,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -32527,11 +33595,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var iterationTypesCache = ts.createMap(); // cache for common IterationTypes instances var noIterationTypes = { @@ -32624,6 +33692,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32636,13 +33707,13 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -32678,10 +33749,10 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { - return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; + return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText; } } } @@ -32691,7 +33762,7 @@ var ts; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); if (_jsxFactoryEntity) { - _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).escapedText; + _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText; } } else if (compilerOptions.reactNamespace) { @@ -32735,7 +33806,7 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32820,7 +33891,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32949,7 +34024,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32959,7 +34034,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -33008,7 +34083,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -33052,7 +34127,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -33066,17 +34141,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -33099,22 +34174,22 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -33135,16 +34210,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -33165,14 +34240,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -33218,12 +34293,12 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 298 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -33240,13 +34315,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -33261,14 +34336,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -33292,7 +34367,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -33306,12 +34381,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -33328,9 +34403,9 @@ var ts; } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! @@ -33349,7 +34424,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -33357,9 +34432,9 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -33377,9 +34452,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -33387,24 +34462,24 @@ var ts; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -33417,7 +34492,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -33426,7 +34501,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33441,25 +34516,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33479,7 +34554,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33552,7 +34627,7 @@ var ts; } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); @@ -33575,10 +34650,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33591,12 +34666,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33608,7 +34683,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 154 /* TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -33663,10 +34738,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33754,11 +34829,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 244 /* EnumDeclaration */); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33790,13 +34869,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33806,7 +34885,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33871,7 +34950,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33883,7 +34967,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33937,9 +35021,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33974,7 +35059,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -33994,34 +35084,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -34101,17 +35213,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 249 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -34127,17 +35239,17 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { - var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); + if (name.kind === 75 /* Identifier */) { + var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); if (!symbol) { return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -34189,7 +35301,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -34228,6 +35340,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -34239,9 +35365,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -34272,7 +35395,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -34343,7 +35466,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -34352,9 +35475,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -34362,15 +35489,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34444,7 +35572,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34581,7 +35709,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34590,7 +35719,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34598,7 +35738,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34606,20 +35746,29 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { @@ -34632,7 +35781,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34710,25 +35859,55 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals + // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would + // trigger resolving late-bound names, which we may already be in the process of doing while we're here! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } @@ -34765,12 +35944,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34787,7 +35966,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34823,7 +36002,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34838,10 +36017,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34958,14 +36137,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -35008,14 +36187,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -35024,7 +36203,7 @@ var ts; // Type Reference or TypeAlias entity = Identifier meaning = 788968 /* Type */; } - var firstIdentifier = getFirstIdentifier(entityName); + var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { @@ -35064,15 +36243,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -35095,14 +36274,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -35133,6 +36315,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -35143,7 +36328,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -35171,26 +36357,26 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -35210,7 +36396,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -35231,31 +36417,31 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -35269,10 +36455,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -35280,6 +36472,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -35290,12 +36483,6 @@ var ts; ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -35303,7 +36490,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -35367,17 +36554,14 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 111551 /* Value */); @@ -35394,24 +36578,7 @@ var ts; } } else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -35424,15 +36591,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35445,12 +36642,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35463,7 +36660,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35471,7 +36668,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35485,12 +36682,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35585,11 +36782,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35636,7 +36833,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35647,25 +36844,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35676,20 +36877,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35730,7 +36941,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35743,7 +36954,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35754,7 +36965,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35762,23 +36973,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -35798,9 +37012,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 307 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35810,15 +37024,14 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35828,22 +37041,22 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); + var firstIdentifier = ts.getFirstIdentifier(accessExpression); var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); @@ -35851,6 +37064,9 @@ var ts; } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35883,6 +37099,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35963,7 +37186,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -36055,16 +37278,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -36097,6 +37336,9 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -36142,9 +37384,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -36153,6 +37392,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -36180,12 +37422,1104 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + ts.forEachEntry(symbolTable, function (symbol, name) { + var baseName = ts.unescapeLeadingUnderscores(name); + void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` + }); + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && + symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && + symbol.escapedName !== "export=" /* ExportEquals */; + var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); + if (symbol.flags & 16 /* Function */ || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */) + && !isConstMergedWithNSPrintableAsSignatureMerge) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + if (ts.some(symbol.declarations, ts.isParameterDeclaration)) + return; + ts.Debug.assertDefined(deferredPrivates); + getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol); // Call to cache unique name for symbol + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function getNamespaceMembersForSerialization(symbol) { + return !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + } + function isTypeOnlyNamespace(symbol) { + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = getNamespaceMembersForSerialization(symbol); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s); + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + includePrivateSymbol(target || s); + var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName; + return ts.createExportSpecifier(name === targetName ? undefined : targetName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), + // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned + // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag + // In such cases, the `target` refers to the module itself already + ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + case 193 /* PropertyAccessExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + // If the target resolves and resolves to a thing defined in this file, emit as an alias, otherwise emit as a const + if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = ts.getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (symbol) { + input = getNameCandidateWorker(symbol, input); + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getNameCandidateWorker(symbol, localName) { + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; + } + if (localName === "default" /* Default */) { + localName = "_default"; + } + else if (localName === "export=" /* ExportEquals */) { + localName = "_exports"; + } + localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); + return localName; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + localName = getNameCandidateWorker(symbol, localName); + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -36230,8 +38564,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -36239,11 +38573,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -36281,9 +38615,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -36296,17 +38630,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -36323,28 +38660,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -36352,53 +38689,54 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -36407,14 +38745,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { + else if (node.parent.kind === 261 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -36431,9 +38772,11 @@ var ts; if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); + var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36493,6 +38836,8 @@ var ts; return !!target.immediateBaseConstraint; case 6 /* JSDocTypeReference */: return !!getSymbolLinks(target).resolvedJSDocType; + case 7 /* ResolvedTypeArguments */: + return !!target.resolvedTypeArguments; } return ts.Debug.assertNever(propertyName); } @@ -36508,12 +38853,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36546,7 +38891,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36598,7 +38943,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36613,23 +38958,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36647,11 +38992,11 @@ var ts; return parentType; } // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36719,30 +39064,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -36761,8 +39106,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36775,11 +39120,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36846,12 +39191,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36869,6 +39216,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36894,9 +39244,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -36989,9 +39339,9 @@ var ts; var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -37066,7 +39416,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -37089,7 +39439,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -37128,7 +39478,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -37184,22 +39534,26 @@ var ts; // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -37240,12 +39594,15 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -37254,7 +39611,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -37281,33 +39638,43 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { @@ -37317,25 +39684,21 @@ var ts; } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + } } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -37343,19 +39706,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -37367,8 +39721,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -37435,7 +39790,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37516,40 +39871,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: - case 305 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37557,7 +39922,8 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); + ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37566,9 +39932,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37587,19 +39954,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37692,24 +40059,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37747,14 +40108,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37762,7 +40130,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37798,8 +40166,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37820,9 +40188,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37838,7 +40212,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37880,10 +40254,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37891,18 +40265,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37916,10 +40291,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37943,7 +40318,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -38015,23 +40390,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -38057,7 +40432,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -38073,14 +40448,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -38135,9 +40510,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -38231,7 +40609,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -38247,9 +40626,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -38290,6 +40669,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -38300,7 +40694,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -38330,7 +40724,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -38393,12 +40787,12 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } - function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { - var sig = new Signature(checker); + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) { + var sig = new Signature(checker, flags); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; @@ -38406,15 +40800,13 @@ var ts; sig.resolvedReturnType = resolvedReturnType; sig.resolvedTypePredicate = resolvedTypePredicate; sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasLiteralTypes = hasLiteralTypes; sig.target = undefined; sig.mapper = undefined; return sig; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; return result; @@ -38426,13 +40818,22 @@ var ts; result.mapper = undefined; return result; } + function getOptionalCallSignature(signature) { + return signatureIsOptionalCall(signature) ? signature : + (signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature))); + } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.flags |= 4 /* IsOptionalCall */; + return result; + } function getExpandedParameters(sig) { - if (sig.hasRestParameter) { + if (signatureHasRestParameter(sig)) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38452,7 +40853,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38549,7 +40950,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38561,8 +40962,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38616,11 +41017,9 @@ var ts; var params = combineUnionParameters(left, right); var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter); var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); - var hasRestParam = left.hasRestParameter || right.hasRestParameter; - var hasLiteralTypes = left.hasLiteralTypes || right.hasLiteralTypes; var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, hasRestParam, hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 3 /* PropagatingFlags */); result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); return result; } @@ -38687,7 +41086,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38710,19 +41109,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38730,7 +41129,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38786,14 +41185,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38936,8 +41339,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38961,8 +41364,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -39178,11 +41581,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; if (t.flags & 63176704 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). @@ -39192,6 +41595,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -39204,8 +41610,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -39291,8 +41697,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39640,10 +42046,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39677,13 +42083,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; - } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39729,7 +42132,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var hasLiteralTypes = false; + var flags = 0 /* None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -39759,8 +42162,8 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { - hasLiteralTypes = true; + if (type && type.kind === 186 /* LiteralType */) { + flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -39773,22 +42176,24 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); - var hasRestLikeParameter = ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters); + if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { + flags |= 1 /* HasRestParameter */; + } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, - /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, hasRestLikeParameter, hasLiteralTypes); + /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); } return links.resolvedSignature; } @@ -39840,13 +42245,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39889,9 +42294,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39920,13 +42322,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39936,8 +42335,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signatureIsOptionalCall(signature)) { + type = addOptionalTypeMarker(type); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39962,7 +42363,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39972,12 +42373,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39992,7 +42393,7 @@ var ts; return tryGetRestTypeOfSignature(signature) || anyType; } function tryGetRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType; return restType && getIndexTypeOfType(restType, 1 /* Number */); @@ -40067,7 +42468,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -40081,7 +42482,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -40115,13 +42516,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -40146,7 +42547,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -40170,7 +42571,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -40203,8 +42604,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -40219,7 +42620,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -40228,16 +42629,50 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + return type; + } + function getTypeArguments(type) { + var _a, _b; + if (!type.resolvedTypeArguments) { + if (!pushTypeResolution(type, 7 /* ResolvedTypeArguments */)) { + return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; + } + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + if (popTypeResolution()) { + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + else { + type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray; + error(type.node || currentNode, type.target.symbol + ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves + : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol)); + } + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -40247,13 +42682,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -40261,10 +42696,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -40285,27 +42723,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -40323,13 +42761,15 @@ var ts; return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -40338,56 +42778,44 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSDocValueReference(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value, but resolve it as a type anyway. + * Note: If the value is imported from commonjs, it should really be an alias, + * but this function's special-case code fakes alias resolution as well. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + function getTypeFromJSDocValueReference(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType; + if (symbol.valueDeclaration) { + var decl = ts.getRootDeclaration(symbol.valueDeclaration); + var isRequireAlias = false; + if (ts.isVariableDeclaration(decl) && decl.initializer) { + var expr = decl.initializer; + // skip past entity names, eg `require("x").a.b.c` + while (ts.isPropertyAccessExpression(expr)) { + expr = expr.expression; } + isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol; } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); + var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol; + if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) { + typeType = getTypeReferenceType(node, valueType.symbol); } } + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } function getSubstitutionType(typeVariable, substitute) { if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === typeVariable) { @@ -40405,7 +42833,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -40414,9 +42842,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 298 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40427,7 +42855,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40464,10 +42892,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40479,7 +42907,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40537,9 +42965,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40658,15 +43086,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40703,7 +43171,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40737,27 +43205,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; - var elementTypes = ts.map(node.elementTypes, function (n) { - var type = getTypeFromTypeNode(n); - return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40806,8 +43260,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40836,8 +43290,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40922,10 +43376,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40944,14 +43398,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -41018,8 +43468,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -41294,21 +43744,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - // tslint:disable no-unnecessary-type-assertion - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -41344,7 +43795,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -41355,13 +43806,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41492,13 +43943,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41623,7 +44071,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41835,7 +44283,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41858,11 +44306,11 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { var errorMessage = targetMeaning === 111551 /* Value */ @@ -41874,16 +44322,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; if (meaning === 111551 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41907,7 +44355,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 137 /* ReadonlyKeyword */) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -42096,12 +44548,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -42114,89 +44580,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -42285,20 +44751,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -42318,7 +44771,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 3 /* PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -42352,17 +44805,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -42378,7 +44831,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -42391,13 +44844,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -42405,9 +44859,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 184 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -42416,7 +44870,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -42425,12 +44879,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42484,7 +44938,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42580,15 +45034,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42652,35 +45109,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42700,7 +45157,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -42712,7 +45169,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42815,23 +45272,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -43003,7 +45460,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -43012,9 +45469,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -43156,11 +45613,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -43195,20 +45652,20 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` */ function isAnySignature(s) { return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 && - s.hasRestParameter && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && + signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && isTypeAny(getReturnTypeOfSignature(s)); } /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -43232,8 +45689,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -43266,11 +45723,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is - compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -43281,15 +45738,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol)) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol)) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43310,6 +45769,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -43322,7 +45784,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -43331,7 +45793,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -43377,12 +45841,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -43393,7 +45857,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43470,9 +45934,9 @@ var ts; return true; } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, relation)); + var related = relation.get(getRelationKey(source, target, /*isIntersectionConstituent*/ false, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43504,9 +45968,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43549,8 +46018,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43563,6 +46155,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43581,8 +46175,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43704,14 +46298,14 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); var isIntersectionConstituent = !!isApparentIntersectionConstituent; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { @@ -43749,15 +46343,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -43767,21 +46361,30 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43801,6 +46404,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43837,7 +46441,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43852,6 +46456,11 @@ var ts; // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43880,9 +46489,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -44018,14 +46627,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { + function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); if (related) { return related; } @@ -44104,17 +46713,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -44124,25 +46722,25 @@ var ts; if (overflow) { return 0 /* False */; } - var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var id = getRelationKey(source, target, isIntersectionConstituent, relation); + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -44173,14 +46771,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -44188,7 +46798,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -44228,7 +46838,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. @@ -44318,7 +46928,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44329,7 +46939,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44338,25 +46948,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44365,13 +46975,23 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44380,14 +47000,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44401,7 +47021,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44420,7 +47040,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -44447,7 +47067,7 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); @@ -44462,7 +47082,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44493,7 +47113,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44521,7 +47141,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44597,11 +47217,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44617,8 +47237,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44631,9 +47251,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -44758,7 +47378,7 @@ var ts; var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44798,8 +47418,8 @@ var ts; if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44809,8 +47429,8 @@ var ts; else { reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44822,7 +47442,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44847,8 +47467,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44862,10 +47483,12 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { @@ -44930,14 +47553,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44951,7 +47575,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44960,10 +47584,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44976,11 +47600,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -45046,7 +47682,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -45178,7 +47814,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -45210,7 +47846,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -45236,8 +47872,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -45246,7 +47885,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -45269,17 +47908,18 @@ var ts; * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. * For other cases, the types ids are used. */ - function getRelationKey(source, target, relation) { + function getRelationKey(source, target, isIntersectionConstituent, relation) { if (relation === identityRelation && source.id > target.id) { var temp = source; source = target; target = temp; } + var intersection = isIntersectionConstituent ? "&" : ""; if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { var typeParameters = []; - return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + intersection; } - return source.id + "," + target.id; + return source.id + "," + target.id + intersection; } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. @@ -45475,20 +48115,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45527,7 +48169,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45535,7 +48177,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45619,7 +48261,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45634,8 +48276,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45700,6 +48342,23 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function isNotOptionalTypeMarker(type) { + return type !== optionalType; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function getOptionalExpressionType(exprType, expression) { + return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) : + ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : + exprType; + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45729,8 +48388,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45882,7 +48541,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45919,7 +48578,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45949,12 +48608,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -45969,23 +48628,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -45999,7 +48658,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -46041,8 +48700,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -46111,6 +48769,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -46120,7 +48784,7 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); @@ -46189,10 +48853,10 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames); @@ -46328,10 +48992,7 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; - inferFromTypes(source, target); - priority = savePriority; + inferWithPriority(source, target, 1 /* NakedTypeVariable */); return; } source = getUnionType(sources); @@ -46418,9 +49079,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -46430,10 +49092,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - var savePriority = priority; - priority |= 32 /* LiteralKeyof */; - inferFromTypes(empty, target.type); - priority = savePriority; + inferWithPriority(empty, target.type, 32 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -46485,6 +49144,12 @@ var ts; } } } + function inferWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromTypes(source, target); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -46550,6 +49215,18 @@ var ts; } return undefined; } + function getSingleTypeVariableFromIntersectionTypes(types) { + var typeVariable; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var type = types_13[_i]; + var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + if (!t || typeVariable && t !== typeVariable) { + return undefined; + } + typeVariable = t; + } + return typeVariable; + } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; if (targetFlags & 1048576 /* Union */) { @@ -46579,6 +49256,16 @@ var ts; } } } + if (typeVariableCount === 0) { + // If every target is an intersection of types containing a single naked type variable, + // make a lower priority inference to that type variable. This handles inferring from + // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. + var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); + if (intersectionTypeVariable) { + inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + } + return; + } // If the target has a single naked type variable and no inference circularities were // encountered above (meaning we explored the types fully), create a union of the source // types from which no inferences have been made so far and infer from that union to the @@ -46610,15 +49297,12 @@ var ts; // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferFromTypes(source, t); + inferWithPriority(source, t, 1 /* NakedTypeVariable */); } } - priority = savePriority; } } function inferToMappedType(source, target, constraintType) { @@ -46639,14 +49323,12 @@ var ts; if (inference && !inference.isFixed) { var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); if (inferredType) { - var savePriority = priority; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - priority |= ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? - 4 /* PartialHomomorphicMappedType */ : 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? + 4 /* PartialHomomorphicMappedType */ : + 2 /* HomomorphicMappedType */); } } return true; @@ -46654,10 +49336,7 @@ var ts; if (constraintType.flags & 262144 /* TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - var savePriority = priority; - priority |= 8 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; + inferWithPriority(getIndexType(source), constraintType, 8 /* MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -46699,6 +49378,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer // from S to T and from X to Y. @@ -46728,10 +49412,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46771,7 +49455,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46941,7 +49625,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46962,7 +49646,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -46972,16 +49656,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46992,24 +49676,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -47017,8 +49701,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -47030,6 +49714,15 @@ var ts; } return false; } + function optionalChainContainsReference(source, target) { + while (ts.isOptionalChain(source)) { + source = source.expression; + if (isMatchingReference(source, target)) { + return true; + } + } + return false; + } // Return true if target is a property access xxx.yyy, source is a property access xxx.zzz, the declared // type of xxx is a union type, and yyy is a property that is possibly a discriminant. We consider a property // a possible discriminant if its type differs in the constituents of containing union type, and if every @@ -47042,7 +49735,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -47073,7 +49766,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -47101,14 +49794,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -47150,8 +49843,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -47256,15 +49949,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -47281,21 +49974,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -47303,7 +49996,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -47321,37 +50014,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -47361,13 +50049,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -47389,8 +50077,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -47473,8 +50161,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47526,8 +50213,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47550,33 +50237,94 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = void 0; + if (node.parent.kind === 225 /* ExpressionStatement */) { + funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); + } + else if (node.expression.kind !== 101 /* SuperKeyword */) { + if (ts.isOptionalChain(node)) { + funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); + } + else { + funcType = checkNonNullExpression(node.expression); + } + } + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + } + function getTypePredicateArgument(predicate, callExpression) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + return callExpression.arguments[predicate.parameterIndex]; + } + var invokedExpression = ts.skipParentheses(callExpression.expression); + return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined; } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47584,6 +50332,82 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isFalseExpression(expr) { + var node = ts.skipParentheses(expr); + return node.kind === 90 /* FalseKeyword */ || node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && predicate.kind === 3 /* AssertsIdentifier */) { + var predicateArgument = flow.node.arguments[predicate.parameterIndex]; + if (predicateArgument && isFalseExpression(predicateArgument)) { + return false; + } + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47595,6 +50419,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47603,7 +50428,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47625,16 +50450,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47646,13 +50462,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47664,14 +50480,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47698,11 +50512,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47714,7 +50528,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47724,11 +50538,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47737,11 +50574,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47750,27 +50587,63 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 90 /* FalseKeyword */) { + return unreachableNeverType; + } + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47778,7 +50651,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47813,7 +50686,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47828,14 +50701,27 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); - } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (containsMatchingReferenceDiscriminant(reference, expr)) { - type = declaredType; + else { + if (strictNullChecks) { + if (optionalChainContainsReference(expr, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + } + else if (expr.kind === 203 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + } + } + if (isMatchingReferenceDiscriminant(expr, type)) { + type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + } + else if (containsMatchingReferenceDiscriminant(reference, expr)) { + type = declaredType; + } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } } return createFlowType(type, isIncomplete(flowType)); } @@ -47845,7 +50731,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47905,25 +50791,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47970,6 +50863,9 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } + if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { + type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } if (isMatchingReferenceDiscriminant(expr, declaredType)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } @@ -47997,19 +50893,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -48018,6 +50914,14 @@ var ts; if (isMatchingReference(reference, right_1)) { return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); } + if (strictNullChecks) { + if (optionalChainContainsReference(left_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + } + else if (optionalChainContainsReference(right_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + } + } if (isMatchingReferenceDiscriminant(left_1, declaredType)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } @@ -48028,9 +50932,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -48041,15 +50945,24 @@ var ts; } return type; } + function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { + // We are in a branch of obj?.foo === value or obj?.foo !== value. We remove undefined and null from + // the type of obj if (a) the operator is === and the type of value doesn't include undefined or (b) the + // operator is !== and the type of value is undefined. + var effectiveTrue = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */ ? assumeTrue : !assumeTrue; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var valueNonNullish = !(getTypeFacts(getTypeOfExpression(value)) & (doubleEquals ? 262144 /* EQUndefinedOrNull */ : 65536 /* EQUndefined */)); + return effectiveTrue === valueNonNullish ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeByEquality(type, operator, value, assumeTrue) { if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -48062,7 +50975,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -48074,7 +50987,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -48087,9 +51000,15 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + assumeTrue = !assumeTrue; + } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { + if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the // narrowed type of 'y' to its declared type. if (containsMatchingReference(reference, target)) { @@ -48097,9 +51016,6 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { - assumeTrue = !assumeTrue; - } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } @@ -48132,6 +51048,10 @@ var ts; return type; } } + function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { + var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify // values with unit types, except for the case where @@ -48264,6 +51184,9 @@ var ts; function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { + if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the // narrowed type of 'y' to its declared type. We do this because preceding 'x.y' // references might reference a different 'y' property. However, we make an exception @@ -48324,38 +51247,29 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' - if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { - return type; - } - if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) { + var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } - if (containsMatchingReference(reference, predicateArgument)) { - return declaredType; - } - } - } - else { - var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { - var possibleReference = ts.skipParentheses(invokedExpression.expression); - if (isMatchingReference(reference, possibleReference)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && + !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (containsMatchingReference(reference, possibleReference)) { + if (containsMatchingReference(reference, predicateArgument)) { return declaredType; } } @@ -48365,27 +51279,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isExpressionOfOptionalChainRoot(expr) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -48393,7 +51324,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -48414,9 +51345,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -48435,10 +51366,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -48453,7 +51384,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -48461,10 +51392,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48501,7 +51432,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -48522,7 +51453,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48534,14 +51465,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48590,7 +51521,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48599,8 +51530,8 @@ var ts; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48608,11 +51539,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48646,7 +51577,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48669,7 +51600,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48687,8 +51618,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48706,7 +51637,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48714,9 +51645,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48727,7 +51658,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48795,37 +51726,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 158 /* Constructor */: + case 161 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48864,10 +51795,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48875,12 +51804,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48909,9 +51836,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48921,16 +51861,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48938,7 +51878,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -48963,7 +51903,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48977,15 +51917,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48998,14 +51938,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -49013,7 +51953,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -49082,7 +52022,7 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -49096,7 +52036,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -49117,7 +52057,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; @@ -49132,7 +52072,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -49140,21 +52080,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -49162,14 +52102,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -49177,7 +52117,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -49204,7 +52144,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -49218,9 +52158,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -49284,9 +52224,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -49401,22 +52341,26 @@ var ts; return undefined; } // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. - function getContextualTypeForArgument(callTarget, arg) { + function getContextualTypeForArgument(callTarget, arg, contextFlags) { var args = getEffectiveCallArguments(callTarget); var argIndex = args.indexOf(arg); // -1 for e.g. the expression of a CallExpression, or the tag of a TaggedTemplateExpression - return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); + return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags); } - function getContextualTypeForArgumentAtIndex(callTarget, argIndex) { + function getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags) { // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } + if (contextFlags && contextFlags & 4 /* Completion */ && signature.target) { + var baseSignature = getBaseSignature(signature.target); + return intersectTypes(getTypeAtPosition(signature, argIndex), getTypeAtPosition(baseSignature, argIndex)); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -49425,7 +52369,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -49434,7 +52378,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -49443,7 +52388,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -49471,7 +52416,7 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); @@ -49482,8 +52427,11 @@ var ts; if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49505,12 +52453,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49554,7 +52503,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49643,25 +52592,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 279 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 271 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -49670,7 +52619,7 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { @@ -49738,7 +52687,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49747,58 +52696,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: - return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* NewExpression */: + return getContextualTypeForArgument(parent, node, contextFlags); + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49953,7 +52902,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49967,7 +52916,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -49981,8 +52930,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -50012,8 +52961,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -50025,7 +52974,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -50050,12 +52999,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -50097,9 +53046,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -50187,7 +53136,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -50202,13 +53151,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -50231,8 +53180,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -50257,7 +53206,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -50283,7 +53232,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -50343,7 +53292,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -50391,7 +53346,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -50436,7 +53391,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -50459,7 +53414,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -50878,7 +53833,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50973,32 +53928,43 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); } - function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + function checkNonNullExpression(node) { + return checkNonNullType(checkExpression(node), node); + } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; } - function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + function reportObjectPossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); + } + function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); + } + function checkNonNullTypeWithReporter(type, node, reportError) { if (strictNullChecks && type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? - (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : - (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : - (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); + reportError(node, kind); var t = getNonNullableType(type); return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } + function checkNonNullType(type, node) { + return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError); + } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); if (nonNullType !== errorType && nonNullType.flags & 16384 /* Void */) { @@ -51007,20 +53973,24 @@ var ts; return nonNullType; } function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + } + function checkPropertyAccessChain(node) { + var leftType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(leftType, node.expression); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType); } function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -51034,6 +54004,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -51061,9 +54032,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -51079,7 +54050,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -51089,11 +54060,11 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -51124,9 +54095,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -51137,22 +54108,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -51192,7 +54163,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -51325,16 +54296,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -51351,13 +54322,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -51374,13 +54345,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -51394,28 +54365,22 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + } + function checkElementAccessChain(node) { + var exprType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(exprType, node.expression); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType); + } + function checkElementAccessExpression(node, exprType) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -51470,13 +54435,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51495,7 +54460,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51503,8 +54468,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51525,7 +54490,7 @@ var ts; lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless // of the cutoff position; see GH#1133 - if (signature.hasLiteralTypes) { + if (signatureHasLiteralTypes(signature)) { specializedIndex++; spliceIndex = specializedIndex; // The cutoff index always needs to be greater than or equal to the specialized signature index @@ -51536,11 +54501,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51554,9 +54519,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -51571,7 +54536,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51586,7 +54551,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51679,7 +54644,7 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51709,7 +54674,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51722,7 +54687,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51746,7 +54711,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51826,12 +54791,24 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + var thisArgumentType = void 0; + if (thisArgumentNode) { + thisArgumentType = checkExpression(thisArgumentNode); + if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { + thisArgumentType = getNonNullableType(thisArgumentType); + } + else if (ts.isOptionalChain(thisArgumentNode.parent)) { + thisArgumentType = removeOptionalTypeMarker(thisArgumentType); + } + } + else { + thisArgumentType = voidType; + } var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -51844,7 +54821,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51885,15 +54862,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51903,17 +54880,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51928,7 +54905,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51943,30 +54920,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 152 /* Parameter */: + case 155 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51980,17 +54957,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -52028,8 +55005,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -52058,7 +55035,7 @@ var ts; if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(getFirstIdentifier(paramDecl.name)) : undefined); + related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); } } if (min < argCount && argCount < max) { @@ -52098,8 +55075,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -52114,22 +55091,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -52178,7 +55155,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -52231,7 +55208,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -52249,7 +55226,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -52383,35 +55360,35 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { - var symbols = ts.mapDefined(candidates, function (_a) { - var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; - return hasRestParameter ? - i < parameters.length - 1 ? parameters[i] : ts.last(parameters) : - i < parameters.length ? parameters[i] : undefined; - }); + var _loop_15 = function (i) { + var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? + i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : + i < s.parameters.length ? s.parameters[i] : undefined; }); ts.Debug.assert(symbols.length !== 0); parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } - var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); - var hasRestParameter = restParameterSymbols.length !== 0; - if (hasRestParameter) { + var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); + var flags = 0 /* None */; + if (restParameterSymbols.length !== 0) { var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); + flags |= 1 /* HasRestParameter */; + } + if (candidates.some(signatureHasLiteralTypes)) { + flags |= 2 /* HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. thisParameter, parameters, /*resolvedReturnType*/ getIntersectionType(candidates.map(getReturnTypeOfSignature)), - /*typePredicate*/ undefined, minArgumentCount, hasRestParameter, - /*hasLiteralTypes*/ candidates.some(function (c) { return c.hasLiteralTypes; })); + /*typePredicate*/ undefined, minArgumentCount, flags); } function getNumNonRestParameters(signature) { var numParams = signature.parameters.length; - return signature.hasRestParameter ? numParams - 1 : numParams; + return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); @@ -52472,7 +55449,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -52487,12 +55464,22 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var isOptional; + var funcType = checkExpression(node.expression); + if (ts.isCallChain(node)) { + var nonOptionalType = getOptionalExpressionType(funcType, node.expression); + isOptional = nonOptionalType !== funcType; + funcType = nonOptionalType; + } + else { + isOptional = false; + } + funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52558,7 +55545,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52621,7 +55608,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52629,7 +55616,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52714,8 +55701,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var constituent = types_14[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var constituent = types_17[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52806,23 +55793,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52859,7 +55846,7 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); @@ -52868,15 +55855,13 @@ var ts; // file would probably be preferable. var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, - /*hasRestparameter*/ false, - /*hasLiteralTypes*/ false); + /*returnTypePredicate*/ undefined, 1, 0 /* None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -52899,7 +55884,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52909,22 +55894,22 @@ var ts; function isPotentiallyUncalledDecorator(decorator, signatures) { return signatures.length && ts.every(signatures, function (signature) { return signature.minArgumentCount === 0 && - !signature.hasRestParameter && + !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52975,57 +55960,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); - } - return false; - } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -53040,15 +56020,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -53068,18 +56048,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -53117,7 +56107,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -53165,19 +56155,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -53192,20 +56183,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -53241,10 +56232,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -53255,7 +56246,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -53269,7 +56260,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -53284,7 +56275,7 @@ var ts; return type; } function getParameterNameAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return signature.parameters[pos].escapedName; } @@ -53301,17 +56292,17 @@ var ts; return tryGetTypeAtPosition(signature, pos) || anyType; } function tryGetTypeAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return getTypeOfParameter(signature.parameters[pos]); } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // We want to return the value undefined for an out of bounds parameter position, // so we need to check bounds here before calling getIndexedAccessType (which // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -53340,16 +56331,16 @@ var ts; } function getParameterCount(signature) { var length = signature.parameters.length; - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; } function getMinArgumentCount(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { var minLength = restType.target.minLength; @@ -53361,14 +56352,14 @@ var ts; return signature.minArgumentCount; } function hasEffectiveRestParameter(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return !isTupleType(restType) || restType.target.hasRestElement; } return false; } function getEffectiveRestType(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType; } @@ -53385,7 +56376,7 @@ var ts; return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType; } function inferFromAnnotatedParameters(signature, context, inferenceContext) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -53418,7 +56409,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter)); } } - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53426,7 +56417,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53441,7 +56432,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -53455,7 +56446,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); @@ -53510,7 +56501,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53693,10 +56684,11 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); @@ -53716,13 +56708,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53762,11 +56748,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53792,10 +56778,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53825,7 +56811,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53836,7 +56822,7 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); returnOnlyType.objectFlags |= 1048576 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; @@ -53845,7 +56831,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53899,7 +56885,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53912,7 +56898,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -53993,11 +56979,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -54010,31 +56996,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -54056,14 +57046,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -54090,14 +57080,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -54105,32 +57095,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54144,7 +57134,7 @@ var ts; var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54165,8 +57155,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -54255,7 +57245,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -54268,9 +57258,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -54313,8 +57303,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -54332,7 +57322,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -54348,7 +57338,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -54364,24 +57354,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - if (checkReferenceExpression(target, error)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -54397,53 +57390,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -54455,15 +57448,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -54471,28 +57476,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54519,17 +57524,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54537,8 +57542,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54571,24 +57576,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54597,25 +57602,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54642,6 +57651,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54659,7 +57671,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54674,15 +57686,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54695,7 +57707,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54729,17 +57741,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; + } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54747,12 +57765,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54761,6 +57779,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54779,7 +57808,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54850,7 +57879,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -54889,12 +57918,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54916,10 +57945,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54971,7 +58000,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54982,7 +58011,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54994,8 +58023,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -55125,11 +58154,22 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var isOptional = void 0; + var funcType = void 0; + if (ts.isCallChain(expr)) { + funcType = checkExpression(expr.expression); + var nonOptionalType = getOptionalExpressionType(funcType, expr.expression); + isOptional = funcType !== nonOptionalType; + funcType = checkNonNullType(nonOptionalType, expr.expression); + } + else { + isOptional = false; + funcType = checkNonNullExpression(expr.expression); + } var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -55175,18 +58215,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 258 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // We allow reexporting const enums + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -55204,20 +58244,20 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -55228,82 +58268,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -55340,7 +58380,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -55351,10 +58391,10 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -55378,18 +58418,20 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { if (typePredicate.parameterIndex >= 0) { - if (signature.hasRestParameter && typePredicate.parameterIndex === signature.parameters.length - 1) { + if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -55410,13 +58452,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -55430,11 +58472,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -55443,13 +58485,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -55479,10 +58521,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55512,7 +58554,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -55522,7 +58564,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { @@ -55537,16 +58579,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: addName(names, name, memberName, 8 /* Method */); break; } @@ -55609,7 +58651,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55617,7 +58659,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55634,7 +58676,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -55654,7 +58696,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55662,7 +58704,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55689,7 +58731,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55714,7 +58756,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55742,9 +58784,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55769,9 +58811,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55779,13 +58821,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55803,7 +58845,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55851,19 +58893,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55899,16 +58938,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55929,7 +58968,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -55980,7 +59019,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -55991,16 +59030,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -56090,7 +59129,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -56129,8 +59168,8 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -56141,10 +59180,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -56205,8 +59244,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -56275,41 +59314,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -56343,7 +59383,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -56539,7 +59579,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -56558,7 +59598,7 @@ var ts; return; } // Verify there is no local declaration that could collide with the promise constructor. - var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); @@ -56578,24 +59618,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56615,8 +59655,8 @@ var ts; function markEntityNameOrEntityExpressionAsReference(typeName) { if (!typeName) return; - var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var rootName = ts.getFirstIdentifier(typeName); + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56641,29 +59681,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var typeNode = types_16[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -56709,14 +59749,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56725,23 +59765,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56804,7 +59844,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 149 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56837,9 +59877,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56852,7 +59892,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56868,7 +59908,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56881,7 +59921,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56907,7 +59947,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56923,42 +59963,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56978,11 +60018,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56991,7 +60031,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -56999,8 +60039,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -57027,7 +60067,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -57062,7 +60102,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -57112,7 +60152,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -57130,7 +60170,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -57151,7 +60191,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -57163,24 +60203,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -57197,7 +60237,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -57210,21 +60250,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -57234,7 +60274,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -57249,7 +60289,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -57275,7 +60315,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57290,7 +60330,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57325,7 +60365,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -57337,17 +60377,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -57377,18 +60417,18 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -57402,26 +60442,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -57458,7 +60498,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -57484,10 +60524,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -57496,7 +60536,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57506,8 +60546,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57544,13 +60584,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57573,12 +60656,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57612,14 +60695,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -57627,7 +60710,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57651,7 +60734,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -57665,7 +60748,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -57673,7 +60756,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -58026,7 +61109,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -58038,7 +61121,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58117,7 +61200,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -58128,7 +61211,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58164,11 +61247,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -58232,11 +61315,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -58329,12 +61414,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -58352,7 +61437,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -58360,7 +61445,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -58381,19 +61466,16 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -58410,6 +61492,9 @@ var ts; } } ts.forEach(clause.statements, checkSourceElement); + if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) { + error(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } }); if (node.caseBlock.locals) { registerForUnusedIdentifiersCheck(node.caseBlock); @@ -58422,7 +61507,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58529,8 +61614,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58607,7 +61692,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58707,7 +61792,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58720,11 +61805,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58762,12 +61848,9 @@ var ts; } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify - // that all instantiated base constructor signatures return the same type. We can simply compare the type - // references (as opposed to checking the structure of the types) because elsewhere we have already checked - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58810,7 +61893,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58829,7 +61912,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58855,7 +61938,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58906,7 +61989,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 210 /* ClassExpression */) { + if (derivedClassDecl.kind === 213 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -58921,17 +62004,55 @@ var ts; // either base or derived property is private - not override, skip it continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment + continue; + } + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; + } + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; + } + else { + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } + } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + // method is overridden with method or property -- correct case + continue; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } else if (base.flags & 98304 /* Accessor */) { @@ -58977,12 +62098,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -58997,7 +62121,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -59021,7 +62145,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -59084,7 +62208,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -59116,7 +62240,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -59126,66 +62250,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 50 /* BarToken */: return left | right; - case 49 /* AmpersandToken */: return left & right; - case 47 /* GreaterThanGreaterThanToken */: return left >> right; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 46 /* LessThanLessThanToken */: return left << right; - case 51 /* CaretToken */: return left ^ right; - case 40 /* AsteriskToken */: return left * right; - case 42 /* SlashToken */: return left / right; - case 38 /* PlusToken */: return left + right; - case 39 /* MinusToken */: return left - right; - case 43 /* PercentToken */: return left % right; - case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -59210,10 +62333,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -59247,7 +62370,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -59270,9 +62393,9 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -59295,7 +62418,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -59334,7 +62457,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -59384,23 +62507,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -59411,12 +62534,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -59435,19 +62558,22 @@ var ts; break; } } - function getFirstIdentifier(node) { + function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -59461,9 +62587,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -59493,20 +62619,21 @@ var ts; // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). + symbol = getMergedSymbol(symbol.exportSymbol || symbol); var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 258 /* ExportSpecifier */ + && node.kind === 261 /* ExportSpecifier */ && !(target.flags & 111551 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59531,7 +62658,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59555,12 +62682,12 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name - var moduleName = getFirstIdentifier(node.moduleReference); + var moduleName = ts.getFirstIdentifier(node.moduleReference); if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } @@ -59571,7 +62698,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59591,10 +62718,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59611,7 +62738,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59627,7 +62754,7 @@ var ts; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { @@ -59644,8 +62771,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59658,7 +62785,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -59678,10 +62805,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59707,9 +62834,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59759,159 +62886,162 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 307 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 299 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -60006,23 +63136,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -60051,7 +63181,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -60137,7 +63267,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -60152,26 +63282,26 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -60180,7 +63310,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -60222,17 +63352,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -60240,16 +63370,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -60277,13 +63407,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -60309,7 +63439,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -60319,7 +63449,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -60327,7 +63457,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -60337,7 +63467,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -60355,7 +63485,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -60371,10 +63501,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 307 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 311 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -60384,19 +63514,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -60406,22 +63536,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -60435,12 +63565,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -60450,11 +63580,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -60466,14 +63596,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -60484,7 +63614,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -60501,21 +63631,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -60527,7 +63657,7 @@ var ts; resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60583,27 +63713,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60642,17 +63772,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60704,7 +63833,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60760,7 +63889,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -60788,7 +63917,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60819,7 +63948,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60860,26 +63989,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60980,15 +64108,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -61073,7 +64201,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -61092,7 +64220,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61100,7 +64228,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61224,12 +64352,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -61242,10 +64370,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -61257,7 +64394,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -61308,7 +64445,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -61336,12 +64473,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -61474,7 +64611,7 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; @@ -61483,7 +64620,7 @@ var ts; var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61530,14 +64667,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -61554,23 +64691,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61584,11 +64721,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61597,7 +64734,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61607,10 +64744,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61619,18 +64756,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61643,52 +64780,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 126 /* DeclareKeyword */: + case 129 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61700,14 +64837,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61715,7 +64852,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61730,13 +64867,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61757,38 +64894,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61800,10 +64937,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61832,7 +64969,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61918,15 +65055,15 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); } - if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -61950,11 +65087,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61984,7 +65127,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -61997,7 +65140,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -62013,14 +65156,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -62031,21 +65174,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -62063,7 +65206,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -62074,21 +65217,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { - // tslint:disable no-unnecessary-type-assertion + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -62103,10 +65246,10 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -62114,13 +65257,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -62157,7 +65300,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -62167,7 +65310,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -62181,14 +65324,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -62199,7 +65342,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -62214,20 +65357,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -62237,7 +65380,7 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 4194304 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */)) { if (languageVersion < 1 /* ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -62252,11 +65395,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 159 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -62278,23 +65421,23 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -62304,13 +65447,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -62319,9 +65462,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -62334,10 +65477,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -62360,17 +65503,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -62381,11 +65524,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -62393,8 +65536,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -62409,13 +65552,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -62438,13 +65581,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -62457,7 +65600,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -62474,8 +65617,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -62487,11 +65630,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -62504,7 +65647,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62521,8 +65664,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62549,15 +65692,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62575,12 +65718,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -62638,7 +65781,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62646,7 +65789,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62654,11 +65797,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62675,13 +65818,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62690,7 +65833,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62699,10 +65842,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -62713,7 +65856,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62735,20 +65878,39 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62784,7 +65946,7 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd); } if (node.typeArguments) { return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); @@ -62808,14 +65970,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62823,21 +65985,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62847,7 +66008,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62856,6 +66016,18 @@ var ts; case 2 /* Next */: return "nextType"; } } + function signatureHasRestParameter(s) { + return !!(s.flags & 1 /* HasRestParameter */); + } + ts.signatureHasRestParameter = signatureHasRestParameter; + function signatureHasLiteralTypes(s) { + return !!(s.flags & 2 /* HasLiteralTypes */); + } + ts.signatureHasLiteralTypes = signatureHasLiteralTypes; + function signatureIsOptionalCall(s) { + return !!(s.flags & 4 /* IsOptionalCall */); + } + ts.signatureIsOptionalCall = signatureIsOptionalCall; })(ts || (ts = {})); var ts; (function (ts) { @@ -62918,6 +66090,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62965,7 +66138,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -63046,23 +66219,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -63073,44 +66246,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -63129,7 +66302,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -63142,7 +66315,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -63158,7 +66331,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -63182,7 +66355,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63195,7 +66368,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -63215,12 +66388,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -63230,8 +66403,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -63239,7 +66412,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -63256,7 +66429,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63269,6 +66442,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -63284,7 +66489,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -63304,7 +66509,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63327,7 +66532,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63348,7 +66553,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -63356,7 +66561,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -63364,7 +66569,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -63404,21 +66609,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -63432,7 +66647,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -63440,7 +66655,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -63448,7 +66663,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -63460,7 +66675,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -63472,7 +66687,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -63484,7 +66699,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -63496,7 +66711,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -63508,7 +66723,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63520,7 +66735,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63528,7 +66743,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63547,7 +66762,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63565,7 +66780,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63577,7 +66792,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63595,7 +66810,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63607,12 +66822,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63622,7 +66837,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63636,7 +66851,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63654,7 +66869,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63667,7 +66882,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63679,7 +66894,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63691,7 +66906,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63710,7 +66925,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63724,7 +66939,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63738,7 +66953,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63746,6 +66961,9 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + if (ts.isOptionalChain(node)) { + return updatePropertyAccessChain(node, expression, node.questionDotToken, name); + } // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63754,22 +66972,64 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + if (ts.isOptionalChain(node)) { + return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression); + } return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63777,6 +67037,9 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + if (ts.isOptionalChain(node)) { + return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray); + } return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63784,8 +67047,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63801,7 +67084,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63824,7 +67107,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63838,7 +67121,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63850,7 +67133,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63874,12 +67157,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63896,7 +67179,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63908,7 +67191,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63920,7 +67203,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63932,7 +67215,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63944,7 +67227,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63957,7 +67240,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63970,7 +67253,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63987,11 +67270,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -64007,7 +67290,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -64031,11 +67314,9 @@ var ts; rawTextScanner.setText("`" + rawText + "`"); break; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; case 17 /* TemplateTail */: @@ -64106,9 +67387,9 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -64120,7 +67401,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64132,7 +67413,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64153,11 +67434,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -64171,7 +67452,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -64185,7 +67466,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -64197,7 +67478,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -64211,7 +67492,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -64225,12 +67506,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -64244,7 +67525,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -64259,11 +67540,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -64279,7 +67560,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -64295,7 +67576,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -64309,7 +67590,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64323,7 +67604,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -64341,7 +67622,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -64357,10 +67638,10 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; - node.expression = expression; + node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression; node.statement = asEmbeddedStatement(statement); return node; } @@ -64375,7 +67656,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -64387,7 +67668,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -64399,7 +67680,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -64411,7 +67692,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64425,7 +67706,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -64439,7 +67720,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -64453,7 +67734,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -64465,7 +67746,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -64481,11 +67762,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -64502,7 +67783,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -64515,7 +67796,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -64541,7 +67822,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64563,7 +67844,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64585,7 +67866,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64605,7 +67886,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64624,8 +67905,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64643,7 +67924,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64655,7 +67936,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64667,7 +67948,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64679,7 +67960,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64697,7 +67978,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64715,7 +67996,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64729,7 +68010,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64741,7 +68022,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64753,7 +68034,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64767,11 +68048,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64784,7 +68065,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64801,8 +68082,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64814,7 +68100,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64829,7 +68115,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64843,14 +68129,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(310 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64858,7 +68144,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(308 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64866,14 +68152,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(309 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64883,7 +68169,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(298 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64897,7 +68183,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64913,7 +68199,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64929,7 +68215,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64945,7 +68231,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64957,7 +68243,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64979,11 +68265,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64995,7 +68281,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -65009,7 +68295,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -65021,7 +68307,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -65033,7 +68319,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -65047,7 +68333,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -65061,7 +68347,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -65073,7 +68359,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -65086,7 +68372,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -65101,7 +68387,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -65116,7 +68402,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -65130,7 +68416,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -65143,7 +68429,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -65164,7 +68450,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -65248,7 +68534,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(315 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -65260,7 +68546,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(319 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65272,7 +68558,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65287,7 +68573,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(316 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -65303,7 +68589,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 317 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -65313,7 +68599,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(317 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -65324,9 +68610,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -65357,7 +68659,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -65439,8 +68741,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -65489,10 +68794,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -65510,14 +68815,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -65563,8 +68868,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65607,43 +68912,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65663,7 +68972,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65707,7 +69019,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65772,7 +69084,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -66248,7 +69559,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -66260,20 +69571,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -66288,7 +69599,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -66300,7 +69611,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66313,7 +69624,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66370,14 +69681,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66655,8 +69966,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66703,7 +70014,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66737,10 +70048,10 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66752,7 +70063,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66789,7 +70100,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66824,10 +70135,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66840,25 +70151,23 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { return ts.createParen(condition); } return condition; @@ -66890,8 +70199,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66907,9 +70216,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66932,7 +70241,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66970,7 +70279,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66981,29 +70290,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -67011,9 +70320,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -67039,28 +70348,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 316 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -67069,15 +70378,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 317 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -67090,13 +70399,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -67121,7 +70430,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -67129,11 +70438,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 316 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -67151,7 +70460,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -67270,10 +70579,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -67392,7 +70701,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -67404,11 +70713,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -67440,12 +70749,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -67457,7 +70766,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -67469,7 +70778,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -67481,7 +70790,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -67504,13 +70813,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -67550,11 +70859,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67678,7 +70987,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict) - statements = ts.ensureUseStrict(statements); // tslint:disable-line no-unnecessary-qualifier + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; @@ -67713,278 +71022,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 161 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -68026,58 +71344,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 315 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68086,12 +71404,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68099,7 +71417,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68107,50 +71425,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -68158,123 +71476,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68283,7 +71601,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68291,140 +71609,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -68497,7 +71815,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -68570,19 +71888,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68785,12 +72104,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68802,6 +72120,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -69170,7 +72489,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -69217,7 +72536,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -69230,13 +72549,13 @@ var ts; hasImportDefault = true; } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -69266,13 +72585,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -69280,7 +72599,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -69300,7 +72619,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -69398,7 +72717,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -69428,42 +72747,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.getInitializedProperties = getInitializedProperties; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); - } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -69989,8 +73294,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -70016,14 +73321,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -70074,16 +73379,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -70095,7 +73400,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -70138,10 +73443,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -70162,13 +73467,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -70188,11 +73493,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -70216,19 +73521,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -70238,7 +73543,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -70255,67 +73560,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70325,7 +73634,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70335,35 +73644,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -70373,35 +73682,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70439,7 +73748,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -70468,7 +73777,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70811,12 +74120,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70969,7 +74278,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? ts.createVoidZero() @@ -71070,13 +74379,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -71092,10 +74401,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -71105,7 +74414,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -71116,12 +74425,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -71138,15 +74447,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -71183,7 +74492,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -71228,69 +74537,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -71301,15 +74610,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var typeNode = types_20[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -71389,12 +74698,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -71410,7 +74719,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.getMutableClone(node); @@ -71418,7 +74727,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -71502,7 +74811,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -71965,12 +75274,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -72095,7 +75404,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -72141,13 +75450,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -72188,7 +75497,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -72401,7 +75710,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -72409,7 +75718,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72419,17 +75728,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -72488,11 +75797,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -72530,9 +75839,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -72554,9 +75863,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -72660,7 +75970,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72671,11 +75983,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72687,20 +75999,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72730,7 +76042,7 @@ var ts; // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { (pendingExpressions || (pendingExpressions = [])).push(expr); } @@ -72743,7 +76055,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72759,9 +76071,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72779,9 +76091,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72793,7 +76105,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72834,8 +76146,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72848,7 +76160,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72892,7 +76204,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72909,7 +76221,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72946,19 +76258,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72978,7 +76300,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -73096,34 +76418,34 @@ var ts; return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73132,27 +76454,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -73353,7 +76675,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -73444,17 +76766,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73502,23 +76824,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73538,11 +76860,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73610,7 +76932,7 @@ var ts; function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -73682,7 +77004,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; @@ -73704,62 +77026,62 @@ var ts; return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return doOutsideOfTopLevel(visitConstructorDeclaration, node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73793,7 +77115,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73805,7 +77127,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73814,7 +77136,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73848,7 +77170,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -74145,7 +77467,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); @@ -74214,17 +77536,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -74272,23 +77594,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -74308,11 +77630,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -74335,8 +77657,7 @@ var ts; }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getUnscopedHelperName("__assign"), @@ -74411,7 +77732,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -74430,6 +77751,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -74442,10 +77764,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -74480,13 +77935,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74496,13 +77951,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -74577,7 +78032,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -74671,7 +78126,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74977,7 +78432,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74985,9 +78440,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -75190,13 +78645,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -75209,72 +78664,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -75285,28 +78740,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -75397,14 +78852,14 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -75415,7 +78870,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75673,7 +79128,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75811,11 +79266,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75823,7 +79278,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75978,10 +79433,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -76005,7 +79460,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -76021,7 +79476,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -76042,25 +79497,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -76089,20 +79544,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -76128,12 +79583,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -76290,7 +79755,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -76334,7 +79799,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -76402,9 +79867,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -76423,9 +79888,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -76460,7 +79925,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -76634,14 +80099,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76829,7 +80294,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76884,7 +80349,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76950,11 +80415,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76979,11 +80444,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -77134,7 +80599,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -77196,7 +80661,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -77234,7 +80699,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -77245,7 +80710,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -77258,7 +80723,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -77272,7 +80737,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -77293,10 +80758,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -77382,20 +80847,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -77502,7 +80967,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77555,7 +81020,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -77679,10 +81144,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -77700,7 +81165,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77712,10 +81177,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -78003,13 +81468,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -78041,7 +81504,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -78051,14 +81514,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -78099,10 +81562,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -78115,9 +81578,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -78184,19 +81647,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -78251,15 +81714,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -78278,9 +81741,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -78337,7 +81800,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -78612,13 +82075,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -78631,24 +82094,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -78669,21 +82132,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -78696,9 +82159,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78897,23 +82360,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78926,7 +82389,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78938,7 +82401,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -79025,7 +82488,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -79314,35 +82777,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79772,7 +83235,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79785,7 +83248,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79958,11 +83421,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80097,7 +83559,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -81014,12 +84476,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -81347,23 +84809,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -81390,24 +84852,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -81885,7 +85347,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81940,10 +85402,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82125,8 +85587,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82142,7 +85604,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -82204,12 +85666,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -82230,7 +85692,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -82298,15 +85760,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -82382,13 +85844,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -82610,7 +86072,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -82635,7 +86097,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -82704,28 +86166,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82775,15 +86237,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82959,7 +86421,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -83023,7 +86485,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -83085,10 +86547,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -83268,43 +86730,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -83551,7 +87013,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -83567,8 +87029,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -83584,7 +87046,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -83634,7 +87096,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -83668,14 +87130,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -83761,22 +87223,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83803,7 +87265,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83842,8 +87304,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -83867,10 +87329,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83977,7 +87439,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84006,7 +87468,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84053,7 +87515,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84062,8 +87524,8 @@ var ts; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -84072,7 +87534,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84097,7 +87559,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.hasModifier(node, 32 /* Static */)) { @@ -84136,26 +87598,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84163,7 +87625,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84177,7 +87639,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84202,30 +87664,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84233,7 +87695,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84246,13 +87708,20 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -84261,39 +87730,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -84308,9 +87777,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -84345,11 +87814,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -84359,7 +87825,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -84423,7 +87889,6 @@ var ts; var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -84506,20 +87971,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -84532,18 +88006,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; - var statements_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(126 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -84580,12 +88054,20 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -84672,11 +88154,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -84684,7 +88166,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -84697,7 +88179,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -84722,19 +88204,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84742,12 +88224,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -84758,26 +88240,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84858,7 +88340,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84878,7 +88360,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84905,7 +88387,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84954,11 +88436,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84968,13 +88450,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -85001,7 +88476,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -85022,75 +88497,65 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 215 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - var isPrivate = ts.hasModifier(input, 8 /* Private */); - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(ts.updateGetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 160 /* SetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - return cleanup(ts.updateSetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 155 /* PropertyDeclaration */: + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } + case 158 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -85098,13 +88563,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 154 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 179 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -85116,13 +88581,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -85151,7 +88616,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -85161,7 +88626,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -85170,13 +88635,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -85186,7 +88651,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -85211,10 +88676,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -85235,14 +88700,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -85257,7 +88722,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -85290,17 +88755,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -85309,7 +88774,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -85336,7 +88801,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -85347,7 +88812,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -85377,7 +88842,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -85387,16 +88852,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -85407,10 +88872,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -85429,7 +88894,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -85450,7 +88915,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -85500,7 +88965,7 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -85521,43 +88986,15 @@ var ts; } return accessorType; } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; - } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -85582,7 +89019,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -85591,52 +89028,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -85765,7 +89202,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(320 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -86050,15 +89487,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -86068,22 +89505,21 @@ var ts; if (!onlyBuildInfo) { 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); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -86106,7 +89542,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -86114,14 +89550,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -86131,9 +89567,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -86174,7 +89608,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -86191,43 +89625,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -86243,11 +89707,11 @@ var ts; return jsFilePath; if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -86255,7 +89719,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -86269,7 +89733,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -86365,17 +89829,20 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle) + return; + if (!declarationFilePath) { + if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly) + emitSkipped = true; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -86407,7 +89874,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -86415,7 +89882,7 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -86426,7 +89893,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -86438,8 +89905,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -86480,7 +89947,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -86587,10 +90054,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -86602,7 +90070,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -86748,6 +90216,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -86776,9 +90246,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86947,8 +90417,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86960,7 +90429,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86976,6 +90445,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86985,21 +90456,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -87014,12 +90496,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -87033,10 +90515,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -87056,279 +90541,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 304 /* JSDocClassTag */: - case 301 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -87346,83 +90831,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -87435,8 +90920,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -87462,7 +90950,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -87562,7 +91050,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -87595,7 +91083,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87631,7 +91119,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -87693,7 +91181,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87734,11 +91222,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87870,18 +91364,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87961,66 +91454,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -88060,22 +91544,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -88100,9 +91584,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ - && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) - || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -88115,7 +91599,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -88143,7 +91627,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -88220,7 +91704,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88228,8 +91712,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -88239,14 +91723,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -88255,14 +91739,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -88274,25 +91758,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -88300,7 +91784,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -88309,12 +91793,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -88342,12 +91826,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88355,7 +91839,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88365,17 +91849,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -88384,13 +91868,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -88415,7 +91899,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -88587,7 +92071,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -88595,7 +92079,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88616,17 +92100,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88635,12 +92119,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -88655,9 +92139,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -88668,42 +92152,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -88723,7 +92207,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88801,7 +92285,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88812,13 +92296,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88830,12 +92314,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88846,7 +92330,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88916,7 +92400,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 310 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88950,7 +92434,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88969,7 +92453,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 299 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -89103,8 +92587,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { - var directive = types_18[_d]; + for (var _d = 0, types_21 = types; _d < types_21.length; _d++) { + var directive = types_21[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -89284,7 +92768,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -89322,8 +92806,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -89730,6 +93213,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -89747,7 +93233,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89812,81 +93298,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89895,12 +93381,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -90080,25 +93566,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -90141,11 +93627,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 315 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -90169,7 +93656,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -90199,6 +93686,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -90412,6 +93900,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -90426,7 +93915,7 @@ var ts; else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -90439,12 +93928,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -91368,6 +94858,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -91472,15 +94964,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -91562,11 +95056,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structuralIsReused; - structuralIsReused = tryReuseStructureFromOldProgram(); + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -91574,20 +95070,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -91600,7 +95112,7 @@ var ts; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -91636,8 +95148,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -91653,12 +95165,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91695,7 +95208,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -91722,9 +95237,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91928,6 +95448,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -92018,7 +95544,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -92055,28 +95581,26 @@ var ts; for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = getModuleNames(newSourceFile); - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); - // ensure that module resolution results are still correct - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); + // ensure that module resolution results are still correct + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -92090,11 +95614,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; var filePath = newSourceFile.path; addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); + if (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -92114,7 +95646,8 @@ var ts; function getEmitHost(writeFileCallback) { return __assign(__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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, 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) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, 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)) @@ -92179,15 +95712,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -92219,7 +95752,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -92294,15 +95828,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -92361,22 +95896,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -92384,41 +95919,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -92431,51 +95966,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -92492,24 +96028,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -92584,8 +96120,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -92615,7 +96151,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -92666,7 +96202,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -92747,24 +96283,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, diagnostic], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([diagnostic], args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -92787,15 +96317,36 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (!source && + host.realpath && + options.preserveSymlinks && + ts.isDeclarationFileName(fileName) && + ts.stringContains(fileName, ts.nodeModulesPathPart)) { + // use host's cached realpath + var realPath = host.realpath(fileName); + if (realPath !== fileName) + source = getSourceOfProjectReferenceRedirect(realPath); + } + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92804,34 +96355,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92849,14 +96401,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92887,7 +96432,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92910,8 +96455,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92926,8 +96481,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92966,6 +96521,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -93000,9 +96584,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -93018,10 +96610,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -93033,7 +96631,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -93043,8 +96641,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -93052,14 +96649,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -93077,20 +96674,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { + if (!refFile) { return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, message], args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -93130,14 +96727,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -93156,12 +96761,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; 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) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -93218,9 +96826,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -93258,14 +96863,12 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -93381,8 +96984,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -93447,8 +97050,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -93475,7 +97111,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -93550,7 +97186,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -93609,6 +97245,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -93654,9 +97296,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -93706,9 +97345,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93954,7 +97593,10 @@ var ts; } } else { - var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); var firstDts_1 = emitOutput_1.outputFiles && programOfThisState.getCompilerOptions().declarationMap ? emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : @@ -94066,6 +97708,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -94169,6 +97812,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -94182,8 +97830,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -94206,7 +97853,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -94252,16 +97900,17 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } + state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit; return state; } function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -94306,7 +97955,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -94383,13 +98033,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -94408,7 +98063,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -94433,7 +98088,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -94451,15 +98106,40 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { return; } + if (!isChangedSignagure(state, affectedFile.path)) + return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } + } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first @@ -94527,7 +98207,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, isEmitResult) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -94537,8 +98217,8 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); - if (isEmitResult) { - (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; @@ -94551,15 +98231,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); return { result: result, affected: affected }; } /** * Returns the result with affected file */ - function toAffectedFileEmitResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, /*isEmitResult*/ true); + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -94589,7 +98269,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -94782,11 +98462,12 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } @@ -94794,10 +98475,11 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94813,7 +98495,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94869,7 +98551,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94901,7 +98583,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94913,8 +98595,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94947,7 +98635,7 @@ var ts; } var state = { fileInfos: fileInfos, - compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), + compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), @@ -94983,33 +98671,6 @@ var ts; } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function convertFromReusableCompilerOptions(options, toAbsolutePath) { - var result = {}; - var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertFromReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); - } - } - if (result.configFilePath) { - result.configFilePath = toAbsolutePath(result.configFilePath); - } - return result; - } - function convertFromReusableCompilerOptionValue(option, value, toAbsolutePath) { - if (option) { - if (option.type === "list") { - var values = value; - if (option.element.isFilePath && values.length) { - return values.map(toAbsolutePath); - } - } - else if (option.isFilePath) { - return toAbsolutePath(value); - } - } - return value; - } function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -95076,15 +98737,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -95330,7 +99003,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -95541,6 +99214,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -95726,8 +99403,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -95743,13 +99421,19 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) @@ -95808,38 +99492,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95850,7 +99508,9 @@ var ts; var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95867,7 +99527,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95909,7 +99593,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95918,28 +99602,34 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); + var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) + var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)); + if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) { return undefined; + } // If the module was found in @types, get the actual Node package name var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1); var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName); @@ -96130,6 +99820,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96137,7 +99836,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -96146,7 +99845,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -96155,7 +99854,7 @@ var ts; /** Parses config file using System interface */ function parseConfigFileWithSystem(configFileName, optionsToExtend, system, reportDiagnostic) { var host = system; - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(ts.sys, reportDiagnostic, diagnostic); }; + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; @@ -96179,7 +99878,7 @@ var ts; } ts.getErrorSummaryText = getErrorSummaryText; function listFiles(program, writeFileName) { - if (program.getCompilerOptions().listFiles) { + if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) { ts.forEach(program.getSourceFiles(), function (file) { writeFileName(file.fileName); }); @@ -96190,6 +99889,7 @@ var ts; * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { + var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly; // First get and report any syntactic errors. var diagnostics = program.getConfigFileParsingDiagnostics().slice(); var configFileParsingDiagnosticsLength = diagnostics.length; @@ -96198,13 +99898,17 @@ var ts; // semantic errors. if (diagnostics.length === configFileParsingDiagnosticsLength) { ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken)); - ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); - if (diagnostics.length === configFileParsingDiagnosticsLength) { - ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + if (!isListFilesOnly) { + ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); + if (diagnostics.length === configFileParsingDiagnosticsLength) { + ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + } } } // Emit and report any errors we ran into. - var emitResult = program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = isListFilesOnly + ? { emitSkipped: true, diagnostics: ts.emptyArray } + : program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics; ts.addRange(diagnostics, emitDiagnostics); ts.sortAndDeduplicateDiagnostics(diagnostics).forEach(reportDiagnostic); @@ -96353,7 +100057,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -96387,7 +100093,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -96436,7 +100142,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -96994,12 +100700,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -97155,11 +100871,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -97168,8 +100887,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -97193,11 +100911,9 @@ var ts; } function createStateBuildOrder(state) { var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); - if (ts.arrayIsEqualTo(state.buildOrder, buildOrder)) - return state.buildOrder; // Clear all to ResolvedConfigFilePaths cache to start fresh state.resolvedConfigFilePaths.clear(); - var currentProjects = ts.arrayToSet(buildOrder, function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); var noopOnDelete = { onDeleteValue: ts.noop }; // Config file cache ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); @@ -97218,6 +100934,8 @@ var ts; function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -97225,6 +100943,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -97296,7 +101015,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -97636,6 +101355,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -97692,8 +101413,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97864,10 +101588,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97926,7 +101652,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -98074,33 +101800,34 @@ var ts; setupInitialBuild(state, cancellationToken); var reportQueue = true; var successfulProjects = 0; - var errorProjects = 0; while (true) { var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue); if (!invalidatedProject) break; reportQueue = false; invalidatedProject.done(cancellationToken); - if (state.diagnostics.has(invalidatedProject.projectPath)) { - errorProjects++; - } - else { + if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; - } } disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) + ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped + : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); }) + ? ts.ExitStatus.Success + : successfulProjects + ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated + : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -98243,8 +101970,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -98276,6 +102003,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -98312,23 +102040,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -98361,13 +102099,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -98389,7 +102130,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -98777,6 +102517,15 @@ var ts; ScriptSnapshot.fromString = fromString; })(ScriptSnapshot = ts.ScriptSnapshot || (ts.ScriptSnapshot = {})); /* @internal */ + var PackageJsonDependencyGroup; + (function (PackageJsonDependencyGroup) { + PackageJsonDependencyGroup[PackageJsonDependencyGroup["Dependencies"] = 1] = "Dependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["DevDependencies"] = 2] = "DevDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["PeerDependencies"] = 4] = "PeerDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["OptionalDependencies"] = 8] = "OptionalDependencies"; + PackageJsonDependencyGroup[PackageJsonDependencyGroup["All"] = 15] = "All"; + })(PackageJsonDependencyGroup = ts.PackageJsonDependencyGroup || (ts.PackageJsonDependencyGroup = {})); + /* @internal */ ts.emptyOptions = {}; var HighlightSpanKind; (function (HighlightSpanKind) { @@ -98791,6 +102540,12 @@ var ts; IndentStyle[IndentStyle["Block"] = 1] = "Block"; IndentStyle[IndentStyle["Smart"] = 2] = "Smart"; })(IndentStyle = ts.IndentStyle || (ts.IndentStyle = {})); + var SemicolonPreference; + (function (SemicolonPreference) { + SemicolonPreference["Ignore"] = "ignore"; + SemicolonPreference["Insert"] = "insert"; + SemicolonPreference["Remove"] = "remove"; + })(SemicolonPreference = ts.SemicolonPreference || (ts.SemicolonPreference = {})); function getDefaultFormatCodeSettings(newLineCharacter) { return { indentSize: 4, @@ -98812,6 +102567,7 @@ var ts; insertSpaceBeforeFunctionParenthesis: false, placeOpenBraceOnNewLineForFunctions: false, placeOpenBraceOnNewLineForControlBlocks: false, + semicolons: SemicolonPreference.Ignore, }; } ts.getDefaultFormatCodeSettings = getDefaultFormatCodeSettings; @@ -99041,37 +102797,37 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.isInJSFile(node) && ts.getJSDocEnumTag(node) ? 7 /* All */ : 1 /* Value */; - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 275 /* CatchClause */: - case 268 /* JsxAttribute */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 278 /* CatchClause */: + case 271 /* JsxAttribute */: return 1 /* Value */; - case 151 /* TypeParameter */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 169 /* TypeLiteral */: + case 154 /* TypeParameter */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 172 /* TypeLiteral */: return 2 /* Type */; - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: // If it has no name node, it shares the name with the value declaration below it. return node.name === undefined ? 1 /* Value */ | 2 /* Type */ : 2 /* Type */; - case 279 /* EnumMember */: - case 241 /* ClassDeclaration */: + case 282 /* EnumMember */: + case 244 /* ClassDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -99081,26 +102837,26 @@ var ts; else { return 4 /* Namespace */; } - case 244 /* EnumDeclaration */: - case 253 /* NamedImports */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 247 /* EnumDeclaration */: + case 256 /* NamedImports */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return 7 /* All */; // An external module can be a Value - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 7 /* All */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 255 /* ExportAssignment */ || node.parent.kind === 260 /* ExternalModuleReference */) { + else if (node.parent.kind === 258 /* ExportAssignment */ || node.parent.kind === 263 /* ExternalModuleReference */) { return 7 /* All */; } else if (isInRightSideOfInternalImportEqualsDeclaration(node)) { @@ -99132,11 +102888,11 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - var name = node.kind === 149 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; - return name && name.parent.kind === 249 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; + var name = node.kind === 152 /* QualifiedName */ ? node : ts.isQualifiedName(node.parent) && node.parent.right === node ? node.parent : undefined; + return name && name.parent.kind === 252 /* ImportEqualsDeclaration */ ? 7 /* All */ : 4 /* Namespace */; } function isInRightSideOfInternalImportEqualsDeclaration(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -99148,27 +102904,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 149 /* QualifiedName */) { - while (root.parent && root.parent.kind === 149 /* QualifiedName */) { + if (root.parent.kind === 152 /* QualifiedName */) { + while (root.parent && root.parent.kind === 152 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 165 /* TypeReference */ && !isLastClause; + return root.parent.kind === 168 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 190 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 190 /* PropertyAccessExpression */) { + if (root.parent.kind === 193 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 193 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 212 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 274 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 215 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 277 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 241 /* ClassDeclaration */ && root.parent.parent.token === 110 /* ImplementsKeyword */) || - (decl.kind === 242 /* InterfaceDeclaration */ && root.parent.parent.token === 87 /* ExtendsKeyword */); + return (decl.kind === 244 /* ClassDeclaration */ && root.parent.parent.token === 112 /* ImplementsKeyword */) || + (decl.kind === 245 /* InterfaceDeclaration */ && root.parent.parent.token === 89 /* ExtendsKeyword */); } return false; } @@ -99177,17 +102933,17 @@ var ts; node = node.parent; } switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return !ts.isExpressionNode(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return true; } switch (node.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return true; - case 184 /* ImportType */: + case 187 /* ImportType */: return !node.parent.isTypeOf; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent); } return false; @@ -99214,7 +102970,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 234 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { + if (referenceNode.kind === 237 /* LabeledStatement */ && referenceNode.label.escapedText === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -99230,11 +102986,11 @@ var ts; } ts.hasPropertyAccessExpressionWithName = hasPropertyAccessExpressionWithName; function isJumpStatementTarget(node) { - return node.kind === 73 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isBreakOrContinueStatement(node.parent) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 73 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; + return node.kind === 75 /* Identifier */ && ts.isLabeledStatement(node.parent) && node.parent.label === node; } ts.isLabelOfLabeledStatement = isLabelOfLabeledStatement; function isLabelName(node) { @@ -99246,40 +103002,40 @@ var ts; } ts.isTagName = isTagName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 245 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 248 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 73 /* Identifier */ && + return node.kind === 75 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { switch (node.parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 276 /* PropertyAssignment */: - case 279 /* EnumMember */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 245 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 279 /* PropertyAssignment */: + case 282 /* EnumMember */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 248 /* ModuleDeclaration */: return ts.getNameOfDeclaration(node.parent) === node; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return true; - case 183 /* LiteralType */: - return node.parent.parent.kind === 181 /* IndexedAccessType */; + case 186 /* LiteralType */: + return node.parent.parent.kind === 184 /* IndexedAccessType */; default: return false; } @@ -99303,17 +103059,17 @@ var ts; return undefined; } switch (node.kind) { - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return node; } } @@ -99321,48 +103077,53 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return "module" /* moduleElement */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return "class" /* classElement */; - case 242 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 243 /* TypeAliasDeclaration */: - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: + case 245 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; + case 246 /* TypeAliasDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return "type" /* typeElement */; - case 244 /* EnumDeclaration */: return "enum" /* enumElement */; - case 238 /* VariableDeclaration */: + case 247 /* EnumDeclaration */: return "enum" /* enumElement */; + case 241 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return "function" /* functionElement */; - case 159 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 160 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 162 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; + case 163 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return "method" /* memberFunctionElement */; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 279 /* PropertyAssignment */: + var initializer = node.initializer; + return ts.isFunctionLike(initializer) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return "property" /* memberVariableElement */; - case 163 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 162 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 161 /* CallSignature */: return "call" /* callSignatureElement */; - case 158 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 151 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 279 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 152 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 166 /* IndexSignature */: return "index" /* indexSignatureElement */; + case 165 /* ConstructSignature */: return "construct" /* constructSignatureElement */; + case 164 /* CallSignature */: return "call" /* callSignatureElement */; + case 161 /* Constructor */: return "constructor" /* constructorImplementationElement */; + case 154 /* TypeParameter */: return "type parameter" /* typeParameterElement */; + case 282 /* EnumMember */: return "enum member" /* enumMemberElement */; + case 155 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return "alias" /* alias */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var kind = ts.getAssignmentDeclarationKind(node); var right = node.right; switch (kind) { @@ -99389,7 +103150,7 @@ var ts; return "" /* unknown */; } } - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isImportClause(node.parent) ? "alias" /* alias */ : "" /* unknown */; default: return "" /* unknown */; @@ -99405,12 +103166,12 @@ var ts; ts.getNodeKind = getNodeKind; function isThis(node) { switch (node.kind) { - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 152 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 155 /* Parameter */; default: return false; } @@ -99475,42 +103236,42 @@ var ts; return false; } switch (n.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 185 /* ObjectBindingPattern */: - case 169 /* TypeLiteral */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 247 /* CaseBlock */: - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 172 /* TypeLiteral */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 250 /* CaseBlock */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return nodeEndsWith(n, 19 /* CloseBraceToken */, sourceFile); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return isCompletedNode(n.block, sourceFile); - case 193 /* NewExpression */: + case 196 /* NewExpression */: if (!n.arguments) { return true; } // falls through - case 192 /* CallExpression */: - case 196 /* ParenthesizedExpression */: - case 178 /* ParenthesizedType */: + case 195 /* CallExpression */: + case 199 /* ParenthesizedExpression */: + case 181 /* ParenthesizedType */: return nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return isCompletedNode(n.type, sourceFile); - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 201 /* ArrowFunction */: if (n.body) { return isCompletedNode(n.body, sourceFile); } @@ -99520,65 +103281,65 @@ var ts; // Even though type parameters can be unclosed, we can get away with // having at least a closing paren. return hasChildOfKind(n, 21 /* CloseParenToken */, sourceFile); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return !!n.body && isCompletedNode(n.body, sourceFile); - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile) || hasChildOfKind(n, 26 /* SemicolonToken */, sourceFile); - case 188 /* ArrayLiteralExpression */: - case 186 /* ArrayBindingPattern */: - case 191 /* ElementAccessExpression */: - case 150 /* ComputedPropertyName */: - case 171 /* TupleType */: + case 191 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 194 /* ElementAccessExpression */: + case 153 /* ComputedPropertyName */: + case 174 /* TupleType */: return nodeEndsWith(n, 23 /* CloseBracketToken */, sourceFile); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: if (n.type) { return isCompletedNode(n.type, sourceFile); } return hasChildOfKind(n, 23 /* CloseBracketToken */, sourceFile); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // there is no such thing as terminator token for CaseClause/DefaultClause so for simplicity always consider them non-completed return false; - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')'; - return hasChildOfKind(n, 108 /* WhileKeyword */, sourceFile) + return hasChildOfKind(n, 110 /* WhileKeyword */, sourceFile) ? nodeEndsWith(n, 21 /* CloseParenToken */, sourceFile) : isCompletedNode(n.statement, sourceFile); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return isCompletedNode(n.exprName, sourceFile); - case 200 /* TypeOfExpression */: - case 199 /* DeleteExpression */: - case 201 /* VoidExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: + case 203 /* TypeOfExpression */: + case 202 /* DeleteExpression */: + case 204 /* VoidExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: var unaryWordExpression = n; return isCompletedNode(unaryWordExpression.expression, sourceFile); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return isCompletedNode(n.template, sourceFile); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: var lastSpan = ts.lastOrUndefined(n.templateSpans); return isCompletedNode(lastSpan, sourceFile); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.nodeIsPresent(n.literal); - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: return ts.nodeIsPresent(n.moduleSpecifier); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return isCompletedNode(n.operand, sourceFile); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isCompletedNode(n.right, sourceFile); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isCompletedNode(n.whenFalse, sourceFile); default: return true; @@ -99710,7 +103471,7 @@ var ts; // this is token that starts at the end of previous token - return it return n; } - return ts.firstDefined(n.getChildren(), function (child) { + return ts.firstDefined(n.getChildren(sourceFile), function (child) { var shouldDiveInChildNode = // previous token is enclosed somewhere in the child (child.pos <= previousToken.pos && child.end > previousToken.end) || @@ -99757,7 +103518,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 285 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); + ts.Debug.assert(startNode !== undefined || n.kind === 288 /* SourceFile */ || n.kind === 1 /* EndOfFileToken */ || ts.isJSDocCommentContainingNode(n)); // Here we know that none of child token nodes embrace the position, // the only known case is when position is at the end of the file. // Try to find the rightmost token in the file without filtering. @@ -99823,21 +103584,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 11 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 271 /* JsxExpression */) { + if (token && token.kind === 19 /* CloseBraceToken */ && token.parent.kind === 274 /* JsxExpression */) { return true; } //
|
- if (token.kind === 28 /* LessThanToken */ && token.parent.kind === 264 /* JsxClosingElement */) { + if (token.kind === 29 /* LessThanToken */ && token.parent.kind === 267 /* JsxClosingElement */) { return true; } return false; @@ -99859,7 +103620,7 @@ var ts; if (token.kind === 18 /* OpenBraceToken */ && ts.isJsxExpression(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } - if (token.kind === 28 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { + if (token.kind === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(token.parent) && ts.isJsxElement(token.parent.parent)) { return true; } return false; @@ -99886,6 +103647,12 @@ var ts; } } ts.findPrecedingMatchingToken = findPrecedingMatchingToken; + function removeOptionality(type, isOptionalExpression, isOptionalChain) { + return isOptionalExpression ? type.getNonNullableType() : + isOptionalChain ? type.getNonOptionalType() : + type; + } + ts.removeOptionality = removeOptionality; function isPossiblyTypeArgumentPosition(token, sourceFile, checker) { var info = getPossibleTypeArgumentsInfo(token, sourceFile); return info !== undefined && (ts.isPartOfTypeNode(info.called) || @@ -99895,6 +103662,9 @@ var ts; ts.isPossiblyTypeArgumentPosition = isPossiblyTypeArgumentPosition; function getPossibleGenericSignatures(called, typeArgumentCount, checker) { var type = checker.getTypeAtLocation(called); + if (ts.isOptionalChain(called.parent)) { + type = removeOptionality(type, !!called.parent.questionDotToken, /*isOptionalChain*/ true); + } var signatures = ts.isNewExpression(called.parent) ? type.getConstructSignatures() : type.getCallSignatures(); return signatures.filter(function (candidate) { return !!candidate.typeParameters && candidate.typeParameters.length >= typeArgumentCount; }); } @@ -99911,9 +103681,12 @@ var ts; var nTypeArguments = 0; while (token) { switch (token.kind) { - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // Found the beginning of the generic argument expression token = findPrecedingToken(token.getFullStart(), sourceFile); + if (token && token.kind === 28 /* QuestionDotToken */) { + token = findPrecedingToken(token.getFullStart(), sourceFile); + } if (!token || !ts.isIdentifier(token)) return undefined; if (!remainingLessThanTokens) { @@ -99921,13 +103694,13 @@ var ts; } remainingLessThanTokens--; break; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: remainingLessThanTokens = +3; break; - case 47 /* GreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: remainingLessThanTokens = +2; break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: remainingLessThanTokens++; break; case 19 /* CloseBraceToken */: @@ -99955,20 +103728,22 @@ var ts; case 27 /* CommaToken */: nTypeArguments++; break; - case 37 /* EqualsGreaterThanToken */: - case 73 /* Identifier */: + case 38 /* EqualsGreaterThanToken */: + // falls through + case 75 /* Identifier */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 105 /* TypeOfKeyword */: - case 87 /* ExtendsKeyword */: - case 130 /* KeyOfKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + // falls through + case 107 /* TypeOfKeyword */: + case 89 /* ExtendsKeyword */: + case 133 /* KeyOfKeyword */: case 24 /* DotToken */: - case 50 /* BarToken */: - case 56 /* QuestionToken */: - case 57 /* ColonToken */: + case 51 /* BarToken */: + case 57 /* QuestionToken */: + case 58 /* ColonToken */: break; default: if (ts.isTypeNode(token)) { @@ -100017,16 +103792,16 @@ var ts; result.push("abstract" /* abstractModifier */); if (flags & 1 /* Export */) result.push("export" /* exportedModifier */); - if (node.flags & 4194304 /* Ambient */) + if (node.flags & 8388608 /* Ambient */) result.push("declare" /* ambientModifier */); return result.length > 0 ? result.join(",") : "" /* none */; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 165 /* TypeReference */ || node.kind === 192 /* CallExpression */) { + if (node.kind === 168 /* TypeReference */ || node.kind === 195 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 241 /* ClassDeclaration */ || node.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 244 /* ClassDeclaration */ || node.kind === 245 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; @@ -100046,7 +103821,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 18 /* FirstPunctuation */ <= kind && kind <= 72 /* LastPunctuation */; + return 18 /* FirstPunctuation */ <= kind && kind <= 74 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position, sourceFile) { @@ -100056,9 +103831,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: return true; } return false; @@ -100071,18 +103846,18 @@ var ts; } ts.cloneCompilerOptions = cloneCompilerOptions; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 188 /* ArrayLiteralExpression */ || - node.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 191 /* ArrayLiteralExpression */ || + node.kind === 192 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 205 /* BinaryExpression */ && + if (node.parent.kind === 208 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 60 /* EqualsToken */) { + node.parent.operatorToken.kind === 62 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 228 /* ForOfStatement */ && + if (node.parent.kind === 231 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -100090,7 +103865,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 276 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 279 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -100134,23 +103909,23 @@ var ts; } ts.createTextChange = createTextChange; ts.typeKeywords = [ - 121 /* AnyKeyword */, - 147 /* BigIntKeyword */, - 124 /* BooleanKeyword */, - 88 /* FalseKeyword */, - 130 /* KeyOfKeyword */, - 133 /* NeverKeyword */, - 97 /* NullKeyword */, - 136 /* NumberKeyword */, - 137 /* ObjectKeyword */, - 134 /* ReadonlyKeyword */, - 139 /* StringKeyword */, - 140 /* SymbolKeyword */, - 103 /* TrueKeyword */, - 107 /* VoidKeyword */, - 142 /* UndefinedKeyword */, - 143 /* UniqueKeyword */, - 144 /* UnknownKeyword */, + 124 /* AnyKeyword */, + 150 /* BigIntKeyword */, + 127 /* BooleanKeyword */, + 90 /* FalseKeyword */, + 133 /* KeyOfKeyword */, + 136 /* NeverKeyword */, + 99 /* NullKeyword */, + 139 /* NumberKeyword */, + 140 /* ObjectKeyword */, + 137 /* ReadonlyKeyword */, + 142 /* StringKeyword */, + 143 /* SymbolKeyword */, + 105 /* TrueKeyword */, + 109 /* VoidKeyword */, + 145 /* UndefinedKeyword */, + 146 /* UniqueKeyword */, + 147 /* UnknownKeyword */, ]; function isTypeKeyword(kind) { return ts.contains(ts.typeKeywords, kind); @@ -100186,7 +103961,7 @@ var ts; } ts.skipConstraint = skipConstraint; function getNameFromPropertyName(name) { - return name.kind === 150 /* ComputedPropertyName */ + return name.kind === 153 /* ComputedPropertyName */ // treat computed property names where expression is string/numeric literal as just string/numeric literal ? ts.isStringOrNumericLiteralLike(name.expression) ? name.expression.text : undefined : ts.getTextOfIdentifierOrLiteral(name); @@ -100262,7 +104037,7 @@ var ts; } return ts.firstDefined(symbol.declarations, function (decl) { var name = ts.getNameOfDeclaration(decl); - return name && name.kind === 73 /* Identifier */ ? name.escapedText : undefined; + return name && name.kind === 75 /* Identifier */ ? name.escapedText : undefined; }); } ts.symbolEscapedNameNoDefault = symbolEscapedNameNoDefault; @@ -100346,12 +104121,31 @@ var ts; return a.fileName === b.fileName && textSpansEqual(a.textSpan, b.textSpan); } ts.documentSpansEqual = documentSpansEqual; + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ + function forEachUnique(array, callback) { + if (array) { + for (var i = 0; i < array.length; i++) { + if (array.indexOf(array[i]) === i) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + } + return undefined; + } + ts.forEachUnique = forEachUnique; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 152 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 155 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -100392,6 +104186,8 @@ var ts; getColumn: function () { return 0; }, getLine: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingWhitespace: function () { return false; }, + hasTrailingComment: function () { return false; }, rawWrite: ts.notImplemented, getIndent: function () { return indent; }, increaseIndent: function () { indent++; }, @@ -100813,15 +104609,15 @@ var ts; function getContextualTypeFromParent(node, checker) { var parent = node.parent; switch (parent.kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return checker.getContextualType(parent); - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var _a = parent, left = _a.left, operatorToken = _a.operatorToken, right = _a.right; return isEqualityOperatorKind(operatorToken.kind) ? checker.getTypeAtLocation(node === right ? left : right) : checker.getContextualType(node); } - case 272 /* CaseClause */: + case 275 /* CaseClause */: return parent.expression === node ? getSwitchedType(parent, checker) : undefined; default: return checker.getContextualType(node); @@ -100849,10 +104645,10 @@ var ts; ts.quote = quote; function isEqualityOperatorKind(kind) { switch (kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: return true; default: return false; @@ -100863,8 +104659,8 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: return true; default: return false; @@ -100885,7 +104681,6 @@ var ts; var notAccessible = function () { typeIsAccessible = false; }; var res = checker.typeToTypeNode(type, enclosingScope, /*flags*/ undefined, { trackSymbol: function (symbol, declaration, meaning) { - // TODO: GH#18217 typeIsAccessible = typeIsAccessible && checker.isSymbolAccessible(symbol, declaration, meaning, /*shouldComputeAliasToMarkVisible*/ false).accessibility === 0 /* Accessible */; }, reportInaccessibleThisError: notAccessible, @@ -100903,28 +104698,90 @@ var ts; return typeIsAccessible ? res : undefined; } ts.getTypeNodeIfAccessible = getTypeNodeIfAccessible; - function syntaxUsuallyHasTrailingSemicolon(kind) { - return kind === 220 /* VariableStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 224 /* DoStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 230 /* BreakStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 155 /* PropertyDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */; - } - ts.syntaxUsuallyHasTrailingSemicolon = syntaxUsuallyHasTrailingSemicolon; + function syntaxRequiresTrailingCommaOrSemicolonOrASI(kind) { + return kind === 164 /* CallSignature */ + || kind === 165 /* ConstructSignature */ + || kind === 166 /* IndexSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */; + } + ts.syntaxRequiresTrailingCommaOrSemicolonOrASI = syntaxRequiresTrailingCommaOrSemicolonOrASI; + function syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(kind) { + return kind === 243 /* FunctionDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; + } + ts.syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI = syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI; + function syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(kind) { + return kind === 248 /* ModuleDeclaration */; + } + ts.syntaxRequiresTrailingModuleBlockOrSemicolonOrASI = syntaxRequiresTrailingModuleBlockOrSemicolonOrASI; + function syntaxRequiresTrailingSemicolonOrASI(kind) { + return kind === 224 /* VariableStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 227 /* DoStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 233 /* BreakStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 158 /* PropertyDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 258 /* ExportAssignment */; + } + ts.syntaxRequiresTrailingSemicolonOrASI = syntaxRequiresTrailingSemicolonOrASI; + ts.syntaxMayBeASICandidate = ts.or(syntaxRequiresTrailingCommaOrSemicolonOrASI, syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI, syntaxRequiresTrailingModuleBlockOrSemicolonOrASI, syntaxRequiresTrailingSemicolonOrASI); + function isASICandidate(node, sourceFile) { + var lastToken = node.getLastToken(sourceFile); + if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { + return false; + } + if (syntaxRequiresTrailingCommaOrSemicolonOrASI(node.kind)) { + if (lastToken && lastToken.kind === 27 /* CommaToken */) { + return false; + } + } + else if (syntaxRequiresTrailingModuleBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isModuleBlock(lastChild)) { + return false; + } + } + else if (syntaxRequiresTrailingFunctionBlockOrSemicolonOrASI(node.kind)) { + var lastChild = ts.last(node.getChildren(sourceFile)); + if (lastChild && ts.isFunctionBlock(lastChild)) { + return false; + } + } + else if (!syntaxRequiresTrailingSemicolonOrASI(node.kind)) { + return false; + } + // See comment in parser’s `parseDoStatement` + if (node.kind === 227 /* DoStatement */) { + return true; + } + var topNode = ts.findAncestor(node, function (ancestor) { return !ancestor.parent; }); + var nextToken = ts.findNextToken(node, topNode, sourceFile); + if (!nextToken || nextToken.kind === 19 /* CloseBraceToken */) { + return true; + } + var startLine = sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line; + var endLine = sourceFile.getLineAndCharacterOfPosition(nextToken.getStart(sourceFile)).line; + return startLine !== endLine; + } + ts.isASICandidate = isASICandidate; function probablyUsesSemicolons(sourceFile) { var withSemicolon = 0; var withoutSemicolon = 0; var nStatementsToObserve = 5; ts.forEachChild(sourceFile, function visit(node) { - if (syntaxUsuallyHasTrailingSemicolon(node.kind)) { + if (syntaxRequiresTrailingSemicolonOrASI(node.kind)) { var lastToken = node.getLastToken(sourceFile); if (lastToken && lastToken.kind === 26 /* SemicolonToken */) { withSemicolon++; @@ -100947,6 +104804,150 @@ var ts; return withSemicolon / withoutSemicolon > 1 / nStatementsToObserve; } ts.probablyUsesSemicolons = probablyUsesSemicolons; + function tryGetDirectories(host, directoryName) { + return tryIOAndConsumeErrors(host, host.getDirectories, directoryName) || []; + } + ts.tryGetDirectories = tryGetDirectories; + function tryReadDirectory(host, path, extensions, exclude, include) { + return tryIOAndConsumeErrors(host, host.readDirectory, path, extensions, exclude, include) || ts.emptyArray; + } + ts.tryReadDirectory = tryReadDirectory; + function tryFileExists(host, path) { + return tryIOAndConsumeErrors(host, host.fileExists, path); + } + ts.tryFileExists = tryFileExists; + function tryDirectoryExists(host, path) { + return tryAndIgnoreErrors(function () { return ts.directoryProbablyExists(path, host); }) || false; + } + ts.tryDirectoryExists = tryDirectoryExists; + function tryAndIgnoreErrors(cb) { + try { + return cb(); + } + catch (_a) { + return undefined; + } + } + ts.tryAndIgnoreErrors = tryAndIgnoreErrors; + function tryIOAndConsumeErrors(host, toApply) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + return tryAndIgnoreErrors(function () { return toApply && toApply.apply(host, args); }); + } + ts.tryIOAndConsumeErrors = tryIOAndConsumeErrors; + function findPackageJsons(startDirectory, host, stopDirectory) { + var paths = []; + ts.forEachAncestorDirectory(startDirectory, function (ancestor) { + if (ancestor === stopDirectory) { + return true; + } + var currentConfigPath = ts.combinePaths(ancestor, "package.json"); + if (tryFileExists(host, currentConfigPath)) { + paths.push(currentConfigPath); + } + }); + return paths; + } + ts.findPackageJsons = findPackageJsons; + function findPackageJson(directory, host) { + var packageJson; + ts.forEachAncestorDirectory(directory, function (ancestor) { + if (ancestor === "node_modules") + return true; + packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); + if (packageJson) { + return true; // break out + } + }); + return packageJson; + } + ts.findPackageJson = findPackageJson; + function getPackageJsonsVisibleToFile(fileName, host) { + if (!host.fileExists) { + return []; + } + var packageJsons = []; + ts.forEachAncestorDirectory(ts.getDirectoryPath(fileName), function (ancestor) { + var packageJsonFileName = ts.combinePaths(ancestor, "package.json"); + if (host.fileExists(packageJsonFileName)) { + var info = createPackageJsonInfo(packageJsonFileName, host); + if (info) { + packageJsons.push(info); + } + } + }); + return packageJsons; + } + ts.getPackageJsonsVisibleToFile = getPackageJsonsVisibleToFile; + function createPackageJsonInfo(fileName, host) { + if (!host.readFile) { + return undefined; + } + var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"]; + var stringContent = host.readFile(fileName); + var content = stringContent && tryParseJson(stringContent); + if (!content) { + return undefined; + } + var info = {}; + for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) { + var key = dependencyKeys_1[_i]; + var dependencies = content[key]; + if (!dependencies) { + continue; + } + var dependencyMap = ts.createMap(); + for (var packageName in dependencies) { + dependencyMap.set(packageName, dependencies[packageName]); + } + info[key] = dependencyMap; + } + var dependencyGroups = [ + [1 /* Dependencies */, info.dependencies], + [2 /* DevDependencies */, info.devDependencies], + [8 /* OptionalDependencies */, info.optionalDependencies], + [4 /* PeerDependencies */, info.peerDependencies], + ]; + return __assign(__assign({}, info), { fileName: fileName, + get: get, + has: function (dependencyName, inGroups) { + return !!get(dependencyName, inGroups); + } }); + function get(dependencyName, inGroups) { + if (inGroups === void 0) { inGroups = 15 /* All */; } + for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { + var _a = dependencyGroups_1[_i], group_1 = _a[0], deps = _a[1]; + if (deps && (inGroups & group_1)) { + var dep = deps.get(dependencyName); + if (dep !== undefined) { + return dep; + } + } + } + } + } + ts.createPackageJsonInfo = createPackageJsonInfo; + function tryParseJson(text) { + try { + return JSON.parse(text); + } + catch (_a) { + return undefined; + } + } + function consumesNodeCoreModules(sourceFile) { + return ts.some(sourceFile.imports, function (_a) { + var text = _a.text; + return ts.JsTyping.nodeCoreModules.has(text); + }); + } + ts.consumesNodeCoreModules = consumesNodeCoreModules; + function isInsideNodeModules(fileOrDirectory) { + return ts.contains(ts.getPathComponents(fileOrDirectory), "node_modules"); + } + ts.isInsideNodeModules = isInsideNodeModules; })(ts || (ts = {})); var ts; (function (ts) { @@ -101028,36 +105029,36 @@ var ts; } while (token !== 1 /* EndOfFileToken */); function handleToken() { switch (token) { - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (!noRegexTable[lastNonTriviaToken] && scanner.reScanSlashToken() === 13 /* RegularExpressionLiteral */) { token = 13 /* RegularExpressionLiteral */; } break; - case 28 /* LessThanToken */: - if (lastNonTriviaToken === 73 /* Identifier */) { + case 29 /* LessThanToken */: + if (lastNonTriviaToken === 75 /* Identifier */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } break; - case 121 /* AnyKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: + case 124 /* AnyKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: if (angleBracketStack > 0 && !syntacticClassifierAbsent) { // If it looks like we're could be in something generic, don't classify this // as a keyword. We may just get overwritten by the syntactic classifier, // causing a noisy experience for the user. - token = 73 /* Identifier */; + token = 75 /* Identifier */; } break; case 15 /* TemplateHead */: @@ -101096,14 +105097,14 @@ var ts; break; } if (lastNonTriviaToken === 24 /* DotToken */) { - token = 73 /* Identifier */; + token = 75 /* Identifier */; } else if (ts.isKeyword(lastNonTriviaToken) && ts.isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 73 /* Identifier */; + token = 75 /* Identifier */; } } } @@ -101117,19 +105118,19 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = ts.arrayToNumericMap([ - 73 /* Identifier */, + 75 /* Identifier */, 10 /* StringLiteral */, 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 13 /* RegularExpressionLiteral */, - 101 /* ThisKeyword */, - 44 /* PlusPlusToken */, - 45 /* MinusMinusToken */, + 103 /* ThisKeyword */, + 45 /* PlusPlusToken */, + 46 /* MinusMinusToken */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 19 /* CloseBraceToken */, - 103 /* TrueKeyword */, - 88 /* FalseKeyword */, + 105 /* TrueKeyword */, + 90 /* FalseKeyword */, ], function (token) { return token; }, function () { return true; }); function getNewEndOfLineState(scanner, token, lastOnTemplateStack) { switch (token) { @@ -101241,10 +105242,10 @@ var ts; return true; } switch (keyword2) { - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 125 /* ConstructorKeyword */: - case 117 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 128 /* ConstructorKeyword */: + case 119 /* StaticKeyword */: return true; // Allow things like "public get", "public constructor" and "public static". default: return false; // Any other keyword following "public" is actually an identifier, not a real keyword. @@ -101277,43 +105278,44 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 49 /* AmpersandToken */: - case 51 /* CaretToken */: - case 50 /* BarToken */: - case 54 /* AmpersandAmpersandToken */: - case 55 /* BarBarToken */: - case 71 /* BarEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 60 /* EqualsToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 50 /* AmpersandToken */: + case 52 /* CaretToken */: + case 51 /* BarToken */: + case 55 /* AmpersandAmpersandToken */: + case 56 /* BarBarToken */: + case 73 /* BarEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: + case 60 /* QuestionQuestionToken */: return true; default: return false; @@ -101321,12 +105323,12 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: return true; default: return false; @@ -101339,7 +105341,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 18 /* FirstPunctuation */ && token <= 72 /* LastPunctuation */) { + else if (token >= 18 /* FirstPunctuation */ && token <= 74 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -101358,7 +105360,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 73 /* Identifier */: + case 75 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -101383,10 +105385,10 @@ var ts; // That means we're calling back into the host around every 1.2k of the file we process. // Lib.d.ts has similar numbers. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -101413,8 +105415,10 @@ var ts; }); return { spans: spans, endOfLineState: 0 /* None */ }; function pushClassification(start, end, type) { + var length = end - start; + ts.Debug.assert(length > 0, "Classification had non-positive length of " + length); spans.push(start); - spans.push(end - start); + spans.push(length); spans.push(type); } } @@ -101604,18 +105608,18 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); // e.g. "param" pos = tag.tagName.end; switch (tag.kind) { - case 307 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); pos = tag.end; break; - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: processElement(tag.typeExpression); pos = tag.end; break; - case 308 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: processElement(tag.typeExpression); pos = tag.end; break; @@ -101656,6 +105660,7 @@ var ts; // defined in `ts.commentPragmas` would be excessive, but we can avoid // some obvious false positives (e.g. in XML-like doc comments) by // checking the element name. + // eslint-disable-next-line no-in-operator if (!match[3] || !(match[3] in ts.commentPragmas)) { return false; } @@ -101765,22 +105770,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -101797,7 +105802,7 @@ var ts; } // Special case `<` and `>`: If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 28 /* LessThanToken */ || tokenKind === 30 /* GreaterThanToken */) { + if (tokenKind === 29 /* LessThanToken */ || tokenKind === 31 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -101807,19 +105812,19 @@ var ts; if (ts.isPunctuation(tokenKind)) { if (token) { var parent = token.parent; - if (tokenKind === 60 /* EqualsToken */) { + if (tokenKind === 62 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (parent.kind === 238 /* VariableDeclaration */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 152 /* Parameter */ || - parent.kind === 268 /* JsxAttribute */) { + if (parent.kind === 241 /* VariableDeclaration */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 155 /* Parameter */ || + parent.kind === 271 /* JsxAttribute */) { return 5 /* operator */; } } - if (parent.kind === 205 /* BinaryExpression */ || - parent.kind === 203 /* PrefixUnaryExpression */ || - parent.kind === 204 /* PostfixUnaryExpression */ || - parent.kind === 206 /* ConditionalExpression */) { + if (parent.kind === 208 /* BinaryExpression */ || + parent.kind === 206 /* PrefixUnaryExpression */ || + parent.kind === 207 /* PostfixUnaryExpression */ || + parent.kind === 209 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -101832,8 +105837,7 @@ var ts; return 25 /* bigintLiteral */; } else if (tokenKind === 10 /* StringLiteral */) { - // TODO: GH#18217 - return token.parent.kind === 268 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token && token.parent.kind === 271 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } else if (tokenKind === 13 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. @@ -101846,35 +105850,35 @@ var ts; else if (tokenKind === 11 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 73 /* Identifier */) { + else if (tokenKind === 75 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 152 /* Parameter */: + case 155 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -101997,11 +106001,11 @@ var ts; function getStringLiteralCompletionEntries(sourceFile, node, position, typeChecker, compilerOptions, host) { var parent = node.parent; switch (parent.kind) { - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (parent.parent.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return { kind: 2 /* Types */, types: getStringLiteralTypes(typeChecker.getTypeArgumentConstraint(parent)), isNewIdentifier: false }; - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: // Get all apparent property names // i.e. interface Foo { // foo: string; @@ -102009,9 +106013,9 @@ var ts; // } // let x: Foo["/*completion position*/"] return stringLiteralCompletionsFromProperties(typeChecker.getTypeFromTypeNode(parent.parent.objectType)); - case 184 /* ImportType */: + case 187 /* ImportType */: return { kind: 0 /* Paths */, paths: getStringLiteralCompletionsFromModuleNames(sourceFile, node, compilerOptions, host, typeChecker) }; - case 174 /* UnionType */: { + case 177 /* UnionType */: { if (!ts.isTypeReferenceNode(parent.parent.parent)) return undefined; var alreadyUsedTypes_1 = getAlreadyUsedTypesInStringLiteralUnion(parent.parent, parent); @@ -102021,7 +106025,7 @@ var ts; default: return undefined; } - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -102038,7 +106042,7 @@ var ts; return stringLiteralCompletionsFromProperties(typeChecker.getContextualType(parent.parent)); } return fromContextualType(); - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { var _a = parent, expression = _a.expression, argumentExpression = _a.argumentExpression; if (node === argumentExpression) { // Get all names of properties on the expression @@ -102051,8 +106055,8 @@ var ts; } return undefined; } - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (!ts.isRequireCall(parent, /*checkArgumentIsStringLiteralLike*/ false) && !ts.isImportCall(parent)) { var argumentInfo = ts.SignatureHelp.getArgumentInfoForCompletions(node, position, sourceFile); // Get string literal completions from specialized signatures of the target @@ -102061,9 +106065,9 @@ var ts; return argumentInfo ? getStringLiteralCompletionsFromSignature(argumentInfo, typeChecker) : fromContextualType(); } // falls through (is `require("")` or `import("")`) - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 260 /* ExternalModuleReference */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 263 /* ExternalModuleReference */: // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // var y = import("/*completion position*/"); @@ -102091,7 +106095,7 @@ var ts; var candidates = []; checker.getResolvedSignature(argumentInfo.invocation, candidates, argumentInfo.argumentCount); var types = ts.flatMap(candidates, function (candidate) { - if (!candidate.hasRestParameter && argumentInfo.argumentCount > candidate.parameters.length) + if (!ts.signatureHasRestParameter(candidate) && argumentInfo.argumentCount > candidate.parameters.length) return; var type = checker.getParameterType(candidate, argumentInfo.argumentIndex); isNewIdentifier = isNewIdentifier || !!(type.flags & 4 /* String */); @@ -102107,11 +106111,8 @@ var ts; if (!type) return ts.emptyArray; type = ts.skipConstraint(type); - return type.isUnion() - ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) - : type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) - ? [type] - : ts.emptyArray; + return type.isUnion() ? ts.flatMap(type.types, function (t) { return getStringLiteralTypes(t, uniques); }) : + type.isStringLiteral() && !(type.flags & 1024 /* EnumLiteral */) && ts.addToSeen(uniques, type.value) ? [type] : ts.emptyArray; } function nameAndKind(name, kind, extension) { return { name: name, kind: kind, extension: extension }; @@ -102201,10 +106202,10 @@ var ts; var absolutePath = ts.resolvePath(scriptPath, fragment); var baseDirectory = ts.hasTrailingDirectorySeparator(absolutePath) ? absolutePath : ts.getDirectoryPath(absolutePath); var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (!tryDirectoryExists(host, baseDirectory)) + if (!ts.tryDirectoryExists(host, baseDirectory)) return result; // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + var files = ts.tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); if (files) { /** * Multiple file entries might map to the same truncated name once we remove extensions @@ -102227,7 +106228,7 @@ var ts; }); } // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); + var directories = ts.tryGetDirectories(host, baseDirectory); if (directories) { for (var _b = 0, directories_1 = directories; _b < directories_1.length; _b++) { var directory = directories_1[_b]; @@ -102238,7 +106239,7 @@ var ts; } } // check for a version redirect - var packageJsonPath = findPackageJson(baseDirectory, host); + var packageJsonPath = ts.findPackageJson(baseDirectory, host); if (packageJsonPath) { var packageJson = ts.readJson(packageJsonPath, host); var typesVersions = packageJson.typesVersions; @@ -102316,7 +106317,7 @@ var ts; if (!foundGlobal) { ts.forEachAncestorDirectory(scriptPath, function (ancestor) { var nodeModules = ts.combinePaths(ancestor, "node_modules"); - if (tryDirectoryExists(host, nodeModules)) { + if (ts.tryDirectoryExists(host, nodeModules)) { getCompletionEntriesForDirectoryFragment(fragment, nodeModules, extensionOptions, host, /*exclude*/ undefined, result); } }); @@ -102366,12 +106367,12 @@ var ts; // that encodes the suffix, but we would have to escape the character "?" which readDirectory // doesn't support. For now, this is safer but slower var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = ts.mapDefined(tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { + var matches = ts.mapDefined(ts.tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]), function (match) { var extension = ts.tryGetExtensionFromPath(match); var name = trimPrefixAndSuffix(match); return name === undefined ? undefined : nameAndKind(ts.removeFileExtension(name), "script" /* scriptElement */, extension); }); - var directories = ts.mapDefined(tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { + var directories = ts.mapDefined(ts.tryGetDirectories(host, baseDirectory).map(function (d) { return ts.combinePaths(baseDirectory, d); }), function (dir) { var name = trimPrefixAndSuffix(dir); return name === undefined ? undefined : directoryResult(name); }); @@ -102423,22 +106424,22 @@ var ts; if (result === void 0) { result = []; } // Check for typings specified in compiler options var seen = ts.createMap(); - var typeRoots = tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; + var typeRoots = ts.tryAndIgnoreErrors(function () { return ts.getEffectiveTypeRoots(options, host); }) || ts.emptyArray; for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) { var root = typeRoots_1[_i]; getCompletionEntriesFromDirectories(root); } // Also get all @types typings installed in visible node_modules directories - for (var _a = 0, _b = findPackageJsons(scriptPath, host); _a < _b.length; _a++) { + for (var _a = 0, _b = ts.findPackageJsons(scriptPath, host); _a < _b.length; _a++) { var packageJson = _b[_a]; var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); getCompletionEntriesFromDirectories(typesDir); } return result; function getCompletionEntriesFromDirectories(directory) { - if (!tryDirectoryExists(host, directory)) + if (!ts.tryDirectoryExists(host, directory)) return; - for (var _i = 0, _a = tryGetDirectories(host, directory); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.tryGetDirectories(host, directory); _i < _a.length; _i++) { var typeDirectoryName = _a[_i]; var packageName = ts.unmangleScopedPackageName(typeDirectoryName); if (options.types && !ts.contains(options.types, packageName)) @@ -102459,34 +106460,11 @@ var ts; } } } - function findPackageJsons(directory, host) { - var paths = []; - ts.forEachAncestorDirectory(directory, function (ancestor) { - var currentConfigPath = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (!currentConfigPath) { - return true; // break out - } - paths.push(currentConfigPath); - }); - return paths; - } - function findPackageJson(directory, host) { - var packageJson; - ts.forEachAncestorDirectory(directory, function (ancestor) { - if (ancestor === "node_modules") - return true; - packageJson = ts.findConfigFile(ancestor, function (f) { return tryFileExists(host, f); }, "package.json"); - if (packageJson) { - return true; // break out - } - }); - return packageJson; - } function enumerateNodeModulesVisibleToScript(host, scriptPath) { if (!host.readFile || !host.fileExists) return ts.emptyArray; var result = []; - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + for (var _i = 0, _a = ts.findPackageJsons(scriptPath, host); _i < _a.length; _i++) { var packageJson = _a[_i]; var contents = ts.readJson(packageJson, host); // Cast to assert that readFile is defined // Provide completions for all non @types dependencies @@ -102535,33 +106513,6 @@ var ts; */ var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*" with type any // And at `
` (with a closing `>`), the completion list will contain "div". var tagName = location.parent.parent.openingElement.tagName; - var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 30 /* GreaterThanToken */, sourceFile); + var hasClosingAngleBracket = !!ts.findChildOfKind(location.parent, 31 /* GreaterThanToken */, sourceFile); var entry = { name: tagName.getFullText(sourceFile) + (hasClosingAngleBracket ? "" : ">"), kind: "class" /* classElement */, @@ -102734,14 +106744,25 @@ var ts; function createCompletionEntry(symbol, sortText, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, preferences) { var insertText; var replacementSpan; - if (origin && origin.kind === 0 /* ThisType */) { - insertText = needsConvertPropertyAccess ? "this[" + ts.quote(name, preferences) + "]" : "this." + name; + var insertQuestionDot = origin && originIsNullableMember(origin); + var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess; + if (origin && originIsThisType(origin)) { + insertText = needsConvertPropertyAccess + ? "this" + (insertQuestionDot ? "?." : "") + "[" + ts.quote(name, preferences) + "]" + : "this" + (insertQuestionDot ? "?." : ".") + name; } // We should only have needsConvertPropertyAccess if there's a property access to convert. But see #21790. // Somehow there was a global with a non-identifier name. Hopefully someone will complain about getting a "foo bar" global completion and provide a repro. - else if ((origin && originIsSymbolMember(origin) || needsConvertPropertyAccess) && propertyAccessToConvert) { - insertText = needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]"; - var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile); + else if ((useBraces || insertQuestionDot) && propertyAccessToConvert) { + insertText = useBraces ? needsConvertPropertyAccess ? "[" + ts.quote(name, preferences) + "]" : "[" + name + "]" : name; + if (insertQuestionDot || propertyAccessToConvert.questionDotToken) { + insertText = "?." + insertText; + } + var dot = ts.findChildOfKind(propertyAccessToConvert, 24 /* DotToken */, sourceFile) || + ts.findChildOfKind(propertyAccessToConvert, 28 /* QuestionDotToken */, sourceFile); + if (!dot) { + return undefined; + } // If the text after the '.' starts with this name, write over it. Else, add new text. var end = ts.startsWith(name, propertyAccessToConvert.name.text) ? propertyAccessToConvert.name.end : dot.end; replacementSpan = ts.createTextSpanFromBounds(dot.getStart(sourceFile), end); @@ -102754,6 +106775,13 @@ var ts; replacementSpan = ts.createTextSpanFromNode(isJsxInitializer, sourceFile); } } + if (origin && originIsPromise(origin) && propertyAccessToConvert) { + if (insertText === undefined) + insertText = name; + var awaitText = "(await " + propertyAccessToConvert.expression.getText() + ")"; + insertText = needsConvertPropertyAccess ? "" + awaitText + insertText : "" + awaitText + (insertQuestionDot ? "?." : ".") + insertText; + replacementSpan = ts.createTextSpanFromBounds(propertyAccessToConvert.getStart(sourceFile), propertyAccessToConvert.end); + } if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) { return undefined; } @@ -102848,9 +106876,9 @@ var ts; } return entries; } - function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId) { + function getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host) { var compilerOptions = program.getCompilerOptions(); - var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId); + var completionData = getCompletionData(program, log, sourceFile, isUncheckedFile(sourceFile, compilerOptions), position, { includeCompletionsForModuleExports: true, includeCompletionsWithInsertText: true }, entryId, host); if (!completionData) { return { type: "none" }; } @@ -102890,7 +106918,7 @@ var ts; return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken); } // Compute all the completion symbols again. - var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + var symbolCompletion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); switch (symbolCompletion.type) { case "request": { var request = symbolCompletion.request; @@ -102946,8 +106974,8 @@ var ts; var _a = ts.codefix.getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction; return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] }; } - function getCompletionEntrySymbol(program, log, sourceFile, position, entryId) { - var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId); + function getCompletionEntrySymbol(program, log, sourceFile, position, entryId, host) { + var completion = getSymbolCompletionFromEntryId(program, log, sourceFile, position, entryId, host); return completion.type === "symbol" ? completion.symbol : undefined; } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; @@ -102980,34 +107008,34 @@ var ts; function getContextualType(previousToken, position, sourceFile, checker) { var parent = previousToken.parent; switch (previousToken.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.getContextualTypeFromParent(previousToken, checker); - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checker.getContextualType(parent.initializer); // TODO: GH#18217 - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checker.getTypeAtLocation(parent.left); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return checker.getContextualTypeForJsxAttribute(parent); default: return undefined; } - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return checker.getContextualType(parent); - case 75 /* CaseKeyword */: + case 77 /* CaseKeyword */: return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker); case 18 /* OpenBraceToken */: - return ts.isJsxExpression(parent) && parent.parent.kind !== 261 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; + return ts.isJsxExpression(parent) && parent.parent.kind !== 264 /* JsxElement */ ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined; default: var argInfo = ts.SignatureHelp.getArgumentInfoForCompletions(previousToken, position, sourceFile); - return argInfo + return argInfo ? // At `,`, treat this as the next argument after the comma. - ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) - : ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) + checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 27 /* CommaToken */ ? 1 : 0)) : + ts.isEqualityOperatorKind(previousToken.kind) && ts.isBinaryExpression(parent) && ts.isEqualityOperatorKind(parent.operatorToken.kind) ? // completion at `x ===/**/` should be for the right side - ? checker.getTypeAtLocation(parent.left) - : checker.getContextualType(previousToken); + checker.getTypeAtLocation(parent.left) : + checker.getContextualType(previousToken); } } function getFirstSymbolInChain(symbol, enclosingDeclaration, checker) { @@ -103017,9 +107045,9 @@ var ts; return symbol.parent && (isModuleSymbol(symbol.parent) ? symbol : getFirstSymbolInChain(symbol.parent, enclosingDeclaration, checker)); } function isModuleSymbol(symbol) { - return symbol.declarations.some(function (d) { return d.kind === 285 /* SourceFile */; }); + return symbol.declarations.some(function (d) { return d.kind === 288 /* SourceFile */; }); } - function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId) { + function getCompletionData(program, log, sourceFile, isUncheckedFile, position, preferences, detailsEntryId, host) { var typeChecker = program.getTypeChecker(); var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 @@ -103068,11 +107096,11 @@ var ts; if (tag.tagName.pos <= position && position <= tag.tagName.end) { return { kind: 1 /* JsDocTagName */ }; } - if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { currentToken = ts.getTokenAtPosition(sourceFile, position); if (!currentToken || (!ts.isDeclarationName(currentToken) && - (currentToken.parent.kind !== 313 /* JSDocPropertyTag */ || + (currentToken.parent.kind !== 316 /* JSDocPropertyTag */ || currentToken.parent.name !== currentToken))) { // Use as type location if inside tag's type expression insideJsDocTagTypeExpression = isCurrentlyEditingNode(tag.typeExpression); @@ -103108,6 +107136,7 @@ var ts; var node = currentToken; var propertyAccessToConvert; var isRightOfDot = false; + var isRightOfQuestionDot = false; var isRightOfOpenTag = false; var isStartingCloseTag = false; var isJsxInitializer = false; @@ -103119,10 +107148,11 @@ var ts; return undefined; } var parent = contextToken.parent; - if (contextToken.kind === 24 /* DotToken */) { - isRightOfDot = true; + if (contextToken.kind === 24 /* DotToken */ || contextToken.kind === 28 /* QuestionDotToken */) { + isRightOfDot = contextToken.kind === 24 /* DotToken */; + isRightOfQuestionDot = contextToken.kind === 28 /* QuestionDotToken */; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: propertyAccessToConvert = parent; node = propertyAccessToConvert.expression; if (node.end === contextToken.pos && @@ -103134,14 +107164,14 @@ var ts; return undefined; } break; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: node = parent.left; break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: node = parent.name; break; - case 184 /* ImportType */: - case 215 /* MetaProperty */: + case 187 /* ImportType */: + case 218 /* MetaProperty */: node = parent; break; default: @@ -103154,56 +107184,56 @@ var ts; // // If the tagname is a property access expression, we will then walk up to the top most of property access expression. // Then, try to get a JSX container and its associated attributes type. - if (parent && parent.kind === 190 /* PropertyAccessExpression */) { + if (parent && parent.kind === 193 /* PropertyAccessExpression */) { contextToken = parent; parent = parent.parent; } // Fix location if (currentToken.parent === location) { switch (currentToken.kind) { - case 30 /* GreaterThanToken */: - if (currentToken.parent.kind === 261 /* JsxElement */ || currentToken.parent.kind === 263 /* JsxOpeningElement */) { + case 31 /* GreaterThanToken */: + if (currentToken.parent.kind === 264 /* JsxElement */ || currentToken.parent.kind === 266 /* JsxOpeningElement */) { location = currentToken; } break; - case 42 /* SlashToken */: - if (currentToken.parent.kind === 262 /* JsxSelfClosingElement */) { + case 43 /* SlashToken */: + if (currentToken.parent.kind === 265 /* JsxSelfClosingElement */) { location = currentToken; } break; } } switch (parent.kind) { - case 264 /* JsxClosingElement */: - if (contextToken.kind === 42 /* SlashToken */) { + case 267 /* JsxClosingElement */: + if (contextToken.kind === 43 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (!binaryExpressionMayBeOpenTag(parent)) { break; } // falls through - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: - case 263 /* JsxOpeningElement */: - if (contextToken.kind === 28 /* LessThanToken */) { + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: + case 266 /* JsxOpeningElement */: + if (contextToken.kind === 29 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: switch (previousToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: isJsxInitializer = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: // For `
` we don't want to treat this as a jsx inializer, instead it's the attribute name. if (parent !== previousToken.parent && !parent.initializer && - ts.findChildOfKind(parent, 60 /* EqualsToken */, sourceFile)) { + ts.findChildOfKind(parent, 62 /* EqualsToken */, sourceFile)) { isJsxInitializer = previousToken; } } @@ -103215,10 +107245,12 @@ var ts; var completionKind = 5 /* None */; var isNewIdentifierLocation = false; var keywordFilters = 0 /* None */; + // This also gets mutated in nested-functions after the return var symbols = []; var symbolToOriginInfoMap = []; var symbolToSortTextMap = []; - if (isRightOfDot) { + var importSuggestionsCache = host.getImportSuggestionsCache && host.getImportSuggestionsCache(); + if (isRightOfDot || isRightOfQuestionDot) { getTypeScriptMemberSymbols(); } else if (isRightOfOpenTag) { @@ -103268,11 +107300,11 @@ var ts; }; function isTagWithTypeExpression(tag) { switch (tag.kind) { - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 312 /* JSDocTypedefTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 315 /* JSDocTypedefTag */: return true; default: return false; @@ -103316,24 +107348,54 @@ var ts; // If the module is merged with a value, we must get the type of the class and add its propertes (for inherited static methods). if (!isTypeLocation && symbol.declarations && - symbol.declarations.some(function (d) { return d.kind !== 285 /* SourceFile */ && d.kind !== 245 /* ModuleDeclaration */ && d.kind !== 244 /* EnumDeclaration */; })) { - addTypeProperties(typeChecker.getTypeOfSymbolAtLocation(symbol, node)); + symbol.declarations.some(function (d) { return d.kind !== 288 /* SourceFile */ && d.kind !== 248 /* ModuleDeclaration */ && d.kind !== 247 /* EnumDeclaration */; })) { + var type = typeChecker.getTypeOfSymbolAtLocation(symbol, node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + var canCorrectToQuestionDot = isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } return; } } } - if (ts.isMetaProperty(node) && (node.keywordToken === 96 /* NewKeyword */ || node.keywordToken === 93 /* ImportKeyword */)) { - var completion = (node.keywordToken === 96 /* NewKeyword */) ? "target" : "meta"; + if (ts.isMetaProperty(node) && (node.keywordToken === 98 /* NewKeyword */ || node.keywordToken === 95 /* ImportKeyword */)) { + var completion = (node.keywordToken === 98 /* NewKeyword */) ? "target" : "meta"; symbols.push(typeChecker.createSymbol(4 /* Property */, ts.escapeLeadingUnderscores(completion))); return; } if (!isTypeLocation) { - addTypeProperties(typeChecker.getTypeAtLocation(node)); + var type = typeChecker.getTypeAtLocation(node).getNonOptionalType(); + var insertQuestionDot = false; + if (type.isNullableType()) { + var canCorrectToQuestionDot = isRightOfDot && + !isRightOfQuestionDot && + preferences.includeAutomaticOptionalChainCompletions !== false; + if (canCorrectToQuestionDot || isRightOfQuestionDot) { + type = type.getNonNullableType(); + if (canCorrectToQuestionDot) { + insertQuestionDot = true; + } + } + } + addTypeProperties(type, !!(node.flags & 32768 /* AwaitContext */), insertQuestionDot); } } - function addTypeProperties(type) { + function addTypeProperties(type, insertAwait, insertQuestionDot) { isNewIdentifierLocation = !!type.getStringIndexType(); + if (isRightOfQuestionDot && ts.some(type.getCallSignatures())) { + isNewIdentifierLocation = true; + } + var propertyAccess = node.kind === 187 /* ImportType */ ? node : node.parent; if (isUncheckedFile) { // In javascript files, for union types, we don't just get the members that // the individual types have in common, we also include all the members that @@ -103345,13 +107407,24 @@ var ts; else { for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) { var symbol = _a[_i]; - if (typeChecker.isValidPropertyAccessForCompletions(node.kind === 184 /* ImportType */ ? node : node.parent, type, symbol)) { - addPropertySymbol(symbol); + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) { + addPropertySymbol(symbol, /*insertAwait*/ false, insertQuestionDot); + } + } + } + if (insertAwait && preferences.includeCompletionsWithInsertText) { + var promiseType = typeChecker.getPromisedTypeOfPromise(type); + if (promiseType) { + for (var _b = 0, _c = promiseType.getApparentProperties(); _b < _c.length; _b++) { + var symbol = _c[_b]; + if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, promiseType, symbol)) { + addPropertySymbol(symbol, /* insertAwait */ true, insertQuestionDot); + } } } } } - function addPropertySymbol(symbol) { + function addPropertySymbol(symbol, insertAwait, insertQuestionDot) { // For a computed property with an accessible name like `Symbol.iterator`, // we'll add a completion for the *name* `Symbol` instead of for the property. // If this is e.g. [Symbol.iterator], add a completion for `Symbol`. @@ -103365,15 +107438,32 @@ var ts; symbols.push(firstAccessibleSymbol); var moduleSymbol = firstAccessibleSymbol.parent; symbolToOriginInfoMap[ts.getSymbolId(firstAccessibleSymbol)] = - !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) ? { kind: 1 /* SymbolMemberNoExport */ } : { kind: 2 /* SymbolMemberExport */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + !moduleSymbol || !ts.isExternalModuleSymbol(moduleSymbol) + ? { kind: getNullableSymbolOriginInfoKind(2 /* SymbolMemberNoExport */) } + : { kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */), moduleSymbol: moduleSymbol, isDefaultExport: false }; } else if (preferences.includeCompletionsWithInsertText) { + addSymbolOriginInfo(symbol); symbols.push(symbol); } } else { + addSymbolOriginInfo(symbol); symbols.push(symbol); } + function addSymbolOriginInfo(symbol) { + if (preferences.includeCompletionsWithInsertText) { + if (insertAwait && !symbolToOriginInfoMap[ts.getSymbolId(symbol)]) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: getNullableSymbolOriginInfoKind(8 /* Promise */) }; + } + else if (insertQuestionDot) { + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 16 /* Nullable */ }; + } + } + } + function getNullableSymbolOriginInfoKind(kind) { + return insertQuestionDot ? kind | 16 /* Nullable */ : kind; + } } /** Given 'a.b.c', returns 'a'. */ function getLeftMostName(e) { @@ -103406,6 +107496,7 @@ var ts; if (!attrsType) return 0 /* Continue */; symbols = filterJsxAttributes(getPropertiesForObjectExpression(attrsType, jsxContainer.attributes, typeChecker), jsxContainer.attributes.properties); + setSortTextToOptionalMember(); completionKind = 3 /* MemberLike */; isNewIdentifierLocation = false; return 1 /* Success */; @@ -103459,19 +107550,38 @@ var ts; } } // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions` - if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 285 /* SourceFile */) { + if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 288 /* SourceFile */) { var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false); if (thisType) { for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) { var symbol = _b[_a]; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 0 /* ThisType */ }; + symbolToOriginInfoMap[ts.getSymbolId(symbol)] = { kind: 1 /* ThisType */ }; symbols.push(symbol); symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.SuggestedClassMembers; } } } if (shouldOfferImportCompletions()) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && ts.isIdentifier(previousToken) ? previousToken.text : "", program.getCompilerOptions().target); + var lowerCaseTokenText_1 = previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() : ""; + var autoImportSuggestions = getSymbolsFromOtherSourceFileExports(program.getCompilerOptions().target, host); + if (!detailsEntryId && importSuggestionsCache) { + importSuggestionsCache.set(sourceFile.fileName, autoImportSuggestions, host.getProjectVersion && host.getProjectVersion()); + } + autoImportSuggestions.forEach(function (_a) { + var symbol = _a.symbol, symbolName = _a.symbolName, skipFilter = _a.skipFilter, origin = _a.origin; + if (detailsEntryId) { + if (detailsEntryId.source && ts.stripQuotes(origin.moduleSymbol.name) !== detailsEntryId.source) { + return; + } + } + else if (!skipFilter && !stringContainsCharactersInOrder(symbolName.toLowerCase(), lowerCaseTokenText_1)) { + return; + } + var symbolId = ts.getSymbolId(symbol); + symbols.push(symbol); + symbolToOriginInfoMap[symbolId] = origin; + symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions; + }); } filterGlobalCompletion(symbols); } @@ -103493,10 +107603,10 @@ var ts; } function isSnippetScope(scopeNode) { switch (scopeNode.kind) { - case 285 /* SourceFile */: - case 207 /* TemplateExpression */: - case 271 /* JsxExpression */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 210 /* TemplateExpression */: + case 274 /* JsxExpression */: + case 222 /* Block */: return true; default: return ts.isStatement(scopeNode); @@ -103541,28 +107651,28 @@ var ts; } function isContextTokenValueLocation(contextToken) { return contextToken && - contextToken.kind === 105 /* TypeOfKeyword */ && - (contextToken.parent.kind === 168 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); + contextToken.kind === 107 /* TypeOfKeyword */ && + (contextToken.parent.kind === 171 /* TypeQuery */ || ts.isTypeOfExpression(contextToken.parent)); } function isContextTokenTypeLocation(contextToken) { if (contextToken) { var parentKind = contextToken.parent.kind; switch (contextToken.kind) { - case 57 /* ColonToken */: - return parentKind === 155 /* PropertyDeclaration */ || - parentKind === 154 /* PropertySignature */ || - parentKind === 152 /* Parameter */ || - parentKind === 238 /* VariableDeclaration */ || + case 58 /* ColonToken */: + return parentKind === 158 /* PropertyDeclaration */ || + parentKind === 157 /* PropertySignature */ || + parentKind === 155 /* Parameter */ || + parentKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(parentKind); - case 60 /* EqualsToken */: - return parentKind === 243 /* TypeAliasDeclaration */; - case 120 /* AsKeyword */: - return parentKind === 213 /* AsExpression */; - case 28 /* LessThanToken */: - return parentKind === 165 /* TypeReference */ || - parentKind === 195 /* TypeAssertionExpression */; - case 87 /* ExtendsKeyword */: - return parentKind === 151 /* TypeParameter */; + case 62 /* EqualsToken */: + return parentKind === 246 /* TypeAliasDeclaration */; + case 122 /* AsKeyword */: + return parentKind === 216 /* AsExpression */; + case 29 /* LessThanToken */: + return parentKind === 168 /* TypeReference */ || + parentKind === 198 /* TypeAssertionExpression */; + case 89 /* ExtendsKeyword */: + return parentKind === 154 /* TypeParameter */; } } return false; @@ -103576,10 +107686,71 @@ var ts; ts.addToSeen(seenModules, ts.getSymbolId(sym)) && typeChecker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, seenModules); }); } - function getSymbolsFromOtherSourceFileExports(symbols, tokenText, target) { - var tokenTextLowerCase = tokenText.toLowerCase(); + /** + * Gathers symbols that can be imported from other files, de-duplicating along the way. Symbols can be "duplicates" + * if re-exported from another module, e.g. `export { foo } from "./a"`. That syntax creates a fresh symbol, but + * it’s just an alias to the first, and both have the same name, so we generally want to filter those aliases out, + * if and only if the the first can be imported (it may be excluded due to package.json filtering in + * `codefix.forEachExternalModuleToImportFrom`). + * + * Example. Imagine a chain of node_modules re-exporting one original symbol: + * + * ```js + * node_modules/x/index.js node_modules/y/index.js node_modules/z/index.js + * +-----------------------+ +--------------------------+ +--------------------------+ + * | | | | | | + * | export const foo = 0; | <--- | export { foo } from 'x'; | <--- | export { foo } from 'y'; | + * | | | | | | + * +-----------------------+ +--------------------------+ +--------------------------+ + * ``` + * + * Also imagine three buckets, which we’ll reference soon: + * + * ```md + * | | | | | | + * | **Bucket A** | | **Bucket B** | | **Bucket C** | + * | Symbols to | | Aliases to symbols | | Symbols to return | + * | definitely | | in Buckets A or C | | if nothing better | + * | return | | (don’t return these) | | comes along | + * |__________________| |______________________| |___________________| + * ``` + * + * We _probably_ want to show `foo` from 'x', but not from 'y' or 'z'. However, if 'x' is not in a package.json, it + * will not appear in a `forEachExternalModuleToImportFrom` iteration. Furthermore, the order of iterations is not + * guaranteed, as it is host-dependent. Therefore, when presented with the symbol `foo` from module 'y' alone, we + * may not be sure whether or not it should go in the list. So, we’ll take the following steps: + * + * 1. Resolve alias `foo` from 'y' to the export declaration in 'x', get the symbol there, and see if that symbol is + * already in Bucket A (symbols we already know will be returned). If it is, put `foo` from 'y' in Bucket B + * (symbols that are aliases to symbols in Bucket A). If it’s not, put it in Bucket C. + * 2. Next, imagine we see `foo` from module 'z'. Again, we resolve the alias to the nearest export, which is in 'y'. + * At this point, if that nearest export from 'y' is in _any_ of the three buckets, we know the symbol in 'z' + * should never be returned in the final list, so put it in Bucket B. + * 3. Next, imagine we see `foo` from module 'x', the original. Syntactically, it doesn’t look like a re-export, so + * we can just check Bucket C to see if we put any aliases to the original in there. If they exist, throw them out. + * Put this symbol in Bucket A. + * 4. After we’ve iterated through every symbol of every module, any symbol left in Bucket C means that step 3 didn’t + * occur for that symbol---that is, the original symbol is not in Bucket A, so we should include the alias. Move + * everything from Bucket C to Bucket A. + */ + function getSymbolsFromOtherSourceFileExports(target, host) { + var cached = importSuggestionsCache && importSuggestionsCache.get(sourceFile.fileName, typeChecker, detailsEntryId && host.getProjectVersion ? host.getProjectVersion() : undefined); + if (cached) { + log("getSymbolsFromOtherSourceFileExports: Using cached list"); + return cached; + } + var startTime = ts.timestamp(); + log("getSymbolsFromOtherSourceFileExports: Recomputing list" + (detailsEntryId ? " for details entry" : "")); var seenResolvedModules = ts.createMap(); - ts.codefix.forEachExternalModuleToImportFrom(typeChecker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + /** Bucket B */ + var aliasesToAlreadyIncludedSymbols = ts.createMap(); + /** Bucket C */ + var aliasesToReturnIfOriginalsAreMissing = ts.createMap(); + /** Bucket A */ + var results = []; + /** Ids present in `results` for faster lookup */ + var resultSymbolIds = ts.createMap(); + ts.codefix.forEachExternalModuleToImportFrom(program, host, sourceFile, !detailsEntryId, function (moduleSymbol) { // Perf -- ignore other modules if this is a request for details if (detailsEntryId && detailsEntryId.source && ts.stripQuotes(moduleSymbol.name) !== detailsEntryId.source) { return; @@ -103589,41 +107760,75 @@ var ts; if (!ts.addToSeen(seenResolvedModules, ts.getSymbolId(resolvedModuleSymbol))) { return; } + // Don't add another completion for `export =` of a symbol that's already global. + // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. if (resolvedModuleSymbol !== moduleSymbol && - // Don't add another completion for `export =` of a symbol that's already global. - // So in `declare namespace foo {} declare module "foo" { export = foo; }`, there will just be the global completion for `foo`. - ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) { - symbols.push(resolvedModuleSymbol); - symbolToSortTextMap[ts.getSymbolId(resolvedModuleSymbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(resolvedModuleSymbol)] = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: false }; + ts.every(resolvedModuleSymbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator && !ts.findAncestor(d, ts.isGlobalScopeAugmentation); })) { + pushSymbol(resolvedModuleSymbol, moduleSymbol, /*skipFilter*/ true); } for (var _i = 0, _a = typeChecker.getExportsOfModule(moduleSymbol); _i < _a.length; _i++) { var symbol = _a[_i]; - // Don't add a completion for a re-export, only for the original. - // The actual import fix might end up coming from a re-export -- we don't compute that until getting completion details. - // This is just to avoid adding duplicate completion entries. - // - // If `symbol.parent !== ...`, this is an `export * from "foo"` re-export. Those don't create new symbols. - if (typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol - || ts.some(symbol.declarations, function (d) { - // If `!!d.name.originalKeywordKind`, this is `export { _break as break };` -- skip this and prefer the keyword completion. - // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). - return ts.isExportSpecifier(d) && (d.propertyName ? ts.isIdentifierANonContextualKeyword(d.name) : !!d.parent.parent.moduleSpecifier); - })) { + // If this is `export { _break as break };` (a keyword) -- skip this and prefer the keyword completion. + if (ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !!d.propertyName && ts.isIdentifierANonContextualKeyword(d.name); })) { continue; } - var isDefaultExport = symbol.escapedName === "default" /* Default */; - if (isDefaultExport) { - symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + var symbolId = ts.getSymbolId(symbol).toString(); + // If `symbol.parent !== moduleSymbol`, this is an `export * from "foo"` re-export. Those don't create new symbols. + var isExportStarFromReExport = typeChecker.getMergedSymbol(symbol.parent) !== resolvedModuleSymbol; + // If `!!d.parent.parent.moduleSpecifier`, this is `export { foo } from "foo"` re-export, which creates a new symbol (thus isn't caught by the first check). + if (isExportStarFromReExport || ts.some(symbol.declarations, function (d) { return ts.isExportSpecifier(d) && !d.propertyName && !!d.parent.parent.moduleSpecifier; })) { + // Walk the export chain back one module (step 1 or 2 in diagrammed example). + // Or, in the case of `export * from "foo"`, `symbol` already points to the original export, so just use that. + var nearestExportSymbol = isExportStarFromReExport ? symbol : getNearestExportSymbol(symbol); + if (!nearestExportSymbol) + continue; + var nearestExportSymbolId = ts.getSymbolId(nearestExportSymbol).toString(); + var symbolHasBeenSeen = resultSymbolIds.has(nearestExportSymbolId) || aliasesToAlreadyIncludedSymbols.has(nearestExportSymbolId); + if (!symbolHasBeenSeen) { + aliasesToReturnIfOriginalsAreMissing.set(nearestExportSymbolId, { alias: symbol, moduleSymbol: moduleSymbol }); + aliasesToAlreadyIncludedSymbols.set(symbolId, true); + } + else { + // Perf - we know this symbol is an alias to one that’s already covered in `symbols`, so store it here + // in case another symbol re-exports this one; that way we can short-circuit as soon as we see this symbol id. + ts.addToSeen(aliasesToAlreadyIncludedSymbols, symbolId); + } } - var origin = { kind: 3 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; - if (detailsEntryId || stringContainsCharactersInOrder(getSymbolName(symbol, origin, target).toLowerCase(), tokenTextLowerCase)) { - symbols.push(symbol); - symbolToSortTextMap[ts.getSymbolId(symbol)] = SortText.AutoImportSuggestions; - symbolToOriginInfoMap[ts.getSymbolId(symbol)] = origin; + else { + // This is not a re-export, so see if we have any aliases pending and remove them (step 3 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.delete(symbolId); + pushSymbol(symbol, moduleSymbol); } } }); + // By this point, any potential duplicates that were actually duplicates have been + // removed, so the rest need to be added. (Step 4 in diagrammed example) + aliasesToReturnIfOriginalsAreMissing.forEach(function (_a) { + var alias = _a.alias, moduleSymbol = _a.moduleSymbol; + return pushSymbol(alias, moduleSymbol); + }); + log("getSymbolsFromOtherSourceFileExports: " + (ts.timestamp() - startTime)); + return results; + function pushSymbol(symbol, moduleSymbol, skipFilter) { + if (skipFilter === void 0) { skipFilter = false; } + var isDefaultExport = symbol.escapedName === "default" /* Default */; + if (isDefaultExport) { + symbol = ts.getLocalSymbolForExportDefault(symbol) || symbol; + } + ts.addToSeen(resultSymbolIds, ts.getSymbolId(symbol)); + var origin = { kind: 4 /* Export */, moduleSymbol: moduleSymbol, isDefaultExport: isDefaultExport }; + results.push({ + symbol: symbol, + symbolName: getSymbolName(symbol, origin, target), + origin: origin, + skipFilter: skipFilter, + }); + } + } + function getNearestExportSymbol(fromSymbol) { + return findAlias(typeChecker, fromSymbol, function (alias) { + return ts.some(alias.declarations, function (d) { return ts.isExportSpecifier(d) || !!d.localSymbol; }); + }); } /** * True if you could remove some characters in `a` to get `b`. @@ -103670,12 +107875,12 @@ var ts; if (contextToken.kind === 11 /* JsxText */) { return true; } - if (contextToken.kind === 30 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 263 /* JsxOpeningElement */) { + if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 266 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 264 /* JsxClosingElement */ || contextToken.parent.kind === 262 /* JsxSelfClosingElement */) { - return !!contextToken.parent.parent && contextToken.parent.parent.kind === 261 /* JsxElement */; + if (contextToken.parent.kind === 267 /* JsxClosingElement */ || contextToken.parent.kind === 265 /* JsxSelfClosingElement */) { + return !!contextToken.parent.parent && contextToken.parent.parent.kind === 264 /* JsxElement */; } } return false; @@ -103686,40 +107891,40 @@ var ts; // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(previousToken)) { case 27 /* CommaToken */: - return containingNodeKind === 192 /* CallExpression */ // func( a, | - || containingNodeKind === 158 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 193 /* NewExpression */ // new C(a, | - || containingNodeKind === 188 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 205 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 166 /* FunctionType */; // var x: (s: string, list| + return containingNodeKind === 195 /* CallExpression */ // func( a, | + || containingNodeKind === 161 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 196 /* NewExpression */ // new C(a, | + || containingNodeKind === 191 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 208 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 169 /* FunctionType */; // var x: (s: string, list| case 20 /* OpenParenToken */: - return containingNodeKind === 192 /* CallExpression */ // func( | - || containingNodeKind === 158 /* Constructor */ // constructor( | - || containingNodeKind === 193 /* NewExpression */ // new C(a| - || containingNodeKind === 196 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 178 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + return containingNodeKind === 195 /* CallExpression */ // func( | + || containingNodeKind === 161 /* Constructor */ // constructor( | + || containingNodeKind === 196 /* NewExpression */ // new C(a| + || containingNodeKind === 199 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 181 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ case 22 /* OpenBracketToken */: - return containingNodeKind === 188 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 163 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 150 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 131 /* ModuleKeyword */: // module | - case 132 /* NamespaceKeyword */: // namespace | + return containingNodeKind === 191 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 166 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 153 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 134 /* ModuleKeyword */: // module | + case 135 /* NamespaceKeyword */: // namespace | return true; case 24 /* DotToken */: - return containingNodeKind === 245 /* ModuleDeclaration */; // module A.| + return containingNodeKind === 248 /* ModuleDeclaration */; // module A.| case 18 /* OpenBraceToken */: - return containingNodeKind === 241 /* ClassDeclaration */; // class A{ | - case 60 /* EqualsToken */: - return containingNodeKind === 238 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 205 /* BinaryExpression */; // x = a| + return containingNodeKind === 244 /* ClassDeclaration */; // class A{ | + case 62 /* EqualsToken */: + return containingNodeKind === 241 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 208 /* BinaryExpression */; // x = a| case 15 /* TemplateHead */: - return containingNodeKind === 207 /* TemplateExpression */; // `aa ${| + return containingNodeKind === 210 /* TemplateExpression */; // `aa ${| case 16 /* TemplateMiddle */: - return containingNodeKind === 217 /* TemplateSpan */; // `aa ${10} dd ${| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */; // class A{ public | + return containingNodeKind === 220 /* TemplateSpan */; // `aa ${10} dd ${| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */; // class A{ public | } } return false; @@ -103746,8 +107951,8 @@ var ts; completionKind = 0 /* ObjectPropertyDeclaration */; var typeMembers; var existingMembers; - if (objectLikeContainer.kind === 189 /* ObjectLiteralExpression */) { - var typeForObject = typeChecker.getContextualType(objectLikeContainer); + if (objectLikeContainer.kind === 192 /* ObjectLiteralExpression */) { + var typeForObject = typeChecker.getContextualType(objectLikeContainer, 4 /* Completion */); if (!typeForObject) return 2 /* Fail */; isNewIdentifierLocation = ts.hasIndexSignature(typeForObject); @@ -103755,7 +107960,7 @@ var ts; existingMembers = objectLikeContainer.properties; } else { - ts.Debug.assert(objectLikeContainer.kind === 185 /* ObjectBindingPattern */); + ts.Debug.assert(objectLikeContainer.kind === 188 /* ObjectBindingPattern */); // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -103766,12 +107971,12 @@ var ts; // through type declaration or inference. // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function - var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 228 /* ForOfStatement */; - if (!canGetType && rootDeclaration.kind === 152 /* Parameter */) { + var canGetType = ts.hasInitializer(rootDeclaration) || ts.hasType(rootDeclaration) || rootDeclaration.parent.parent.kind === 231 /* ForOfStatement */; + if (!canGetType && rootDeclaration.kind === 155 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 157 /* MethodDeclaration */ || rootDeclaration.parent.kind === 160 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 160 /* MethodDeclaration */ || rootDeclaration.parent.kind === 163 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -103788,6 +107993,7 @@ var ts; // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, ts.Debug.assertDefined(existingMembers)); } + setSortTextToOptionalMember(); return 1 /* Success */; } /** @@ -103813,7 +108019,7 @@ var ts; return 0 /* Continue */; // cursor is in an import clause // try to show exported member for imported module - var moduleSpecifier = (namedImportsOrExports.kind === 253 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; + var moduleSpecifier = (namedImportsOrExports.kind === 256 /* NamedImports */ ? namedImportsOrExports.parent.parent : namedImportsOrExports.parent).moduleSpecifier; var moduleSpecifierSymbol = typeChecker.getSymbolAtLocation(moduleSpecifier); // TODO: GH#18217 if (!moduleSpecifierSymbol) return 2 /* Fail */; @@ -103836,7 +108042,7 @@ var ts; completionKind = 3 /* MemberLike */; // Declaring new property/method/accessor isNewIdentifierLocation = true; - keywordFilters = contextToken.kind === 40 /* AsteriskToken */ ? 0 /* None */ : + keywordFilters = contextToken.kind === 41 /* AsteriskToken */ ? 0 /* None */ : ts.isClassLike(decl) ? 2 /* ClassElementKeywords */ : 3 /* InterfaceElementKeywords */; // If you're in an interface you don't want to repeat things from super-interface. So just stop here. if (!ts.isClassLike(decl)) @@ -103844,7 +108050,7 @@ var ts; var classElement = contextToken.kind === 26 /* SemicolonToken */ ? contextToken.parent.parent : contextToken.parent; var classElementModifierFlags = ts.isClassElement(classElement) ? ts.getModifierFlags(classElement) : 0 /* None */; // If this is context token is not something we are editing now, consider if this would lead to be modifier - if (contextToken.kind === 73 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { + if (contextToken.kind === 75 /* Identifier */ && !isCurrentlyEditingNode(contextToken)) { switch (contextToken.getText()) { case "private": classElementModifierFlags = classElementModifierFlags | 8 /* Private */; @@ -103879,9 +108085,9 @@ var ts; return parent; } break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined; - case 73 /* Identifier */: + case 75 /* Identifier */: return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent) ? contextToken.parent.parent : undefined; } @@ -103931,23 +108137,23 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 30 /* GreaterThanToken */: // End of a type argument list - case 29 /* LessThanSlashToken */: - case 42 /* SlashToken */: - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 269 /* JsxAttributes */: - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 262 /* JsxSelfClosingElement */ || parent.kind === 263 /* JsxOpeningElement */)) { - if (contextToken.kind === 30 /* GreaterThanToken */) { + case 31 /* GreaterThanToken */: // End of a type argument list + case 30 /* LessThanSlashToken */: + case 43 /* SlashToken */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 272 /* JsxAttributes */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 265 /* JsxSelfClosingElement */ || parent.kind === 266 /* JsxOpeningElement */)) { + if (contextToken.kind === 31 /* GreaterThanToken */) { var precedingToken = ts.findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); - if (!parent.typeArguments || (precedingToken && precedingToken.kind === 42 /* SlashToken */)) + if (!parent.typeArguments || (precedingToken && precedingToken.kind === 43 /* SlashToken */)) break; } return parent; } - else if (parent.kind === 268 /* JsxAttribute */) { + else if (parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103959,7 +108165,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 10 /* StringLiteral */: - if (parent && ((parent.kind === 268 /* JsxAttribute */) || (parent.kind === 270 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 271 /* JsxAttribute */) || (parent.kind === 273 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103969,8 +108175,8 @@ var ts; break; case 19 /* CloseBraceToken */: if (parent && - parent.kind === 271 /* JsxExpression */ && - parent.parent && parent.parent.kind === 268 /* JsxAttribute */) { + parent.kind === 274 /* JsxExpression */ && + parent.parent && parent.parent.kind === 271 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103978,7 +108184,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 270 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 273 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -103998,64 +108204,64 @@ var ts; var containingNodeKind = parent.kind; switch (contextToken.kind) { case 27 /* CommaToken */: - return containingNodeKind === 238 /* VariableDeclaration */ || - containingNodeKind === 239 /* VariableDeclarationList */ || - containingNodeKind === 220 /* VariableStatement */ || - containingNodeKind === 244 /* EnumDeclaration */ || // enum a { foo, | + return containingNodeKind === 241 /* VariableDeclaration */ || + containingNodeKind === 242 /* VariableDeclarationList */ || + containingNodeKind === 224 /* VariableStatement */ || + containingNodeKind === 247 /* EnumDeclaration */ || // enum a { foo, | isFunctionLikeButNotConstructor(containingNodeKind) || - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A= contextToken.pos); case 24 /* DotToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [.| - case 57 /* ColonToken */: - return containingNodeKind === 187 /* BindingElement */; // var {x :html| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [.| + case 58 /* ColonToken */: + return containingNodeKind === 190 /* BindingElement */; // var {x :html| case 22 /* OpenBracketToken */: - return containingNodeKind === 186 /* ArrayBindingPattern */; // var [x| + return containingNodeKind === 189 /* ArrayBindingPattern */; // var [x| case 20 /* OpenParenToken */: - return containingNodeKind === 275 /* CatchClause */ || + return containingNodeKind === 278 /* CatchClause */ || isFunctionLikeButNotConstructor(containingNodeKind); case 18 /* OpenBraceToken */: - return containingNodeKind === 244 /* EnumDeclaration */; // enum a { | - case 28 /* LessThanToken */: - return containingNodeKind === 241 /* ClassDeclaration */ || // class A< | - containingNodeKind === 210 /* ClassExpression */ || // var C = class D< | - containingNodeKind === 242 /* InterfaceDeclaration */ || // interface A< | - containingNodeKind === 243 /* TypeAliasDeclaration */ || // type List< | + return containingNodeKind === 247 /* EnumDeclaration */; // enum a { | + case 29 /* LessThanToken */: + return containingNodeKind === 244 /* ClassDeclaration */ || // class A< | + containingNodeKind === 213 /* ClassExpression */ || // var C = class D< | + containingNodeKind === 245 /* InterfaceDeclaration */ || // interface A< | + containingNodeKind === 246 /* TypeAliasDeclaration */ || // type List< | ts.isFunctionLikeKind(containingNodeKind); - case 117 /* StaticKeyword */: - return containingNodeKind === 155 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); + case 119 /* StaticKeyword */: + return containingNodeKind === 158 /* PropertyDeclaration */ && !ts.isClassLike(parent.parent); case 25 /* DotDotDotToken */: - return containingNodeKind === 152 /* Parameter */ || - (!!parent.parent && parent.parent.kind === 186 /* ArrayBindingPattern */); // var [...z| - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - return containingNodeKind === 152 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); - case 120 /* AsKeyword */: - return containingNodeKind === 254 /* ImportSpecifier */ || - containingNodeKind === 258 /* ExportSpecifier */ || - containingNodeKind === 252 /* NamespaceImport */; - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + return containingNodeKind === 155 /* Parameter */ || + (!!parent.parent && parent.parent.kind === 189 /* ArrayBindingPattern */); // var [...z| + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + return containingNodeKind === 155 /* Parameter */ && !ts.isConstructorDeclaration(parent.parent); + case 122 /* AsKeyword */: + return containingNodeKind === 257 /* ImportSpecifier */ || + containingNodeKind === 261 /* ExportSpecifier */ || + containingNodeKind === 255 /* NamespaceImport */; + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: return !isFromObjectTypeDeclaration(contextToken); - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 111 /* InterfaceKeyword */: - case 91 /* FunctionKeyword */: - case 106 /* VarKeyword */: - case 93 /* ImportKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 118 /* YieldKeyword */: - case 141 /* TypeKeyword */: // type htm| + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 113 /* InterfaceKeyword */: + case 93 /* FunctionKeyword */: + case 108 /* VarKeyword */: + case 95 /* ImportKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 120 /* YieldKeyword */: + case 144 /* TypeKeyword */: // type htm| return true; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return ts.isFunctionLike(contextToken.parent) && !ts.isMethodDeclaration(contextToken.parent); } // If the previous token is keyword correspoding to class member completion keyword @@ -104076,22 +108282,22 @@ var ts; } // Previous token may have been a keyword that was converted to an identifier. switch (keywordForNode(contextToken)) { - case 119 /* AbstractKeyword */: - case 77 /* ClassKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 91 /* FunctionKeyword */: - case 111 /* InterfaceKeyword */: - case 112 /* LetKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 117 /* StaticKeyword */: - case 106 /* VarKeyword */: - case 118 /* YieldKeyword */: + case 121 /* AbstractKeyword */: + case 79 /* ClassKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 93 /* FunctionKeyword */: + case 113 /* InterfaceKeyword */: + case 114 /* LetKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 119 /* StaticKeyword */: + case 108 /* VarKeyword */: + case 120 /* YieldKeyword */: return true; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return ts.isPropertyDeclaration(contextToken.parent); } return ts.isDeclarationName(contextToken) @@ -104101,7 +108307,7 @@ var ts; && !(ts.isClassLike(contextToken.parent) && (contextToken !== previousToken || position > previousToken.end)); } function isFunctionLikeButNotConstructor(kind) { - return ts.isFunctionLikeKind(kind) && kind !== 158 /* Constructor */; + return ts.isFunctionLikeKind(kind) && kind !== 161 /* Constructor */; } function isDotOfNumericLiteral(contextToken) { if (contextToken.kind === 8 /* NumericLiteral */) { @@ -104120,16 +108326,18 @@ var ts; if (existingMembers.length === 0) { return contextualMemberSymbols; } + var membersDeclaredBySpreadAssignment = ts.createMap(); var existingMemberNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 276 /* PropertyAssignment */ && - m.kind !== 277 /* ShorthandPropertyAssignment */ && - m.kind !== 187 /* BindingElement */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 279 /* PropertyAssignment */ && + m.kind !== 280 /* ShorthandPropertyAssignment */ && + m.kind !== 190 /* BindingElement */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */ && + m.kind !== 281 /* SpreadAssignment */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -104137,9 +108345,12 @@ var ts; continue; } var existingName = void 0; - if (ts.isBindingElement(m) && m.propertyName) { + if (ts.isSpreadAssignment(m)) { + setMembersDeclaredBySpreadAssignment(m, membersDeclaredBySpreadAssignment); + } + else if (ts.isBindingElement(m) && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 73 /* Identifier */) { + if (m.propertyName.kind === 75 /* Identifier */) { existingName = m.propertyName.escapedText; } } @@ -104152,7 +108363,40 @@ var ts; } existingMemberNames.set(existingName, true); // TODO: GH#18217 } - return contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + var filteredSymbols = contextualMemberSymbols.filter(function (m) { return !existingMemberNames.get(m.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; + } + function setMembersDeclaredBySpreadAssignment(declaration, membersDeclaredBySpreadAssignment) { + var expression = declaration.expression; + var symbol = typeChecker.getSymbolAtLocation(expression); + var type = symbol && typeChecker.getTypeOfSymbolAtLocation(symbol, expression); + var properties = type && type.properties; + if (properties) { + properties.forEach(function (property) { + membersDeclaredBySpreadAssignment.set(property.name, true); + }); + } + } + // Set SortText to OptionalMember if it is an optinoal member + function setSortTextToOptionalMember() { + symbols.forEach(function (m) { + if (m.flags & 16777216 /* Optional */) { + symbolToSortTextMap[ts.getSymbolId(m)] = symbolToSortTextMap[ts.getSymbolId(m)] || SortText.OptionalMember; + } + }); + } + // Set SortText to MemberDeclaredBySpreadAssignment if it is fulfilled by spread assignment + function setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, contextualMemberSymbols) { + if (membersDeclaredBySpreadAssignment.size === 0) { + return; + } + for (var _i = 0, contextualMemberSymbols_1 = contextualMemberSymbols; _i < contextualMemberSymbols_1.length; _i++) { + var contextualMemberSymbol = contextualMemberSymbols_1[_i]; + if (membersDeclaredBySpreadAssignment.has(contextualMemberSymbol.name)) { + symbolToSortTextMap[ts.getSymbolId(contextualMemberSymbol)] = SortText.MemberDeclaredBySpreadAssignment; + } + } } /** * Filters out completion suggestions for class elements. @@ -104164,10 +108408,10 @@ var ts; for (var _i = 0, existingMembers_2 = existingMembers; _i < existingMembers_2.length; _i++) { var m = existingMembers_2[_i]; // Ignore omitted expressions for missing members - if (m.kind !== 155 /* PropertyDeclaration */ && - m.kind !== 157 /* MethodDeclaration */ && - m.kind !== 159 /* GetAccessor */ && - m.kind !== 160 /* SetAccessor */) { + if (m.kind !== 158 /* PropertyDeclaration */ && + m.kind !== 160 /* MethodDeclaration */ && + m.kind !== 162 /* GetAccessor */ && + m.kind !== 163 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -104201,17 +108445,23 @@ var ts; */ function filterJsxAttributes(symbols, attributes) { var seenNames = ts.createUnderscoreEscapedMap(); + var membersDeclaredBySpreadAssignment = ts.createMap(); for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) { var attr = attributes_1[_i]; // If this is the current item we are editing right now, do not filter it out if (isCurrentlyEditingNode(attr)) { continue; } - if (attr.kind === 268 /* JsxAttribute */) { + if (attr.kind === 271 /* JsxAttribute */) { seenNames.set(attr.name.escapedText, true); } + else if (ts.isJsxSpreadAttribute(attr)) { + setMembersDeclaredBySpreadAssignment(attr, membersDeclaredBySpreadAssignment); + } } - return symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + var filteredSymbols = symbols.filter(function (a) { return !seenNames.get(a.escapedName); }); + setSortTextToMemberDeclaredBySpreadAssignment(membersDeclaredBySpreadAssignment, filteredSymbols); + return filteredSymbols; } function isCurrentlyEditingNode(node) { return node.getStart(sourceFile) <= position && position <= node.getEnd(); @@ -104222,7 +108472,7 @@ var ts; if (name === undefined // If the symbol is external module, don't show it in the completion list // (i.e declare module "http" { const x; } | // <= request completion here, "http" should not be there) - || symbol.flags & 1536 /* Module */ && ts.startsWithQuote(name) + || symbol.flags & 1536 /* Module */ && ts.isSingleOrDoubleQuote(name.charCodeAt(0)) // If the symbol is the internal name of an ES symbol, it is not a valid entry. Internal names for ES symbols start with "__@" || ts.isKnownSymbol(symbol)) { return undefined; @@ -104251,7 +108501,7 @@ var ts; var _keywordCompletions = []; var allKeywordsCompletions = ts.memoize(function () { var res = []; - for (var i = 74 /* FirstKeyword */; i <= 148 /* LastKeyword */; i++) { + for (var i = 76 /* FirstKeyword */; i <= 151 /* LastKeyword */; i++) { res.push({ name: ts.tokenToString(i), kind: "keyword" /* keyword */, @@ -104277,9 +108527,11 @@ var ts; return false; case 1 /* All */: return isFunctionLikeBodyKeyword(kind) - || kind === 126 /* DeclareKeyword */ - || kind === 131 /* ModuleKeyword */ - || ts.isTypeKeyword(kind) && kind !== 142 /* UndefinedKeyword */; + || kind === 129 /* DeclareKeyword */ + || kind === 134 /* ModuleKeyword */ + || kind === 144 /* TypeKeyword */ + || kind === 135 /* NamespaceKeyword */ + || ts.isTypeKeyword(kind) && kind !== 145 /* UndefinedKeyword */; case 5 /* FunctionLikeBodyKeywords */: return isFunctionLikeBodyKeyword(kind); case 2 /* ClassElementKeywords */: @@ -104289,7 +108541,7 @@ var ts; case 4 /* ConstructorParameterKeywords */: return ts.isParameterPropertyModifier(kind); case 6 /* TypeAssertionKeywords */: - return ts.isTypeKeyword(kind) || kind === 78 /* ConstKeyword */; + return ts.isTypeKeyword(kind) || kind === 80 /* ConstKeyword */; case 7 /* TypeKeywords */: return ts.isTypeKeyword(kind); default: @@ -104299,55 +108551,55 @@ var ts; } function isTypeScriptOnlyKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 121 /* AnyKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 126 /* DeclareKeyword */: - case 85 /* EnumKeyword */: - case 146 /* GlobalKeyword */: - case 110 /* ImplementsKeyword */: - case 128 /* InferKeyword */: - case 111 /* InterfaceKeyword */: - case 129 /* IsKeyword */: - case 130 /* KeyOfKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 133 /* NeverKeyword */: - case 136 /* NumberKeyword */: - case 137 /* ObjectKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: - case 139 /* StringKeyword */: - case 140 /* SymbolKeyword */: - case 141 /* TypeKeyword */: - case 143 /* UniqueKeyword */: - case 144 /* UnknownKeyword */: + case 121 /* AbstractKeyword */: + case 124 /* AnyKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 129 /* DeclareKeyword */: + case 87 /* EnumKeyword */: + case 149 /* GlobalKeyword */: + case 112 /* ImplementsKeyword */: + case 131 /* InferKeyword */: + case 113 /* InterfaceKeyword */: + case 132 /* IsKeyword */: + case 133 /* KeyOfKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 136 /* NeverKeyword */: + case 139 /* NumberKeyword */: + case 140 /* ObjectKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: + case 142 /* StringKeyword */: + case 143 /* SymbolKeyword */: + case 144 /* TypeKeyword */: + case 146 /* UniqueKeyword */: + case 147 /* UnknownKeyword */: return true; default: return false; } } function isInterfaceOrTypeLiteralCompletionKeyword(kind) { - return kind === 134 /* ReadonlyKeyword */; + return kind === 137 /* ReadonlyKeyword */; } function isClassMemberCompletionKeyword(kind) { switch (kind) { - case 119 /* AbstractKeyword */: - case 125 /* ConstructorKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - case 122 /* AsyncKeyword */: + case 121 /* AbstractKeyword */: + case 128 /* ConstructorKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + case 125 /* AsyncKeyword */: return true; default: return ts.isClassMemberModifier(kind); } } function isFunctionLikeBodyKeyword(kind) { - return kind === 122 /* AsyncKeyword */ - || kind === 123 /* AwaitKeyword */ + return kind === 125 /* AsyncKeyword */ + || kind === 126 /* AwaitKeyword */ || !ts.isContextualKeyword(kind) && !isClassMemberCompletionKeyword(kind); } function keywordForNode(node) { @@ -104385,7 +108637,7 @@ var ts; function tryGetObjectTypeDeclarationCompletionContainer(sourceFile, contextToken, location, position) { // class c { method() { } | method2() { } } switch (location.kind) { - case 314 /* SyntaxList */: + case 317 /* SyntaxList */: return ts.tryCast(location.parent, ts.isObjectTypeDeclaration); case 1 /* EndOfFileToken */: var cls = ts.tryCast(ts.lastOrUndefined(ts.cast(location.parent, ts.isSourceFile).statements), ts.isObjectTypeDeclaration); @@ -104393,7 +108645,7 @@ var ts; return cls; } break; - case 73 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } + case 75 /* Identifier */: // class c extends React.Component { a: () => 1\n compon| } if (isFromObjectTypeDeclaration(location)) { return ts.findAncestor(location, ts.isObjectTypeDeclaration); } @@ -104419,7 +108671,7 @@ var ts; return undefined; } var isValidKeyword = ts.isClassLike(contextToken.parent.parent) ? isClassMemberCompletionKeyword : isInterfaceOrTypeLiteralCompletionKeyword; - return (isValidKeyword(contextToken.kind) || contextToken.kind === 40 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 + return (isValidKeyword(contextToken.kind) || contextToken.kind === 41 /* AsteriskToken */ || ts.isIdentifier(contextToken) && isValidKeyword(ts.stringToToken(contextToken.text))) // TODO: GH#18217 ? contextToken.parent.parent : undefined; } } @@ -104439,11 +108691,11 @@ var ts; return !!contextToken && ts.isStringLiteralOrTemplate(contextToken) && position === contextToken.getStart(sourceFile) + 1; case "<": // Opening JSX tag - return !!contextToken && contextToken.kind === 28 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); + return !!contextToken && contextToken.kind === 29 /* LessThanToken */ && (!ts.isBinaryExpression(contextToken.parent) || binaryExpressionMayBeOpenTag(contextToken.parent)); case "/": return !!contextToken && (ts.isStringLiteralLike(contextToken) ? !!ts.tryGetImportFromModuleSpecifier(contextToken) - : contextToken.kind === 42 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); + : contextToken.kind === 43 /* SlashToken */ && ts.isJsxClosingElement(contextToken.parent)); default: return ts.Debug.assertNever(triggerCharacter); } @@ -104452,6 +108704,14 @@ var ts; var left = _a.left; return ts.nodeIsMissing(left); } + function findAlias(typeChecker, symbol, predicate) { + var currentAlias = symbol; + while (currentAlias.flags & 2097152 /* Alias */ && (currentAlias = typeChecker.getImmediateAliasedSymbol(currentAlias))) { + if (predicate(currentAlias)) { + return currentAlias; + } + } + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -104504,40 +108764,40 @@ var ts; } function getHighlightSpans(node, sourceFile) { switch (node.kind) { - case 92 /* IfKeyword */: - case 84 /* ElseKeyword */: + case 94 /* IfKeyword */: + case 86 /* ElseKeyword */: return ts.isIfStatement(node.parent) ? getIfElseOccurrences(node.parent, sourceFile) : undefined; - case 98 /* ReturnKeyword */: + case 100 /* ReturnKeyword */: return useParent(node.parent, ts.isReturnStatement, getReturnOccurrences); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return useParent(node.parent, ts.isThrowStatement, getThrowOccurrences); - case 104 /* TryKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: - var tryStatement = node.kind === 76 /* CatchKeyword */ ? node.parent.parent : node.parent; + case 106 /* TryKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: + var tryStatement = node.kind === 78 /* CatchKeyword */ ? node.parent.parent : node.parent; return useParent(tryStatement, ts.isTryStatement, getTryCatchFinallyOccurrences); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return useParent(node.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 75 /* CaseKeyword */: - case 81 /* DefaultKeyword */: + case 77 /* CaseKeyword */: + case 83 /* DefaultKeyword */: return useParent(node.parent.parent.parent, ts.isSwitchStatement, getSwitchCaseDefaultOccurrences); - case 74 /* BreakKeyword */: - case 79 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 81 /* ContinueKeyword */: return useParent(node.parent, ts.isBreakOrContinueStatement, getBreakOrContinueStatementOccurrences); - case 90 /* ForKeyword */: - case 108 /* WhileKeyword */: - case 83 /* DoKeyword */: + case 92 /* ForKeyword */: + case 110 /* WhileKeyword */: + case 85 /* DoKeyword */: return useParent(node.parent, function (n) { return ts.isIterationStatement(n, /*lookInLabeledStatements*/ true); }, getLoopBreakContinueOccurrences); - case 125 /* ConstructorKeyword */: - return getFromAllDeclarations(ts.isConstructorDeclaration, [125 /* ConstructorKeyword */]); - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: - return getFromAllDeclarations(ts.isAccessor, [127 /* GetKeyword */, 138 /* SetKeyword */]); - case 123 /* AwaitKeyword */: + case 128 /* ConstructorKeyword */: + return getFromAllDeclarations(ts.isConstructorDeclaration, [128 /* ConstructorKeyword */]); + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: + return getFromAllDeclarations(ts.isAccessor, [130 /* GetKeyword */, 141 /* SetKeyword */]); + case 126 /* AwaitKeyword */: return useParent(node.parent, ts.isAwaitExpression, getAsyncAndAwaitOccurrences); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: return highlightSpans(getAsyncAndAwaitOccurrences(node)); - case 118 /* YieldKeyword */: + case 120 /* YieldKeyword */: return highlightSpans(getYieldOccurrences(node)); default: return ts.isModifierKind(node.kind) && (ts.isDeclaration(node.parent) || ts.isVariableStatement(node.parent)) @@ -104580,7 +108840,7 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (ts.isFunctionBlock(parent) || parent.kind === 285 /* SourceFile */) { + if (ts.isFunctionBlock(parent) || parent.kind === 288 /* SourceFile */) { return parent; } // A throw-statement is only owned by a try-statement if the try-statement has @@ -104612,16 +108872,16 @@ var ts; function getBreakOrContinueOwner(statement) { return ts.findAncestor(statement, function (node) { switch (node.kind) { - case 233 /* SwitchStatement */: - if (statement.kind === 229 /* ContinueStatement */) { + case 236 /* SwitchStatement */: + if (statement.kind === 232 /* ContinueStatement */) { return false; } // falls through - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return !statement.label || isLabeledBy(node, statement.label.escapedText); default: // Don't cross function boundaries. @@ -104637,11 +108897,11 @@ var ts; // Types of node whose children might have modifiers. var container = declaration.parent; switch (container.kind) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 219 /* Block */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 222 /* Block */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // Container is either a class declaration or the declaration is a classDeclaration if (modifierFlag & 128 /* Abstract */ && ts.isClassDeclaration(declaration)) { return __spreadArrays(declaration.members, [declaration]); @@ -104649,14 +108909,14 @@ var ts; else { return container.statements; } - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: return __spreadArrays(container.parameters, (ts.isClassLike(container.parent) ? container.parent.members : [])); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 172 /* TypeLiteral */: var nodes = container.members; // If we're an accessibility modifier, we're in an instance member and should search // the constructor's parameter list for instance members as well. @@ -104687,12 +108947,12 @@ var ts; } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 90 /* ForKeyword */, 108 /* WhileKeyword */, 83 /* DoKeyword */)) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 92 /* ForKeyword */, 110 /* WhileKeyword */, 85 /* DoKeyword */)) { // If we succeeded and got a do-while loop, then start looking for a 'while' keyword. - if (loopNode.kind === 224 /* DoStatement */) { + if (loopNode.kind === 227 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 108 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 110 /* WhileKeyword */)) { break; } } @@ -104700,7 +108960,7 @@ var ts; } ts.forEach(aggregateAllBreakAndContinueStatements(loopNode.statement), function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */, 79 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */, 81 /* ContinueKeyword */); } }); return keywords; @@ -104709,13 +108969,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -104723,13 +108983,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 100 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 102 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 75 /* CaseKeyword */, 81 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 77 /* CaseKeyword */, 83 /* DefaultKeyword */); ts.forEach(aggregateAllBreakAndContinueStatements(clause), function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 74 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 76 /* BreakKeyword */); } }); }); @@ -104737,13 +108997,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 104 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 106 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 76 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 78 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 89 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 91 /* FinallyKeyword */); } return keywords; } @@ -104754,13 +109014,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); } return keywords; @@ -104772,11 +109032,11 @@ var ts; } var keywords = []; ts.forEachReturnStatement(ts.cast(func.body, ts.isBlock), function (returnStatement) { - keywords.push(ts.findChildOfKind(returnStatement, 98 /* ReturnKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(returnStatement, 100 /* ReturnKeyword */, sourceFile)); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - keywords.push(ts.findChildOfKind(throwStatement, 102 /* ThrowKeyword */, sourceFile)); + keywords.push(ts.findChildOfKind(throwStatement, 104 /* ThrowKeyword */, sourceFile)); }); return keywords; } @@ -104788,13 +109048,13 @@ var ts; var keywords = []; if (func.modifiers) { func.modifiers.forEach(function (modifier) { - pushKeywordIf(keywords, modifier, 122 /* AsyncKeyword */); + pushKeywordIf(keywords, modifier, 125 /* AsyncKeyword */); }); } ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isAwaitExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 123 /* AwaitKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 126 /* AwaitKeyword */); } }); }); @@ -104809,7 +109069,7 @@ var ts; ts.forEachChild(func, function (child) { traverseWithoutCrossingFunction(child, function (node) { if (ts.isYieldExpression(node)) { - pushKeywordIf(keywords, node.getFirstToken(), 118 /* YieldKeyword */); + pushKeywordIf(keywords, node.getFirstToken(), 120 /* YieldKeyword */); } }); }); @@ -104828,7 +109088,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 84 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 86 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombineElseAndIf = true; @@ -104863,10 +109123,10 @@ var ts; // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (true) { var children = ifStatement.getChildren(sourceFile); - pushKeywordIf(keywords, children[0], 92 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 94 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 84 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 86 /* ElseKeyword */)) { break; } } @@ -105082,12 +109342,12 @@ var ts; if (cancellationToken) cancellationToken.throwIfCancellationRequested(); switch (direct.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (!isAvailableThroughGlobal) { var parent = direct.parent; - if (exportKind === 2 /* ExportEquals */ && parent.kind === 238 /* VariableDeclaration */) { + if (exportKind === 2 /* ExportEquals */ && parent.kind === 241 /* VariableDeclaration */) { var name = parent.name; - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { directImports.push(name); break; } @@ -105096,22 +109356,22 @@ var ts; addIndirectUser(direct.getSourceFile()); } break; - case 73 /* Identifier */: // for 'const x = require("y"); + case 75 /* Identifier */: // for 'const x = require("y"); break; // TODO: GH#23879 - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */), /*alreadyAddedDirect*/ false); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: directImports.push(direct); var namedBindings = direct.importClause && direct.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 255 /* NamespaceImport */) { handleNamespaceImport(direct, namedBindings.name, /*isReExport*/ false, /*alreadyAddedDirect*/ true); } else if (!isAvailableThroughGlobal && ts.isDefaultImport(direct)) { addIndirectUser(getSourceFileLikeForImportDeclaration(direct)); // Add a check for indirect uses to handle synthetic default imports } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (!direct.exportClause) { // This is `export * from "foo"`, so imports of this module may import the export too. handleDirectImports(getContainingModuleSymbol(direct, checker)); @@ -105121,7 +109381,7 @@ var ts; directImports.push(direct); } break; - case 184 /* ImportType */: + case 187 /* ImportType */: directImports.push(direct); break; default: @@ -105138,7 +109398,7 @@ var ts; } else if (!isAvailableThroughGlobal) { var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); - ts.Debug.assert(sourceFileLike.kind === 285 /* SourceFile */ || sourceFileLike.kind === 245 /* ModuleDeclaration */); + ts.Debug.assert(sourceFileLike.kind === 288 /* SourceFile */ || sourceFileLike.kind === 248 /* ModuleDeclaration */); if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { addIndirectUsers(sourceFileLike); } @@ -105193,17 +109453,17 @@ var ts; } return { importSearches: importSearches, singleReferences: singleReferences }; function handleImport(decl) { - if (decl.kind === 249 /* ImportEqualsDeclaration */) { + if (decl.kind === 252 /* ImportEqualsDeclaration */) { if (isExternalModuleImportEquals(decl)) { handleNamespaceImportLike(decl.name); } return; } - if (decl.kind === 73 /* Identifier */) { + if (decl.kind === 75 /* Identifier */) { handleNamespaceImportLike(decl); return; } - if (decl.kind === 184 /* ImportType */) { + if (decl.kind === 187 /* ImportType */) { if (decl.qualifier) { if (ts.isIdentifier(decl.qualifier) && decl.qualifier.escapedText === ts.symbolName(exportSymbol)) { singleReferences.push(decl.qualifier); @@ -105218,17 +109478,17 @@ var ts; if (decl.moduleSpecifier.kind !== 10 /* StringLiteral */) { return; } - if (decl.kind === 256 /* ExportDeclaration */) { + if (decl.kind === 259 /* ExportDeclaration */) { searchForNamedImport(decl.exportClause); return; } var _a = decl.importClause || { name: undefined, namedBindings: undefined }, name = _a.name, namedBindings = _a.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: handleNamespaceImportLike(namedBindings.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: // 'default' might be accessed as a named import `{ default as foo }`. if (exportKind === 0 /* Named */ || exportKind === 1 /* Default */) { searchForNamedImport(namedBindings); @@ -105278,7 +109538,7 @@ var ts; } } else { - var localSymbol = element.kind === 258 /* ExportSpecifier */ && element.propertyName + var localSymbol = element.kind === 261 /* ExportSpecifier */ && element.propertyName ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. : checker.getSymbolAtLocation(name); addSearch(name, localSymbol); @@ -105307,7 +109567,7 @@ var ts; for (var _i = 0, sourceFiles_1 = sourceFiles; _i < sourceFiles_1.length; _i++) { var referencingFile = sourceFiles_1[_i]; var searchSourceFile = searchModuleSymbol.valueDeclaration; - if (searchSourceFile.kind === 285 /* SourceFile */) { + if (searchSourceFile.kind === 288 /* SourceFile */) { for (var _a = 0, _b = referencingFile.referencedFiles; _a < _b.length; _a++) { var ref = _b[_a]; if (program.getSourceFileFromReference(referencingFile, ref) === searchSourceFile) { @@ -105355,7 +109615,7 @@ var ts; } /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ function forEachPossibleImportOrExportStatement(sourceFileLike, action) { - return ts.forEach(sourceFileLike.kind === 285 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return ts.forEach(sourceFileLike.kind === 288 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); }); } @@ -105370,15 +109630,15 @@ var ts; else { forEachPossibleImportOrExportStatement(sourceFile, function (statement) { switch (statement.kind) { - case 256 /* ExportDeclaration */: - case 250 /* ImportDeclaration */: { + case 259 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: { var decl = statement; if (decl.moduleSpecifier && ts.isStringLiteral(decl.moduleSpecifier)) { action(decl, decl.moduleSpecifier); } break; } - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { var decl = statement; if (isExternalModuleImportEquals(decl)) { action(decl, decl.moduleReference.expression); @@ -105402,7 +109662,7 @@ var ts; var parent = node.parent; var grandParent = parent.parent; if (symbol.exportSymbol) { - if (parent.kind === 190 /* PropertyAccessExpression */) { + if (parent.kind === 193 /* PropertyAccessExpression */) { // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. // So check that we are at the declaration. return symbol.declarations.some(function (d) { return d === parent; }) && ts.isBinaryExpression(grandParent) @@ -105536,13 +109796,13 @@ var ts; function isNodeImport(node) { var parent = node.parent; switch (parent.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return parent.name === node && isExternalModuleImportEquals(parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. return !parent.propertyName; - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: ts.Debug.assert(parent.name === node); return true; default: @@ -105575,21 +109835,21 @@ var ts; return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); } function getSourceFileLikeForImportDeclaration(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { return node.getSourceFile(); } var parent = node.parent; - if (parent.kind === 285 /* SourceFile */) { + if (parent.kind === 288 /* SourceFile */) { return parent; } - ts.Debug.assert(parent.kind === 246 /* ModuleBlock */); + ts.Debug.assert(parent.kind === 249 /* ModuleBlock */); return ts.cast(parent.parent, isAmbientModuleDeclaration); } function isAmbientModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; + return node.kind === 248 /* ModuleDeclaration */ && node.name.kind === 10 /* StringLiteral */; } function isExternalModuleImportEquals(eq) { - return eq.moduleReference.kind === 260 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; + return eq.moduleReference.kind === 263 /* ExternalModuleReference */ && eq.moduleReference.expression.kind === 10 /* StringLiteral */; } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -105638,7 +109898,7 @@ var ts; if (ts.isInJSFile(node)) { var binaryExpression = ts.isBinaryExpression(node.parent) ? node.parent : - ts.isPropertyAccessExpression(node.parent) && + ts.isAccessExpression(node.parent) && ts.isBinaryExpression(node.parent.parent) && node.parent.parent.left === node.parent ? node.parent.parent : @@ -105682,7 +109942,7 @@ var ts; ((ts.isImportOrExportSpecifier(node.parent) || ts.isBindingElement(node.parent)) && node.parent.propertyName === node) || // Is default export - (node.kind === 81 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { + (node.kind === 83 /* DefaultKeyword */ && ts.hasModifier(node.parent, 513 /* ExportDefault */))) { return getContextNode(node.parent); } return undefined; @@ -105691,7 +109951,7 @@ var ts; if (!node) return undefined; switch (node.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !ts.isVariableDeclarationList(node.parent) || node.parent.declarations.length !== 1 ? node : ts.isVariableStatement(node.parent.parent) ? @@ -105699,27 +109959,27 @@ var ts; ts.isForInOrOfStatement(node.parent.parent) ? getContextNode(node.parent.parent) : node.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextNode(node.parent.parent); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; - case 258 /* ExportSpecifier */: - case 252 /* NamespaceImport */: + case 261 /* ExportSpecifier */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.isExpressionStatement(node.parent) ? node.parent : node; - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return { start: node.initializer, end: node.expression }; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ? getContextNode(ts.findAncestor(node.parent, function (node) { return ts.isBinaryExpression(node) || ts.isForInOrOfStatement(node); @@ -105763,18 +110023,18 @@ var ts; } FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; function getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return undefined; } var checker = program.getTypeChecker(); // If invoked directly on a shorthand property assignment, then return // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var result_1 = []; FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, checker, function (node) { return result_1.push(nodeEntry(node)); }); return result_1; } - else if (node.kind === 99 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + else if (node.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { // References to and accesses on the super keyword only have one possible implementation, so no // need to "Find all References" var symbol = checker.getSymbolAtLocation(node); @@ -105863,7 +110123,7 @@ var ts; return __assign(__assign({}, documentSpan), { isWriteAccess: false, isDefinition: false }); } var kind = entry.kind, node = entry.node; - return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 81 /* DefaultKeyword */ + return __assign(__assign({}, documentSpan), { isWriteAccess: isWriteAccessForReference(node), isDefinition: node.kind === 83 /* DefaultKeyword */ || !!ts.getDeclarationFromName(node) || ts.isLiteralComputedPropertyDeclarationName(node), isInString: kind === 2 /* StringLiteral */ ? true : undefined }); } @@ -105918,13 +110178,13 @@ var ts; if (symbol) { return getDefinitionKindAndDisplayParts(symbol, checker, node); } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { return { kind: "interface" /* interfaceElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(21 /* CloseParenToken */)] }; } - else if (node.kind === 210 /* ClassExpression */) { + else if (node.kind === 213 /* ClassExpression */) { return { kind: "local class" /* localClassElement */, displayParts: [ts.punctuationPart(20 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(21 /* CloseParenToken */)] @@ -105953,7 +110213,7 @@ var ts; function getTextSpan(node, sourceFile, endNode) { var start = node.getStart(sourceFile); var end = (endNode || node).getEnd(); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { ts.Debug.assert(endNode === undefined); start += 1; end -= 1; @@ -105968,7 +110228,7 @@ var ts; /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ function isWriteAccessForReference(node) { var decl = ts.getDeclarationFromName(node); - return !!decl && declarationIsWriteAccess(decl) || node.kind === 81 /* DefaultKeyword */ || ts.isWriteAccess(node); + return !!decl && declarationIsWriteAccess(decl) || node.kind === 83 /* DefaultKeyword */ || ts.isWriteAccess(node); } /** * True if 'decl' provides a value, as in `function f() {}`; @@ -105976,49 +110236,49 @@ var ts; */ function declarationIsWriteAccess(decl) { // Consider anything in an ambient declaration to be a write access since it may be coming from JS. - if (!!(decl.flags & 4194304 /* Ambient */)) + if (!!(decl.flags & 8388608 /* Ambient */)) return true; switch (decl.kind) { - case 205 /* BinaryExpression */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 81 /* DefaultKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 258 /* ExportSpecifier */: - case 251 /* ImportClause */: // default import - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 242 /* InterfaceDeclaration */: - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 268 /* JsxAttribute */: - case 245 /* ModuleDeclaration */: - case 248 /* NamespaceExportDeclaration */: - case 252 /* NamespaceImport */: - case 152 /* Parameter */: - case 277 /* ShorthandPropertyAssignment */: - case 243 /* TypeAliasDeclaration */: - case 151 /* TypeParameter */: + case 208 /* BinaryExpression */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 83 /* DefaultKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 261 /* ExportSpecifier */: + case 254 /* ImportClause */: // default import + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 245 /* InterfaceDeclaration */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 271 /* JsxAttribute */: + case 248 /* ModuleDeclaration */: + case 251 /* NamespaceExportDeclaration */: + case 255 /* NamespaceImport */: + case 155 /* Parameter */: + case 280 /* ShorthandPropertyAssignment */: + case 246 /* TypeAliasDeclaration */: + case 154 /* TypeParameter */: return true; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // In `({ x: y } = 0);`, `x` is not a write access. (Won't call this function for `y`.) return !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(decl.parent); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return !!decl.body; - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: return !!decl.initializer || ts.isCatchClause(decl.parent); - case 156 /* MethodSignature */: - case 154 /* PropertySignature */: - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: + case 159 /* MethodSignature */: + case 157 /* PropertySignature */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: return false; default: return ts.Debug.failBadSyntaxKind(decl); @@ -106178,10 +110438,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; switch (decl.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: // Don't include the source file itself. (This may not be ideal behavior, but awkward to include an entire file as a reference.) break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (sourceFilesSet.has(decl.getSourceFile().fileName)) { references.push(FindAllReferences.nodeEntry(decl.name)); } @@ -106198,11 +110458,9 @@ var ts; var sourceFile = decl.getSourceFile(); if (sourceFilesSet.has(sourceFile.fileName)) { // At `module.exports = ...`, reference node is `module` - var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) - ? decl.left.expression - : ts.isExportAssignment(decl) - ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 86 /* ExportKeyword */, sourceFile)) - : ts.getNameOfDeclaration(decl) || decl; + var node = ts.isBinaryExpression(decl) && ts.isPropertyAccessExpression(decl.left) ? decl.left.expression : + ts.isExportAssignment(decl) ? ts.Debug.assertDefined(ts.findChildOfKind(decl, 88 /* ExportKeyword */, sourceFile)) : + ts.getNameOfDeclaration(decl) || decl; references.push(FindAllReferences.nodeEntry(node)); } } @@ -106211,21 +110469,21 @@ var ts; } /** As in a `readonly prop: any` or `constructor(readonly prop: any)`, not a `readonly any[]`. */ function isReadonlyTypeOperator(node) { - return node.kind === 134 /* ReadonlyKeyword */ + return node.kind === 137 /* ReadonlyKeyword */ && ts.isTypeOperatorNode(node.parent) - && node.parent.operator === 134 /* ReadonlyKeyword */; + && node.parent.operator === 137 /* ReadonlyKeyword */; } /** getReferencedSymbols for special node kinds. */ function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { if (ts.isTypeKeyword(node.kind)) { // A modifier readonly (like on a property declaration) is not special; // a readonly type keyword (like `readonly string[]`) is. - if (node.kind === 134 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { + if (node.kind === 137 /* ReadonlyKeyword */ && !isReadonlyTypeOperator(node)) { return undefined; } // Likewise, when we *are* looking for a special keyword, make sure we // *don’t* include readonly member modifiers. - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 134 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken, node.kind === 137 /* ReadonlyKeyword */ ? isReadonlyTypeOperator : undefined); } // Labels if (ts.isJumpStatementTarget(node)) { @@ -106241,7 +110499,7 @@ var ts; if (ts.isThis(node)) { return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); } - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } return undefined; @@ -106258,7 +110516,7 @@ var ts; // When renaming at an export specifier, rename the export and not the thing being exported. getReferencesAtExportSpecifier(exportSpecifier.name, symbol, exportSpecifier, state.createSearch(node, originalSymbol, /*comingFrom*/ undefined), state, /*addReferencesHere*/ true, /*alwaysGetReferences*/ true); } - else if (node && node.kind === 81 /* DefaultKeyword */) { + else if (node && node.kind === 83 /* DefaultKeyword */) { addReference(node, symbol, state); searchForImportsOfExport(node, symbol, { exportingModuleSymbol: ts.Debug.assertDefined(symbol.parent, "Expected export symbol to have a parent"), exportKind: 1 /* Default */ }, state); } @@ -106286,9 +110544,9 @@ var ts; } function getSpecialSearchKind(node) { switch (node.kind) { - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: return 1 /* Constructor */; - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isClassLike(node.parent)) { ts.Debug.assert(node.parent.name === node); return 2 /* Class */; @@ -106524,7 +110782,7 @@ var ts; // If this is the symbol of a named function expression or named class expression, // then named references are limited to its own scope. var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 197 /* FunctionExpression */ || valueDeclaration.kind === 210 /* ClassExpression */)) { + if (valueDeclaration && (valueDeclaration.kind === 200 /* FunctionExpression */ || valueDeclaration.kind === 213 /* ClassExpression */)) { return valueDeclaration; } if (!declarations) { @@ -106534,7 +110792,7 @@ var ts; if (flags & (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.find(declarations, function (d) { return ts.hasModifier(d, 8 /* Private */); }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 241 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 244 /* ClassDeclaration */); } // Else this is a public property and could be accessed from anywhere. return undefined; @@ -106563,7 +110821,7 @@ var ts; // Different declarations have different containers, bail out return undefined; } - if (!container || container.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { + if (!container || container.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -106671,8 +110929,9 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.text.length === searchSymbolName.length; + case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: { var str = node; return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(str) || ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || (ts.isCallExpression(node.parent) && ts.isBindableObjectDefinePropertyCall(node.parent) && node.parent.arguments[1] === node)) && @@ -106680,7 +110939,7 @@ var ts; } case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; - case 81 /* DefaultKeyword */: + case 83 /* DefaultKeyword */: return "default".length === searchSymbolName.length; default: return false; @@ -106746,7 +111005,7 @@ var ts; return; } if (ts.isExportSpecifier(parent)) { - ts.Debug.assert(referenceLocation.kind === 73 /* Identifier */); + ts.Debug.assert(referenceLocation.kind === 75 /* Identifier */); getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state, addReferencesHere); return; } @@ -106802,12 +111061,14 @@ var ts; } // For `export { foo as bar }`, rename `foo`, but not `bar`. if (!isForRenameWithPrefixAndSuffixText(state.options) || alwaysGetReferences) { - var isDefaultExport = referenceLocation.originalKeywordKind === 81 /* DefaultKeyword */ - || exportSpecifier.name.originalKeywordKind === 81 /* DefaultKeyword */; + var isDefaultExport = referenceLocation.originalKeywordKind === 83 /* DefaultKeyword */ + || exportSpecifier.name.originalKeywordKind === 83 /* DefaultKeyword */; var exportKind = isDefaultExport ? 1 /* Default */ : 0 /* Named */; var exportSymbol = ts.Debug.assertDefined(exportSpecifier.symbol); - var exportInfo = ts.Debug.assertDefined(FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker)); - searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); + var exportInfo = FindAllReferences.getExportInfo(exportSymbol, exportKind, state.checker); + if (exportInfo) { + searchForImportsOfExport(referenceLocation, exportSymbol, exportInfo, state); + } } // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName && !isForRenameWithPrefixAndSuffixText(state.options)) { @@ -106866,7 +111127,7 @@ var ts; } } function addReference(referenceLocation, relatedSymbol, state) { - var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; + var _a = "kind" in relatedSymbol ? relatedSymbol : { kind: undefined, symbol: relatedSymbol }, kind = _a.kind, symbol = _a.symbol; // eslint-disable-line no-in-operator var addRef = state.referenceAdder(symbol); if (state.options.implementations) { addImplementationReferences(referenceLocation, addRef, state); @@ -106882,7 +111143,7 @@ var ts; } var pusher = function () { return state.referenceAdder(search.symbol); }; if (ts.isClassLike(referenceLocation.parent)) { - ts.Debug.assert(referenceLocation.kind === 81 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); + ts.Debug.assert(referenceLocation.kind === 83 /* DefaultKeyword */ || referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. findOwnConstructorReferences(search.symbol, sourceFile, pusher()); } @@ -106909,7 +111170,7 @@ var ts; } if (member.body) { member.body.forEachChild(function cb(node) { - if (node.kind === 101 /* ThisKeyword */) { + if (node.kind === 103 /* ThisKeyword */) { addRef(node); } else if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -106928,18 +111189,18 @@ var ts; if (constructorSymbol) { for (var _i = 0, _a = constructorSymbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 125 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 158 /* Constructor */ && !!ctrKeyword); + var ctrKeyword = ts.findChildOfKind(decl, 128 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 161 /* Constructor */ && !!ctrKeyword); addNode(ctrKeyword); } } if (classSymbol.exports) { classSymbol.exports.forEach(function (member) { var decl = member.valueDeclaration; - if (decl && decl.kind === 157 /* MethodDeclaration */) { + if (decl && decl.kind === 160 /* MethodDeclaration */) { var body = decl.body; if (body) { - forEachDescendantOfKind(body, 101 /* ThisKeyword */, function (thisKeyword) { + forEachDescendantOfKind(body, 103 /* ThisKeyword */, function (thisKeyword) { if (ts.isNewExpressionTarget(thisKeyword)) { addNode(thisKeyword); } @@ -106960,10 +111221,10 @@ var ts; } for (var _i = 0, _a = constructor.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - ts.Debug.assert(decl.kind === 158 /* Constructor */); + ts.Debug.assert(decl.kind === 161 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 99 /* SuperKeyword */, function (node) { + forEachDescendantOfKind(body, 101 /* SuperKeyword */, function (node) { if (ts.isCallExpressionTarget(node)) { addNode(node); } @@ -106987,10 +111248,10 @@ var ts; addReference(refNode); return; } - if (refNode.kind !== 73 /* Identifier */) { + if (refNode.kind !== 75 /* Identifier */) { return; } - if (refNode.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (refNode.parent.kind === 280 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } @@ -107010,7 +111271,7 @@ var ts; } else if (ts.isFunctionLike(typeHavingNode) && typeHavingNode.body) { var body = typeHavingNode.body; - if (body.kind === 219 /* Block */) { + if (body.kind === 222 /* Block */) { ts.forEachReturnStatement(body, function (returnStatement) { if (returnStatement.expression) addIfImplementation(returnStatement.expression); @@ -107038,13 +111299,13 @@ var ts; */ function isImplementationExpression(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isImplementationExpression(node.expression); - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 188 /* ArrayLiteralExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 191 /* ArrayLiteralExpression */: return true; default: return false; @@ -107097,13 +111358,13 @@ var ts; // Whether 'super' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; @@ -107112,7 +111373,7 @@ var ts; } var sourceFile = searchSpaceNode.getSourceFile(); var references = ts.mapDefined(getPossibleSymbolReferenceNodes(sourceFile, "super", searchSpaceNode), function (node) { - if (node.kind !== 99 /* SuperKeyword */) { + if (node.kind !== 101 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); @@ -107124,41 +111385,41 @@ var ts; return [{ definition: { type: 0 /* Symbol */, symbol: searchSpaceNode.symbol }, references: references }]; } function isParameterName(node) { - return node.kind === 73 /* Identifier */ && node.parent.kind === 152 /* Parameter */ && node.parent.name === node; + return node.kind === 75 /* Identifier */ && node.parent.kind === 155 /* Parameter */ && node.parent.name === node; } function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); // Whether 'this' occurs in a static context within a class. var staticFlag = 32 /* Static */; switch (searchSpaceNode.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.isObjectLiteralMethod(searchSpaceNode)) { break; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: staticFlag &= ts.getModifierFlags(searchSpaceNode); searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode) || isParameterName(thisOrSuperKeyword)) { return undefined; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: break; // Computed properties in classes are not handled here because references to this are illegal, // so there is no point finding references to them. default: return undefined; } - var references = ts.flatMap(searchSpaceNode.kind === 285 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { + var references = ts.flatMap(searchSpaceNode.kind === 288 /* SourceFile */ ? sourceFiles : [searchSpaceNode.getSourceFile()], function (sourceFile) { cancellationToken.throwIfCancellationRequested(); return getPossibleSymbolReferenceNodes(sourceFile, "this", ts.isSourceFile(searchSpaceNode) ? sourceFile : searchSpaceNode).filter(function (node) { if (!ts.isThis(node)) { @@ -107166,19 +111427,19 @@ var ts; } var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); switch (searchSpaceNode.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return searchSpaceNode.symbol === container.symbol; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol; - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // Make sure the container belongs to the same class // and has the appropriate static modifier from the original container. return container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag; - case 285 /* SourceFile */: - return container.kind === 285 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); + case 288 /* SourceFile */: + return container.kind === 288 /* SourceFile */ && !ts.isExternalModule(container) && !isParameterName(node); } }); }).map(function (n) { return FindAllReferences.nodeEntry(n); }); @@ -107297,7 +111558,7 @@ var ts; }); } function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { - var bindingElement = ts.getDeclarationOfKind(symbol, 187 /* BindingElement */); + var bindingElement = ts.getDeclarationOfKind(symbol, 190 /* BindingElement */); if (bindingElement && ts.isObjectBindingElementWithoutPropertyName(bindingElement)) { return ts.getPropertySymbolFromBindingElement(checker, bindingElement); } @@ -107347,11 +111608,10 @@ var ts; } Core.getIntersectingMeaningFromDeclarations = getIntersectingMeaningFromDeclarations; function isImplementation(node) { - return !!(node.flags & 4194304 /* Ambient */) - ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) - : (ts.isVariableLike(node) ? ts.hasInitializer(node) - : ts.isFunctionLikeDeclaration(node) ? !!node.body - : ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); + return !!(node.flags & 8388608 /* Ambient */) ? !(ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) : + (ts.isVariableLike(node) ? ts.hasInitializer(node) : + ts.isFunctionLikeDeclaration(node) ? !!node.body : + ts.isClassLike(node) || ts.isModuleOrEnumDeclaration(node)); } function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { var refSymbol = checker.getSymbolAtLocation(node); @@ -107401,12 +111661,12 @@ var ts; /* @internal */ var ts; (function (ts) { - function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, _preferences, sourceMapper) { + function getEditsForFileRename(program, oldFileOrDirPath, newFileOrDirPath, host, formatContext, preferences, sourceMapper) { var useCaseSensitiveFileNames = ts.hostUsesCaseSensitiveFileNames(host); var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var oldToNew = getPathUpdater(oldFileOrDirPath, newFileOrDirPath, getCanonicalFileName, sourceMapper); var newToOld = getPathUpdater(newFileOrDirPath, oldFileOrDirPath, getCanonicalFileName, sourceMapper); - return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext }, function (changeTracker) { + return ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, function (changeTracker) { updateTsconfigFiles(program, changeTracker, oldToNew, oldFileOrDirPath, newFileOrDirPath, host.getCurrentDirectory(), useCaseSensitiveFileNames); updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName); }); @@ -107654,9 +111914,9 @@ var ts; return [sigInfo]; } else { - var defs = getDefinitionFromSymbol(typeChecker, symbol, node) || ts.emptyArray; + var defs = getDefinitionFromSymbol(typeChecker, symbol, node, calledDeclaration) || ts.emptyArray; // For a 'super()' call, put the signature first, else put the variable first. - return node.kind === 99 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); + return node.kind === 101 /* SuperKeyword */ ? __spreadArrays([sigInfo], defs) : __spreadArrays(defs, [sigInfo]); } } // Because name in short-hand property assignment has two different meanings: property name and property value, @@ -107664,7 +111924,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { var shorthandSymbol_1 = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); return shorthandSymbol_1 ? shorthandSymbol_1.declarations.map(function (decl) { return createDefinitionInfo(decl, typeChecker, shorthandSymbol_1, node); }) : []; } @@ -107817,31 +112077,32 @@ var ts; // (2) when the aliased symbol is originating from an import. // function shouldSkipAlias(node, declaration) { - if (node.kind !== 73 /* Identifier */) { + if (node.kind !== 75 /* Identifier */) { return false; } if (node.parent === declaration) { return true; } switch (declaration.kind) { - case 251 /* ImportClause */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: return true; - case 254 /* ImportSpecifier */: - return declaration.parent.kind === 253 /* NamedImports */; + case 257 /* ImportSpecifier */: + return declaration.parent.kind === 256 /* NamedImports */; default: return false; } } - function getDefinitionFromSymbol(typeChecker, symbol, node) { + function getDefinitionFromSymbol(typeChecker, symbol, node, declarationNode) { // There are cases when you extend a function by adding properties to it afterwards, - // we want to strip those extra properties - var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return !ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration; }) || undefined; + // we want to strip those extra properties. + // For deduping purposes, we also want to exclude any declarationNodes if provided. + var filteredDeclarations = ts.filter(symbol.declarations, function (d) { return d !== declarationNode && (!ts.isAssignmentDeclaration(d) || d === symbol.valueDeclaration); }) || undefined; return getConstructSignatureDefinition() || getCallSignatureDefinition() || ts.map(filteredDeclarations, function (declaration) { return createDefinitionInfo(declaration, typeChecker, symbol, node); }); function getConstructSignatureDefinition() { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (symbol.flags & 32 /* Class */ && (ts.isNewExpressionTarget(node) || node.kind === 125 /* ConstructorKeyword */)) { + if (symbol.flags & 32 /* Class */ && !(symbol.flags & 16 /* Function */) && (ts.isNewExpressionTarget(node) || node.kind === 128 /* ConstructorKeyword */)) { var cls = ts.find(filteredDeclarations, ts.isClassLike) || ts.Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } @@ -107856,8 +112117,12 @@ var ts; return undefined; } var declarations = signatureDeclarations.filter(selectConstructors ? ts.isConstructorDeclaration : ts.isFunctionLike); + var declarationsWithBody = declarations.filter(function (d) { return !!d.body; }); + // declarations defined on the global scope can be defined on multiple files. Get all of them. return declarations.length - ? [createDefinitionInfo(ts.find(declarations, function (d) { return !!d.body; }) || ts.last(declarations), typeChecker, symbol, node)] + ? declarationsWithBody.length !== 0 + ? declarationsWithBody.map(function (x) { return createDefinitionInfo(x, typeChecker, symbol, node); }) + : [createDefinitionInfo(ts.last(declarations), typeChecker, symbol, node)] : undefined; } } @@ -107910,9 +112175,9 @@ var ts; } function isConstructorLike(node) { switch (node.kind) { - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return true; default: return false; @@ -108014,7 +112279,7 @@ var ts; // The property length will have two declarations of property length coming // from Array - Array and Array var documentationComment = []; - forEachUnique(declarations, function (declaration) { + ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = getCommentHavingNodes(declaration); _i < _a.length; _i++) { var comment = _a[_i].comment; if (comment === undefined) @@ -108030,11 +112295,11 @@ var ts; JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; function getCommentHavingNodes(declaration) { switch (declaration.kind) { - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return [declaration]; - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: return [declaration, declaration.parent]; default: return ts.getJSDocCommentsAndTags(declaration); @@ -108043,7 +112308,7 @@ var ts; function getJsDocTagsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once. var tags = []; - forEachUnique(declarations, function (declaration) { + ts.forEachUnique(declarations, function (declaration) { for (var _i = 0, _a = ts.getJSDocTags(declaration); _i < _a.length; _i++) { var tag = _a[_i]; tags.push({ name: tag.tagName.text, text: getCommentText(tag) }); @@ -108055,16 +112320,16 @@ var ts; function getCommentText(tag) { var comment = tag.comment; switch (tag.kind) { - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return withNode(tag.class); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return withList(tag.typeParameters); - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return withNode(tag.typeExpression); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: var name = tag.name; return name ? withNode(name) : comment; default: @@ -108080,24 +112345,6 @@ var ts; return comment === undefined ? s : s + " " + comment; } } - /** - * Iterates through 'array' by index and performs the callback on each element of array until the callback - * returns a truthy value, then returns that value. - * If no such value is found, the callback is applied to each element of array and undefined is returned. - */ - function forEachUnique(array, callback) { - if (array) { - for (var i = 0; i < array.length; i++) { - if (array.indexOf(array[i]) === i) { - var result = callback(array[i], i); - if (result) { - return result; - } - } - } - } - return undefined; - } function getJSDocTagNameCompletions() { return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { @@ -108241,7 +112488,7 @@ var ts; function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) { return parameters.map(function (_a, i) { var name = _a.name, dotDotDotToken = _a.dotDotDotToken; - var paramName = name.kind === 73 /* Identifier */ ? name.text : "param" + i; + var paramName = name.kind === 75 /* Identifier */ ? name.text : "param" + i; var type = isJavaScriptFile ? (dotDotDotToken ? "{...any} " : "{any} ") : ""; return indentationStr + " * @param " + type + paramName + newLine; }).join(""); @@ -108251,23 +112498,23 @@ var ts; } function getCommentOwnerInfoWorker(commentOwner) { switch (commentOwner.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 159 /* MethodSignature */: var parameters = commentOwner.parameters; return { commentOwner: commentOwner, parameters: parameters }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getCommentOwnerInfoWorker(commentOwner.initializer); - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 154 /* PropertySignature */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 157 /* PropertySignature */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 246 /* TypeAliasDeclaration */: return { commentOwner: commentOwner }; - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer @@ -108275,14 +112522,14 @@ var ts; : undefined; return { commentOwner: commentOwner, parameters: parameters_1 }; } - case 285 /* SourceFile */: + case 288 /* SourceFile */: return "quit"; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // If in walking up the tree, we hit a a nested namespace declaration, // then we must be somewhere within a dotted namespace name; however we don't // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - return commentOwner.parent.kind === 245 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; - case 205 /* BinaryExpression */: { + return commentOwner.parent.kind === 248 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 208 /* BinaryExpression */: { var be = commentOwner; if (ts.getAssignmentDeclarationKind(be) === 0 /* None */) { return "quit"; @@ -108301,14 +112548,14 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 196 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 199 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return rightHandSide.parameters; - case 210 /* ClassExpression */: { + case 213 /* ClassExpression */: { var ctr = ts.find(rightHandSide.members, ts.isConstructorDeclaration); return ctr ? ctr.parameters : ts.emptyArray; } @@ -108370,9 +112617,9 @@ var ts; } function shouldKeepItem(declaration, checker) { switch (declaration.kind) { - case 251 /* ImportClause */: - case 254 /* ImportSpecifier */: - case 249 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 257 /* ImportSpecifier */: + case 252 /* ImportEqualsDeclaration */: var importer = checker.getSymbolAtLocation(declaration.name); // TODO: GH#18217 var imported = checker.getAliasedSymbol(importer); return importer.escapedName !== imported.escapedName; @@ -108382,7 +112629,7 @@ var ts; } function tryAddSingleDeclarationName(declaration, containers) { var name = ts.getNameOfDeclaration(declaration); - return !!name && (pushLiteral(name, containers) || name.kind === 150 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); + return !!name && (pushLiteral(name, containers) || name.kind === 153 /* ComputedPropertyName */ && tryAddComputedPropertyName(name.expression, containers)); } // Only added the names of computed properties if they're simple dotted expressions, like: // @@ -108399,7 +112646,7 @@ var ts; // First, if we started with a computed property name, then add all but the last // portion into the container array. var name = ts.getNameOfDeclaration(declaration); - if (name && name.kind === 150 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { + if (name && name.kind === 153 /* ComputedPropertyName */ && !tryAddComputedPropertyName(name.expression, containers)) { return ts.emptyArray; } // Don't include the last portion. @@ -108443,6 +112690,7 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { + var _a; /** * Matches all whitespace characters in a string. Eg: * @@ -108457,6 +112705,11 @@ var ts; * does not match. */ var whiteSpaceRegex = /\s+/g; + /** + * Maximum amount of characters to return + * The amount was choosen arbitrarily. + */ + var maxLength = 150; // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. var curCancellationToken; var curSourceFile; @@ -108467,13 +112720,15 @@ var ts; */ var parentsStack = []; var parent; + var trackedEs5ClassesStack = []; + var trackedEs5Classes; // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. var emptyChildItemArray = []; function getNavigationBarItems(sourceFile, cancellationToken) { curCancellationToken = cancellationToken; curSourceFile = sourceFile; try { - return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + return ts.map(primaryNavBarMenuItems(rootNavigationBarNode(sourceFile)), convertToPrimaryNavBarMenuItem); } finally { reset(); @@ -108499,7 +112754,7 @@ var ts; emptyChildItemArray = []; } function nodeText(node) { - return node.getText(curSourceFile); + return cleanText(node.getText(curSourceFile)); } function navigationBarNodeKind(n) { return n.node.kind; @@ -108524,28 +112779,56 @@ var ts; ts.Debug.assert(!parent && !parentsStack.length); return root; } - function addLeafNode(node) { - pushChild(parent, emptyNavigationBarNode(node)); + function addLeafNode(node, name) { + pushChild(parent, emptyNavigationBarNode(node, name)); } - function emptyNavigationBarNode(node) { + function emptyNavigationBarNode(node, name) { return { node: node, - name: ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined, + name: name || (ts.isDeclaration(node) || ts.isExpression(node) ? ts.getNameOfDeclaration(node) : undefined), additionalNodes: undefined, parent: parent, children: undefined, indent: parent.indent + 1 }; } + function addTrackedEs5Class(name) { + if (!trackedEs5Classes) { + trackedEs5Classes = ts.createMap(); + } + trackedEs5Classes.set(name, true); + } + function endNestedNodes(depth) { + for (var i = 0; i < depth; i++) + endNode(); + } + function startNestedNodes(targetNode, entityName) { + var names = []; + while (!ts.isPropertyNameLiteral(entityName)) { + var name = ts.getNameOrArgument(entityName); + var nameText = ts.getElementOrPropertyAccessName(entityName); + entityName = entityName.expression; + if (nameText === "prototype") + continue; + names.push(name); + } + names.push(entityName); + for (var i = names.length - 1; i > 0; i--) { + var name = names[i]; + startNode(targetNode, name); + } + return [names.length - 1, names[0]]; + } /** * Add a new level of NavigationBarNodes. * This pushes to the stack, so you must call `endNode` when you are done adding to this node. */ - function startNode(node) { - var navNode = emptyNavigationBarNode(node); + function startNode(node, name) { + var navNode = emptyNavigationBarNode(node, name); pushChild(parent, navNode); // Save the old parent parentsStack.push(parent); + trackedEs5ClassesStack.push(trackedEs5Classes); parent = navNode; } /** Call after calling `startNode` and adding children to it. */ @@ -108555,46 +112838,48 @@ var ts; sortChildren(parent.children); } parent = parentsStack.pop(); + trackedEs5Classes = trackedEs5ClassesStack.pop(); } - function addNodeWithRecursiveChild(node, child) { - startNode(node); + function addNodeWithRecursiveChild(node, child, name) { + startNode(node, name); addChildrenRecursively(child); endNode(); } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + var _a; curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); // Parameter properties are children of the class, not the constructor. - for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { - var param = _a[_i]; + for (var _i = 0, _b = ctr.parameters; _i < _b.length; _i++) { + var param = _b[_i]; if (ts.isParameterPropertyDeclaration(param, ctr)) { addLeafNode(param); } } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 159 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -108606,90 +112891,168 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { addLeafNode(namedBindings); } else { - for (var _b = 0, _c = namedBindings.elements; _b < _c.length; _b++) { - var element = _c[_b]; + for (var _c = 0, _d = namedBindings.elements; _c < _d.length; _c++) { + var element = _d[_c]; addLeafNode(element); } } } break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: - var _d = node, name = _d.name, initializer = _d.initializer; + case 280 /* ShorthandPropertyAssignment */: + addNodeWithRecursiveChild(node, node.name); + break; + case 281 /* SpreadAssignment */: + var expression = node.expression; + // Use the expression as the name of the SpreadAssignment, otherwise show as . + ts.isIdentifier(expression) ? addLeafNode(node, expression) : addLeafNode(node); + break; + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: + case 241 /* VariableDeclaration */: + var _e = node, name = _e.name, initializer = _e.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } else if (initializer && isFunctionOrClassExpression(initializer)) { - if (initializer.name) { - // Don't add a node for the VariableDeclaration, just for the initializer. - addChildrenRecursively(initializer); - } - else { - // Add a node for the VariableDeclaration, but not for the initializer. - startNode(node); - ts.forEachChild(initializer, addChildrenRecursively); - endNode(); - } + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); } else { addNodeWithRecursiveChild(node, initializer); } break; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + var nameNode = node.name; + // If we see a function declaration track as a possible ES5 class + if (nameNode && ts.isIdentifier(nameNode)) { + addTrackedEs5Class(nameNode.text); + } addNodeWithRecursiveChild(node, node.body); break; - case 244 /* EnumDeclaration */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + addNodeWithRecursiveChild(node, node.body); + break; + case 247 /* EnumDeclaration */: startNode(node); - for (var _e = 0, _f = node.members; _e < _f.length; _e++) { - var member = _f[_e]; + for (var _f = 0, _g = node.members; _f < _g.length; _f++) { + var member = _g[_f]; if (!isComputedProperty(member)) { addLeafNode(member); } } endNode(); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: startNode(node); - for (var _g = 0, _h = node.members; _g < _h.length; _g++) { - var member = _h[_g]; + for (var _h = 0, _j = node.members; _h < _j.length; _h++) { + var member = _j[_h]; addChildrenRecursively(member); } endNode(); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 258 /* ExportSpecifier */: - case 249 /* ImportEqualsDeclaration */: - case 163 /* IndexSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 243 /* TypeAliasDeclaration */: + case 261 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 166 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 246 /* TypeAliasDeclaration */: addLeafNode(node); break; - case 205 /* BinaryExpression */: { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { var special = ts.getAssignmentDeclarationKind(node); switch (special) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - case 3 /* PrototypeProperty */: - case 6 /* Prototype */: addNodeWithRecursiveChild(node, node.right); return; + case 6 /* Prototype */: + case 3 /* PrototypeProperty */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var prototypeAccess = special === 3 /* PrototypeProperty */ ? + assignmentTarget.expression : + assignmentTarget; + var depth = 0; + var className = void 0; + // If we see a prototype assignment, start tracking the target as a class + // This is only done for simple classes not nested assignments. + if (ts.isIdentifier(prototypeAccess.expression)) { + addTrackedEs5Class(prototypeAccess.expression.text); + className = prototypeAccess.expression; + } + else { + _a = startNestedNodes(binaryExpression, prototypeAccess.expression), depth = _a[0], className = _a[1]; + } + if (special === 6 /* Prototype */) { + if (ts.isObjectLiteralExpression(binaryExpression.right)) { + if (binaryExpression.right.properties.length > 0) { + startNode(binaryExpression, className); + ts.forEachChild(binaryExpression.right, addChildrenRecursively); + endNode(); + } + } + } + else if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, className); + } + else { + startNode(binaryExpression, className); + addNodeWithRecursiveChild(node, binaryExpression.right, assignmentTarget.name); + endNode(); + } + endNestedNodes(depth); + return; + } + case 7 /* ObjectDefinePropertyValue */: + case 9 /* ObjectDefinePrototypeProperty */: { + var defineCall = node; + var className = special === 7 /* ObjectDefinePropertyValue */ ? + defineCall.arguments[0] : + defineCall.arguments[0].expression; + var memberName = defineCall.arguments[1]; + var _k = startNestedNodes(node, className), depth = _k[0], classNameIdentifier = _k[1]; + startNode(node, classNameIdentifier); + startNode(node, ts.setTextRange(ts.createIdentifier(memberName.text), memberName)); + addChildrenRecursively(node.arguments[2]); + endNode(); + endNode(); + endNestedNodes(depth); + return; + } + case 5 /* Property */: { + var binaryExpression = node; + var assignmentTarget = binaryExpression.left; + var targetFunction = assignmentTarget.expression; + if (ts.isIdentifier(targetFunction) && ts.getElementOrPropertyAccessName(assignmentTarget) !== "prototype" && + trackedEs5Classes && trackedEs5Classes.has(targetFunction.text)) { + if (ts.isFunctionExpression(binaryExpression.right) || ts.isArrowFunction(binaryExpression.right)) { + addNodeWithRecursiveChild(node, binaryExpression.right, targetFunction); + } + else if (ts.isBindableStaticAccessExpression(assignmentTarget)) { + startNode(binaryExpression, targetFunction); + addNodeWithRecursiveChild(binaryExpression.left, binaryExpression.right, ts.getNameOrArgument(assignmentTarget)); + endNode(); + } + return; + } + break; + } case 4 /* ThisProperty */: - case 5 /* Property */: case 0 /* None */: - case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: - case 9 /* ObjectDefinePrototypeProperty */: break; default: ts.Debug.assertNever(special); @@ -108712,8 +113075,8 @@ var ts; /** Merge declarations of the same kind. */ function mergeChildren(children, node) { var nameToItems = ts.createMap(); - ts.filterMutate(children, function (child) { - var declName = ts.getNameOfDeclaration(child.node); + ts.filterMutate(children, function (child, index) { + var declName = child.name || ts.getNameOfDeclaration(child.node); var name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. @@ -108727,7 +113090,7 @@ var ts; if (itemsWithSameName instanceof Array) { for (var _i = 0, itemsWithSameName_1 = itemsWithSameName; _i < itemsWithSameName_1.length; _i++) { var itemWithSameName = itemsWithSameName_1[_i]; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } } @@ -108736,7 +113099,7 @@ var ts; } else { var itemWithSameName = itemsWithSameName; - if (tryMerge(itemWithSameName, child, node)) { + if (tryMerge(itemWithSameName, child, index, node)) { return false; } nameToItems.set(name, [itemWithSameName, child]); @@ -108744,7 +113107,100 @@ var ts; } }); } - function tryMerge(a, b, parent) { + var isEs5ClassMember = (_a = {}, + _a[5 /* Property */] = true, + _a[3 /* PrototypeProperty */] = true, + _a[7 /* ObjectDefinePropertyValue */] = true, + _a[9 /* ObjectDefinePrototypeProperty */] = true, + _a[0 /* None */] = false, + _a[1 /* ExportsProperty */] = false, + _a[2 /* ModuleExports */] = false, + _a[8 /* ObjectDefinePropertyExports */] = false, + _a[6 /* Prototype */] = true, + _a[4 /* ThisProperty */] = false, + _a); + function tryMergeEs5Class(a, b, bIndex, parent) { + function isPossibleConstructor(node) { + return ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node); + } + var bAssignmentDeclarationKind = ts.isBinaryExpression(b.node) || ts.isCallExpression(b.node) ? + ts.getAssignmentDeclarationKind(b.node) : + 0 /* None */; + var aAssignmentDeclarationKind = ts.isBinaryExpression(a.node) || ts.isCallExpression(a.node) ? + ts.getAssignmentDeclarationKind(a.node) : + 0 /* None */; + // We treat this as an es5 class and merge the nodes in in one of several cases + if ((isEs5ClassMember[bAssignmentDeclarationKind] && isEs5ClassMember[aAssignmentDeclarationKind]) // merge two class elements + || (isPossibleConstructor(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // ctor function & member + || (isPossibleConstructor(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & ctor function + || (ts.isClassDeclaration(a.node) && isEs5ClassMember[bAssignmentDeclarationKind]) // class (generated) & member + || (ts.isClassDeclaration(b.node) && isEs5ClassMember[aAssignmentDeclarationKind]) // member & class (generated) + || (ts.isClassDeclaration(a.node) && isPossibleConstructor(b.node)) // class (generated) & ctor + || (ts.isClassDeclaration(b.node) && isPossibleConstructor(a.node)) // ctor & class (generated) + ) { + var lastANode = a.additionalNodes && ts.lastOrUndefined(a.additionalNodes) || a.node; + if ((!ts.isClassDeclaration(a.node) && !ts.isClassDeclaration(b.node)) // If neither outline node is a class + || isPossibleConstructor(a.node) || isPossibleConstructor(b.node) // If either function is a constructor function + ) { + var ctorFunction = isPossibleConstructor(a.node) ? a.node : + isPossibleConstructor(b.node) ? b.node : + undefined; + if (ctorFunction !== undefined) { + var ctorNode = ts.setTextRange(ts.createConstructor(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); + var ctor = emptyNavigationBarNode(ctorNode); + ctor.indent = a.indent + 1; + ctor.children = a.node === ctorFunction ? a.children : b.children; + a.children = a.node === ctorFunction ? ts.concatenate([ctor], b.children || [b]) : ts.concatenate(a.children || [a], [ctor]); + } + else { + if (a.children || b.children) { + a.children = ts.concatenate(a.children || [a], b.children || [b]); + if (a.children) { + mergeChildren(a.children, a); + sortChildren(a.children); + } + } + } + lastANode = a.node = ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), a.node); + } + else { + a.children = ts.concatenate(a.children, b.children); + if (a.children) { + mergeChildren(a.children, a); + } + } + var bNode = b.node; + // We merge if the outline node previous to b (bIndex - 1) is already part of the current class + // We do this so that statements between class members that do not generate outline nodes do not split up the class outline: + // Ex This should produce one outline node C: + // function C() {}; a = 1; C.prototype.m = function () {} + // Ex This will produce 3 outline nodes: C, a, C + // function C() {}; let a = 1; C.prototype.m = function () {} + if (parent.children[bIndex - 1].node.end === lastANode.end) { + ts.setTextRange(lastANode, { pos: lastANode.pos, end: bNode.end }); + } + else { + if (!a.additionalNodes) + a.additionalNodes = []; + a.additionalNodes.push(ts.setTextRange(ts.createClassDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, a.name || ts.createIdentifier("__class__"), + /* typeParameters */ undefined, + /* heritageClauses */ undefined, []), b.node)); + } + return true; + } + return bAssignmentDeclarationKind === 0 /* None */ ? false : true; + } + function tryMerge(a, b, bIndex, parent) { + // const v = false as boolean; + if (tryMergeEs5Class(a, b, bIndex, parent)) { + return true; + } if (shouldReallyMerge(a.node, b.node, parent)) { merge(a, b); return true; @@ -108757,12 +113213,12 @@ var ts; return false; } switch (a.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.hasModifier(a, 32 /* Static */) === ts.hasModifier(b, 32 /* Static */); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return areSameModule(a, b); default: return true; @@ -108778,7 +113234,7 @@ var ts; // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { // TODO: GH#18217 - return a.body.kind === b.body.kind && (a.body.kind !== 245 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); + return a.body.kind === b.body.kind && (a.body.kind !== 248 /* ModuleDeclaration */ || areSameModule(a.body, b.body)); } /** Merge source into target. Source should be thrown away after this is called. */ function merge(target, source) { @@ -108808,43 +113264,46 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 245 /* ModuleDeclaration */) { + if (node.kind === 248 /* ModuleDeclaration */) { return getModuleName(node); } var declName = ts.getNameOfDeclaration(node); if (declName && ts.isPropertyName(declName)) { - return ts.unescapeLeadingUnderscores(ts.getPropertyNameForPropertyNameNode(declName)); // TODO: GH#18217 + var propertyName = ts.getPropertyNameForPropertyNameNode(declName); + return propertyName && ts.unescapeLeadingUnderscores(propertyName); } switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: return getFunctionOrClassName(node); default: return undefined; } } function getItemName(node, name) { - if (node.kind === 245 /* ModuleDeclaration */) { - return getModuleName(node); + if (node.kind === 248 /* ModuleDeclaration */) { + return cleanText(getModuleName(node)); } if (name) { - var text = nodeText(name); + var text = ts.isIdentifier(name) ? name.text + : ts.isElementAccessExpression(name) ? "[" + nodeText(name.argumentExpression) + "]" + : nodeText(name); if (text.length > 0) { - return text; + return cleanText(text); } } switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -108852,24 +113311,27 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return "new()"; - case 161 /* CallSignature */: + case 164 /* CallSignature */: return "()"; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "[]"; default: return ""; } } - /** Flattens the NavNode tree to a list, keeping only the top-level items. */ - function topLevelItems(root) { - var topLevel = []; + /** Flattens the NavNode tree to a list of items to appear in the primary navbar menu. */ + function primaryNavBarMenuItems(root) { + // The primary (middle) navbar menu displays the general code navigation hierarchy, similar to the navtree. + // The secondary (right) navbar menu displays the child items of whichever primary item is selected. + // Some less interesting items without their own child navigation items (e.g. a local variable declaration) only show up in the secondary menu. + var primaryNavBarMenuItems = []; function recur(item) { - if (isTopLevel(item)) { - topLevel.push(item); + if (shouldAppearInPrimaryNavBarMenu(item)) { + primaryNavBarMenuItems.push(item); if (item.children) { for (var _i = 0, _a = item.children; _i < _a.length; _i++) { var child = _a[_i]; @@ -108879,28 +113341,28 @@ var ts; } } recur(root); - return topLevel; - function isTopLevel(item) { + return primaryNavBarMenuItems; + /** Determines if a node should appear in the primary navbar menu. */ + function shouldAppearInPrimaryNavBarMenu(item) { + // Items with children should always appear in the primary navbar menu. + if (item.children) { + return true; + } + // Some nodes are otherwise important enough to always include in the primary navigation menu. switch (navigationBarNodeKind(item)) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 285 /* SourceFile */: - case 243 /* TypeAliasDeclaration */: - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 288 /* SourceFile */: + case 246 /* TypeAliasDeclaration */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: return true; - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 238 /* VariableDeclaration */: - return hasSomeImportantChild(item); - case 198 /* ArrowFunction */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -108910,21 +113372,15 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 246 /* ModuleBlock */: - case 285 /* SourceFile */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: + case 249 /* ModuleBlock */: + case 288 /* SourceFile */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: return true; default: - return hasSomeImportantChild(item); + return false; } } - function hasSomeImportantChild(item) { - return ts.some(item.children, function (child) { - var childKind = navigationBarNodeKind(child); - return childKind !== 238 /* VariableDeclaration */ && childKind !== 187 /* BindingElement */; - }); - } } } function convertToTree(n) { @@ -108937,18 +113393,18 @@ var ts; childItems: ts.map(n.children, convertToTree) }; } - function convertToTopLevelItem(n) { + function convertToPrimaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), kindModifiers: getModifiers(n.node), spans: getSpans(n), - childItems: ts.map(n.children, convertToChildItem) || emptyChildItemArray, + childItems: ts.map(n.children, convertToSecondaryNavBarMenuItem) || emptyChildItemArray, indent: n.indent, bolded: false, grayed: false }; - function convertToChildItem(n) { + function convertToSecondaryNavBarMenuItem(n) { return { text: getItemName(n.node, n.name), kind: ts.getNodeKind(n.node), @@ -108979,7 +113435,7 @@ var ts; // Otherwise, we need to aggregate each identifier to build up the qualified name. var result = []; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(ts.getTextOfIdentifierOrLiteral(moduleDeclaration.name)); } @@ -108993,13 +113449,13 @@ var ts; return decl.body && ts.isModuleDeclaration(decl.body) ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 150 /* ComputedPropertyName */; + return !member.name || member.name.kind === 153 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 285 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); + return node.kind === 288 /* SourceFile */ ? ts.createTextSpanFromRange(node) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 238 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 241 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -109007,14 +113463,14 @@ var ts; function getFunctionOrClassName(node) { var parent = node.parent; if (node.name && ts.getFullWidth(node.name) > 0) { - return ts.declarationNameToString(node.name); + return cleanText(ts.declarationNameToString(node.name)); } // See if it is a var initializer. If so, use the var name. else if (ts.isVariableDeclaration(parent)) { - return ts.declarationNameToString(parent.name); + return cleanText(ts.declarationNameToString(parent.name)); } // See if it is of the form " = function(){...}". If so, use the text from the left-hand side. - else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */) { + else if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */) { return nodeText(parent.left).replace(whiteSpaceRegex, ""); } // See if it is a property assignment, and if so use the property name @@ -109031,7 +113487,11 @@ var ts; else if (ts.isCallExpression(parent)) { var name = getCalledExpressionName(parent.expression); if (name !== undefined) { - var args = ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", "); + name = cleanText(name); + if (name.length > maxLength) { + return name + " callback"; + } + var args = cleanText(ts.mapDefined(parent.arguments, function (a) { return ts.isStringLiteralLike(a) ? a.getText(curSourceFile) : undefined; }).join(", ")); return name + "(" + args + ") callback"; } } @@ -109052,14 +113512,24 @@ var ts; } function isFunctionOrClassExpression(node) { switch (node.kind) { - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: return true; default: return false; } } + function cleanText(text) { + // Truncate to maximum amount of characters as we don't want to do a big replace operation. + text = text.length > maxLength ? text.substring(0, maxLength) + "..." : text; + // Replaces ECMAScript line terminators and removes the trailing `\` from each line: + // \n - Line Feed + // \r - Carriage Return + // \u2028 - Line separator + // \u2029 - Paragraph separator + return text.replace(/\\?(\r?\n|\r|\u2028|\u2029)/g, ""); + } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -109073,8 +113543,8 @@ var ts; * 2) Coalescing imports from the same module * 3) Sorting imports */ - function organizeImports(sourceFile, formatContext, host, program, _preferences) { - var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext }); + function organizeImports(sourceFile, formatContext, host, program, preferences) { + var changeTracker = ts.textChanges.ChangeTracker.fromContext({ host: host, formatContext: formatContext, preferences: preferences }); var coalesceAndOrganizeImports = function (importGroup) { return coalesceImports(removeUnusedImports(importGroup, sourceFile, program)); }; // All of the old ImportDeclarations in the file, in syntactic order. var topLevelImportDecls = sourceFile.statements.filter(ts.isImportDeclaration); @@ -109402,7 +113872,7 @@ var ts; } var lastImport = current - 1; if (lastImport !== firstImport) { - out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 93 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); + out.push(createOutliningSpanFromBounds(ts.findChildOfKind(statements[firstImport], 95 /* ImportKeyword */, sourceFile).getStart(sourceFile), statements[lastImport].getEnd(), "imports" /* Imports */)); } } function visitNonImportNode(n) { @@ -109519,7 +113989,7 @@ var ts; } function getOutliningSpanForNode(n, sourceFile) { switch (n.kind) { - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionLike(n.parent)) { return functionSpan(n.parent, n, sourceFile); } @@ -109527,23 +113997,23 @@ var ts; // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. switch (n.parent.kind) { - case 224 /* DoStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 275 /* CatchClause */: + case 227 /* DoStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 278 /* CatchClause */: return spanForNode(n.parent); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // Could be the try-block, or the finally-block. var tryStatement = n.parent; if (tryStatement.tryBlock === n) { return spanForNode(n.parent); } else if (tryStatement.finallyBlock === n) { - return spanForNode(ts.findChildOfKind(tryStatement, 89 /* FinallyKeyword */, sourceFile)); + return spanForNode(ts.findChildOfKind(tryStatement, 91 /* FinallyKeyword */, sourceFile)); } // falls through default: @@ -109551,24 +114021,24 @@ var ts; // the span of the block, independent of any parent span. return createOutliningSpan(ts.createTextSpanFromNode(n, sourceFile), "code" /* Code */); } - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanForNode(n.parent); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 247 /* CaseBlock */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 250 /* CaseBlock */: return spanForNode(n); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return spanForObjectOrArrayLiteral(n); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return spanForObjectOrArrayLiteral(n, 22 /* OpenBracketToken */); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return spanForJSXElement(n); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return spanForJSXFragment(n); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return spanForJSXAttributes(n.attributes); } function spanForJSXElement(node) { @@ -109610,7 +114080,7 @@ var ts; ? ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile) : ts.findChildOfKind(body, 18 /* OpenBraceToken */, sourceFile); var closeToken = ts.findChildOfKind(body, 19 /* CloseBraceToken */, sourceFile); - return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 198 /* ArrowFunction */); + return openToken && closeToken && spanBetweenTokens(openToken, closeToken, node, sourceFile, /*autoCollapse*/ node.kind !== 201 /* ArrowFunction */); } function spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart) { if (autoCollapse === void 0) { autoCollapse = false; } @@ -110145,10 +114615,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 126 /* DeclareKeyword */) { + if (token === 129 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 131 /* ModuleKeyword */) { + if (token === 134 /* ModuleKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { recordAmbientExternalModule(); @@ -110166,7 +114636,7 @@ var ts; return false; } var token = ts.scanner.getToken(); - if (token === 93 /* ImportKeyword */) { + if (token === 95 /* ImportKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -110182,9 +114652,9 @@ var ts; return true; } else { - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import d from "mod"; @@ -110192,7 +114662,7 @@ var ts; return true; } } - else if (token === 60 /* EqualsToken */) { + else if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -110215,7 +114685,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import {a as A} from "mod"; @@ -110225,13 +114695,13 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 120 /* AsKeyword */) { + if (token === 122 /* AsKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // import * as NS from "mod" @@ -110249,7 +114719,7 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 86 /* ExportKeyword */) { + if (token === 88 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); if (token === 18 /* OpenBraceToken */) { @@ -110261,7 +114731,7 @@ var ts; } if (token === 19 /* CloseBraceToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export {a as A} from "mod"; @@ -110271,9 +114741,9 @@ var ts; } } } - else if (token === 40 /* AsteriskToken */) { + else if (token === 41 /* AsteriskToken */) { token = nextToken(); - if (token === 145 /* FromKeyword */) { + if (token === 148 /* FromKeyword */) { token = nextToken(); if (token === 10 /* StringLiteral */) { // export * from "mod" @@ -110281,11 +114751,11 @@ var ts; } } } - else if (token === 93 /* ImportKeyword */) { + else if (token === 95 /* ImportKeyword */) { token = nextToken(); - if (token === 73 /* Identifier */ || ts.isKeyword(token)) { + if (token === 75 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 60 /* EqualsToken */) { + if (token === 62 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -110298,7 +114768,7 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 135 /* RequireKeyword */) { + if (token === 138 /* RequireKeyword */) { token = nextToken(); if (token === 20 /* OpenParenToken */) { token = nextToken(); @@ -110313,7 +114783,7 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 73 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 75 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); if (token !== 20 /* OpenParenToken */) { return true; @@ -110447,14 +114917,14 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } // Cannot rename `default` as in `import { default as foo } from "./someModule"; - if (ts.isIdentifier(node) && node.originalKeywordKind === 81 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { + if (ts.isIdentifier(node) && node.originalKeywordKind === 83 /* DefaultKeyword */ && symbol.parent.flags & 1536 /* Module */) { return undefined; } if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) { return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined; } var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); - var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 150 /* ComputedPropertyName */) + var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 153 /* ComputedPropertyName */) ? ts.stripQuotes(ts.getTextOfIdentifierOrLiteral(node)) : undefined; var displayName = specifierName || typeChecker.symbolToString(symbol); @@ -110501,7 +114971,7 @@ var ts; function createTriggerSpanForNode(node, sourceFile) { var start = node.getStart(sourceFile); var width = node.getWidth(sourceFile); - if (node.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(node)) { // Exclude the quotes start += 1; width -= 2; @@ -110510,9 +114980,10 @@ var ts; } function nodeIsEligibleForRename(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return true; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); @@ -110552,7 +115023,7 @@ var ts; // // Dive in without pushing a selection range. if (ts.isBlock(node) - || ts.isTemplateSpan(node) || ts.isTemplateHead(node) + || ts.isTemplateSpan(node) || ts.isTemplateHead(node) || ts.isTemplateTail(node) || prevNode && ts.isTemplateHead(prevNode) || ts.isVariableDeclarationList(node) && ts.isVariableStatement(parentNode) || ts.isSyntaxList(node) && ts.isVariableDeclarationList(parentNode) @@ -110664,14 +115135,14 @@ var ts; ts.Debug.assertEqual(closeBraceToken.kind, 19 /* CloseBraceToken */); // Group `-/+readonly` and `-/+?` var groupedWithPlusMinusTokens = groupChildren(children, function (child) { - return child === node.readonlyToken || child.kind === 134 /* ReadonlyKeyword */ || - child === node.questionToken || child.kind === 56 /* QuestionToken */; + return child === node.readonlyToken || child.kind === 137 /* ReadonlyKeyword */ || + child === node.questionToken || child.kind === 57 /* QuestionToken */; }); // Group type parameter with surrounding brackets var groupedWithBrackets = groupChildren(groupedWithPlusMinusTokens, function (_a) { var kind = _a.kind; return kind === 22 /* OpenBracketToken */ || - kind === 151 /* TypeParameter */ || + kind === 154 /* TypeParameter */ || kind === 23 /* CloseBracketToken */; }); return [ @@ -110679,7 +115150,7 @@ var ts; // Pivot on `:` createSyntaxList(splitChildren(groupedWithBrackets, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; })), closeBraceToken, ]; @@ -110691,7 +115162,7 @@ var ts; }); return splitChildren(children, function (_a) { var kind = _a.kind; - return kind === 57 /* ColonToken */; + return kind === 58 /* ColonToken */; }); } // Group the parameter name with its `...`, then that group with its `?`, then pivot on `=`. @@ -110704,14 +115175,14 @@ var ts; }); return splitChildren(groupedWithQuestionToken, function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } // Pivot on '=' if (ts.isBindingElement(node)) { return splitChildren(node.getChildren(), function (_a) { var kind = _a.kind; - return kind === 60 /* EqualsToken */; + return kind === 62 /* EqualsToken */; }); } return node.getChildren(); @@ -110778,7 +115249,7 @@ var ts; } function createSyntaxList(children) { ts.Debug.assertGreaterThanOrEqual(children.length, 1); - var syntaxList = ts.createNode(314 /* SyntaxList */, children[0].pos, ts.last(children).end); + var syntaxList = ts.createNode(317 /* SyntaxList */, children[0].pos, ts.last(children).end); syntaxList._children = children; return syntaxList; } @@ -110787,14 +115258,14 @@ var ts; return kind === 18 /* OpenBraceToken */ || kind === 22 /* OpenBracketToken */ || kind === 20 /* OpenParenToken */ - || kind === 263 /* JsxOpeningElement */; + || kind === 266 /* JsxOpeningElement */; } function isListCloser(token) { var kind = token && token.kind; return kind === 19 /* CloseBraceToken */ || kind === 23 /* CloseBracketToken */ || kind === 21 /* CloseParenToken */ - || kind === 264 /* JsxClosingElement */; + || kind === 267 /* JsxClosingElement */; } })(SmartSelectionRange = ts.SmartSelectionRange || (ts.SmartSelectionRange = {})); })(ts || (ts = {})); @@ -110887,7 +115358,7 @@ var ts; var containingList = ts.findContainingList(startingToken); return !!containingList && ts.contains(invocationChildren, containingList); } - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return containsPrecedingToken(startingToken, sourceFile, node.expression); default: return false; @@ -110946,7 +115417,7 @@ var ts; return { list: list, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; } function getArgumentOrParameterListAndIndex(node, sourceFile) { - if (node.kind === 28 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { + if (node.kind === 29 /* LessThanToken */ || node.kind === 20 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 }; @@ -110999,10 +115470,10 @@ var ts; } return undefined; } - else if (ts.isTemplateHead(node) && parent.parent.kind === 194 /* TaggedTemplateExpression */) { + else if (ts.isTemplateHead(node) && parent.parent.kind === 197 /* TaggedTemplateExpression */) { var templateExpression = parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 207 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 210 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position, sourceFile) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } @@ -111069,17 +115540,17 @@ var ts; return undefined; var parent = startingToken.parent; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 199 /* ParenthesizedExpression */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: var info = getArgumentOrParameterListInfo(startingToken, sourceFile); if (!info) return undefined; var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan; var contextualType = ts.isMethodDeclaration(parent) ? checker.getContextualTypeForObjectLiteralElement(parent) : checker.getContextualType(parent); return contextualType && { contextualType: contextualType, argumentIndex: argumentIndex, argumentCount: argumentCount, argumentsSpan: argumentsSpan }; - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var highestBinary = getHighestBinary(parent); var contextualType_1 = checker.getContextualType(highestBinary); var argumentIndex_1 = startingToken.kind === 20 /* OpenParenToken */ ? 0 : countBinaryExpressionParameters(parent) - 1; @@ -111150,11 +115621,11 @@ var ts; // not enough to put us in the substitution expression; we should consider ourselves part of // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // - // tslint:disable no-double-space + /* eslint-disable no-double-space */ // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ // Case: 1 1 3 2 1 3 2 2 1 - // tslint:enable no-double-space + /* eslint-enable no-double-space */ ts.Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (ts.isTemplateLiteralToken(node)) { if (ts.isInsideTemplateLiteral(node, position, sourceFile)) { @@ -111203,7 +115674,7 @@ var ts; // | | // This is because a Missing node has no width. However, what we actually want is to include trivia // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { var lastSpan = ts.last(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -111268,8 +115739,8 @@ var ts; var parameters = typeParameters.map(function (t) { return createSignatureHelpParameterForTypeParameter(t, checker, enclosingDeclaration, sourceFile, printer); }); var documentation = symbol.getDocumentationComment(checker); var tags = symbol.getJsDocTags(); - var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(28 /* LessThanToken */)]); - return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(30 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; + var prefixDisplayParts = __spreadArrays(typeSymbolDisplay, [ts.punctuationPart(29 /* LessThanToken */)]); + return { isVariadic: false, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: [ts.punctuationPart(31 /* GreaterThanToken */)], separatorDisplayParts: separatorDisplayParts, parameters: parameters, documentation: documentation, tags: tags }; } var separatorDisplayParts = [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]; function getSignatureHelpItem(candidateSignature, callTargetDisplayParts, isTypeParameterList, checker, enclosingDeclaration, sourceFile) { @@ -111302,7 +115773,7 @@ var ts; var params = ts.createNodeArray(__spreadArrays(thisParameter, checker.getExpandedParameters(candidateSignature).map(function (param) { return checker.symbolToParameterDeclaration(param, enclosingDeclaration, signatureHelpNodeBuilderFlags); }))); printer.writeList(2576 /* CallExpressionArguments */, params, sourceFile, writer); }); - return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(28 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(30 /* GreaterThanToken */)], parameterParts) }; + return { isVariadic: false, parameters: parameters, prefix: [ts.punctuationPart(29 /* LessThanToken */)], suffix: __spreadArrays([ts.punctuationPart(31 /* GreaterThanToken */)], parameterParts) }; } function itemInfoForParameters(candidateSignature, checker, enclosingDeclaration, sourceFile) { var isVariadic = checker.hasEffectiveRestParameter(candidateSignature); @@ -111378,6 +115849,10 @@ var ts; if (!sourceFile) return undefined; var program = host.getProgram(); + // If this is source file of project reference source (instead of redirect) there is no generated position + if (program.isSourceOfProjectReferenceRedirect(sourceFile.fileName)) { + return undefined; + } var options = program.getCompilerOptions(); var outPath = options.outFile || options.out; var declarationPath = outPath ? @@ -111515,7 +115990,7 @@ var ts; function check(node) { if (isJsFile) { switch (node.kind) { - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var decl = ts.getDeclarationOfExpando(node); if (decl) { var symbol_1 = decl.symbol; @@ -111525,7 +116000,7 @@ var ts; } } // falls through if no diagnostic was created - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: var symbol = node.symbol; if (symbol.members && (symbol.members.size > 0)) { diags.push(ts.createDiagnosticForNode(ts.isVariableDeclaration(node.parent) ? node.parent.name : node, ts.Diagnostics.This_constructor_function_may_be_converted_to_a_class_declaration)); @@ -111558,11 +116033,11 @@ var ts; function containsTopLevelCommonjs(sourceFile) { return sourceFile.statements.some(function (statement) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return statement.declarationList.declarations.some(function (decl) { return !!decl.initializer && ts.isRequireCall(propertyAccessLeftHandSide(decl.initializer), /*checkArgumentIsStringLiteralLike*/ true); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; if (!ts.isBinaryExpression(expression)) return ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true); @@ -111579,12 +116054,12 @@ var ts; } function importNameForConvertToDefaultImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause, moduleSpecifier = node.moduleSpecifier; - return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 252 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) + return importClause && !importClause.name && importClause.namedBindings && importClause.namedBindings.kind === 255 /* NamespaceImport */ && ts.isStringLiteral(moduleSpecifier) ? importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; default: return undefined; @@ -111642,13 +116117,13 @@ var ts; // should be kept up to date with getTransformationBody in convertToAsyncFunction.ts function isFixablePromiseArgument(arg) { switch (arg.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true); - /* falls through */ - case 97 /* NullKeyword */: - case 73 /* Identifier */: // identifier includes undefined + // falls through + case 99 /* NullKeyword */: + case 75 /* Identifier */: // identifier includes undefined return true; default: return false; @@ -111671,7 +116146,7 @@ var ts; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); if (flags & 32 /* Class */) { - return ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */) ? "local class" /* localClassElement */ : "class" /* classElement */; } if (flags & 384 /* Enum */) @@ -111708,7 +116183,7 @@ var ts; if (typeChecker.isArgumentsSymbol(symbol)) { return "local var" /* localVariableElement */; } - if (location.kind === 101 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 103 /* ThisKeyword */ && ts.isExpression(location)) { return "parameter" /* parameterElement */; } var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol); @@ -111759,11 +116234,11 @@ var ts; // If we requested completions after `x.` at the top-level, we may be at a source file location. switch (location.parent && location.parent.kind) { // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'. - case 263 /* JsxOpeningElement */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - return location.kind === 73 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; - case 268 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + return location.kind === 75 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */; + case 271 /* JsxAttribute */: return "JSX attribute" /* jsxAttribute */; default: return "property" /* memberVariableElement */; @@ -111790,13 +116265,13 @@ var ts; var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol); var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */; var hasAddedSymbolInfo = false; - var isThisExpression = location.kind === 101 /* ThisKeyword */ && ts.isInExpressionContext(location); + var isThisExpression = location.kind === 103 /* ThisKeyword */ && ts.isInExpressionContext(location); var type; var printer; var documentationFromAlias; var tagsFromAlias; - if (location.kind === 101 /* ThisKeyword */ && !isThisExpression) { - return { displayParts: [ts.keywordPart(101 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; + if (location.kind === 103 /* ThisKeyword */ && !isThisExpression) { + return { displayParts: [ts.keywordPart(103 /* ThisKeyword */)], documentation: [], symbolKind: "primitive type" /* primitiveType */, tags: undefined }; } // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) { @@ -111806,7 +116281,7 @@ var ts; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location); - if (location.parent && location.parent.kind === 190 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 193 /* PropertyAccessExpression */) { var right = location.parent.name; // Either the location is on the right of a property access, or on the left and the right is missing if (right === location || (right && right.getFullWidth() === 0)) { @@ -111826,7 +116301,7 @@ var ts; } if (callExpressionLike) { signature = typeChecker.getResolvedSignature(callExpressionLike); // TODO: GH#18217 - var useConstructSignatures = callExpressionLike.kind === 193 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 99 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 196 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 101 /* SuperKeyword */); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { // Get the first signature if there is one -- allSignatures may contain @@ -111844,7 +116319,7 @@ var ts; pushSymbolKind(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -111861,14 +116336,14 @@ var ts; case "parameter" /* parameterElement */: case "local var" /* localVariableElement */: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); if (!(ts.getObjectFlags(type) & 16 /* Anonymous */) && type.symbol) { ts.addRange(displayParts, ts.symbolToDisplayParts(typeChecker, type.symbol, enclosingDeclaration, /*meaning*/ undefined, 4 /* AllowAnyNodeKind */ | 1 /* WriteTypeParametersOrArguments */)); displayParts.push(ts.lineBreakPart()); } if (useConstructSignatures) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addSignatureDisplayParts(signature, allSignatures, 262144 /* WriteArrowStyleSignature */); @@ -111881,29 +116356,29 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbolFlags & 98304 /* Accessor */)) || // name of function declaration - (location.kind === 125 /* ConstructorKeyword */ && location.parent.kind === 158 /* Constructor */)) { // At constructor keyword of constructor declaration + (location.kind === 128 /* ConstructorKeyword */ && location.parent.kind === 161 /* Constructor */)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it var functionDeclaration_1 = location.parent; // Use function declaration to write the signatures only if the symbol corresponding to this declaration - var locationIsSymbolDeclaration = ts.find(symbol.declarations, function (declaration) { - return declaration === (location.kind === 125 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); + var locationIsSymbolDeclaration = symbol.declarations && ts.find(symbol.declarations, function (declaration) { + return declaration === (location.kind === 128 /* ConstructorKeyword */ ? functionDeclaration_1.parent : functionDeclaration_1); }); if (locationIsSymbolDeclaration) { - var allSignatures = functionDeclaration_1.kind === 158 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration_1.kind === 161 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration_1)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration_1); // TODO: GH#18217 } else { signature = allSignatures[0]; } - if (functionDeclaration_1.kind === 158 /* Constructor */) { + if (functionDeclaration_1.kind === 161 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = "constructor" /* constructorImplementationElement */; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 161 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration_1.kind === 164 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -111913,7 +116388,7 @@ var ts; } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { addAliasPrefixIfNecessary(); - if (ts.getDeclarationOfKind(symbol, 210 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 213 /* ClassExpression */)) { // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class @@ -111921,7 +116396,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(77 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(79 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -111929,37 +116404,37 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(111 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(113 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 524288 /* TypeAlias */) && (semanticMeaning & 2 /* Type */)) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 8388608 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { prefixNextMeaning(); if (ts.some(symbol.declarations, function (d) { return ts.isEnumDeclaration(d) && ts.isEnumConst(d); })) { - displayParts.push(ts.keywordPart(78 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(80 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(85 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(87 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */ && !isThisExpression) { prefixNextMeaning(); - var declaration = ts.getDeclarationOfKind(symbol, 245 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 73 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 132 /* NamespaceKeyword */ : 131 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 248 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 75 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 135 /* NamespaceKeyword */ : 134 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } @@ -111978,7 +116453,7 @@ var ts; } else { // Method/function type parameter - var decl = ts.getDeclarationOfKind(symbol, 151 /* TypeParameter */); + var decl = ts.getDeclarationOfKind(symbol, 154 /* TypeParameter */); if (decl === undefined) return ts.Debug.fail(); var declaration = decl.parent; @@ -111986,21 +116461,21 @@ var ts; if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); // TODO: GH#18217 - if (declaration.kind === 162 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(96 /* NewKeyword */)); + if (declaration.kind === 165 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(98 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 161 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 164 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 243 /* TypeAliasDeclaration */) { + else if (declaration.kind === 246 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(141 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(144 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -112012,11 +116487,11 @@ var ts; symbolKind = "enum member" /* enumMemberElement */; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 279 /* EnumMember */) { + if (declaration.kind === 282 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(ts.getTextOfConstantValue(constantValue), typeof constantValue === "number" ? ts.SymbolDisplayPartKind.numericLiteral : ts.SymbolDisplayPartKind.stringLiteral)); } @@ -112042,32 +116517,32 @@ var ts; } } switch (symbol.declarations[0].kind) { - case 248 /* NamespaceExportDeclaration */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 251 /* NamespaceExportDeclaration */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(132 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(135 /* NamespaceKeyword */)); break; - case 255 /* ExportAssignment */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 258 /* ExportAssignment */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 60 /* EqualsToken */ : 81 /* DefaultKeyword */)); + displayParts.push(ts.keywordPart(symbol.declarations[0].isExportEquals ? 62 /* EqualsToken */ : 83 /* DefaultKeyword */)); break; - case 258 /* ExportSpecifier */: - displayParts.push(ts.keywordPart(86 /* ExportKeyword */)); + case 261 /* ExportSpecifier */: + displayParts.push(ts.keywordPart(88 /* ExportKeyword */)); break; default: - displayParts.push(ts.keywordPart(93 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(95 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 249 /* ImportEqualsDeclaration */) { + if (declaration.kind === 252 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(135 /* RequireKeyword */)); + displayParts.push(ts.keywordPart(138 /* RequireKeyword */)); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); displayParts.push(ts.punctuationPart(21 /* CloseParenToken */)); @@ -112076,7 +116551,7 @@ var ts; var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(60 /* EqualsToken */)); + displayParts.push(ts.operatorPart(62 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -112090,7 +116565,7 @@ var ts; if (type) { if (isThisExpression) { prefixNextMeaning(); - displayParts.push(ts.keywordPart(101 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(103 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -112101,7 +116576,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === "local var" /* localVariableElement */ || isThisExpression) { - displayParts.push(ts.punctuationPart(57 /* ColonToken */)); + displayParts.push(ts.punctuationPart(58 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -112139,10 +116614,10 @@ var ts; // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 285 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 288 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 205 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 208 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -112185,7 +116660,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(94 /* InKeyword */)); + displayParts.push(ts.keywordPart(96 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbolToDisplay, enclosingDeclaration) { @@ -112195,7 +116670,7 @@ var ts; var fullSymbolDisplayParts = ts.symbolToDisplayParts(typeChecker, symbolToDisplay, enclosingDeclaration || sourceFile, /*meaning*/ undefined, 1 /* WriteTypeParametersOrArguments */ | 2 /* UseOnlyExternalAliasing */ | 4 /* AllowAnyNodeKind */); ts.addRange(displayParts, fullSymbolDisplayParts); if (symbol.flags & 16777216 /* Optional */) { - displayParts.push(ts.punctuationPart(56 /* QuestionToken */)); + displayParts.push(ts.punctuationPart(57 /* QuestionToken */)); } } function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { @@ -112230,7 +116705,7 @@ var ts; if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); displayParts.push(ts.punctuationPart(20 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(38 /* PlusToken */)); + displayParts.push(ts.operatorPart(39 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); @@ -112255,16 +116730,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 197 /* FunctionExpression */) { + if (declaration.kind === 200 /* FunctionExpression */) { return true; } - if (declaration.kind !== 238 /* VariableDeclaration */ && declaration.kind !== 240 /* FunctionDeclaration */) { + if (declaration.kind !== 241 /* VariableDeclaration */ && declaration.kind !== 243 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 285 /* SourceFile */ || parent.kind === 246 /* ModuleBlock */) { + if (parent.kind === 288 /* SourceFile */ || parent.kind === 249 /* ModuleBlock */) { return false; } } @@ -112509,7 +116984,9 @@ var ts; var res = cb({ advance: advance, readTokenInfo: readTokenInfo, + readEOFTokenRange: readEOFTokenRange, isOnToken: isOnToken, + isOnEOF: isOnEOF, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, @@ -112549,11 +117026,11 @@ var ts; } function shouldRescanGreaterThanToken(node) { switch (node.kind) { - case 32 /* GreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 47 /* GreaterThanGreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 48 /* GreaterThanGreaterThanToken */: return true; } return false; @@ -112561,12 +117038,12 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 268 /* JsxAttribute */: - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 271 /* JsxAttribute */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. - return ts.isKeyword(node.kind) || node.kind === 73 /* Identifier */; + return ts.isKeyword(node.kind) || node.kind === 75 /* Identifier */; } } return false; @@ -112582,23 +117059,18 @@ var ts; container.kind === 17 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 42 /* SlashToken */ || t === 65 /* SlashEqualsToken */; + return t === 43 /* SlashToken */ || t === 67 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. - var expectedScanAction = shouldRescanGreaterThanToken(n) - ? 1 /* RescanGreaterThanToken */ - : shouldRescanSlashToken(n) - ? 2 /* RescanSlashToken */ - : shouldRescanTemplateToken(n) - ? 3 /* RescanTemplateToken */ - : shouldRescanJsxIdentifier(n) - ? 4 /* RescanJsxIdentifier */ - : shouldRescanJsxText(n) - ? 5 /* RescanJsxText */ - : 0 /* Scan */; + var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 /* RescanGreaterThanToken */ : + shouldRescanSlashToken(n) ? 2 /* RescanSlashToken */ : + shouldRescanTemplateToken(n) ? 3 /* RescanTemplateToken */ : + shouldRescanJsxIdentifier(n) ? 4 /* RescanJsxIdentifier */ : + shouldRescanJsxText(n) ? 5 /* RescanJsxText */ : + 0 /* Scan */; if (lastTokenInfo && expectedScanAction === lastScanAction) { // readTokenInfo was called before with the same expected scan action. // No need to re-scan text, return existing 'lastTokenInfo' @@ -112615,11 +117087,7 @@ var ts; scanner.scan(); } var currentToken = getNextToken(n, expectedScanAction); - var token = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var token = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); // consume trailing trivia if (trailingTrivia) { trailingTrivia = undefined; @@ -112629,11 +117097,7 @@ var ts; if (!ts.isTrivia(currentToken)) { break; } - var trivia = { - pos: scanner.getStartPos(), - end: scanner.getTextPos(), - kind: currentToken - }; + var trivia = formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), currentToken); if (!trailingTrivia) { trailingTrivia = []; } @@ -112652,7 +117116,7 @@ var ts; lastScanAction = 0 /* Scan */; switch (expectedScanAction) { case 1 /* RescanGreaterThanToken */: - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { lastScanAction = 1 /* RescanGreaterThanToken */; var newToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === newToken); @@ -112686,11 +117150,19 @@ var ts; } return token; } + function readEOFTokenRange() { + ts.Debug.assert(isOnEOF()); + return formatting.createTextRangeWithKind(scanner.getStartPos(), scanner.getTextPos(), 1 /* EndOfFileToken */); + } function isOnToken() { var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } + function isOnEOF() { + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + return current === 1 /* EndOfFileToken */; + } // when containing node in the tree is token // but its kind differs from the kind that was returned by the scanner, // then kind needs to be fixed. This might happen in cases @@ -112722,10 +117194,16 @@ var ts; formatting.anyContext = ts.emptyArray; var RuleAction; (function (RuleAction) { - RuleAction[RuleAction["Ignore"] = 1] = "Ignore"; - RuleAction[RuleAction["Space"] = 2] = "Space"; - RuleAction[RuleAction["NewLine"] = 4] = "NewLine"; - RuleAction[RuleAction["Delete"] = 8] = "Delete"; + RuleAction[RuleAction["StopProcessingSpaceActions"] = 1] = "StopProcessingSpaceActions"; + RuleAction[RuleAction["StopProcessingTokenActions"] = 2] = "StopProcessingTokenActions"; + RuleAction[RuleAction["InsertSpace"] = 4] = "InsertSpace"; + RuleAction[RuleAction["InsertNewLine"] = 8] = "InsertNewLine"; + RuleAction[RuleAction["DeleteSpace"] = 16] = "DeleteSpace"; + RuleAction[RuleAction["DeleteToken"] = 32] = "DeleteToken"; + RuleAction[RuleAction["InsertTrailingSemicolon"] = 64] = "InsertTrailingSemicolon"; + RuleAction[RuleAction["StopAction"] = 3] = "StopAction"; + RuleAction[RuleAction["ModifySpaceAction"] = 28] = "ModifySpaceAction"; + RuleAction[RuleAction["ModifyTokenAction"] = 96] = "ModifyTokenAction"; })(RuleAction = formatting.RuleAction || (formatting.RuleAction = {})); var RuleFlags; (function (RuleFlags) { @@ -112741,8 +117219,10 @@ var ts; (function (formatting) { function getAllRules() { var allTokens = []; - for (var token = 0 /* FirstToken */; token <= 148 /* LastToken */; token++) { - allTokens.push(token); + for (var token = 0 /* FirstToken */; token <= 151 /* LastToken */; token++) { + if (token !== 1 /* EndOfFileToken */) { + allTokens.push(token); + } } function anyTokenExcept() { var tokens = []; @@ -112753,256 +117233,259 @@ var ts; } var anyToken = { tokens: allTokens, isSpecific: false }; var anyTokenIncludingMultilineComments = tokenRangeFrom(__spreadArrays(allTokens, [3 /* MultiLineCommentTrivia */])); - var keywords = tokenRangeFromRange(74 /* FirstKeyword */, 148 /* LastKeyword */); - var binaryOperators = tokenRangeFromRange(28 /* FirstBinaryOperator */, 72 /* LastBinaryOperator */); - var binaryKeywordOperators = [94 /* InKeyword */, 95 /* InstanceOfKeyword */, 148 /* OfKeyword */, 120 /* AsKeyword */, 129 /* IsKeyword */]; - var unaryPrefixOperators = [44 /* PlusPlusToken */, 45 /* MinusMinusToken */, 53 /* TildeToken */, 52 /* ExclamationToken */]; + var anyTokenIncludingEOF = tokenRangeFrom(__spreadArrays(allTokens, [1 /* EndOfFileToken */])); + var keywords = tokenRangeFromRange(76 /* FirstKeyword */, 151 /* LastKeyword */); + var binaryOperators = tokenRangeFromRange(29 /* FirstBinaryOperator */, 74 /* LastBinaryOperator */); + var binaryKeywordOperators = [96 /* InKeyword */, 97 /* InstanceOfKeyword */, 151 /* OfKeyword */, 122 /* AsKeyword */, 132 /* IsKeyword */]; + var unaryPrefixOperators = [45 /* PlusPlusToken */, 46 /* MinusMinusToken */, 54 /* TildeToken */, 53 /* ExclamationToken */]; var unaryPrefixExpressions = [ - 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 73 /* Identifier */, 20 /* OpenParenToken */, - 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */ + 8 /* NumericLiteral */, 9 /* BigIntLiteral */, 75 /* Identifier */, 20 /* OpenParenToken */, + 22 /* OpenBracketToken */, 18 /* OpenBraceToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */ ]; - var unaryPreincrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostincrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; - var unaryPredecrementExpressions = [73 /* Identifier */, 20 /* OpenParenToken */, 101 /* ThisKeyword */, 96 /* NewKeyword */]; - var unaryPostdecrementExpressions = [73 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 96 /* NewKeyword */]; + var unaryPreincrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostincrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; + var unaryPredecrementExpressions = [75 /* Identifier */, 20 /* OpenParenToken */, 103 /* ThisKeyword */, 98 /* NewKeyword */]; + var unaryPostdecrementExpressions = [75 /* Identifier */, 21 /* CloseParenToken */, 23 /* CloseBracketToken */, 98 /* NewKeyword */]; var comments = [2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]; - var typeNames = __spreadArrays([73 /* Identifier */], ts.typeKeywords); + var typeNames = __spreadArrays([75 /* Identifier */], ts.typeKeywords); // Place a space before open brace in a function declaration // TypeScript: Function can have return types, which can be made of tons of different token kinds var functionOpenBraceLeftTokenRange = anyTokenIncludingMultilineComments; // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([73 /* Identifier */, 3 /* MultiLineCommentTrivia */, 77 /* ClassKeyword */, 86 /* ExportKeyword */, 93 /* ImportKeyword */]); + var typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([75 /* Identifier */, 3 /* MultiLineCommentTrivia */, 79 /* ClassKeyword */, 88 /* ExportKeyword */, 95 /* ImportKeyword */]); // Place a space before open brace in a control flow construct - var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 83 /* DoKeyword */, 104 /* TryKeyword */, 89 /* FinallyKeyword */, 84 /* ElseKeyword */]); + var controlOpenBraceLeftTokenRange = tokenRangeFrom([21 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 85 /* DoKeyword */, 106 /* TryKeyword */, 91 /* FinallyKeyword */, 86 /* ElseKeyword */]); // These rules are higher in priority than user-configurable var highPriorityCommonRules = [ // Leave comments alone - rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* Ignore */), - rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* Ignore */), - rule("NotSpaceBeforeColon", anyToken, 57 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 8 /* Delete */), - rule("SpaceAfterColon", 57 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeQuestionMark", anyToken, 56 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("IgnoreBeforeComment", anyToken, comments, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("IgnoreAfterLineComment", 2 /* SingleLineCommentTrivia */, anyToken, formatting.anyContext, 1 /* StopProcessingSpaceActions */), + rule("NotSpaceBeforeColon", anyToken, 58 /* ColonToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext, isNotTypeAnnotationContext], 16 /* DeleteSpace */), + rule("SpaceAfterColon", 58 /* ColonToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeQuestionMark", anyToken, 57 /* QuestionToken */, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // insert space after '?' only when it is used in conditional operator - rule("SpaceAfterQuestionMarkInConditionalOperator", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 2 /* Space */), + rule("SpaceAfterQuestionMarkInConditionalOperator", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext, isConditionalOperatorContext], 4 /* InsertSpace */), // in other cases there should be no space between '?' and next token - rule("NoSpaceAfterQuestionMark", 56 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeDot", anyToken, 24 /* DotToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterDot", 24 /* DotToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBetweenImportParenInImportType", 93 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 8 /* Delete */), + rule("NoSpaceAfterQuestionMark", 57 /* QuestionToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeDot", anyToken, [24 /* DotToken */, 28 /* QuestionDotToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterDot", [24 /* DotToken */, 28 /* QuestionDotToken */], anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenImportParenInImportType", 95 /* ImportKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isImportTypeContext], 16 /* DeleteSpace */), // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. - rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPreincrementOperator", 44 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterUnaryPredecrementOperator", 45 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterUnaryPrefixOperator", unaryPrefixOperators, unaryPrefixExpressions, [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPreincrementOperator", 45 /* PlusPlusToken */, unaryPreincrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterUnaryPredecrementOperator", 46 /* MinusMinusToken */, unaryPredecrementExpressions, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostincrementOperator", unaryPostincrementExpressions, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeUnaryPostdecrementOperator", unaryPostdecrementExpressions, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // More unary operator special-casing. // DevDiv 181814: Be careful when removing leading whitespace // around unary operators. Examples: // 1 - -2 --X--> 1--2 // a + ++b --X--> a+++b - rule("SpaceAfterPostincrementWhenFollowedByAdd", 44 /* PlusPlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByUnaryPlus", 38 /* PlusToken */, 38 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterAddWhenFollowedByPreincrement", 38 /* PlusToken */, 44 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 45 /* MinusMinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 39 /* MinusToken */, 39 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterSubtractWhenFollowedByPredecrement", 39 /* MinusToken */, 45 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterPostincrementWhenFollowedByAdd", 45 /* PlusPlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByUnaryPlus", 39 /* PlusToken */, 39 /* PlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterAddWhenFollowedByPreincrement", 39 /* PlusToken */, 45 /* PlusPlusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterPostdecrementWhenFollowedBySubtract", 46 /* MinusMinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByUnaryMinus", 40 /* MinusToken */, 40 /* MinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterSubtractWhenFollowedByPredecrement", 40 /* MinusToken */, 46 /* MinusMinusToken */, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceAfterCloseBrace", 19 /* CloseBraceToken */, [27 /* CommaToken */, 26 /* SemicolonToken */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // For functions and control block place } on a new line [multi-line rule] - rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineBeforeCloseBraceInBlockContext", anyTokenIncludingMultilineComments, 19 /* CloseBraceToken */, [isMultilineBlockContext], 8 /* InsertNewLine */), // Space/new line after }. - rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 2 /* Space */), + rule("SpaceAfterCloseBrace", 19 /* CloseBraceToken */, anyTokenExcept(21 /* CloseParenToken */), [isNonJsxSameLineTokenContext, isAfterCodeBlockContext], 4 /* InsertSpace */), // Special case for (}, else) and (}, while) since else & while tokens are not part of the tree which makes SpaceAfterCloseBrace rule not applied // Also should not apply to }) - rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 84 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 108 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), + rule("SpaceBetweenCloseBraceAndElse", 19 /* CloseBraceToken */, 86 /* ElseKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenCloseBraceAndWhile", 19 /* CloseBraceToken */, 110 /* WhileKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), // Add a space after control dec context if the next character is an open bracket ex: 'if (false)[a, b] = [1, 2];' -> 'if (false) [a, b] = [1, 2];' - rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 2 /* Space */), - rule("NoSpaceBetweenFunctionKeywordAndStar", 91 /* FunctionKeyword */, 40 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 8 /* Delete */), - rule("SpaceAfterStarInGeneratorDeclaration", 40 /* AsteriskToken */, 73 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 2 /* Space */), - rule("SpaceAfterFunctionInFuncDecl", 91 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 2 /* Space */), + rule("SpaceAfterConditionalClosingParen", 21 /* CloseParenToken */, 22 /* OpenBracketToken */, [isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenFunctionKeywordAndStar", 93 /* FunctionKeyword */, 41 /* AsteriskToken */, [isFunctionDeclarationOrFunctionExpressionContext], 16 /* DeleteSpace */), + rule("SpaceAfterStarInGeneratorDeclaration", 41 /* AsteriskToken */, 75 /* Identifier */, [isFunctionDeclarationOrFunctionExpressionContext], 4 /* InsertSpace */), + rule("SpaceAfterFunctionInFuncDecl", 93 /* FunctionKeyword */, anyToken, [isFunctionDeclContext], 4 /* InsertSpace */), // Insert new line after { and before } in multi-line contexts. - rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 4 /* NewLine */), + rule("NewLineAfterOpenBraceInBlockContext", 18 /* OpenBraceToken */, anyToken, [isMultilineBlockContext], 8 /* InsertNewLine */), // For get/set members, we check for (identifier,identifier) since get/set don't have tokens and they are represented as just an identifier token. // Though, we do extra check on the context to make sure we are dealing with get/set node. Example: // get x() {} // set x(val) {} - rule("SpaceAfterGetSetInMember", [127 /* GetKeyword */, 138 /* SetKeyword */], 73 /* Identifier */, [isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBetweenYieldKeywordAndStar", 118 /* YieldKeyword */, 40 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 8 /* Delete */), - rule("SpaceBetweenYieldOrYieldStarAndOperand", [118 /* YieldKeyword */, 40 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 2 /* Space */), - rule("NoSpaceBetweenReturnAndSemicolon", 98 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterCertainKeywords", [106 /* VarKeyword */, 102 /* ThrowKeyword */, 96 /* NewKeyword */, 82 /* DeleteKeyword */, 98 /* ReturnKeyword */, 105 /* TypeOfKeyword */, 123 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterLetConstInVariableDeclaration", [112 /* LetKeyword */, 78 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 8 /* Delete */), + rule("SpaceAfterGetSetInMember", [130 /* GetKeyword */, 141 /* SetKeyword */], 75 /* Identifier */, [isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenYieldKeywordAndStar", 120 /* YieldKeyword */, 41 /* AsteriskToken */, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 16 /* DeleteSpace */), + rule("SpaceBetweenYieldOrYieldStarAndOperand", [120 /* YieldKeyword */, 41 /* AsteriskToken */], anyToken, [isNonJsxSameLineTokenContext, isYieldOrYieldStarWithOperand], 4 /* InsertSpace */), + rule("NoSpaceBetweenReturnAndSemicolon", 100 /* ReturnKeyword */, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterCertainKeywords", [108 /* VarKeyword */, 104 /* ThrowKeyword */, 98 /* NewKeyword */, 84 /* DeleteKeyword */, 100 /* ReturnKeyword */, 107 /* TypeOfKeyword */, 126 /* AwaitKeyword */], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterLetConstInVariableDeclaration", [114 /* LetKeyword */, 80 /* ConstKeyword */], anyToken, [isNonJsxSameLineTokenContext, isStartOfVariableDeclarationList], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncCall", anyToken, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isFunctionCallOrNewContext, isPreviousTokenNotComma], 16 /* DeleteSpace */), // Special case for binary operators (that are keywords). For these we have to add a space and shouldn't follow any user options. - rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterVoidOperator", 107 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 2 /* Space */), + rule("SpaceBeforeBinaryKeywordOperator", anyToken, binaryKeywordOperators, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryKeywordOperator", binaryKeywordOperators, anyToken, [isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterVoidOperator", 109 /* VoidKeyword */, anyToken, [isNonJsxSameLineTokenContext, isVoidOpContext], 4 /* InsertSpace */), // Async-await - rule("SpaceBetweenAsyncAndOpenParen", 122 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenAsyncAndFunctionKeyword", 122 /* AsyncKeyword */, 91 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenAsyncAndOpenParen", 125 /* AsyncKeyword */, 20 /* OpenParenToken */, [isArrowFunctionContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenAsyncAndFunctionKeyword", 125 /* AsyncKeyword */, 93 /* FunctionKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Template string - rule("NoSpaceBetweenTagAndTemplateString", [73 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBetweenTagAndTemplateString", [75 /* Identifier */, 21 /* CloseParenToken */], [14 /* NoSubstitutionTemplateLiteral */, 15 /* TemplateHead */], [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // JSX opening elements - rule("SpaceBeforeJsxAttribute", anyToken, 73 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 42 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 42 /* SlashToken */, 30 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 60 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterEqualInJsxAttribute", 60 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeJsxAttribute", anyToken, 75 /* Identifier */, [isNextTokenParentJsxAttribute, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeSlashInJsxOpeningElement", anyToken, 43 /* SlashToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeGreaterThanTokenInJsxOpeningElement", 43 /* SlashToken */, 31 /* GreaterThanToken */, [isJsxSelfClosingElementContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeEqualInJsxAttribute", anyToken, 62 /* EqualsToken */, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterEqualInJsxAttribute", 62 /* EqualsToken */, anyToken, [isJsxAttributeContext, isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // TypeScript-specific rules // Use of module as a function call. e.g.: import m2 = module("m2"); - rule("NoSpaceAfterModuleImport", [131 /* ModuleKeyword */, 135 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceAfterModuleImport", [134 /* ModuleKeyword */, 138 /* RequireKeyword */], 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Add a space around certain TypeScript keywords rule("SpaceAfterCertainTypeScriptKeywords", [ - 119 /* AbstractKeyword */, - 77 /* ClassKeyword */, - 126 /* DeclareKeyword */, - 81 /* DefaultKeyword */, - 85 /* EnumKeyword */, - 86 /* ExportKeyword */, - 87 /* ExtendsKeyword */, - 127 /* GetKeyword */, - 110 /* ImplementsKeyword */, - 93 /* ImportKeyword */, - 111 /* InterfaceKeyword */, - 131 /* ModuleKeyword */, - 132 /* NamespaceKeyword */, - 114 /* PrivateKeyword */, - 116 /* PublicKeyword */, - 115 /* ProtectedKeyword */, - 134 /* ReadonlyKeyword */, - 138 /* SetKeyword */, - 117 /* StaticKeyword */, - 141 /* TypeKeyword */, - 145 /* FromKeyword */, - 130 /* KeyOfKeyword */, - 128 /* InferKeyword */, - ], anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [87 /* ExtendsKeyword */, 110 /* ImplementsKeyword */, 145 /* FromKeyword */], [isNonJsxSameLineTokenContext], 2 /* Space */), + 121 /* AbstractKeyword */, + 79 /* ClassKeyword */, + 129 /* DeclareKeyword */, + 83 /* DefaultKeyword */, + 87 /* EnumKeyword */, + 88 /* ExportKeyword */, + 89 /* ExtendsKeyword */, + 130 /* GetKeyword */, + 112 /* ImplementsKeyword */, + 95 /* ImportKeyword */, + 113 /* InterfaceKeyword */, + 134 /* ModuleKeyword */, + 135 /* NamespaceKeyword */, + 116 /* PrivateKeyword */, + 118 /* PublicKeyword */, + 117 /* ProtectedKeyword */, + 137 /* ReadonlyKeyword */, + 141 /* SetKeyword */, + 119 /* StaticKeyword */, + 144 /* TypeKeyword */, + 148 /* FromKeyword */, + 133 /* KeyOfKeyword */, + 131 /* InferKeyword */, + ], anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCertainTypeScriptKeywords", anyToken, [89 /* ExtendsKeyword */, 112 /* ImplementsKeyword */, 148 /* FromKeyword */], [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Treat string literals in module names as identifiers, and add a space between the literal and the opening Brace braces, e.g.: module "m2" { - rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 2 /* Space */), + rule("SpaceAfterModuleName", 10 /* StringLiteral */, 18 /* OpenBraceToken */, [isModuleDeclContext], 4 /* InsertSpace */), // Lambda expressions - rule("SpaceBeforeArrow", anyToken, 37 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceAfterArrow", 37 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBeforeArrow", anyToken, 38 /* EqualsGreaterThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceAfterArrow", 38 /* EqualsGreaterThanToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Optional parameters and let args - rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 73 /* Identifier */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOptionalParameters", 56 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 8 /* Delete */), + rule("NoSpaceAfterEllipsis", 25 /* DotDotDotToken */, 75 /* Identifier */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOptionalParameters", 57 /* QuestionToken */, [21 /* CloseParenToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isNotBinaryOpContext], 16 /* DeleteSpace */), // Remove spaces in empty interface literals. e.g.: x: {} - rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 8 /* Delete */), + rule("NoSpaceBetweenEmptyInterfaceBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectTypeContext], 16 /* DeleteSpace */), // generics and type assertions - rule("NoSpaceBeforeOpenAngularBracket", typeNames, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterOpenAngularBracket", 28 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseAngularBracket", anyToken, 30 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterCloseAngularBracket", 30 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 30 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 8 /* Delete */), + rule("NoSpaceBeforeOpenAngularBracket", typeNames, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBetweenCloseParenAndAngularBracket", 21 /* CloseParenToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenAngularBracket", 29 /* LessThanToken */, anyToken, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseAngularBracket", anyToken, 31 /* GreaterThanToken */, [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseAngularBracket", 31 /* GreaterThanToken */, [20 /* OpenParenToken */, 22 /* OpenBracketToken */, 31 /* GreaterThanToken */, 27 /* CommaToken */], [isNonJsxSameLineTokenContext, isTypeArgumentOrParameterOrAssertionContext, isNotFunctionDeclContext /*To prevent an interference with the SpaceBeforeOpenParenInFuncDecl rule*/], 16 /* DeleteSpace */), // decorators - rule("SpaceBeforeAt", [21 /* CloseParenToken */, 73 /* Identifier */], 58 /* AtToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterAt", 58 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceBeforeAt", [21 /* CloseParenToken */, 75 /* Identifier */], 59 /* AtToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAt", 59 /* AtToken */, anyToken, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after @ in decorator rule("SpaceAfterDecorator", anyToken, [ - 119 /* AbstractKeyword */, - 73 /* Identifier */, - 86 /* ExportKeyword */, - 81 /* DefaultKeyword */, - 77 /* ClassKeyword */, - 117 /* StaticKeyword */, - 116 /* PublicKeyword */, - 114 /* PrivateKeyword */, - 115 /* ProtectedKeyword */, - 127 /* GetKeyword */, - 138 /* SetKeyword */, + 121 /* AbstractKeyword */, + 75 /* Identifier */, + 88 /* ExportKeyword */, + 83 /* DefaultKeyword */, + 79 /* ClassKeyword */, + 119 /* StaticKeyword */, + 118 /* PublicKeyword */, + 116 /* PrivateKeyword */, + 117 /* ProtectedKeyword */, + 130 /* GetKeyword */, + 141 /* SetKeyword */, 22 /* OpenBracketToken */, - 40 /* AsteriskToken */, - ], [isEndOfDecoratorContextOnSameLine], 2 /* Space */), - rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 52 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 8 /* Delete */), - rule("NoSpaceAfterNewKeywordOnConstructorSignature", 96 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 8 /* Delete */), - rule("SpaceLessThanAndNonJSXTypeAnnotation", 28 /* LessThanToken */, 28 /* LessThanToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + 41 /* AsteriskToken */, + ], [isEndOfDecoratorContextOnSameLine], 4 /* InsertSpace */), + rule("NoSpaceBeforeNonNullAssertionOperator", anyToken, 53 /* ExclamationToken */, [isNonJsxSameLineTokenContext, isNonNullAssertionContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterNewKeywordOnConstructorSignature", 98 /* NewKeyword */, 20 /* OpenParenToken */, [isNonJsxSameLineTokenContext, isConstructorSignatureContext], 16 /* DeleteSpace */), + rule("SpaceLessThanAndNonJSXTypeAnnotation", 29 /* LessThanToken */, 29 /* LessThanToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; // These rules are applied after high priority var userConfigurableRules = [ // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - rule("SpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterConstructor", 125 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 2 /* Space */), - rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 8 /* Delete */), + rule("SpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterConstructor", 128 /* ConstructorKeyword */, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterConstructor"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionEnabled("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNextTokenNotCloseBracket], 4 /* InsertSpace */), + rule("NoSpaceAfterComma", 27 /* CommaToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext], 16 /* DeleteSpace */), // Insert space after function keyword for anonymous functions - rule("SpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceAfterAnonymousFunctionKeyword", [91 /* FunctionKeyword */, 40 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 8 /* Delete */), + rule("SpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterAnonymousFunctionKeyword", [93 /* FunctionKeyword */, 41 /* AsteriskToken */], 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), isFunctionDeclContext], 16 /* DeleteSpace */), // Insert space after keywords in control flow statements - rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 2 /* Space */), - rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 8 /* Delete */), + rule("SpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 4 /* InsertSpace */), + rule("NoSpaceAfterKeywordInControl", keywords, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), isControlDeclContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty parenthesis - rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBetweenOpenParens", 20 /* OpenParenToken */, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenParens", 20 /* OpenParenToken */, 21 /* CloseParenToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenParen", 20 /* OpenParenToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseParen", anyToken, 21 /* CloseParenToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing nonempty brackets - rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenBrackets", 22 /* OpenBracketToken */, 23 /* CloseBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBracket", 22 /* OpenBracketToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBracket", anyToken, 23 /* CloseBracketToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 2 /* Space */), - rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 8 /* Delete */), - rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isBraceWrappedContext], 4 /* InsertSpace */), + rule("NoSpaceBetweenEmptyBraceBrackets", 18 /* OpenBraceToken */, 19 /* CloseBraceToken */, [isNonJsxSameLineTokenContext, isObjectContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterOpenBrace", 18 /* OpenBraceToken */, anyToken, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBrace", anyToken, 19 /* CloseBraceToken */, [isOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // Insert space after opening and before closing template string braces - rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 2 /* Space */), - rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("SpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("SpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTemplateHeadAndMiddle", [15 /* TemplateHead */, 16 /* TemplateMiddle */], anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeTemplateMiddleAndTail", anyToken, [16 /* TemplateMiddle */, 17 /* TemplateTail */], [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space after { and before } in JSX expression - rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 2 /* Space */), - rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), - rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 8 /* Delete */), + rule("SpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("SpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterOpenBraceInJsxExpression", 18 /* OpenBraceToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), + rule("NoSpaceBeforeCloseBraceInJsxExpression", anyToken, 19 /* CloseBraceToken */, [isOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), isNonJsxSameLineTokenContext, isJsxExpressionContext], 16 /* DeleteSpace */), // Insert space after semicolon in for statement - rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 2 /* Space */), - rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 8 /* Delete */), + rule("SpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionEnabled("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 4 /* InsertSpace */), + rule("NoSpaceAfterSemicolonInFor", 26 /* SemicolonToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), isNonJsxSameLineTokenContext, isForContext], 16 /* DeleteSpace */), // Insert space before and after binary operators - rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 2 /* Space */), - rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 8 /* Delete */), - rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 2 /* Space */), - rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 8 /* Delete */), + rule("SpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("SpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeBinaryOperator", anyToken, binaryOperators, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterBinaryOperator", binaryOperators, anyToken, [isOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), isNonJsxSameLineTokenContext, isBinaryOpContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionEnabled("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeOpenParenInFuncDecl", anyToken, 20 /* OpenParenToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), isNonJsxSameLineTokenContext, isFunctionDeclContext], 16 /* DeleteSpace */), // Open Brace braces after control block - rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), + rule("NewLineBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), // Open Brace braces after TypeScript module/class/interface - rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 4 /* NewLine */, 1 /* CanDeleteNewLines */), - rule("SpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 2 /* Space */), - rule("NoSpaceAfterTypeAssertion", 30 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 8 /* Delete */), - rule("SpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 2 /* Space */), - rule("NoSpaceBeforeTypeAnnotation", anyToken, 57 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 8 /* Delete */), + rule("NewLineBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionEnabled("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isBeforeMultilineBlockContext], 8 /* InsertNewLine */, 1 /* CanDeleteNewLines */), + rule("SpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionEnabled("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 4 /* InsertSpace */), + rule("NoSpaceAfterTypeAssertion", 31 /* GreaterThanToken */, anyToken, [isOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), isNonJsxSameLineTokenContext, isTypeAssertionContext], 16 /* DeleteSpace */), + rule("SpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionEnabled("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 4 /* InsertSpace */), + rule("NoSpaceBeforeTypeAnnotation", anyToken, 58 /* ColonToken */, [isOptionDisabledOrUndefined("insertSpaceBeforeTypeAnnotation"), isNonJsxSameLineTokenContext, isTypeAnnotationContext], 16 /* DeleteSpace */), + rule("NoOptionalSemicolon", 26 /* SemicolonToken */, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Remove), isSemicolonDeletionContext], 32 /* DeleteToken */), + rule("OptionalSemicolon", anyToken, anyTokenIncludingEOF, [optionEquals("semicolons", ts.SemicolonPreference.Insert), isSemicolonInsertionContext], 64 /* InsertTrailingSemicolon */), ]; // These rules are lower in priority than user-configurable. Rules earlier in this list have priority over rules later in the list. var lowPriorityCommonRules = [ // Space after keyword but not before ; or : or ? - rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 2 /* Space */, 1 /* CanDeleteNewLines */), - rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), + rule("NoSpaceBeforeSemicolon", anyToken, 26 /* SemicolonToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("SpaceBeforeOpenBraceInControl", controlOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForControlBlocks"), isControlDeclContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInFunction", functionOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isFunctionDeclContext, isBeforeBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("SpaceBeforeOpenBraceInTypeScriptDeclWithBlock", typeScriptOpenBraceLeftTokenRange, 18 /* OpenBraceToken */, [isOptionDisabledOrUndefinedOrTokensOnSameLine("placeOpenBraceOnNewLineForFunctions"), isTypeScriptDeclWithBlockContext, isNotFormatOnEnter, isSameLineTokenOrBeforeBlockContext], 4 /* InsertSpace */, 1 /* CanDeleteNewLines */), + rule("NoSpaceBeforeComma", anyToken, 27 /* CommaToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), // No space before and after indexer `x[]` - rule("NoSpaceBeforeOpenBracket", anyTokenExcept(122 /* AsyncKeyword */, 75 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 8 /* Delete */), - rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 8 /* Delete */), - rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("NoSpaceBeforeOpenBracket", anyTokenExcept(125 /* AsyncKeyword */, 77 /* CaseKeyword */), 22 /* OpenBracketToken */, [isNonJsxSameLineTokenContext], 16 /* DeleteSpace */), + rule("NoSpaceAfterCloseBracket", 23 /* CloseBracketToken */, anyToken, [isNonJsxSameLineTokenContext, isNotBeforeBlockInFunctionDeclarationContext], 16 /* DeleteSpace */), + rule("SpaceAfterSemicolon", 26 /* SemicolonToken */, anyToken, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Remove extra space between for and await - rule("SpaceBetweenForAndAwaitKeyword", 90 /* ForKeyword */, 123 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceBetweenForAndAwaitKeyword", 92 /* ForKeyword */, 126 /* AwaitKeyword */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), // Add a space between statements. All keywords except (do,else,case) has open/close parens after them. // So, we have a rule to add a space for [),Any], [do,Any], [else,Any], and [case,Any] - rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 83 /* DoKeyword */, 84 /* ElseKeyword */, 75 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 2 /* Space */), + rule("SpaceBetweenStatements", [21 /* CloseParenToken */, 85 /* DoKeyword */, 86 /* ElseKeyword */, 77 /* CaseKeyword */], anyToken, [isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext], 4 /* InsertSpace */), // This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter. - rule("SpaceAfterTryFinally", [104 /* TryKeyword */, 89 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 2 /* Space */), + rule("SpaceAfterTryFinally", [106 /* TryKeyword */, 91 /* FinallyKeyword */], 18 /* OpenBraceToken */, [isNonJsxSameLineTokenContext], 4 /* InsertSpace */), ]; return __spreadArrays(highPriorityCommonRules, userConfigurableRules, lowPriorityCommonRules); } @@ -113042,6 +117525,9 @@ var ts; /// /// Contexts /// + function optionEquals(optionName, optionValue) { + return function (context) { return context.options && context.options[optionName] === optionValue; }; + } function isOptionEnabled(optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; } @@ -113058,45 +117544,50 @@ var ts; return function (context) { return !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; }; } function isForContext(context) { - return context.contextNode.kind === 226 /* ForStatement */; + return context.contextNode.kind === 229 /* ForStatement */; } function isNotForContext(context) { return !isForContext(context); } function isBinaryOpContext(context) { switch (context.contextNode.kind) { - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 176 /* ConditionalType */: - case 213 /* AsExpression */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 164 /* TypePredicate */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 179 /* ConditionalType */: + case 216 /* AsExpression */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 167 /* TypePredicate */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 187 /* BindingElement */: + case 190 /* BindingElement */: // equals in type X = ... - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 249 /* ImportEqualsDeclaration */: - // equal in let a = 0; - case 238 /* VariableDeclaration */: - // equal in p = 0; - case 152 /* Parameter */: - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - return context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 252 /* ImportEqualsDeclaration */: + // equal in let a = 0 + // falls through + case 241 /* VariableDeclaration */: + // equal in p = 0 + // falls through + case 155 /* Parameter */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + return context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 151 /* TypeParameter */: - return context.currentTokenSpan.kind === 94 /* InKeyword */ || context.nextTokenSpan.kind === 94 /* InKeyword */ || context.currentTokenSpan.kind === 60 /* EqualsToken */ || context.nextTokenSpan.kind === 60 /* EqualsToken */; + // falls through + case 154 /* TypeParameter */: + return context.currentTokenSpan.kind === 96 /* InKeyword */ || context.nextTokenSpan.kind === 96 /* InKeyword */ || context.currentTokenSpan.kind === 62 /* EqualsToken */ || context.nextTokenSpan.kind === 62 /* EqualsToken */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 228 /* ForOfStatement */: - return context.currentTokenSpan.kind === 148 /* OfKeyword */ || context.nextTokenSpan.kind === 148 /* OfKeyword */; + case 231 /* ForOfStatement */: + return context.currentTokenSpan.kind === 151 /* OfKeyword */ || context.nextTokenSpan.kind === 151 /* OfKeyword */; } return false; } @@ -113108,22 +117599,22 @@ var ts; } function isTypeAnnotationContext(context) { var contextKind = context.contextNode.kind; - return contextKind === 155 /* PropertyDeclaration */ || - contextKind === 154 /* PropertySignature */ || - contextKind === 152 /* Parameter */ || - contextKind === 238 /* VariableDeclaration */ || + return contextKind === 158 /* PropertyDeclaration */ || + contextKind === 157 /* PropertySignature */ || + contextKind === 155 /* Parameter */ || + contextKind === 241 /* VariableDeclaration */ || ts.isFunctionLikeKind(contextKind); } function isConditionalOperatorContext(context) { - return context.contextNode.kind === 206 /* ConditionalExpression */ || - context.contextNode.kind === 176 /* ConditionalType */; + return context.contextNode.kind === 209 /* ConditionalExpression */ || + context.contextNode.kind === 179 /* ConditionalType */; } function isSameLineTokenOrBeforeBlockContext(context) { return context.TokensAreOnSameLine() || isBeforeBlockContext(context); } function isBraceWrappedContext(context) { - return context.contextNode.kind === 185 /* ObjectBindingPattern */ || - context.contextNode.kind === 182 /* MappedType */ || + return context.contextNode.kind === 188 /* ObjectBindingPattern */ || + context.contextNode.kind === 185 /* MappedType */ || isSingleLineBlockContext(context); } // This check is done before an open brace in a control construct, a function, or a typescript block declaration @@ -113149,31 +117640,34 @@ var ts; return true; } switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 189 /* ObjectLiteralExpression */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 192 /* ObjectLiteralExpression */: + case 249 /* ModuleBlock */: return true; } return false; } function isFunctionDeclContext(context) { switch (context.contextNode.kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + // falls through + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 161 /* CallSignature */: - case 197 /* FunctionExpression */: - case 158 /* Constructor */: - case 198 /* ArrowFunction */: + // falls through + case 164 /* CallSignature */: + case 200 /* FunctionExpression */: + case 161 /* Constructor */: + case 201 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 242 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one + // falls through + case 245 /* InterfaceDeclaration */: // This one is not truly a function, but for formatting purposes, it acts just like one return true; } return false; @@ -113182,40 +117676,40 @@ var ts; return !isFunctionDeclContext(context); } function isFunctionDeclarationOrFunctionExpressionContext(context) { - return context.contextNode.kind === 240 /* FunctionDeclaration */ || context.contextNode.kind === 197 /* FunctionExpression */; + return context.contextNode.kind === 243 /* FunctionDeclaration */ || context.contextNode.kind === 200 /* FunctionExpression */; } function isTypeScriptDeclWithBlockContext(context) { return nodeIsTypeScriptDeclWithBlockContext(context.contextNode); } function nodeIsTypeScriptDeclWithBlockContext(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 169 /* TypeLiteral */: - case 245 /* ModuleDeclaration */: - case 256 /* ExportDeclaration */: - case 257 /* NamedExports */: - case 250 /* ImportDeclaration */: - case 253 /* NamedImports */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 172 /* TypeLiteral */: + case 248 /* ModuleDeclaration */: + case 259 /* ExportDeclaration */: + case 260 /* NamedExports */: + case 253 /* ImportDeclaration */: + case 256 /* NamedImports */: return true; } return false; } function isAfterCodeBlockContext(context) { switch (context.currentTokenParent.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 275 /* CatchClause */: - case 246 /* ModuleBlock */: - case 233 /* SwitchStatement */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 278 /* CatchClause */: + case 249 /* ModuleBlock */: + case 236 /* SwitchStatement */: return true; - case 219 /* Block */: { + case 222 /* Block */: { var blockParent = context.currentTokenParent.parent; // In a codefix scenario, we can't rely on parents being set. So just always return true. - if (!blockParent || blockParent.kind !== 198 /* ArrowFunction */ && blockParent.kind !== 197 /* FunctionExpression */) { + if (!blockParent || blockParent.kind !== 201 /* ArrowFunction */ && blockParent.kind !== 200 /* FunctionExpression */) { return true; } } @@ -113224,31 +117718,32 @@ var ts; } function isControlDeclContext(context) { switch (context.contextNode.kind) { - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 232 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 235 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 275 /* CatchClause */: + // falls through + case 278 /* CatchClause */: return true; default: return false; } } function isObjectContext(context) { - return context.contextNode.kind === 189 /* ObjectLiteralExpression */; + return context.contextNode.kind === 192 /* ObjectLiteralExpression */; } function isFunctionCallContext(context) { - return context.contextNode.kind === 192 /* CallExpression */; + return context.contextNode.kind === 195 /* CallExpression */; } function isNewContext(context) { - return context.contextNode.kind === 193 /* NewExpression */; + return context.contextNode.kind === 196 /* NewExpression */; } function isFunctionCallOrNewContext(context) { return isFunctionCallContext(context) || isNewContext(context); @@ -113260,28 +117755,28 @@ var ts; return context.nextTokenSpan.kind !== 23 /* CloseBracketToken */; } function isArrowFunctionContext(context) { - return context.contextNode.kind === 198 /* ArrowFunction */; + return context.contextNode.kind === 201 /* ArrowFunction */; } function isImportTypeContext(context) { - return context.contextNode.kind === 184 /* ImportType */; + return context.contextNode.kind === 187 /* ImportType */; } function isNonJsxSameLineTokenContext(context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 11 /* JsxText */; } function isNonJsxElementOrFragmentContext(context) { - return context.contextNode.kind !== 261 /* JsxElement */ && context.contextNode.kind !== 265 /* JsxFragment */; + return context.contextNode.kind !== 264 /* JsxElement */ && context.contextNode.kind !== 268 /* JsxFragment */; } function isJsxExpressionContext(context) { - return context.contextNode.kind === 271 /* JsxExpression */ || context.contextNode.kind === 270 /* JsxSpreadAttribute */; + return context.contextNode.kind === 274 /* JsxExpression */ || context.contextNode.kind === 273 /* JsxSpreadAttribute */; } function isNextTokenParentJsxAttribute(context) { - return context.nextTokenParent.kind === 268 /* JsxAttribute */; + return context.nextTokenParent.kind === 271 /* JsxAttribute */; } function isJsxAttributeContext(context) { - return context.contextNode.kind === 268 /* JsxAttribute */; + return context.contextNode.kind === 271 /* JsxAttribute */; } function isJsxSelfClosingElementContext(context) { - return context.contextNode.kind === 262 /* JsxSelfClosingElement */; + return context.contextNode.kind === 265 /* JsxSelfClosingElement */; } function isNotBeforeBlockInFunctionDeclarationContext(context) { return !isFunctionDeclContext(context) && !isBeforeBlockContext(context); @@ -113296,45 +117791,45 @@ var ts; while (ts.isExpressionNode(node)) { node = node.parent; } - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } function isStartOfVariableDeclarationList(context) { - return context.currentTokenParent.kind === 239 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 242 /* VariableDeclarationList */ && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; } function isNotFormatOnEnter(context) { return context.formattingRequestKind !== 2 /* FormatOnEnter */; } function isModuleDeclContext(context) { - return context.contextNode.kind === 245 /* ModuleDeclaration */; + return context.contextNode.kind === 248 /* ModuleDeclaration */; } function isObjectTypeContext(context) { - return context.contextNode.kind === 169 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 172 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } function isConstructorSignatureContext(context) { - return context.contextNode.kind === 162 /* ConstructSignature */; + return context.contextNode.kind === 165 /* ConstructSignature */; } function isTypeArgumentOrParameterOrAssertion(token, parent) { - if (token.kind !== 28 /* LessThanToken */ && token.kind !== 30 /* GreaterThanToken */) { + if (token.kind !== 29 /* LessThanToken */ && token.kind !== 31 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 165 /* TypeReference */: - case 195 /* TypeAssertionExpression */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 198 /* TypeAssertionExpression */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -113345,16 +117840,78 @@ var ts; isTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); } function isTypeAssertionContext(context) { - return context.contextNode.kind === 195 /* TypeAssertionExpression */; + return context.contextNode.kind === 198 /* TypeAssertionExpression */; } function isVoidOpContext(context) { - return context.currentTokenSpan.kind === 107 /* VoidKeyword */ && context.currentTokenParent.kind === 201 /* VoidExpression */; + return context.currentTokenSpan.kind === 109 /* VoidKeyword */ && context.currentTokenParent.kind === 204 /* VoidExpression */; } function isYieldOrYieldStarWithOperand(context) { - return context.contextNode.kind === 208 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 211 /* YieldExpression */ && context.contextNode.expression !== undefined; } function isNonNullAssertionContext(context) { - return context.contextNode.kind === 214 /* NonNullExpression */; + return context.contextNode.kind === 217 /* NonNullExpression */; + } + function isSemicolonDeletionContext(context) { + var nextTokenKind = context.nextTokenSpan.kind; + var nextTokenStart = context.nextTokenSpan.pos; + if (ts.isTrivia(nextTokenKind)) { + var nextRealToken = context.nextTokenParent === context.currentTokenParent + ? ts.findNextToken(context.currentTokenParent, ts.findAncestor(context.currentTokenParent, function (a) { return !a.parent; }), context.sourceFile) + : context.nextTokenParent.getFirstToken(context.sourceFile); + if (!nextRealToken) { + return true; + } + nextTokenKind = nextRealToken.kind; + nextTokenStart = nextRealToken.getStart(context.sourceFile); + } + var startLine = context.sourceFile.getLineAndCharacterOfPosition(context.currentTokenSpan.pos).line; + var endLine = context.sourceFile.getLineAndCharacterOfPosition(nextTokenStart).line; + if (startLine === endLine) { + return nextTokenKind === 19 /* CloseBraceToken */ + || nextTokenKind === 1 /* EndOfFileToken */; + } + if (nextTokenKind === 221 /* SemicolonClassElement */ || + nextTokenKind === 26 /* SemicolonToken */) { + return false; + } + if (context.contextNode.kind === 245 /* InterfaceDeclaration */ || + context.contextNode.kind === 246 /* TypeAliasDeclaration */) { + // Can’t remove semicolon after `foo`; it would parse as a method declaration: + // + // interface I { + // foo; + // (): void + // } + return !ts.isPropertySignature(context.currentTokenParent) + || !!context.currentTokenParent.type + || nextTokenKind !== 20 /* OpenParenToken */; + } + if (ts.isPropertyDeclaration(context.currentTokenParent)) { + return !context.currentTokenParent.initializer; + } + return context.currentTokenParent.kind !== 229 /* ForStatement */ + && context.currentTokenParent.kind !== 223 /* EmptyStatement */ + && context.currentTokenParent.kind !== 221 /* SemicolonClassElement */ + && nextTokenKind !== 22 /* OpenBracketToken */ + && nextTokenKind !== 20 /* OpenParenToken */ + && nextTokenKind !== 39 /* PlusToken */ + && nextTokenKind !== 40 /* MinusToken */ + && nextTokenKind !== 43 /* SlashToken */ + && nextTokenKind !== 13 /* RegularExpressionLiteral */ + && nextTokenKind !== 27 /* CommaToken */ + && nextTokenKind !== 210 /* TemplateExpression */ + && nextTokenKind !== 15 /* TemplateHead */ + && nextTokenKind !== 14 /* NoSubstitutionTemplateLiteral */ + && nextTokenKind !== 24 /* DotToken */; + } + function isSemicolonInsertionContext(context) { + var contextAncestor = ts.findAncestor(context.currentTokenParent, function (ancestor) { + if (ancestor.end !== context.currentTokenSpan.end) { + return "quit"; + } + return ts.syntaxMayBeASICandidate(ancestor.kind); + }); + return !!contextAncestor && ts.isASICandidate(contextAncestor, context.sourceFile); } })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); @@ -113364,7 +117921,7 @@ var ts; var formatting; (function (formatting) { function getFormatContext(options) { - return { options: options, getRule: getRulesMap() }; + return { options: options, getRules: getRulesMap() }; } formatting.getFormatContext = getFormatContext; var rulesMapCache; @@ -113374,11 +117931,45 @@ var ts; } return rulesMapCache; } + /** + * For a given rule action, gets a mask of other rule actions that + * cannot be applied at the same position. + */ + function getRuleActionExclusion(ruleAction) { + var mask = 0; + if (ruleAction & 1 /* StopProcessingSpaceActions */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 2 /* StopProcessingTokenActions */) { + mask |= 96 /* ModifyTokenAction */; + } + if (ruleAction & 28 /* ModifySpaceAction */) { + mask |= 28 /* ModifySpaceAction */; + } + if (ruleAction & 96 /* ModifyTokenAction */) { + mask |= 96 /* ModifyTokenAction */; + } + return mask; + } function createRulesMap(rules) { var map = buildMap(rules); return function (context) { var bucket = map[getRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind)]; - return bucket && ts.find(bucket, function (rule) { return ts.every(rule.context, function (c) { return c(context); }); }); + if (bucket) { + var rules_1 = []; + var ruleActionMask = 0; + for (var _i = 0, bucket_1 = bucket; _i < bucket_1.length; _i++) { + var rule = bucket_1[_i]; + var acceptRuleActions = ~getRuleActionExclusion(ruleActionMask); + if (rule.action & acceptRuleActions && ts.every(rule.context, function (c) { return c(context); })) { + rules_1.push(rule); + ruleActionMask |= rule.action; + } + } + if (rules_1.length) { + return rules_1; + } + } }; } function buildMap(rules) { @@ -113386,8 +117977,8 @@ var ts; var map = new Array(mapRowLength * mapRowLength); // This array is used only during construction of the rulesbucket in the map var rulesBucketConstructionStateList = new Array(map.length); - for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) { - var rule = rules_1[_i]; + for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) { + var rule = rules_2[_i]; var specificRule = rule.leftTokenRange.isSpecific && rule.rightTokenRange.isSpecific; for (var _a = 0, _b = rule.leftTokenRange.tokens; _a < _b.length; _a++) { var left = _b[_a]; @@ -113405,16 +117996,16 @@ var ts; return map; } function getRuleBucketIndex(row, column) { - ts.Debug.assert(row <= 148 /* LastKeyword */ && column <= 148 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 151 /* LastKeyword */ && column <= 151 /* LastKeyword */, "Must compute formatting context from tokens"); return (row * mapRowLength) + column; } var maskBitSize = 5; var mask = 31; // MaskBitSize bits - var mapRowLength = 148 /* LastToken */ + 1; + var mapRowLength = 151 /* LastToken */ + 1; var RulesPosition; (function (RulesPosition) { - RulesPosition[RulesPosition["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific"; - RulesPosition[RulesPosition["IgnoreRulesAny"] = maskBitSize * 1] = "IgnoreRulesAny"; + RulesPosition[RulesPosition["StopRulesSpecific"] = 0] = "StopRulesSpecific"; + RulesPosition[RulesPosition["StopRulesAny"] = maskBitSize * 1] = "StopRulesAny"; RulesPosition[RulesPosition["ContextRulesSpecific"] = maskBitSize * 2] = "ContextRulesSpecific"; RulesPosition[RulesPosition["ContextRulesAny"] = maskBitSize * 3] = "ContextRulesAny"; RulesPosition[RulesPosition["NoContextRulesSpecific"] = maskBitSize * 4] = "NoContextRulesSpecific"; @@ -113436,11 +118027,11 @@ var ts; // In order to insert a rule to the end of sub-bucket (3), we get the index by adding // the values in the bitmap segments 3rd, 2nd, and 1st. function addRule(rules, rule, specificTokens, constructionState, rulesBucketIndex) { - var position = rule.action === 1 /* Ignore */ - ? specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny - : rule.context !== formatting.anyContext - ? specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny - : specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; + var position = rule.action & 3 /* StopAction */ ? + specificTokens ? RulesPosition.StopRulesSpecific : RulesPosition.StopRulesAny : + rule.context !== formatting.anyContext ? + specificTokens ? RulesPosition.ContextRulesSpecific : RulesPosition.ContextRulesAny : + specificTokens ? RulesPosition.NoContextRulesSpecific : RulesPosition.NoContextRulesAny; var state = constructionState[rulesBucketIndex] || 0; rules.splice(getInsertionIndex(state, position), 0, rule); constructionState[rulesBucketIndex] = increaseInsertionIndex(state, position); @@ -113465,6 +118056,16 @@ var ts; (function (ts) { var formatting; (function (formatting) { + function createTextRangeWithKind(pos, end, kind) { + var textRangeWithKind = { pos: pos, end: end, kind: kind }; + if (ts.Debug.isDebugging) { + Object.defineProperty(textRangeWithKind, "__debugKind", { + get: function () { return ts.Debug.formatSyntaxKind(kind); }, + }); + } + return textRangeWithKind; + } + formatting.createTextRangeWithKind = createTextRangeWithKind; var Constants; (function (Constants) { Constants[Constants["Unknown"] = -1] = "Unknown"; @@ -113588,17 +118189,17 @@ var ts; // i.e. parent is class declaration with the list of members and node is one of members. function isListElement(parent, node) { switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: var body = parent.body; - return !!body && body.kind === 246 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 285 /* SourceFile */: - case 219 /* Block */: - case 246 /* ModuleBlock */: + return !!body && body.kind === 249 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 288 /* SourceFile */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -113733,7 +118334,7 @@ var ts; return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, formatContext.options), getOwnOrInheritedDelta(enclosingNode, formatContext.options, sourceFile), scanner, formatContext, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, _a, requestKind, rangeContainsError, sourceFile) { - var options = _a.options, getRule = _a.getRule; + var options = _a.options, getRules = _a.getRules; // formatting context is used by rules provider var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); var previousRange; @@ -113823,19 +118424,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 241 /* ClassDeclaration */: return 77 /* ClassKeyword */; - case 242 /* InterfaceDeclaration */: return 111 /* InterfaceKeyword */; - case 240 /* FunctionDeclaration */: return 91 /* FunctionKeyword */; - case 244 /* EnumDeclaration */: return 244 /* EnumDeclaration */; - case 159 /* GetAccessor */: return 127 /* GetKeyword */; - case 160 /* SetAccessor */: return 138 /* SetKeyword */; - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: return 79 /* ClassKeyword */; + case 245 /* InterfaceDeclaration */: return 113 /* InterfaceKeyword */; + case 243 /* FunctionDeclaration */: return 93 /* FunctionKeyword */; + case 247 /* EnumDeclaration */: return 247 /* EnumDeclaration */; + case 162 /* GetAccessor */: return 130 /* GetKeyword */; + case 163 /* SetAccessor */: return 141 /* SetKeyword */; + case 160 /* MethodDeclaration */: if (node.asteriskToken) { - return 40 /* AsteriskToken */; + return 41 /* AsteriskToken */; } // falls through - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: var name = ts.getNameOfDeclaration(node); if (name) { return name.kind; @@ -113885,22 +118486,22 @@ var ts; case 18 /* OpenBraceToken */: case 19 /* CloseBraceToken */: case 21 /* CloseParenToken */: - case 84 /* ElseKeyword */: - case 108 /* WhileKeyword */: - case 58 /* AtToken */: + case 86 /* ElseKeyword */: + case 110 /* WhileKeyword */: + case 59 /* AtToken */: return false; - case 42 /* SlashToken */: - case 30 /* GreaterThanToken */: + case 43 /* SlashToken */: + case 31 /* GreaterThanToken */: switch (container.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: return false; } break; case 22 /* OpenBracketToken */: case 23 /* CloseBracketToken */: - if (container.kind !== 182 /* MappedType */) { + if (container.kind !== 185 /* MappedType */) { return false; } break; @@ -113947,6 +118548,12 @@ var ts; } consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node); } + if (!node.parent && formattingScanner.isOnEOF()) { + var token = formattingScanner.readEOFTokenRange(); + if (token.end <= node.end && previousRange) { + processPair(token, sourceFile.getLineAndCharacterOfPosition(token.pos).line, node, previousRange, previousRangeStartLine, previousParent, contextNode, nodeDynamicIndentation); + } + } function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) { var childStartPos = child.getStart(sourceFile); var childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; @@ -113992,7 +118599,7 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 153 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 156 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); if (child.kind === 11 /* JsxText */) { @@ -114000,7 +118607,7 @@ var ts; indentMultilineCommentOrJsxText(range, childIndentation.indentation, /*firstLineIsIndented*/ true, /*indentFinalLine*/ false); } childContextNode = node; - if (isFirstListItem && parent.kind === 188 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 191 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -114168,35 +118775,39 @@ var ts; } function processPair(currentItem, currentStartLine, currentParent, previousItem, previousStartLine, previousParent, contextNode, dynamicIndentation) { formattingContext.updateContext(previousItem, previousParent, currentItem, currentParent, contextNode); - var rule = getRule(formattingContext); - var trimTrailingWhitespaces; + var rules = getRules(formattingContext); + var trimTrailingWhitespaces = false; var lineAction = 0 /* None */; - if (rule) { - lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); - switch (lineAction) { - case 2 /* LineRemoved */: - // Handle the case where the next line is moved to be the end of this line. - // In this case we don't indent the next line in the next pass. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); - } - break; - case 1 /* LineAdded */: - // Handle the case where token2 is moved to the new line. - // In this case we indent token2 in the next pass but we set - // sameLineIndent flag to notify the indenter that the indentation is within the line. - if (currentParent.getStart(sourceFile) === currentItem.pos) { - dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); - } - break; - default: - ts.Debug.assert(lineAction === 0 /* None */); - } - // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line - trimTrailingWhitespaces = !(rule.action & 8 /* Delete */) && rule.flags !== 1 /* CanDeleteNewLines */; + if (rules) { + // Apply rules in reverse order so that higher priority rules (which are first in the array) + // win in a conflict with lower priority rules. + ts.forEachRight(rules, function (rule) { + lineAction = applyRuleEdits(rule, previousItem, previousStartLine, currentItem, currentStartLine); + switch (lineAction) { + case 2 /* LineRemoved */: + // Handle the case where the next line is moved to be the end of this line. + // In this case we don't indent the next line in the next pass. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ false); + } + break; + case 1 /* LineAdded */: + // Handle the case where token2 is moved to the new line. + // In this case we indent token2 in the next pass but we set + // sameLineIndent flag to notify the indenter that the indentation is within the line. + if (currentParent.getStart(sourceFile) === currentItem.pos) { + dynamicIndentation.recomputeIndentation(/*lineAddedByFormatting*/ true); + } + break; + default: + ts.Debug.assert(lineAction === 0 /* None */); + } + // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line + trimTrailingWhitespaces = !(rule.action & 16 /* DeleteSpace */) && rule.flags !== 1 /* CanDeleteNewLines */; + }); } else { - trimTrailingWhitespaces = true; + trimTrailingWhitespaces = currentItem.kind !== 1 /* EndOfFileToken */; } if (currentStartLine !== previousStartLine && trimTrailingWhitespaces) { // We need to trim trailing whitespace between the tokens if they were on different lines, and no rule was applied to put them on the same line @@ -114333,20 +118944,28 @@ var ts; edits.push(ts.createTextChangeFromStartLength(start, len, newText)); } } + function recordInsert(start, text) { + if (text) { + edits.push(ts.createTextChangeFromStartLength(start, 0, text)); + } + } function applyRuleEdits(rule, previousRange, previousStartLine, currentRange, currentStartLine) { var onLaterLine = currentStartLine !== previousStartLine; switch (rule.action) { - case 1 /* Ignore */: + case 1 /* StopProcessingSpaceActions */: // no action required return 0 /* None */; - case 8 /* Delete */: + case 16 /* DeleteSpace */: if (previousRange.end !== currentRange.pos) { // delete characters starting from t1.end up to t2.pos exclusive recordDelete(previousRange.end, currentRange.pos - previousRange.end); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } break; - case 4 /* NewLine */: + case 32 /* DeleteToken */: + recordDelete(previousRange.pos, previousRange.end - previousRange.pos); + break; + case 8 /* InsertNewLine */: // exit early if we on different lines and rule cannot change number of newlines // if line1 and line2 are on subsequent lines then no edits are required - ok to exit // if line1 and line2 are separated with more than one newline - ok to exit since we cannot delete extra new lines @@ -114360,7 +118979,7 @@ var ts; return onLaterLine ? 0 /* None */ : 1 /* LineAdded */; } break; - case 2 /* Space */: + case 4 /* InsertSpace */: // exit early if we on different lines and rule cannot change number of newlines if (rule.flags !== 1 /* CanDeleteNewLines */ && previousStartLine !== currentStartLine) { return 0 /* None */; @@ -114370,6 +118989,9 @@ var ts; recordReplace(previousRange.end, currentRange.pos - previousRange.end, " "); return onLaterLine ? 2 /* LineRemoved */ : 0 /* None */; } + break; + case 64 /* InsertTrailingSemicolon */: + recordInsert(previousRange.end, ";"); } return 0 /* None */; } @@ -114383,8 +119005,7 @@ var ts; /** * @param precedingToken pass `null` if preceding token was already computed and result was `undefined`. */ - function getRangeOfEnclosingComment(sourceFile, position, precedingToken, // tslint:disable-line:no-null-keyword - tokenAtPosition) { + function getRangeOfEnclosingComment(sourceFile, position, precedingToken, tokenAtPosition) { if (tokenAtPosition === void 0) { tokenAtPosition = ts.getTokenAtPosition(sourceFile, position); } var jsdoc = ts.findAncestor(tokenAtPosition, ts.isJSDoc); if (jsdoc) @@ -114393,6 +119014,7 @@ var ts; if (tokenStart <= position && position < tokenAtPosition.getEnd()) { return undefined; } + // eslint-disable-next-line no-null/no-null precedingToken = precedingToken === null ? undefined : precedingToken === undefined ? ts.findPrecedingToken(position, sourceFile) : precedingToken; // Between two consecutive tokens, all comments are either trailing on the former // or leading on the latter (and none are in both lists). @@ -114418,34 +119040,34 @@ var ts; formatting.getRangeOfEnclosingComment = getRangeOfEnclosingComment; function getOpenTokenForList(node, list) { switch (node.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 198 /* ArrowFunction */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 201 /* ArrowFunction */: if (node.typeParameters === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.parameters === list) { return 20 /* OpenParenToken */; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } else if (node.arguments === list) { return 20 /* OpenParenToken */; } break; - case 165 /* TypeReference */: + case 168 /* TypeReference */: if (node.typeArguments === list) { - return 28 /* LessThanToken */; + return 29 /* LessThanToken */; } break; - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return 18 /* OpenBraceToken */; } return 0 /* Unknown */; @@ -114454,8 +119076,8 @@ var ts; switch (kind) { case 20 /* OpenParenToken */: return 21 /* CloseParenToken */; - case 28 /* LessThanToken */: - return 30 /* GreaterThanToken */; + case 29 /* LessThanToken */: + return 31 /* GreaterThanToken */; case 18 /* OpenBraceToken */: return 19 /* CloseBraceToken */; } @@ -114543,7 +119165,8 @@ var ts; return 0; } var precedingToken = ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined, /*excludeJsdoc*/ true); - var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); // tslint:disable-line:no-null-keyword + // eslint-disable-next-line no-null/no-null + var enclosingCommentRange = formatting.getRangeOfEnclosingComment(sourceFile, position, precedingToken || null); if (enclosingCommentRange && enclosingCommentRange.kind === 3 /* MultiLineCommentTrivia */) { return getCommentIndent(sourceFile, position, options, enclosingCommentRange); } @@ -114562,7 +119185,7 @@ var ts; if (options.indentStyle === ts.IndentStyle.Block) { return getBlockIndent(sourceFile, position, options); } - if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 205 /* BinaryExpression */) { + if (precedingToken.kind === 27 /* CommaToken */ && precedingToken.parent.kind !== 208 /* BinaryExpression */) { // previous token is comma that separates items in list - find the previous item and try to derive indentation from it var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1 /* Unknown */) { @@ -114716,7 +119339,7 @@ var ts; // - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually // - parent and child are not on the same line var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 285 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 288 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } @@ -114764,8 +119387,8 @@ var ts; } SmartIndenter.isArgumentAndStartLineOverlapsExpressionBeingCalled = isArgumentAndStartLineOverlapsExpressionBeingCalled; function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 223 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 84 /* ElseKeyword */, sourceFile); + if (parent.kind === 226 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 86 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -114777,7 +119400,10 @@ var ts; if (ts.isCallOrNewExpression(parent)) { if (!parent.arguments) return false; - var currentNode = ts.Debug.assertDefined(ts.find(parent.arguments, function (arg) { return arg.pos === child.pos; })); + var currentNode = ts.find(parent.arguments, function (arg) { return arg.pos === child.pos; }); + // If it's not one of the arguments, don't look past this + if (!currentNode) + return false; var currentIndex = parent.arguments.indexOf(currentNode); if (currentIndex === 0) return false; // Can't look at previous node if first @@ -114799,40 +119425,40 @@ var ts; } function getListByRange(start, end, node, sourceFile) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getList(node.typeArguments); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return getList(node.properties); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getList(node.elements); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return getList(node.members); - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 158 /* Constructor */: - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 161 /* Constructor */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return getList(node.typeParameters) || getList(node.parameters); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: return getList(node.typeParameters); - case 193 /* NewExpression */: - case 192 /* CallExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: return getList(node.typeArguments) || getList(node.arguments); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return getList(node.declarations); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return getList(node.elements); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return getList(node.elements); } function getList(list) { @@ -114855,7 +119481,7 @@ var ts; return findColumnForFirstNonWhitespaceCharacterInLine(sourceFile.getLineAndCharacterOfPosition(list.pos), sourceFile, options); } function getActualIndentationForListItem(node, sourceFile, options, listIndentsChild) { - if (node.parent && node.parent.kind === 239 /* VariableDeclarationList */) { + if (node.parent && node.parent.kind === 242 /* VariableDeclarationList */) { // VariableDeclarationList has no wrapping tokens return -1 /* Unknown */; } @@ -114928,83 +119554,87 @@ var ts; function nodeWillIndentChild(settings, parent, child, sourceFile, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 222 /* ExpressionStatement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 188 /* ArrayLiteralExpression */: - case 219 /* Block */: - case 246 /* ModuleBlock */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 182 /* MappedType */: - case 171 /* TupleType */: - case 247 /* CaseBlock */: - case 273 /* DefaultClause */: - case 272 /* CaseClause */: - case 196 /* ParenthesizedExpression */: - case 190 /* PropertyAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 220 /* VariableStatement */: - case 255 /* ExportAssignment */: - case 231 /* ReturnStatement */: - case 206 /* ConditionalExpression */: - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: - case 262 /* JsxSelfClosingElement */: - case 271 /* JsxExpression */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 152 /* Parameter */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 178 /* ParenthesizedType */: - case 194 /* TaggedTemplateExpression */: - case 202 /* AwaitExpression */: - case 257 /* NamedExports */: - case 253 /* NamedImports */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 155 /* PropertyDeclaration */: + case 225 /* ExpressionStatement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 191 /* ArrayLiteralExpression */: + case 222 /* Block */: + case 249 /* ModuleBlock */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 185 /* MappedType */: + case 174 /* TupleType */: + case 250 /* CaseBlock */: + case 276 /* DefaultClause */: + case 275 /* CaseClause */: + case 199 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 224 /* VariableStatement */: + case 258 /* ExportAssignment */: + case 234 /* ReturnStatement */: + case 209 /* ConditionalExpression */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: + case 265 /* JsxSelfClosingElement */: + case 274 /* JsxExpression */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 155 /* Parameter */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 181 /* ParenthesizedType */: + case 197 /* TaggedTemplateExpression */: + case 205 /* AwaitExpression */: + case 260 /* NamedExports */: + case 256 /* NamedImports */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 158 /* PropertyDeclaration */: return true; - case 238 /* VariableDeclaration */: - case 276 /* PropertyAssignment */: - if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 189 /* ObjectLiteralExpression */) { // TODO: GH#18217 + case 241 /* VariableDeclaration */: + case 279 /* PropertyAssignment */: + case 208 /* BinaryExpression */: + if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === 192 /* ObjectLiteralExpression */) { // TODO: GH#18217 return rangeIsOnOneLine(sourceFile, child); } - return true; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 223 /* IfStatement */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return childKind !== 219 /* Block */; - case 256 /* ExportDeclaration */: - return childKind !== 257 /* NamedExports */; - case 250 /* ImportDeclaration */: - return childKind !== 251 /* ImportClause */ || - (!!child.namedBindings && child.namedBindings.kind !== 253 /* NamedImports */); - case 261 /* JsxElement */: - return childKind !== 264 /* JsxClosingElement */; - case 265 /* JsxFragment */: - return childKind !== 267 /* JsxClosingFragment */; - case 175 /* IntersectionType */: - case 174 /* UnionType */: - if (childKind === 169 /* TypeLiteral */) { + if (parent.kind !== 208 /* BinaryExpression */) { + return true; + } + break; + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 226 /* IfStatement */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return childKind !== 222 /* Block */; + case 259 /* ExportDeclaration */: + return childKind !== 260 /* NamedExports */; + case 253 /* ImportDeclaration */: + return childKind !== 254 /* ImportClause */ || + (!!child.namedBindings && child.namedBindings.kind !== 256 /* NamedImports */); + case 264 /* JsxElement */: + return childKind !== 267 /* JsxClosingElement */; + case 268 /* JsxFragment */: + return childKind !== 270 /* JsxClosingFragment */; + case 178 /* IntersectionType */: + case 177 /* UnionType */: + if (childKind === 172 /* TypeLiteral */) { return false; } // falls through @@ -115015,11 +119645,11 @@ var ts; SmartIndenter.nodeWillIndentChild = nodeWillIndentChild; function isControlFlowEndingStatement(kind, parent) { switch (kind) { - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: - return parent.kind !== 219 /* Block */; + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: + return parent.kind !== 222 /* Block */; default: return false; } @@ -115161,7 +119791,7 @@ var ts; * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element */ function isSeparator(node, candidate) { - return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 189 /* ObjectLiteralExpression */)); + return !!candidate && !!node.parent && (candidate.kind === 27 /* CommaToken */ || (candidate.kind === 26 /* SemicolonToken */ && node.parent.kind === 192 /* ObjectLiteralExpression */)); } function spaces(count) { var s = ""; @@ -115192,6 +119822,18 @@ var ts; cb(tracker); return tracker.getChanges(); }; + ChangeTracker.prototype.pushRaw = function (sourceFile, change) { + ts.Debug.assertEqual(sourceFile.fileName, change.fileName); + for (var _i = 0, _a = change.textChanges; _i < _a.length; _i++) { + var c = _a[_i]; + this.changes.push({ + kind: ChangeKind.Text, + sourceFile: sourceFile, + text: c.newText, + range: ts.createTextRangeFromSpan(c.span), + }); + } + }; ChangeTracker.prototype.deleteRange = function (sourceFile, range) { this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); }; @@ -115320,15 +119962,16 @@ var ts; endNode = ts.findChildOfKind(node, 21 /* CloseParenToken */, sourceFile); if (!endNode) { if (!ts.isArrowFunction(node)) - return; // Function missing parentheses, give up + return false; // Function missing parentheses, give up // If no `)`, is an arrow function `x => x`, so use the end of the first parameter endNode = ts.first(node.parameters); } } else { - endNode = node.kind !== 238 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; + endNode = node.kind !== 241 /* VariableDeclaration */ && node.questionToken ? node.questionToken : node.name; } this.insertNodeAt(sourceFile, endNode.end, type, { prefix: ": " }); + return true; }; ChangeTracker.prototype.tryInsertThisTypeAnnotation = function (sourceFile, node, type) { var start = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile).getStart(sourceFile) + 1; @@ -115443,18 +120086,18 @@ var ts; }; ChangeTracker.prototype.getInsertNodeAfterOptionsWorker = function (node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: return { prefix: this.newLineCharacter, suffix: this.newLineCharacter }; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: case 10 /* StringLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return { prefix: ", " }; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return { suffix: "," + this.newLineCharacter }; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return { prefix: " " }; - case 152 /* Parameter */: + case 155 /* Parameter */: return {}; default: ts.Debug.assert(ts.isStatement(node) || ts.isClassOrTypeElement(node)); // Else we haven't handled this kind of node yet -- add it @@ -115463,12 +120106,12 @@ var ts; }; ChangeTracker.prototype.insertName = function (sourceFile, node, name) { ts.Debug.assert(!node.name); - if (node.kind === 198 /* ArrowFunction */) { - var arrow = ts.findChildOfKind(node, 37 /* EqualsGreaterThanToken */, sourceFile); + if (node.kind === 201 /* ArrowFunction */) { + var arrow = ts.findChildOfKind(node, 38 /* EqualsGreaterThanToken */, sourceFile); var lparen = ts.findChildOfKind(node, 20 /* OpenParenToken */, sourceFile); if (lparen) { // `() => {}` --> `function f() {}` - this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(91 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); + this.insertNodesAt(sourceFile, lparen.getStart(sourceFile), [ts.createToken(93 /* FunctionKeyword */), ts.createIdentifier(name)], { joiner: " " }); deleteNode(this, sourceFile, arrow); } else { @@ -115477,14 +120120,14 @@ var ts; // Replacing full range of arrow to get rid of the leading space -- replace ` =>` with `)` this.replaceRange(sourceFile, arrow, ts.createToken(21 /* CloseParenToken */)); } - if (node.body.kind !== 219 /* Block */) { + if (node.body.kind !== 222 /* Block */) { // `() => 0` => `function f() { return 0; }` - this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(98 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); + this.insertNodesAt(sourceFile, node.body.getStart(sourceFile), [ts.createToken(18 /* OpenBraceToken */), ts.createToken(100 /* ReturnKeyword */)], { joiner: " ", suffix: " " }); this.insertNodesAt(sourceFile, node.body.end, [ts.createToken(26 /* SemicolonToken */), ts.createToken(19 /* CloseBraceToken */)], { joiner: " " }); } } else { - var pos = ts.findChildOfKind(node, node.kind === 197 /* FunctionExpression */ ? 91 /* FunctionKeyword */ : 77 /* ClassKeyword */, sourceFile).end; + var pos = ts.findChildOfKind(node, node.kind === 200 /* FunctionExpression */ ? 93 /* FunctionKeyword */ : 79 /* ClassKeyword */, sourceFile).end; this.insertNodeAt(sourceFile, pos, ts.createIdentifier(name), { prefix: " " }); } }; @@ -115735,29 +120378,34 @@ var ts; var noIndent = (options.preserveLeadingWhitespace || options.indentation !== undefined || ts.getLineStartPositionForPosition(pos, sourceFile) === pos) ? text : text.replace(/^\s+/, ""); return (options.prefix || "") + noIndent + (options.suffix || ""); } + function getFormatCodeSettingsForWriting(_a, sourceFile) { + var options = _a.options; + var shouldAutoDetectSemicolonPreference = !options.semicolons || options.semicolons === ts.SemicolonPreference.Ignore; + var shouldRemoveSemicolons = options.semicolons === ts.SemicolonPreference.Remove || shouldAutoDetectSemicolonPreference && !ts.probablyUsesSemicolons(sourceFile); + return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore }); + } /** Note: this may mutate `nodeIn`. */ function getFormattedTextOfNode(nodeIn, sourceFile, pos, _a, newLineCharacter, formatContext, validate) { var indentation = _a.indentation, prefix = _a.prefix, delta = _a.delta; var _b = getNonformattedText(nodeIn, sourceFile, newLineCharacter), node = _b.node, text = _b.text; if (validate) validate(node, text); - var formatOptions = formatContext.options; + var formatOptions = getFormatCodeSettingsForWriting(formatContext, sourceFile); var initialIndentation = indentation !== undefined ? indentation : ts.formatting.SmartIndenter.getIndentation(pos, sourceFile, formatOptions, prefix === newLineCharacter || ts.getLineStartPositionForPosition(pos, sourceFile) === pos); if (delta === undefined) { - delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatContext.options, nodeIn) ? (formatOptions.indentSize || 0) : 0; + delta = ts.formatting.SmartIndenter.shouldIndentChildNode(formatOptions, nodeIn) ? (formatOptions.indentSize || 0) : 0; } var file = { text: text, getLineAndCharacterOfPosition: function (pos) { return ts.getLineAndCharacterOfPosition(this, pos); } }; - var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, formatContext); + var changes = ts.formatting.formatNodeGivenIndentation(node, file, sourceFile.languageVariant, initialIndentation, delta, __assign(__assign({}, formatContext), { options: formatOptions })); return applyChanges(text, changes); } /** Note: output node may be mutated input node. */ function getNonformattedText(node, sourceFile, newLineCharacter) { - var omitTrailingSemicolon = !!sourceFile && !ts.probablyUsesSemicolons(sourceFile); - var writer = createWriter(newLineCharacter, omitTrailingSemicolon); + var writer = createWriter(newLineCharacter); var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - ts.createPrinter({ newLine: newLine, neverAsciiEscape: true, omitTrailingSemicolon: omitTrailingSemicolon }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); + ts.createPrinter({ newLine: newLine, neverAsciiEscape: true }, writer).writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } changesToText.getNonformattedText = getNonformattedText; @@ -115792,9 +120440,9 @@ var ts; nodeArray.end = getEnd(nodes); return nodeArray; } - function createWriter(newLine, omitTrailingSemicolon) { + function createWriter(newLine) { var lastNonTriviaPosition = 0; - var writer = omitTrailingSemicolon ? ts.getTrailingSemicolonOmittingWriter(ts.createTextWriter(newLine)) : ts.createTextWriter(newLine); + var writer = ts.createTextWriter(newLine); var onEmitNode = function (hint, node, printCallback) { if (node) { setPos(node, lastNonTriviaPosition); @@ -115945,6 +120593,8 @@ var ts; getColumn: getColumn, getIndent: getIndent, isAtStartOfLine: isAtStartOfLine, + hasTrailingComment: function () { return writer.hasTrailingComment(); }, + hasTrailingWhitespace: function () { return writer.hasTrailingWhitespace(); }, clear: clear }; } @@ -116009,14 +120659,14 @@ var ts; } textChanges_3.isValidLocationToAddComment = isValidLocationToAddComment; function needSemicolonBetween(a, b) { - return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 150 /* ComputedPropertyName */ + return (ts.isPropertySignature(a) || ts.isPropertyDeclaration(a)) && ts.isClassOrTypeElement(b) && b.name.kind === 153 /* ComputedPropertyName */ || ts.isStatementButNotDeclaration(a) && ts.isStatementButNotDeclaration(b); // TODO: only if b would start with a `(` or `[` } var deleteDeclaration; (function (deleteDeclaration_1) { function deleteDeclaration(changes, deletedNodesInLists, sourceFile, node) { switch (node.kind) { - case 152 /* Parameter */: { + case 155 /* Parameter */: { var oldFunction = node.parent; if (ts.isArrowFunction(oldFunction) && oldFunction.parameters.length === 1 && @@ -116031,14 +120681,14 @@ var ts; } break; } - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteNode(changes, sourceFile, node, // For first import, leave header comment in place node === sourceFile.imports[0].parent ? { leadingTriviaOption: LeadingTriviaOption.Exclude } : undefined); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: var pattern = node.parent; - var preserveComma = pattern.kind === 186 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); + var preserveComma = pattern.kind === 189 /* ArrayBindingPattern */ && node !== ts.last(pattern.elements); if (preserveComma) { deleteNode(changes, sourceFile, node); } @@ -116046,13 +120696,13 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node); break; - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: var namedImports = node.parent; if (namedImports.elements.length === 1) { deleteImportBinding(changes, sourceFile, namedImports); @@ -116061,7 +120711,7 @@ var ts; deleteNodeInList(changes, deletedNodesInLists, sourceFile, node); } break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: deleteImportBinding(changes, sourceFile, node); break; default: @@ -116108,13 +120758,13 @@ var ts; // Delete the entire import declaration // |import * as ns from './file'| // |import { a } from './file'| - var importDecl = ts.getAncestor(node, 250 /* ImportDeclaration */); + var importDecl = ts.getAncestor(node, 253 /* ImportDeclaration */); deleteNode(changes, sourceFile, importDecl); } } function deleteVariableDeclaration(changes, deletedNodesInLists, sourceFile, node) { var parent = node.parent; - if (parent.kind === 275 /* CatchClause */) { + if (parent.kind === 278 /* CatchClause */) { // TODO: There's currently no unused diagnostic for this, could be a suggestion changes.deleteNodeRange(sourceFile, ts.findChildOfKind(parent, 20 /* OpenParenToken */, sourceFile), ts.findChildOfKind(parent, 21 /* CloseParenToken */, sourceFile)); return; @@ -116125,14 +120775,14 @@ var ts; } var gp = parent.parent; switch (gp.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: changes.replaceNode(sourceFile, node, ts.createObjectLiteral()); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: deleteNode(changes, sourceFile, parent); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: deleteNode(changes, sourceFile, gp); break; default: @@ -116293,10 +120943,10 @@ var ts; }); function makeChange(changeTracker, sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); })); + var assertion = ts.Debug.assertDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertion(n); }), "Expected to find an assertion expression"); var replacement = ts.isAsExpression(assertion) - ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(144 /* UnknownKeyword */)) - : ts.createTypeAssertion(ts.createKeywordTypeNode(144 /* UnknownKeyword */), assertion.expression); + ? ts.createAsExpression(assertion.expression, ts.createKeywordTypeNode(147 /* UnknownKeyword */)) + : ts.createTypeAssertion(ts.createKeywordTypeNode(147 /* UnknownKeyword */), assertion.expression); changeTracker.replaceNode(sourceFile, assertion.expression, replacement); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -116334,7 +120984,7 @@ var ts; errorCodes: errorCodes, getCodeActions: function (context) { var sourceFile = context.sourceFile, errorCode = context.errorCode, span = context.span, cancellationToken = context.cancellationToken, program = context.program; - var expression = getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program); if (!expression) { return; } @@ -116348,27 +120998,38 @@ var ts; getAllCodeActions: function (context) { var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; var checker = context.program.getTypeChecker(); + var fixedDeclarations = ts.createMap(); return codefix.codeFixAll(context, errorCodes, function (t, diagnostic) { - var expression = getAwaitableExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); + var expression = getFixableErrorSpanExpression(sourceFile, diagnostic.code, diagnostic, cancellationToken, program); if (!expression) { return; } var trackChanges = function (cb) { return (cb(t), []); }; - return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges) - || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges); + return getDeclarationSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations) + || getUseSiteFix(context, expression, diagnostic.code, checker, trackChanges, fixedDeclarations); }); }, }); - function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges) { - var sourceFile = context.sourceFile; - var awaitableInitializer = findAwaitableInitializer(expression, sourceFile, checker); - if (awaitableInitializer) { - var initializerChanges = trackChanges(function (t) { return makeChange(t, errorCode, sourceFile, checker, awaitableInitializer); }); - return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, [ts.Diagnostics.Add_await_to_initializer_for_0, expression.getText(sourceFile)]); + function getDeclarationSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken; + var awaitableInitializers = findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker); + if (awaitableInitializers) { + var initializerChanges = trackChanges(function (t) { + ts.forEach(awaitableInitializers.initializers, function (_a) { + var expression = _a.expression; + return makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + }); + if (fixedDeclarations && awaitableInitializers.needsSecondPassForFixAll) { + makeChange(t, errorCode, sourceFile, checker, expression, fixedDeclarations); + } + }); + return codefix.createCodeFixActionNoFixId("addMissingAwaitToInitializer", initializerChanges, awaitableInitializers.initializers.length === 1 + ? [ts.Diagnostics.Add_await_to_initializer_for_0, awaitableInitializers.initializers[0].declarationSymbol.name] + : ts.Diagnostics.Add_await_to_initializers); } } - function getUseSiteFix(context, expression, errorCode, checker, trackChanges) { - var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression); }); + function getUseSiteFix(context, expression, errorCode, checker, trackChanges, fixedDeclarations) { + var changes = trackChanges(function (t) { return makeChange(t, errorCode, context.sourceFile, checker, expression, fixedDeclarations); }); return codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_await, fixId, ts.Diagnostics.Fix_all_expressions_possibly_missing_await); } function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) { @@ -116382,7 +121043,7 @@ var ts; ts.some(relatedInformation, function (related) { return related.code === ts.Diagnostics.Did_you_forget_to_use_await.code; }); }); } - function getAwaitableExpression(sourceFile, errorCode, span, cancellationToken, program) { + function getFixableErrorSpanExpression(sourceFile, errorCode, span, cancellationToken, program) { var token = ts.getTokenAtPosition(sourceFile, span.start); // Checker has already done work to determine that await might be possible, and has attached // related info to the node, so start by finding the expression that exactly matches up @@ -116395,64 +121056,146 @@ var ts; }); return expression && isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) - && isInsideAwaitableBody(expression) - ? expression - : undefined; + && isInsideAwaitableBody(expression) ? expression : undefined; } - function findAwaitableInitializer(expression, sourceFile, checker) { - if (!ts.isIdentifier(expression)) { + function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) { + var identifiers = getIdentifiersFromErrorSpanExpression(expression, checker); + if (!identifiers) { return; } - var symbol = checker.getSymbolAtLocation(expression); - if (!symbol) { - return; + var isCompleteFix = identifiers.isCompleteFix; + var initializers; + var _loop_11 = function (identifier) { + var symbol = checker.getSymbolAtLocation(identifier); + if (!symbol) { + return "continue"; + } + var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); + var variableName = declaration && ts.tryCast(declaration.name, ts.isIdentifier); + var variableStatement = ts.getAncestor(declaration, 224 /* VariableStatement */); + if (!declaration || !variableStatement || + declaration.type || + !declaration.initializer || + variableStatement.getSourceFile() !== sourceFile || + ts.hasModifier(variableStatement, 1 /* Export */) || + !variableName || + !isInsideAwaitableBody(declaration.initializer)) { + isCompleteFix = false; + return "continue"; + } + var diagnostics = program.getSemanticDiagnostics(sourceFile, cancellationToken); + var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (reference) { + return identifier !== reference && !symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker); + }); + if (isUsedElsewhere) { + isCompleteFix = false; + return "continue"; + } + (initializers || (initializers = [])).push({ + expression: declaration.initializer, + declarationSymbol: symbol, + }); + }; + for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) { + var identifier = _a[_i]; + _loop_11(identifier); } - var declaration = ts.tryCast(symbol.valueDeclaration, ts.isVariableDeclaration); - var variableName = ts.tryCast(declaration && declaration.name, ts.isIdentifier); - var variableStatement = ts.getAncestor(declaration, 220 /* VariableStatement */); - if (!declaration || !variableStatement || - declaration.type || - !declaration.initializer || - variableStatement.getSourceFile() !== sourceFile || - ts.hasModifier(variableStatement, 1 /* Export */) || - !variableName || - !isInsideAwaitableBody(declaration.initializer)) { - return; + return initializers && { + initializers: initializers, + needsSecondPassForFixAll: !isCompleteFix, + }; + } + function getIdentifiersFromErrorSpanExpression(expression, checker) { + if (ts.isPropertyAccessExpression(expression.parent) && ts.isIdentifier(expression.parent.expression)) { + return { identifiers: [expression.parent.expression], isCompleteFix: true }; + } + if (ts.isIdentifier(expression)) { + return { identifiers: [expression], isCompleteFix: true }; + } + if (ts.isBinaryExpression(expression)) { + var sides = void 0; + var isCompleteFix = true; + for (var _i = 0, _a = [expression.left, expression.right]; _i < _a.length; _i++) { + var side = _a[_i]; + var type = checker.getTypeAtLocation(side); + if (checker.getPromisedTypeOfPromise(type)) { + if (!ts.isIdentifier(side)) { + isCompleteFix = false; + continue; + } + (sides || (sides = [])).push(side); + } + } + return sides && { identifiers: sides, isCompleteFix: isCompleteFix }; } - var isUsedElsewhere = ts.FindAllReferences.Core.eachSymbolReferenceInFile(variableName, checker, sourceFile, function (identifier) { - return identifier !== expression; + } + function symbolReferenceIsAlsoMissingAwait(reference, diagnostics, sourceFile, checker) { + var errorNode = ts.isPropertyAccessExpression(reference.parent) ? reference.parent.name : + ts.isBinaryExpression(reference.parent) ? reference.parent : + reference; + var diagnostic = ts.find(diagnostics, function (diagnostic) { + return diagnostic.start === errorNode.getStart(sourceFile) && + diagnostic.start + diagnostic.length === errorNode.getEnd(); }); - if (isUsedElsewhere) { - return; - } - return declaration.initializer; + return diagnostic && ts.contains(errorCodes, diagnostic.code) || + // A Promise is usually not correct in a binary expression (it’s not valid + // in an arithmetic expression and an equality comparison seems unusual), + // but if the other side of the binary expression has an error, the side + // is typed `any` which will squash the error that would identify this + // Promise as an invalid operand. So if the whole binary expression is + // typed `any` as a result, there is a strong likelihood that this Promise + // is accidentally missing `await`. + checker.getTypeAtLocation(errorNode).flags & 1 /* Any */; } function isInsideAwaitableBody(node) { - return node.kind & 16384 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { + return node.kind & 32768 /* AwaitContext */ || !!ts.findAncestor(node, function (ancestor) { return ancestor.parent && ts.isArrowFunction(ancestor.parent) && ancestor.parent.body === ancestor || - ts.isBlock(ancestor) && (ancestor.parent.kind === 240 /* FunctionDeclaration */ || - ancestor.parent.kind === 197 /* FunctionExpression */ || - ancestor.parent.kind === 198 /* ArrowFunction */ || - ancestor.parent.kind === 157 /* MethodDeclaration */); + ts.isBlock(ancestor) && (ancestor.parent.kind === 243 /* FunctionDeclaration */ || + ancestor.parent.kind === 200 /* FunctionExpression */ || + ancestor.parent.kind === 201 /* ArrowFunction */ || + ancestor.parent.kind === 160 /* MethodDeclaration */); }); } - function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite) { + function makeChange(changeTracker, errorCode, sourceFile, checker, insertionSite, fixedDeclarations) { if (ts.isBinaryExpression(insertionSite)) { - var left = insertionSite.left, right = insertionSite.right; - var leftType = checker.getTypeAtLocation(left); - var rightType = checker.getTypeAtLocation(right); - var newLeft = checker.getPromisedTypeOfPromise(leftType) ? ts.createAwait(left) : left; - var newRight = checker.getPromisedTypeOfPromise(rightType) ? ts.createAwait(right) : right; - changeTracker.replaceNode(sourceFile, left, newLeft); - changeTracker.replaceNode(sourceFile, right, newRight); + for (var _i = 0, _a = [insertionSite.left, insertionSite.right]; _i < _a.length; _i++) { + var side = _a[_i]; + if (fixedDeclarations && ts.isIdentifier(side)) { + var symbol = checker.getSymbolAtLocation(side); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + continue; + } + } + var type = checker.getTypeAtLocation(side); + var newNode = checker.getPromisedTypeOfPromise(type) ? ts.createAwait(side) : side; + changeTracker.replaceNode(sourceFile, side, newNode); + } } else if (errorCode === propertyAccessCode && ts.isPropertyAccessExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite.parent.expression)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.expression); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite.parent.expression, ts.createParen(ts.createAwait(insertionSite.parent.expression))); } else if (ts.contains(callableConstructableErrorCodes, errorCode) && ts.isCallOrNewExpression(insertionSite.parent)) { + if (fixedDeclarations && ts.isIdentifier(insertionSite)) { + var symbol = checker.getSymbolAtLocation(insertionSite); + if (symbol && fixedDeclarations.has(ts.getSymbolId(symbol).toString())) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createParen(ts.createAwait(insertionSite))); } else { + if (fixedDeclarations && ts.isVariableDeclaration(insertionSite.parent) && ts.isIdentifier(insertionSite.parent.name)) { + var symbol = checker.getSymbolAtLocation(insertionSite.parent.name); + if (symbol && !ts.addToSeen(fixedDeclarations, ts.getSymbolId(symbol))) { + return; + } + } changeTracker.replaceNode(sourceFile, insertionSite, ts.createAwait(insertionSite)); } } @@ -116515,16 +121258,16 @@ var ts; } function applyChange(changeTracker, initializer, sourceFile, fixedNodes) { if (!fixedNodes || fixedNodes.tryAdd(initializer)) { - changeTracker.insertModifierBefore(sourceFile, 78 /* ConstKeyword */, initializer); + changeTracker.insertModifierBefore(sourceFile, 80 /* ConstKeyword */, initializer); } } function isPossiblyPartOfDestructuring(node) { switch (node.kind) { - case 73 /* Identifier */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 75 /* Identifier */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return true; default: return false; @@ -116538,8 +121281,8 @@ var ts; } function isPossiblyPartOfCommaSeperatedInitializer(node) { switch (node.kind) { - case 73 /* Identifier */: - case 205 /* BinaryExpression */: + case 75 /* Identifier */: + case 208 /* BinaryExpression */: case 27 /* CommaToken */: return true; default: @@ -116559,6 +121302,42 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "addMissingDeclareProperty"; + var errorCodes = [ + ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span.start); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Prefix_with_declare, fixId, ts.Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + var fixedNodes = new ts.NodeSet(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag.start, fixedNodes); }); + }, + }); + function makeChange(changeTracker, sourceFile, pos, fixedNodes) { + var token = ts.getTokenAtPosition(sourceFile, pos); + if (!ts.isIdentifier(token)) { + return; + } + var declaration = token.parent; + if (declaration.kind === 158 /* PropertyDeclaration */ && + (!fixedNodes || fixedNodes.tryAdd(declaration))) { + changeTracker.insertModifierBefore(sourceFile, 129 /* DeclareKeyword */, declaration); + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -116680,33 +121459,33 @@ var ts; } } else { - var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl)); // If not defined, shouldn't have been an error to fix - ts.Debug.assert(!decl.type); // If defined, shouldn't have been an error to fix. + var jsdocType = ts.Debug.assertDefined(ts.getJSDocType(decl), "A JSDocType for this declaration should exist"); // If not defined, shouldn't have been an error to fix + ts.Debug.assert(!decl.type, "The JSDocType decl should have a type"); // If defined, shouldn't have been an error to fix. changes.tryInsertTypeAnnotation(sourceFile, decl, transformJSDocType(jsdocType)); } } function isDeclarationWithType(node) { return ts.isFunctionLikeDeclaration(node) || - node.kind === 238 /* VariableDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 241 /* VariableDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 158 /* PropertyDeclaration */; } function transformJSDocType(node) { switch (node.kind) { - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return ts.createTypeReferenceNode("any", ts.emptyArray); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return transformJSDocOptionalType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return transformJSDocType(node.type); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return transformJSDocNullableType(node); - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: return transformJSDocVariadicType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return transformJSDocFunctionType(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return transformJSDocTypeReference(node); default: var visited = ts.visitEachChild(node, transformJSDocType, /*context*/ undefined); // TODO: GH#18217 @@ -116728,7 +121507,7 @@ var ts; } function transformJSDocParameter(node) { var index = node.parent.parameters.indexOf(node); - var isRest = node.type.kind === 296 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 + var isRest = node.type.kind === 299 /* JSDocVariadicType */ && index === node.parent.parameters.length - 1; // TODO: GH#18217 var name = node.name || (isRest ? "rest" : "arg" + index); var dotdotdot = isRest ? ts.createToken(25 /* DotDotDotToken */) : node.dotDotDotToken; return ts.createParameter(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, ts.visitNode(node.type, transformJSDocType), node.initializer); @@ -116768,8 +121547,8 @@ var ts; var index = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "n" : "s", - /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 136 /* NumberKeyword */ ? "number" : "string", []), + /*dotDotDotToken*/ undefined, node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "n" : "s", + /*questionToken*/ undefined, ts.createTypeReferenceNode(node.typeArguments[0].kind === 139 /* NumberKeyword */ ? "number" : "string", []), /*initializer*/ undefined); var indexSignature = ts.createTypeLiteralNode([ts.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments[1])]); ts.setEmitFlags(indexSignature, 1 /* SingleLine */); @@ -116819,20 +121598,20 @@ var ts; codefix.registerCodeFix({ errorCodes: errorCodes, getCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host; + var sourceFile = context.sourceFile, program = context.program, start = context.span.start, errorCode = context.errorCode, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; var token = ts.getTokenAtPosition(sourceFile, start); var declaration; - var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host); }); + var changes = ts.textChanges.ChangeTracker.with(context, function (changes) { declaration = doChange(changes, sourceFile, token, errorCode, program, cancellationToken, /*markSeen*/ ts.returnTrue, host, formatContext, preferences); }); var name = declaration && ts.getNameOfDeclaration(declaration); return !name || changes.length === 0 ? undefined : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)]; }, fixIds: [fixId], getAllCodeActions: function (context) { - var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host; + var sourceFile = context.sourceFile, program = context.program, cancellationToken = context.cancellationToken, host = context.host, formatContext = context.formatContext, preferences = context.preferences; var markSeen = ts.nodeSeenTracker(); return codefix.codeFixAll(context, errorCodes, function (changes, err) { - doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host); + doChange(changes, sourceFile, ts.getTokenAtPosition(err.file, err.start), err.code, program, cancellationToken, markSeen, host, formatContext, preferences); }); }, }); @@ -116872,8 +121651,8 @@ var ts; } return errorCode; } - function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host) { - if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 73 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 101 /* ThisKeyword */) { + function doChange(changes, sourceFile, token, errorCode, program, cancellationToken, markSeen, host, formatContext, preferences) { + if (!ts.isParameterPropertyModifier(token.kind) && token.kind !== 75 /* Identifier */ && token.kind !== 25 /* DotDotDotToken */ && token.kind !== 103 /* ThisKeyword */) { return undefined; } var parent = token.parent; @@ -116883,7 +121662,7 @@ var ts; case ts.Diagnostics.Member_0_implicitly_has_an_1_type.code: case ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined.code: if ((ts.isVariableDeclaration(parent) && markSeen(parent)) || ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) { // handle bad location - annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken); + annotateVariableDeclaration(changes, sourceFile, parent, program, host, cancellationToken, formatContext, preferences); return parent; } if (ts.isPropertyAccessExpression(parent)) { @@ -116900,7 +121679,7 @@ var ts; case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: { var symbol = program.getTypeChecker().getSymbolAtLocation(token); if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) { - annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken); + annotateVariableDeclaration(changes, sourceFile, symbol.valueDeclaration, program, host, cancellationToken, formatContext, preferences); return symbol.valueDeclaration; } return undefined; @@ -116914,14 +121693,14 @@ var ts; // Parameter declarations case ts.Diagnostics.Parameter_0_implicitly_has_an_1_type.code: if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); return containingFunction; } // falls through case ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type.code: if (markSeen(containingFunction)) { var param = ts.cast(parent, ts.isParameter); - annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken); + annotateParameters(changes, sourceFile, param, containingFunction, program, host, cancellationToken, formatContext, preferences); return param; } return undefined; @@ -116929,14 +121708,14 @@ var ts; case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation.code: case ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type.code: if (ts.isGetAccessorDeclaration(containingFunction) && ts.isIdentifier(containingFunction.name)) { - annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host); + annotate(changes, sourceFile, containingFunction, inferTypeForVariableFromUsage(containingFunction.name, program, cancellationToken), program, host, formatContext, preferences); return containingFunction; } return undefined; // Set Accessor declarations case ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation.code: if (ts.isSetAccessorDeclaration(containingFunction)) { - annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken); + annotateSetAccessor(changes, sourceFile, containingFunction, program, host, cancellationToken, formatContext, preferences); return containingFunction; } return undefined; @@ -116951,22 +121730,17 @@ var ts; return ts.Debug.fail(String(errorCode)); } } - function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken) { + function annotateVariableDeclaration(changes, sourceFile, declaration, program, host, cancellationToken, formatContext, preferences) { if (ts.isIdentifier(declaration.name)) { - annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host); + annotate(changes, sourceFile, declaration, inferTypeForVariableFromUsage(declaration.name, program, cancellationToken), program, host, formatContext, preferences); } } - function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken) { + function annotateParameters(changes, sourceFile, parameterDeclaration, containingFunction, program, host, cancellationToken, formatContext, preferences) { if (!ts.isIdentifier(parameterDeclaration.name)) { return; } - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - var parameterInferences = InferFromReference.inferTypeForParametersFromReferences(references, containingFunction, program, cancellationToken) || - containingFunction.parameters.map(function (p) { return ({ - declaration: p, - type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() - }); }); - ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length); + var parameterInferences = inferTypeForParametersFromUsage(containingFunction, sourceFile, program, cancellationToken); + ts.Debug.assert(containingFunction.parameters.length === parameterInferences.length, "Parameter count and inference count should match"); if (ts.isInJSFile(containingFunction)) { annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host); } @@ -116977,7 +121751,7 @@ var ts; for (var _i = 0, parameterInferences_1 = parameterInferences; _i < parameterInferences_1.length; _i++) { var _a = parameterInferences_1[_i], declaration = _a.declaration, type = _a.type; if (declaration && !declaration.type && !declaration.initializer) { - annotate(changes, sourceFile, declaration, type, program, host); + annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences); } } if (needParens) @@ -116985,14 +121759,11 @@ var ts; } } function annotateThis(changes, sourceFile, containingFunction, program, host, cancellationToken) { - var references = inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken); - if (!references) { - return; - } - var thisInference = InferFromReference.inferTypeForThisFromReferences(references, program, cancellationToken); - if (!thisInference) { + var references = getFunctionReferences(containingFunction, sourceFile, program, cancellationToken); + if (!references || !references.length) { return; } + var thisInference = inferTypeFromReferences(program, references, cancellationToken).thisParameter(); var typeNode = ts.getTypeNodeIfAccessible(thisInference, containingFunction, program, host); if (!typeNode) { return; @@ -117009,7 +121780,7 @@ var ts; ts.createJSDocThisTag(ts.createJSDocTypeExpression(typeNode)), ]); } - function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken) { + function annotateSetAccessor(changes, sourceFile, setAccessorDeclaration, program, host, cancellationToken, formatContext, preferences) { var param = ts.firstOrUndefined(setAccessorDeclaration.parameters); if (param && ts.isIdentifier(setAccessorDeclaration.name) && ts.isIdentifier(param.name)) { var type = inferTypeForVariableFromUsage(setAccessorDeclaration.name, program, cancellationToken); @@ -117020,14 +121791,14 @@ var ts; annotateJSDocParameters(changes, sourceFile, [{ declaration: param, type: type }], program, host); } else { - annotate(changes, sourceFile, param, type, program, host); + annotate(changes, sourceFile, param, type, program, host, formatContext, preferences); } } } - function annotate(changes, sourceFile, declaration, type, program, host) { + function annotate(changes, sourceFile, declaration, type, program, host, formatContext, preferences) { var typeNode = ts.getTypeNodeIfAccessible(type, declaration, program, host); if (typeNode) { - if (ts.isInJSFile(sourceFile) && declaration.kind !== 154 /* PropertySignature */) { + if (ts.isInJSFile(sourceFile) && declaration.kind !== 157 /* PropertySignature */) { var parent = ts.isVariableDeclaration(declaration) ? ts.tryCast(declaration.parent.parent, ts.isVariableStatement) : declaration; if (!parent) { return; @@ -117036,11 +121807,32 @@ var ts; var typeTag = ts.isGetAccessorDeclaration(declaration) ? ts.createJSDocReturnTag(typeExpression, "") : ts.createJSDocTypeTag(typeExpression, ""); addJSDocTags(changes, sourceFile, parent, [typeTag]); } - else { + else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences)) { changes.tryInsertTypeAnnotation(sourceFile, declaration, typeNode); } } } + function tryReplaceImportTypeNodeWithAutoImport(typeNode, changes, sourceFile, declaration, type, program, host, formatContext, preferences) { + var _a; + if (ts.isLiteralImportTypeNode(typeNode) && typeNode.qualifier && type.symbol) { + // Replace 'import("./a").SomeType' with 'SomeType' and an actual import if possible + var moduleSymbol = (_a = ts.find(type.symbol.declarations, function (d) { return !!d.getSourceFile().externalModuleIndicator; })) === null || _a === void 0 ? void 0 : _a.getSourceFile().symbol; + // Symbol for the left-most thing after the dot + if (moduleSymbol) { + var symbol = ts.getFirstIdentifier(typeNode.qualifier).symbol; + var action = codefix.getImportCompletionAction(symbol, moduleSymbol, sourceFile, symbol.name, host, program, formatContext, declaration.pos, preferences); + if (action.codeAction.changes.length && changes.tryInsertTypeAnnotation(sourceFile, declaration, ts.createTypeReferenceNode(typeNode.qualifier, typeNode.typeArguments))) { + for (var _i = 0, _b = action.codeAction.changes; _i < _b.length; _i++) { + var change = _b[_i]; + var file = sourceFile.fileName === change.fileName ? sourceFile : ts.Debug.assertDefined(program.getSourceFile(change.fileName)); + changes.pushRaw(file, change); + } + return true; + } + } + } + return false; + } function annotateJSDocParameters(changes, sourceFile, parameterInferences, program, host) { var signature = parameterInferences.length && parameterInferences[0].declaration.parent; if (!signature) { @@ -117068,13 +121860,13 @@ var ts; return !!merged; }); }); var tag = ts.createJSDocComment(comments.join("\n"), ts.createNodeArray(__spreadArrays((oldTags || ts.emptyArray), unmergedNewTags))); - var jsDocNode = parent.kind === 198 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; + var jsDocNode = parent.kind === 201 /* ArrowFunction */ ? getJsDocNodeForArrowFunction(parent) : parent; jsDocNode.jsDoc = parent.jsDoc; jsDocNode.jsDocCache = parent.jsDocCache; changes.insertJsdocCommentBefore(sourceFile, jsDocNode, tag); } function getJsDocNodeForArrowFunction(signature) { - if (signature.parent.kind === 155 /* PropertyDeclaration */) { + if (signature.parent.kind === 158 /* PropertyDeclaration */) { return signature.parent; } return signature.parent.parent; @@ -117084,14 +121876,14 @@ var ts; return undefined; } switch (oldTag.kind) { - case 307 /* JSDocParameterTag */: { + case 310 /* JSDocParameterTag */: { var oldParam = oldTag; var newParam = newTag; return ts.isIdentifier(oldParam.name) && ts.isIdentifier(newParam.name) && oldParam.name.escapedText === newParam.name.escapedText ? ts.createJSDocParamTag(newParam.name, newParam.isBracketed, newParam.typeExpression, oldParam.comment) : undefined; } - case 308 /* JSDocReturnTag */: + case 311 /* JSDocReturnTag */: return ts.createJSDocReturnTag(newTag.typeExpression, oldTag.comment); } } @@ -117103,25 +121895,31 @@ var ts; } function inferTypeForVariableFromUsage(token, program, cancellationToken) { var references = getReferences(token, program, cancellationToken); - var checker = program.getTypeChecker(); - var types = InferFromReference.inferTypesFromReferences(references, checker, cancellationToken); - return InferFromReference.unifyFromContext(types, checker); + return inferTypeFromReferences(program, references, cancellationToken).single(); } - function inferFunctionReferencesFromUsage(containingFunction, sourceFile, program, cancellationToken) { + function inferTypeForParametersFromUsage(func, sourceFile, program, cancellationToken) { + var references = getFunctionReferences(func, sourceFile, program, cancellationToken); + return references && inferTypeFromReferences(program, references, cancellationToken).parameters(func) || + func.parameters.map(function (p) { return ({ + declaration: p, + type: ts.isIdentifier(p.name) ? inferTypeForVariableFromUsage(p.name, program, cancellationToken) : program.getTypeChecker().getAnyType() + }); }); + } + function getFunctionReferences(containingFunction, sourceFile, program, cancellationToken) { var searchToken; switch (containingFunction.kind) { - case 158 /* Constructor */: - searchToken = ts.findChildOfKind(containingFunction, 125 /* ConstructorKeyword */, sourceFile); + case 161 /* Constructor */: + searchToken = ts.findChildOfKind(containingFunction, 128 /* ConstructorKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: - case 197 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 200 /* FunctionExpression */: var parent = containingFunction.parent; searchToken = ts.isVariableDeclaration(parent) && ts.isIdentifier(parent.name) ? parent.name : containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: searchToken = containingFunction.name; break; } @@ -117130,54 +121928,109 @@ var ts; } return getReferences(searchToken, program, cancellationToken); } - var InferFromReference; - (function (InferFromReference) { - function inferTypesFromReferences(references, checker, cancellationToken) { - var usageContext = {}; - for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { - var reference = references_2[_i]; - cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + function inferTypeFromReferences(program, references, cancellationToken) { + var checker = program.getTypeChecker(); + var builtinConstructors = { + string: function () { return checker.getStringType(); }, + number: function () { return checker.getNumberType(); }, + Array: function (t) { return checker.createArrayType(t); }, + Promise: function (t) { return checker.createPromiseType(t); }, + }; + var builtins = [ + checker.getStringType(), + checker.getNumberType(), + checker.createArrayType(checker.getAnyType()), + checker.createPromiseType(checker.getAnyType()), + ]; + return { + single: single, + parameters: parameters, + thisParameter: thisParameter, + }; + function createEmptyUsage() { + return { + isNumber: undefined, + isString: undefined, + isNumberOrString: undefined, + candidateTypes: undefined, + properties: undefined, + calls: undefined, + constructs: undefined, + numberIndex: undefined, + stringIndex: undefined, + candidateThisTypes: undefined, + inferredTypes: undefined, + }; + } + function combineUsages(usages) { + var combinedProperties = ts.createUnderscoreEscapedMap(); + for (var _i = 0, usages_1 = usages; _i < usages_1.length; _i++) { + var u = usages_1[_i]; + if (u.properties) { + u.properties.forEach(function (p, name) { + if (!combinedProperties.has(name)) { + combinedProperties.set(name, []); + } + combinedProperties.get(name).push(p); + }); + } } - return inferFromContext(usageContext, checker); + var properties = ts.createUnderscoreEscapedMap(); + combinedProperties.forEach(function (ps, name) { + properties.set(name, combineUsages(ps)); + }); + return { + isNumber: usages.some(function (u) { return u.isNumber; }), + isString: usages.some(function (u) { return u.isString; }), + isNumberOrString: usages.some(function (u) { return u.isNumberOrString; }), + candidateTypes: ts.flatMap(usages, function (u) { return u.candidateTypes; }), + properties: properties, + calls: ts.flatMap(usages, function (u) { return u.calls; }), + constructs: ts.flatMap(usages, function (u) { return u.constructs; }), + numberIndex: ts.forEach(usages, function (u) { return u.numberIndex; }), + stringIndex: ts.forEach(usages, function (u) { return u.stringIndex; }), + candidateThisTypes: ts.flatMap(usages, function (u) { return u.candidateThisTypes; }), + inferredTypes: undefined, + }; + } + function single() { + return combineTypes(inferTypesFromReferencesSingle(references)); } - InferFromReference.inferTypesFromReferences = inferTypesFromReferences; - function inferTypeForParametersFromReferences(references, declaration, program, cancellationToken) { - if (references === undefined || references.length === 0 || !declaration.parameters) { + function parameters(declaration) { + if (references.length === 0 || !declaration.parameters) { return undefined; } - var checker = program.getTypeChecker(); - var usageContext = {}; - for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { - var reference = references_3[_i]; + var usage = createEmptyUsage(); + for (var _i = 0, references_2 = references; _i < references_2.length; _i++) { + var reference = references_2[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - var callContexts = __spreadArrays(usageContext.constructContexts || [], usageContext.callContexts || []); + var calls = __spreadArrays(usage.constructs || [], usage.calls || []); return declaration.parameters.map(function (parameter, parameterIndex) { var types = []; var isRest = ts.isRestParameter(parameter); var isOptional = false; - for (var _i = 0, callContexts_1 = callContexts; _i < callContexts_1.length; _i++) { - var callContext = callContexts_1[_i]; - if (callContext.argumentTypes.length <= parameterIndex) { + for (var _i = 0, calls_1 = calls; _i < calls_1.length; _i++) { + var call = calls_1[_i]; + if (call.argumentTypes.length <= parameterIndex) { isOptional = ts.isInJSFile(declaration); types.push(checker.getUndefinedType()); } else if (isRest) { - for (var i = parameterIndex; i < callContext.argumentTypes.length; i++) { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + for (var i = parameterIndex; i < call.argumentTypes.length; i++) { + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[i])); } } else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + types.push(checker.getBaseTypeOfLiteralType(call.argumentTypes[parameterIndex])); } } if (ts.isIdentifier(parameter.name)) { - var inferred = inferTypesFromReferences(getReferences(parameter.name, program, cancellationToken), checker, cancellationToken); + var inferred = inferTypesFromReferencesSingle(getReferences(parameter.name, program, cancellationToken)); types.push.apply(types, (isRest ? ts.mapDefined(inferred, checker.getElementTypeOfArrayType) : inferred)); } - var type = unifyFromContext(types, checker); + var type = combineTypes(types); return { type: isRest ? checker.createArrayType(type) : type, isOptional: isOptional && !isRest, @@ -117185,242 +122038,255 @@ var ts; }; }); } - InferFromReference.inferTypeForParametersFromReferences = inferTypeForParametersFromReferences; - function inferTypeForThisFromReferences(references, program, cancellationToken) { - if (references.length === 0) { - return undefined; + function thisParameter() { + var usage = createEmptyUsage(); + for (var _i = 0, references_3 = references; _i < references_3.length; _i++) { + var reference = references_3[_i]; + cancellationToken.throwIfCancellationRequested(); + calculateUsageOfNode(reference, usage); } - var checker = program.getTypeChecker(); - var usageContext = {}; + return combineTypes(usage.candidateThisTypes || ts.emptyArray); + } + function inferTypesFromReferencesSingle(references) { + var usage = createEmptyUsage(); for (var _i = 0, references_4 = references; _i < references_4.length; _i++) { var reference = references_4[_i]; cancellationToken.throwIfCancellationRequested(); - inferTypeFromContext(reference, checker, usageContext); + calculateUsageOfNode(reference, usage); } - return unifyFromContext(usageContext.candidateThisTypes || ts.emptyArray, checker); + return inferTypes(usage); } - InferFromReference.inferTypeForThisFromReferences = inferTypeForThisFromReferences; - function inferTypeFromContext(node, checker, usageContext) { + function calculateUsageOfNode(node, usage) { while (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } switch (node.parent.kind) { - case 204 /* PostfixUnaryExpression */: - usageContext.isNumber = true; + case 225 /* ExpressionStatement */: + addCandidateType(usage, checker.getVoidType()); + break; + case 207 /* PostfixUnaryExpression */: + usage.isNumber = true; break; - case 203 /* PrefixUnaryExpression */: - inferTypeFromPrefixUnaryExpressionContext(node.parent, usageContext); + case 206 /* PrefixUnaryExpression */: + inferTypeFromPrefixUnaryExpression(node.parent, usage); break; - case 205 /* BinaryExpression */: - inferTypeFromBinaryExpressionContext(node, node.parent, checker, usageContext); + case 208 /* BinaryExpression */: + inferTypeFromBinaryExpression(node, node.parent, usage); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - inferTypeFromSwitchStatementLabelContext(node.parent, checker, usageContext); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + inferTypeFromSwitchStatementLabel(node.parent, usage); break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: if (node.parent.expression === node) { - inferTypeFromCallExpressionContext(node.parent, checker, usageContext); + inferTypeFromCallExpression(node.parent, usage); } else { - inferTypeFromContextualType(node, checker, usageContext); + inferTypeFromContextualType(node, usage); } break; - case 190 /* PropertyAccessExpression */: - inferTypeFromPropertyAccessExpressionContext(node.parent, checker, usageContext); + case 193 /* PropertyAccessExpression */: + inferTypeFromPropertyAccessExpression(node.parent, usage); break; - case 191 /* ElementAccessExpression */: - inferTypeFromPropertyElementExpressionContext(node.parent, node, checker, usageContext); + case 194 /* ElementAccessExpression */: + inferTypeFromPropertyElementExpression(node.parent, node, usage); break; - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - inferTypeFromPropertyAssignment(node.parent, checker, usageContext); + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + inferTypeFromPropertyAssignment(node.parent, usage); break; - case 155 /* PropertyDeclaration */: - inferTypeFromPropertyDeclaration(node.parent, checker, usageContext); + case 158 /* PropertyDeclaration */: + inferTypeFromPropertyDeclaration(node.parent, usage); break; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var _a = node.parent, name = _a.name, initializer = _a.initializer; if (node === name) { if (initializer) { // This can happen for `let x = null;` which still has an implicit-any error. - addCandidateType(usageContext, checker.getTypeAtLocation(initializer)); + addCandidateType(usage, checker.getTypeAtLocation(initializer)); } break; } } // falls through default: - return inferTypeFromContextualType(node, checker, usageContext); + return inferTypeFromContextualType(node, usage); } } - function inferTypeFromContextualType(node, checker, usageContext) { + function inferTypeFromContextualType(node, usage) { if (ts.isExpressionNode(node)) { - addCandidateType(usageContext, checker.getContextualType(node)); + addCandidateType(usage, checker.getContextualType(node)); } } - function inferTypeFromPrefixUnaryExpressionContext(node, usageContext) { + function inferTypeFromPrefixUnaryExpression(node, usage) { switch (node.operator) { - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - usageContext.isNumber = true; + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + usage.isNumber = true; break; - case 38 /* PlusToken */: - usageContext.isNumberOrString = true; + case 39 /* PlusToken */: + usage.isNumberOrString = true; break; // case SyntaxKind.ExclamationToken: // no inferences here; } } - function inferTypeFromBinaryExpressionContext(node, parent, checker, usageContext) { + function inferTypeFromBinaryExpression(node, parent, usage) { switch (parent.operatorToken.kind) { // ExponentiationOperator - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: // MultiplicativeOperator - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + // falls through + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: // ShiftOperator - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + // falls through + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: // BitwiseOperator - case 49 /* AmpersandToken */: - case 50 /* BarToken */: - case 51 /* CaretToken */: + // falls through + case 50 /* AmpersandToken */: + case 51 /* BarToken */: + case 52 /* CaretToken */: // CompoundAssignmentOperator - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 71 /* BarEqualsToken */: - case 72 /* CaretEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: + // falls through + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 73 /* BarEqualsToken */: + case 74 /* CaretEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: // AdditiveOperator - case 39 /* MinusToken */: + // falls through + case 40 /* MinusToken */: // RelationalOperator - case 28 /* LessThanToken */: - case 31 /* LessThanEqualsToken */: - case 30 /* GreaterThanToken */: - case 32 /* GreaterThanEqualsToken */: + // falls through + case 29 /* LessThanToken */: + case 32 /* LessThanEqualsToken */: + case 31 /* GreaterThanToken */: + case 33 /* GreaterThanEqualsToken */: var operandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (operandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, operandType); + addCandidateType(usage, operandType); } else { - usageContext.isNumber = true; + usage.isNumber = true; } break; - case 61 /* PlusEqualsToken */: - case 38 /* PlusToken */: + case 63 /* PlusEqualsToken */: + case 39 /* PlusToken */: var otherOperandType = checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left); if (otherOperandType.flags & 1056 /* EnumLike */) { - addCandidateType(usageContext, otherOperandType); + addCandidateType(usage, otherOperandType); } else if (otherOperandType.flags & 296 /* NumberLike */) { - usageContext.isNumber = true; + usage.isNumber = true; } else if (otherOperandType.flags & 132 /* StringLike */) { - usageContext.isString = true; + usage.isString = true; + } + else if (otherOperandType.flags & 1 /* Any */) { + // do nothing, maybe we'll learn something elsewhere } else { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; } break; // AssignmentOperators - case 60 /* EqualsToken */: - case 33 /* EqualsEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - addCandidateType(usageContext, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); + case 62 /* EqualsToken */: + case 34 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + addCandidateType(usage, checker.getTypeAtLocation(parent.left === node ? parent.right : parent.left)); break; - case 94 /* InKeyword */: + case 96 /* InKeyword */: if (node === parent.left) { - usageContext.isString = true; + usage.isString = true; } break; - // LogicalOperator - case 55 /* BarBarToken */: + // LogicalOperator Or NullishCoalescing + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: if (node === parent.left && - (node.parent.parent.kind === 238 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { + (node.parent.parent.kind === 241 /* VariableDeclaration */ || ts.isAssignmentExpression(node.parent.parent, /*excludeCompoundAssignment*/ true))) { // var x = x || {}; // TODO: use getFalsyflagsOfType - addCandidateType(usageContext, checker.getTypeAtLocation(parent.right)); + addCandidateType(usage, checker.getTypeAtLocation(parent.right)); } break; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: // nothing to infer here break; } } - function inferTypeFromSwitchStatementLabelContext(parent, checker, usageContext) { - addCandidateType(usageContext, checker.getTypeAtLocation(parent.parent.parent.expression)); + function inferTypeFromSwitchStatementLabel(parent, usage) { + addCandidateType(usage, checker.getTypeAtLocation(parent.parent.parent.expression)); } - function inferTypeFromCallExpressionContext(parent, checker, usageContext) { - var callContext = { + function inferTypeFromCallExpression(parent, usage) { + var call = { argumentTypes: [], - returnType: {} + return_: createEmptyUsage() }; if (parent.arguments) { for (var _i = 0, _a = parent.arguments; _i < _a.length; _i++) { var argument = _a[_i]; - callContext.argumentTypes.push(checker.getTypeAtLocation(argument)); + call.argumentTypes.push(checker.getTypeAtLocation(argument)); } } - inferTypeFromContext(parent, checker, callContext.returnType); - if (parent.kind === 192 /* CallExpression */) { - (usageContext.callContexts || (usageContext.callContexts = [])).push(callContext); + calculateUsageOfNode(parent, call.return_); + if (parent.kind === 195 /* CallExpression */) { + (usage.calls || (usage.calls = [])).push(call); } else { - (usageContext.constructContexts || (usageContext.constructContexts = [])).push(callContext); + (usage.constructs || (usage.constructs = [])).push(call); } } - function inferTypeFromPropertyAccessExpressionContext(parent, checker, usageContext) { + function inferTypeFromPropertyAccessExpression(parent, usage) { var name = ts.escapeLeadingUnderscores(parent.name.text); - if (!usageContext.properties) { - usageContext.properties = ts.createUnderscoreEscapedMap(); + if (!usage.properties) { + usage.properties = ts.createUnderscoreEscapedMap(); } - var propertyUsageContext = usageContext.properties.get(name) || {}; - inferTypeFromContext(parent, checker, propertyUsageContext); - usageContext.properties.set(name, propertyUsageContext); + var propertyUsage = usage.properties.get(name) || createEmptyUsage(); + calculateUsageOfNode(parent, propertyUsage); + usage.properties.set(name, propertyUsage); } - function inferTypeFromPropertyElementExpressionContext(parent, node, checker, usageContext) { + function inferTypeFromPropertyElementExpression(parent, node, usage) { if (node === parent.argumentExpression) { - usageContext.isNumberOrString = true; + usage.isNumberOrString = true; return; } else { var indexType = checker.getTypeAtLocation(parent.argumentExpression); - var indexUsageContext = {}; - inferTypeFromContext(parent, checker, indexUsageContext); + var indexUsage = createEmptyUsage(); + calculateUsageOfNode(parent, indexUsage); if (indexType.flags & 296 /* NumberLike */) { - usageContext.numberIndexContext = indexUsageContext; + usage.numberIndex = indexUsage; } else { - usageContext.stringIndexContext = indexUsageContext; + usage.stringIndex = indexUsage; } } } - function inferTypeFromPropertyAssignment(assignment, checker, usageContext) { - var objectLiteral = ts.isShorthandPropertyAssignment(assignment) ? - assignment.parent : - assignment.parent.parent; - var nodeWithRealType = ts.isVariableDeclaration(objectLiteral.parent) ? - objectLiteral.parent : - objectLiteral; - addCandidateThisType(usageContext, checker.getTypeAtLocation(nodeWithRealType)); + function inferTypeFromPropertyAssignment(assignment, usage) { + var nodeWithRealType = ts.isVariableDeclaration(assignment.parent.parent) ? + assignment.parent.parent : + assignment.parent; + addCandidateThisType(usage, checker.getTypeAtLocation(nodeWithRealType)); } - function inferTypeFromPropertyDeclaration(declaration, checker, usageContext) { - addCandidateThisType(usageContext, checker.getTypeAtLocation(declaration.parent)); + function inferTypeFromPropertyDeclaration(declaration, usage) { + addCandidateThisType(usage, checker.getTypeAtLocation(declaration.parent)); } function removeLowPriorityInferences(inferences, priorities) { var toRemove = []; @@ -117429,17 +122295,19 @@ var ts; for (var _a = 0, priorities_1 = priorities; _a < priorities_1.length; _a++) { var _b = priorities_1[_a], high = _b.high, low = _b.low; if (high(i)) { - ts.Debug.assert(!low(i)); + ts.Debug.assert(!low(i), "Priority can't have both low and high"); toRemove.push(low); } } } return inferences.filter(function (i) { return toRemove.every(function (f) { return !f(i); }); }); } - function unifyFromContext(inferences, checker, fallback) { - if (fallback === void 0) { fallback = checker.getAnyType(); } + function combineFromUsage(usage) { + return combineTypes(inferTypes(usage)); + } + function combineTypes(inferences) { if (!inferences.length) - return fallback; + return checker.getAnyType(); // 1. string or number individually override string | number // 2. non-any, non-void overrides any or void // 3. non-nullable, non-any, non-void, non-anonymous overrides anonymous types @@ -117462,12 +122330,11 @@ var ts; var anons = good.filter(function (i) { return checker.getObjectFlags(i) & 16 /* Anonymous */; }); if (anons.length) { good = good.filter(function (i) { return !(checker.getObjectFlags(i) & 16 /* Anonymous */); }); - good.push(unifyAnonymousTypes(anons, checker)); + good.push(combineAnonymousTypes(anons)); } - return checker.getWidenedType(checker.getUnionType(good)); + return checker.getWidenedType(checker.getUnionType(good.map(checker.getBaseTypeOfLiteralType), 2 /* Subtype */)); } - InferFromReference.unifyFromContext = unifyFromContext; - function unifyAnonymousTypes(anons, checker) { + function combineAnonymousTypes(anons) { if (anons.length === 1) { return anons[0]; } @@ -117503,109 +122370,173 @@ var ts; }); return checker.createAnonymousType(anons[0].symbol, members, calls, constructs, stringIndices.length ? checker.createIndexInfo(checker.getUnionType(stringIndices), stringIndexReadonly) : undefined, numberIndices.length ? checker.createIndexInfo(checker.getUnionType(numberIndices), numberIndexReadonly) : undefined); } - function inferFromContext(usageContext, checker) { + function inferTypes(usage) { var types = []; - if (usageContext.isNumber) { + if (usage.isNumber) { types.push(checker.getNumberType()); } - if (usageContext.isString) { + if (usage.isString) { types.push(checker.getStringType()); } - if (usageContext.isNumberOrString) { + if (usage.isNumberOrString) { types.push(checker.getUnionType([checker.getStringType(), checker.getNumberType()])); } - types.push.apply(types, (usageContext.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); - if (usageContext.properties && hasCallContext(usageContext.properties.get("then"))) { - var paramType = getParameterTypeFromCallContexts(0, usageContext.properties.get("then").callContexts, /*isRestParameter*/ false, checker); // TODO: GH#18217 - var types_1 = paramType.getCallSignatures().map(function (c) { return c.getReturnType(); }); - types_1.push(checker.createPromiseType(types_1.length ? checker.getUnionType(types_1, 2 /* Subtype */) : checker.getAnyType())); - } - else if (usageContext.properties && hasCallContext(usageContext.properties.get("push"))) { - types.push(checker.createArrayType(getParameterTypeFromCallContexts(0, usageContext.properties.get("push").callContexts, /*isRestParameter*/ false, checker))); - } - if (usageContext.numberIndexContext) { - types.push(checker.createArrayType(recur(usageContext.numberIndexContext))); - } - else if (usageContext.properties || usageContext.callContexts || usageContext.constructContexts || usageContext.stringIndexContext) { - var members_1 = ts.createUnderscoreEscapedMap(); - var callSignatures = []; - var constructSignatures = []; - var stringIndexInfo = void 0; - if (usageContext.properties) { - usageContext.properties.forEach(function (context, name) { - var symbol = checker.createSymbol(4 /* Property */, name); - symbol.type = recur(context); - members_1.set(name, symbol); - }); - } - if (usageContext.callContexts) { - for (var _i = 0, _a = usageContext.callContexts; _i < _a.length; _i++) { - var callContext = _a[_i]; - callSignatures.push(getSignatureFromCallContext(callContext, checker)); - } - } - if (usageContext.constructContexts) { - for (var _b = 0, _c = usageContext.constructContexts; _b < _c.length; _b++) { - var constructContext = _c[_b]; - constructSignatures.push(getSignatureFromCallContext(constructContext, checker)); - } - } - if (usageContext.stringIndexContext) { - stringIndexInfo = checker.createIndexInfo(recur(usageContext.stringIndexContext), /*isReadonly*/ false); - } - types.push(checker.createAnonymousType(/*symbol*/ undefined, members_1, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined)); // TODO: GH#18217 + if (usage.numberIndex) { + types.push(checker.createArrayType(combineFromUsage(usage.numberIndex))); } + if (usage.properties && usage.properties.size + || usage.calls && usage.calls.length + || usage.constructs && usage.constructs.length + || usage.stringIndex) { + types.push(inferStructuralType(usage)); + } + types.push.apply(types, (usage.candidateTypes || []).map(function (t) { return checker.getBaseTypeOfLiteralType(t); })); + types.push.apply(types, inferNamedTypesFromProperties(usage)); return types; - function recur(innerContext) { - return unifyFromContext(inferFromContext(innerContext, checker), checker); + } + function inferStructuralType(usage) { + var members = ts.createUnderscoreEscapedMap(); + if (usage.properties) { + usage.properties.forEach(function (u, name) { + var symbol = checker.createSymbol(4 /* Property */, name); + symbol.type = combineFromUsage(u); + members.set(name, symbol); + }); + } + var callSignatures = usage.calls ? [getSignatureFromCalls(usage.calls)] : []; + var constructSignatures = usage.constructs ? [getSignatureFromCalls(usage.constructs)] : []; + var stringIndexInfo = usage.stringIndex && checker.createIndexInfo(combineFromUsage(usage.stringIndex), /*isReadonly*/ false); + return checker.createAnonymousType(/*symbol*/ undefined, members, callSignatures, constructSignatures, stringIndexInfo, /*numberIndexInfo*/ undefined); // TODO: GH#18217 + } + function inferNamedTypesFromProperties(usage) { + if (!usage.properties || !usage.properties.size) + return []; + var types = builtins.filter(function (t) { return allPropertiesAreAssignableToUsage(t, usage); }); + if (0 < types.length && types.length < 3) { + return types.map(function (t) { return inferInstantiationFromUsage(t, usage); }); } + return []; + } + function allPropertiesAreAssignableToUsage(type, usage) { + if (!usage.properties) + return false; + return !ts.forEachEntry(usage.properties, function (propUsage, name) { + var source = checker.getTypeOfPropertyOfType(type, name); + if (!source) { + return true; + } + if (propUsage.calls) { + var sigs = checker.getSignaturesOfType(source, 0 /* Call */); + return !sigs.length || !checker.isTypeAssignableTo(source, getFunctionFromCalls(propUsage.calls)); + } + else { + return !checker.isTypeAssignableTo(source, combineFromUsage(propUsage)); + } + }); } - function getParameterTypeFromCallContexts(parameterIndex, callContexts, isRestParameter, checker) { + /** + * inference is limited to + * 1. generic types with a single parameter + * 2. inference to/from calls with a single signature + */ + function inferInstantiationFromUsage(type, usage) { + if (!(ts.getObjectFlags(type) & 4 /* Reference */) || !usage.properties) { + return type; + } + var generic = type.target; + var singleTypeParameter = ts.singleOrUndefined(generic.typeParameters); + if (!singleTypeParameter) + return type; var types = []; - if (callContexts) { - for (var _i = 0, callContexts_2 = callContexts; _i < callContexts_2.length; _i++) { - var callContext = callContexts_2[_i]; - if (callContext.argumentTypes.length > parameterIndex) { - if (isRestParameter) { - types = ts.concatenate(types, ts.map(callContext.argumentTypes.slice(parameterIndex), function (a) { return checker.getBaseTypeOfLiteralType(a); })); - } - else { - types.push(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[parameterIndex])); + usage.properties.forEach(function (propUsage, name) { + var genericPropertyType = checker.getTypeOfPropertyOfType(generic, name); + ts.Debug.assert(!!genericPropertyType, "generic should have all the properties of its reference."); + types.push.apply(types, inferTypeParameters(genericPropertyType, combineFromUsage(propUsage), singleTypeParameter)); + }); + return builtinConstructors[type.symbol.escapedName](combineTypes(types)); + } + function inferTypeParameters(genericType, usageType, typeParameter) { + if (genericType === typeParameter) { + return [usageType]; + } + else if (genericType.flags & 3145728 /* UnionOrIntersection */) { + return ts.flatMap(genericType.types, function (t) { return inferTypeParameters(t, usageType, typeParameter); }); + } + else if (ts.getObjectFlags(genericType) & 4 /* Reference */ && ts.getObjectFlags(usageType) & 4 /* Reference */) { + // this is wrong because we need a reference to the targetType to, so we can check that it's also a reference + var genericArgs = checker.getTypeArguments(genericType); + var usageArgs = checker.getTypeArguments(usageType); + var types = []; + if (genericArgs && usageArgs) { + for (var i = 0; i < genericArgs.length; i++) { + if (usageArgs[i]) { + types.push.apply(types, inferTypeParameters(genericArgs[i], usageArgs[i], typeParameter)); } } } + return types; } - if (types.length) { - var type = checker.getWidenedType(checker.getUnionType(types, 2 /* Subtype */)); - return isRestParameter ? checker.createArrayType(type) : type; + var genericSigs = checker.getSignaturesOfType(genericType, 0 /* Call */); + var usageSigs = checker.getSignaturesOfType(usageType, 0 /* Call */); + if (genericSigs.length === 1 && usageSigs.length === 1) { + return inferFromSignatures(genericSigs[0], usageSigs[0], typeParameter); } - return undefined; + return []; + } + function inferFromSignatures(genericSig, usageSig, typeParameter) { + var types = []; + for (var i = 0; i < genericSig.parameters.length; i++) { + var genericParam = genericSig.parameters[i]; + var usageParam = usageSig.parameters[i]; + var isRest = genericSig.declaration && ts.isRestParameter(genericSig.declaration.parameters[i]); + if (!usageParam) { + break; + } + var genericParamType = checker.getTypeOfSymbolAtLocation(genericParam, genericParam.valueDeclaration); + var elementType = isRest && checker.getElementTypeOfArrayType(genericParamType); + if (elementType) { + genericParamType = elementType; + } + var targetType = usageParam.type || checker.getTypeOfSymbolAtLocation(usageParam, usageParam.valueDeclaration); + types.push.apply(types, inferTypeParameters(genericParamType, targetType, typeParameter)); + } + var genericReturn = checker.getReturnTypeOfSignature(genericSig); + var usageReturn = checker.getReturnTypeOfSignature(usageSig); + types.push.apply(types, inferTypeParameters(genericReturn, usageReturn, typeParameter)); + return types; } - function getSignatureFromCallContext(callContext, checker) { + function getFunctionFromCalls(calls) { + return checker.createAnonymousType(undefined, ts.createSymbolTable(), [getSignatureFromCalls(calls)], ts.emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); + } + function getSignatureFromCalls(calls) { var parameters = []; - for (var i = 0; i < callContext.argumentTypes.length; i++) { + var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; })); + var _loop_12 = function (i) { var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i)); - symbol.type = checker.getWidenedType(checker.getBaseTypeOfLiteralType(callContext.argumentTypes[i])); + symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); })); + if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) { + symbol.flags |= 16777216 /* Optional */; + } parameters.push(symbol); + }; + for (var i = 0; i < length; i++) { + _loop_12(i); } - var returnType = unifyFromContext(inferFromContext(callContext.returnType, checker), checker, checker.getVoidType()); + var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; }))); // TODO: GH#18217 - return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, callContext.argumentTypes.length, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */); } - function addCandidateType(context, type) { + function addCandidateType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateTypes || (context.candidateTypes = [])).push(type); + (usage.candidateTypes || (usage.candidateTypes = [])).push(type); } } - function addCandidateThisType(context, type) { + function addCandidateThisType(usage, type) { if (type && !(type.flags & 1 /* Any */) && !(type.flags & 131072 /* Never */)) { - (context.candidateThisTypes || (context.candidateThisTypes = [])).push(type); + (usage.candidateThisTypes || (usage.candidateThisTypes = [])).push(type); } } - function hasCallContext(usageContext) { - return !!usageContext && !!usageContext.callContexts; - } - })(InferFromReference || (InferFromReference = {})); + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -117634,12 +122565,12 @@ var ts; var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: precedingNode = ctorDeclaration; changes.delete(sourceFile, ctorDeclaration); newClassDeclaration = createClassFromFunctionDeclaration(ctorDeclaration); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: precedingNode = ctorDeclaration.parent.parent; newClassDeclaration = createClassFromVariableDeclaration(ctorDeclaration); if (ctorDeclaration.parent.declarations.length === 1) { @@ -117671,7 +122602,7 @@ var ts; // all static members are stored in the "exports" array of symbol if (symbol.exports) { symbol.exports.forEach(function (member) { - var memberElement = createClassElement(member, [ts.createToken(117 /* StaticKeyword */)]); + var memberElement = createClassElement(member, [ts.createToken(119 /* StaticKeyword */)]); if (memberElement) { memberElements.push(memberElement); } @@ -117694,7 +122625,7 @@ var ts; return; } // delete the entire statement if this expression is the sole expression to take care of the semicolon at the end - var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 222 /* ExpressionStatement */ + var nodeToDelete = assignmentBinaryExpression.parent && assignmentBinaryExpression.parent.kind === 225 /* ExpressionStatement */ ? assignmentBinaryExpression.parent : assignmentBinaryExpression; changes.delete(sourceFile, nodeToDelete); if (!assignmentBinaryExpression.right) { @@ -117702,27 +122633,27 @@ var ts; /*type*/ undefined, /*initializer*/ undefined); } switch (assignmentBinaryExpression.right.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var functionExpression = assignmentBinaryExpression.right; - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(functionExpression, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); return method; } - case 198 /* ArrowFunction */: { + case 201 /* ArrowFunction */: { var arrowFunction = assignmentBinaryExpression.right; var arrowFunctionBody = arrowFunction.body; var bodyBlock = void 0; // case 1: () => { return [1,2,3] } - if (arrowFunctionBody.kind === 219 /* Block */) { + if (arrowFunctionBody.kind === 222 /* Block */) { bodyBlock = arrowFunctionBody; } // case 2: () => [1,2,3] else { bodyBlock = ts.createBlock([ts.createReturn(arrowFunctionBody)]); } - var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 122 /* AsyncKeyword */)); + var fullModifiers = ts.concatenate(modifiers, getModifierKindFromSource(arrowFunction, 125 /* AsyncKeyword */)); var method = ts.createMethod(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, memberDeclaration.name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); ts.copyLeadingComments(assignmentBinaryExpression, method, sourceFile); @@ -117743,17 +122674,17 @@ var ts; } function createClassFromVariableDeclaration(node) { var initializer = node.initializer; - if (!initializer || initializer.kind !== 197 /* FunctionExpression */) { + if (!initializer || initializer.kind !== 200 /* FunctionExpression */) { return undefined; } - if (node.name.kind !== 73 /* Identifier */) { + if (node.name.kind !== 75 /* Identifier */) { return undefined; } var memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } - var modifiers = getModifierKindFromSource(precedingNode, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(precedingNode, 88 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -117764,7 +122695,7 @@ var ts; if (node.body) { memberElements.unshift(ts.createConstructor(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); } - var modifiers = getModifierKindFromSource(node, 86 /* ExportKeyword */); + var modifiers = getModifierKindFromSource(node, 88 /* ExportKeyword */); var cls = ts.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place @@ -117827,12 +122758,12 @@ var ts; return; } // add the async keyword - changes.insertLastModifierBefore(sourceFile, 122 /* AsyncKeyword */, functionToConvert); + changes.insertLastModifierBefore(sourceFile, 125 /* AsyncKeyword */, functionToConvert); function startTransformation(node, nodeToReplace) { var newNodes = transformExpression(node, transformer, node); changes.replaceNodeWithNodes(sourceFile, nodeToReplace, newNodes); } - var _loop_11 = function (statement) { + var _loop_13 = function (statement) { ts.forEachChild(statement, function visit(node) { if (ts.isCallExpression(node)) { startTransformation(node, statement); @@ -117844,7 +122775,7 @@ var ts; }; for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) { var statement = returnStatements_1[_i]; - _loop_11(statement); + _loop_13(statement); } } function getReturnStatementsWithPromiseHandlers(body) { @@ -118138,10 +123069,10 @@ var ts; function getTransformationBody(func, prevArgName, argName, parent, transformer) { var shouldReturn = transformer.setOfExpressionsToReturn.get(ts.getNodeId(parent).toString()); switch (func.kind) { - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: // do not produce a transformed statement for a null argument break; - case 73 /* Identifier */: // identifier includes undefined + case 75 /* Identifier */: // identifier includes undefined if (!argName) { // undefined was argument passed to promise handler break; @@ -118163,8 +123094,8 @@ var ts; prevArgName.types.push(returnType); } return varDeclOrAssignment; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { var funcBody = func.body; // Arrow functions with block bodies { } will enter this control flow if (ts.isBlock(funcBody)) { @@ -118276,6 +123207,7 @@ var ts; name = getMapEntryOrDefault(funcNode); } // return undefined argName when arg is null or undefined + // eslint-disable-next-line no-in-operator if (!name || "identifier" in name && name.identifier.text === "undefined") { return undefined; } @@ -118367,10 +123299,10 @@ var ts; } var importNode = ts.importFromModuleSpecifier(moduleSpecifier); switch (importNode.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: changes.replaceNode(importingFile, importNode, ts.makeImport(importNode.name, /*namedImports*/ undefined, moduleSpecifier, quotePreference)); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (ts.isRequireCall(importNode, /*checkArgumentIsStringLiteralLike*/ false)) { changes.replaceNode(importingFile, importNode, ts.createPropertyAccess(ts.getSynthesizedDeepClone(importNode), "default")); } @@ -118416,29 +123348,29 @@ var ts; sourceFile.forEachChild(function recur(node) { if (ts.isPropertyAccessExpression(node) && ts.isExportsOrModuleExportsOrAlias(sourceFile, node.expression)) { var parent = node.parent; - cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 60 /* EqualsToken */); + cb(node, ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === 62 /* EqualsToken */); } node.forEachChild(recur); }); } function convertStatement(sourceFile, statement, checker, changes, identifiers, target, exports, quotePreference) { switch (statement.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: convertVariableStatement(sourceFile, statement, changes, checker, identifiers, target, quotePreference); return false; - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; switch (expression.kind) { - case 192 /* CallExpression */: { + case 195 /* CallExpression */: { if (ts.isRequireCall(expression, /*checkArgumentIsStringLiteralLike*/ true)) { // For side-effecting require() call, just make a side-effecting import. changes.replaceNode(sourceFile, statement, ts.makeImport(/*name*/ undefined, /*namedImports*/ undefined, expression.arguments[0], quotePreference)); } return false; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var operatorToken = expression.operatorToken; - return operatorToken.kind === 60 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); + return operatorToken.kind === 62 /* EqualsToken */ && convertAssignment(sourceFile, checker, expression, changes, exports); } } } @@ -118478,8 +123410,8 @@ var ts; /** Converts `const name = require("moduleSpecifier").propertyName` */ function convertPropertyAccessImport(name, propertyName, moduleSpecifier, identifiers, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: { + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: { // `const [a, b] = require("c").d` --> `import { d } from "c"; const [a, b] = d;` var tmp = makeUniqueName(propertyName, identifiers); return [ @@ -118487,11 +123419,11 @@ var ts; makeConst(/*modifiers*/ undefined, name, ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: // `const a = require("b").c` --> `import { c as a } from "./b"; return [makeSingleImport(name.text, propertyName, moduleSpecifier, quotePreference)]; default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid syntax form " + name.kind); } } function convertAssignment(sourceFile, checker, assignment, changes, exports) { @@ -118530,18 +123462,19 @@ var ts; function tryChangeModuleExportsObject(object) { var statements = ts.mapAllOrFail(object.properties, function (prop) { switch (prop.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // TODO: Maybe we should handle this? See fourslash test `refactorConvertToEs6Module_export_object_shorthand.ts`. - case 277 /* ShorthandPropertyAssignment */: - case 278 /* SpreadAssignment */: + // falls through + case 280 /* ShorthandPropertyAssignment */: + case 281 /* SpreadAssignment */: return undefined; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return !ts.isIdentifier(prop.name) ? undefined : convertExportsDotXEquals_replaceNode(prop.name.text, prop.initializer); - case 157 /* MethodDeclaration */: - return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(86 /* ExportKeyword */)], prop); + case 160 /* MethodDeclaration */: + return !ts.isIdentifier(prop.name) ? undefined : functionExpressionToDeclaration(prop.name.text, [ts.createToken(88 /* ExportKeyword */)], prop); default: - ts.Debug.assertNever(prop); + ts.Debug.assertNever(prop, "Convert to ES6 got invalid prop kind " + prop.kind); } }); return statements && [statements, false]; @@ -118570,12 +123503,10 @@ var ts; var moduleSpecifier = reExported.text; var moduleSymbol = checker.getSymbolAtLocation(reExported); var exports = moduleSymbol ? moduleSymbol.exports : ts.emptyUnderscoreEscapedMap; - return exports.has("export=") - ? [[reExportDefault(moduleSpecifier)], true] - : !exports.has("default") - ? [[reExportStar(moduleSpecifier)], false] + return exports.has("export=") ? [[reExportDefault(moduleSpecifier)], true] : + !exports.has("default") ? [[reExportStar(moduleSpecifier)], false] : // If there's some non-default export, must include both `export *` and `export default`. - : exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; + exports.size > 1 ? [[reExportStar(moduleSpecifier), reExportDefault(moduleSpecifier)], true] : [[reExportDefault(moduleSpecifier)], true]; } function reExportStar(moduleSpecifier) { return makeExportDeclaration(/*exportClause*/ undefined, moduleSpecifier); @@ -118588,7 +123519,7 @@ var ts; var name = left.name.text; if ((ts.isFunctionExpression(right) || ts.isArrowFunction(right) || ts.isClassExpression(right)) && (!right.name || right.name.text === name)) { // `exports.f = function() {}` -> `export function f() {}` -- Replace `exports.f = ` with `export `, and insert the name after `function`. - changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(86 /* ExportKeyword */), { suffix: " " }); + changes.replaceRange(sourceFile, { pos: left.getStart(sourceFile), end: right.getStart(sourceFile) }, ts.createToken(88 /* ExportKeyword */), { suffix: " " }); if (!right.name) changes.insertName(sourceFile, right, name); var semi = ts.findChildOfKind(parent, 26 /* SemicolonToken */, sourceFile); @@ -118597,14 +123528,14 @@ var ts; } else { // `exports.f = function g() {}` -> `export const f = function g() {}` -- just replace `exports.` with `export const ` - changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(86 /* ExportKeyword */), ts.createToken(78 /* ConstKeyword */)], { joiner: " ", suffix: " " }); + changes.replaceNodeRangeWithNodes(sourceFile, left.expression, ts.findChildOfKind(left, 24 /* DotToken */, sourceFile), [ts.createToken(88 /* ExportKeyword */), ts.createToken(80 /* ConstKeyword */)], { joiner: " ", suffix: " " }); } } // TODO: GH#22492 this will cause an error if a change has been made inside the body of the node. function convertExportsDotXEquals_replaceNode(name, exported) { - var modifiers = [ts.createToken(86 /* ExportKeyword */)]; + var modifiers = [ts.createToken(88 /* ExportKeyword */)]; switch (exported.kind) { - case 197 /* FunctionExpression */: { + case 200 /* FunctionExpression */: { var expressionName = exported.name; if (expressionName && expressionName.text !== name) { // `exports.f = function g() {}` -> `export const f = function g() {}` @@ -118612,10 +123543,10 @@ var ts; } } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // `exports.f = function() {}` --> `export function f() {}` return functionExpressionToDeclaration(name, modifiers, exported); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // `exports.C = class {}` --> `export class C {}` return classExpressionToDeclaration(name, modifiers, exported); default: @@ -118633,18 +123564,20 @@ var ts; */ function convertSingleImport(file, name, moduleSpecifier, changes, checker, identifiers, target, quotePreference) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: { + case 188 /* ObjectBindingPattern */: { var importSpecifiers = ts.mapAllOrFail(name.elements, function (e) { return e.dotDotDotToken || e.initializer || e.propertyName && !ts.isIdentifier(e.propertyName) || !ts.isIdentifier(e.name) ? undefined + // (TODO: GH#18217) + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion : makeImportSpecifier(e.propertyName && e.propertyName.text, e.name.text); - }); // tslint:disable-line no-unnecessary-type-assertion (TODO: GH#18217) + }); if (importSpecifiers) { return [ts.makeImport(/*name*/ undefined, importSpecifiers, moduleSpecifier, quotePreference)]; } } // falls through -- object destructuring has an interesting pattern and must be a variable declaration - case 186 /* ArrayBindingPattern */: { + case 189 /* ArrayBindingPattern */: { /* import x from "x"; const [a, b, c] = x; @@ -118655,10 +123588,10 @@ var ts; makeConst(/*modifiers*/ undefined, ts.getSynthesizedDeepClone(name), ts.createIdentifier(tmp)), ]; } - case 73 /* Identifier */: + case 75 /* Identifier */: return convertSingleIdentifierImport(file, name, moduleSpecifier, changes, checker, identifiers, quotePreference); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Convert to ES6 module got invalid name kind " + name.kind); } } /** @@ -118680,7 +123613,7 @@ var ts; var parent = use.parent; if (ts.isPropertyAccessExpression(parent)) { var expression = parent.expression, propertyName = parent.name.text; - ts.Debug.assert(expression === use); // Else shouldn't have been in `collectIdentifiers` + ts.Debug.assert(expression === use, "Didn't expect expression === use"); // Else shouldn't have been in `collectIdentifiers` var idName = namedBindingsNames.get(propertyName); if (idName === undefined) { idName = makeUniqueName(propertyName, identifiers); @@ -118727,11 +123660,11 @@ var ts; function isFreeIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return parent.propertyName !== node; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return parent.propertyName !== node; default: return true; @@ -118806,8 +123739,10 @@ var ts; (function (ts) { var codefix; (function (codefix) { - var errorCodes = [ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, - ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code]; + var errorCodes = [ + ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code, + ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code + ]; var fixId = "fixClassIncorrectlyImplementsInterface"; // TODO: share a group with fixClassDoesntImplementInheritedAbstractMember? codefix.registerCodeFix({ errorCodes: errorCodes, @@ -118834,7 +123769,7 @@ var ts; }, }); function getClass(sourceFile, pos) { - return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos))); + return ts.Debug.assertDefined(ts.getContainingClass(ts.getTokenAtPosition(sourceFile, pos)), "There should be a containing class"); } function symbolPointsToNonPrivateMember(symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); @@ -118932,7 +123867,7 @@ var ts; ts.pushIfUnique(entry.namedImports, symbolName); } else { - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add to Existing) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; } break; @@ -118945,7 +123880,7 @@ var ts; } switch (importKind) { case 1 /* Default */: - ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName); + ts.Debug.assert(entry.defaultImport === undefined || entry.defaultImport === symbolName, "(Add new) Default import should be missing or match symbolName"); entry.defaultImport = symbolName; break; case 0 /* Named */: @@ -118953,14 +123888,14 @@ var ts; break; case 3 /* Equals */: case 2 /* Namespace */: - ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName); + ts.Debug.assert(entry.namespaceLikeImport === undefined || entry.namespaceLikeImport.name === symbolName, "Namespacelike import shoudl be missing or match symbolName"); entry.namespaceLikeImport = { importKind: importKind, name: symbolName }; break; } break; } default: - ts.Debug.assertNever(fix); + ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind); } }); return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) { @@ -119001,11 +123936,11 @@ var ts; })(ImportKind || (ImportKind = {})); function getImportCompletionAction(exportedSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) { var exportInfos = getAllReExportingModules(sourceFile, exportedSymbol, moduleSymbol, symbolName, sourceFile, program.getCompilerOptions(), program.getTypeChecker(), program.getSourceFiles()); - ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; })); + ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol"); // We sort the best codefixes first, so taking `first` is best for completions. var moduleSpecifier = ts.first(getNewImportInfos(program, sourceFile, position, exportInfos, host, preferences)).moduleSpecifier; var fix = ts.first(getFixForImport(exportInfos, symbolName, position, program, sourceFile, host, preferences)); - return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; + return { moduleSpecifier: moduleSpecifier, codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences))) }; } codefix.getImportCompletionAction = getImportCompletionAction; function codeFixActionToCodeAction(_a) { @@ -119071,21 +124006,21 @@ var ts; function tryAddToExistingImport(existingImports) { return ts.firstDefined(existingImports, function (_a) { var declaration = _a.declaration, importKind = _a.importKind; - if (declaration.kind !== 250 /* ImportDeclaration */) + if (declaration.kind !== 253 /* ImportDeclaration */) return undefined; var importClause = declaration.importClause; if (!importClause) return undefined; var name = importClause.name, namedBindings = importClause.namedBindings; - return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 253 /* NamedImports */) + return importKind === 1 /* Default */ && !name || importKind === 0 /* Named */ && (!namedBindings || namedBindings.kind === 256 /* NamedImports */) ? { kind: 2 /* AddToExisting */, importClause: importClause, importKind: importKind } : undefined; }); } function getNamespaceImportName(declaration) { - if (declaration.kind === 250 /* ImportDeclaration */) { + if (declaration.kind === 253 /* ImportDeclaration */) { var namedBindings = declaration.importClause && ts.isImportClause(declaration.importClause) && declaration.importClause.namedBindings; - return namedBindings && namedBindings.kind === 252 /* NamespaceImport */ ? namedBindings.name : undefined; + return namedBindings && namedBindings.kind === 255 /* NamespaceImport */ ? namedBindings.name : undefined; } else { return declaration.name; @@ -119096,22 +124031,35 @@ var ts; // Can't use an es6 import for a type in JS. return exportedSymbolIsTypeOnly && ts.isSourceFileJS(sourceFile) ? ts.emptyArray : ts.mapDefined(sourceFile.imports, function (moduleSpecifier) { var i = ts.importFromModuleSpecifier(moduleSpecifier); - return (i.kind === 250 /* ImportDeclaration */ || i.kind === 249 /* ImportEqualsDeclaration */) + return (i.kind === 253 /* ImportDeclaration */ || i.kind === 252 /* ImportEqualsDeclaration */) && checker.getSymbolAtLocation(moduleSpecifier) === moduleSymbol ? { declaration: i, importKind: importKind } : undefined; }); } function getNewImportInfos(program, sourceFile, position, moduleSymbols, host, preferences) { var isJs = ts.isSourceFileJS(sourceFile); + var allowsImportingSpecifier = createAutoImportFilter(sourceFile, program, host).allowsImportingSpecifier; var choicesForEachExportingModule = ts.flatMap(moduleSymbols, function (_a) { var moduleSymbol = _a.moduleSymbol, importKind = _a.importKind, exportedSymbolIsTypeOnly = _a.exportedSymbolIsTypeOnly; return ts.moduleSpecifiers.getModuleSpecifiers(moduleSymbol, program.getCompilerOptions(), sourceFile, host, program.getSourceFiles(), preferences, program.redirectTargetsMap) .map(function (moduleSpecifier) { // `position` should only be undefined at a missing jsx namespace, in which case we shouldn't be looking for pure types. - return exportedSymbolIsTypeOnly && isJs ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position) } : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; + return exportedSymbolIsTypeOnly && isJs + ? { kind: 1 /* ImportType */, moduleSpecifier: moduleSpecifier, position: ts.Debug.assertDefined(position, "position should be defined") } + : { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind }; }); }); - // Sort to keep the shortest paths first - return ts.sort(choicesForEachExportingModule, function (a, b) { return a.moduleSpecifier.length - b.moduleSpecifier.length; }); + // Sort by presence in package.json, then shortest paths first + return ts.sort(choicesForEachExportingModule, function (a, b) { + var allowsImportingA = allowsImportingSpecifier(a.moduleSpecifier); + var allowsImportingB = allowsImportingSpecifier(b.moduleSpecifier); + if (allowsImportingA && !allowsImportingB) { + return -1; + } + if (allowsImportingB && !allowsImportingA) { + return 1; + } + return a.moduleSpecifier.length - b.moduleSpecifier.length; + }); } function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, host, preferences) { var existingDeclaration = ts.firstDefined(existingImports, newImportInfoFromExistingSpecifier); @@ -119119,9 +124067,9 @@ var ts; } function newImportInfoFromExistingSpecifier(_a) { var declaration = _a.declaration, importKind = _a.importKind; - var expression = declaration.kind === 250 /* ImportDeclaration */ + var expression = declaration.kind === 253 /* ImportDeclaration */ ? declaration.moduleSpecifier - : declaration.moduleReference.kind === 260 /* ExternalModuleReference */ + : declaration.moduleReference.kind === 263 /* ExternalModuleReference */ ? declaration.moduleReference.expression : undefined; return expression && ts.isStringLiteral(expression) ? { kind: 3 /* AddNew */, moduleSpecifier: expression.text, importKind: importKind } : undefined; @@ -119178,7 +124126,7 @@ var ts; // Fall back to the `import * as ns` style import. return 2 /* Namespace */; default: - return ts.Debug.assertNever(moduleKind); + return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind); } } function getFixesInfoForNonUMDImport(_a, symbolToken) { @@ -119191,22 +124139,23 @@ var ts; ? checker.getJsxNamespace(sourceFile) : symbolToken.text; // "default" is a keyword and not a legal identifier for the import, so we don't expect it here - ts.Debug.assert(symbolName !== "default" /* Default */); - var fixes = ts.arrayFrom(ts.flatMapIterator(getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program).entries(), function (_a) { + ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here"); + var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, checker, program, host); + var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) { var _ = _a[0], exportInfos = _a[1]; return getFixForImport(exportInfos, symbolName, symbolToken.getStart(sourceFile), program, sourceFile, host, preferences); })); return { fixes: fixes, symbolName: symbolName }; } // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported. - function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program) { + function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, sourceFile, checker, program, host) { // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once. // Maps symbol id to info for modules providing that symbol (original export + re-exports). var originalSymbolToExportInfos = ts.createMultiMap(); function addSymbol(moduleSymbol, exportedSymbol, importKind) { originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { moduleSymbol: moduleSymbol, importKind: importKind, exportedSymbolIsTypeOnly: isTypeOnlySymbol(exportedSymbol, checker) }); } - forEachExternalModuleToImportFrom(checker, sourceFile, program.getSourceFiles(), function (moduleSymbol) { + forEachExternalModuleToImportFrom(program, host, sourceFile, /*filterByPackageJson*/ true, function (moduleSymbol) { cancellationToken.throwIfCancellationRequested(); var defaultInfo = getDefaultLikeExportInfo(sourceFile, moduleSymbol, checker, program.getCompilerOptions()); if (defaultInfo && defaultInfo.name === symbolName && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { @@ -119265,7 +124214,7 @@ var ts; return { symbolForMeaning: defaultExport, name: name }; if (defaultExport.flags & 2097152 /* Alias */) { var aliased = checker.getImmediateAliasedSymbol(defaultExport); - return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent), checker, compilerOptions); + return aliased && getDefaultExportInfoWorker(aliased, ts.Debug.assertDefined(aliased.parent, "Alias targets of default exports must have a parent"), checker, compilerOptions); } if (defaultExport.escapedName !== "default" /* Default */ && defaultExport.escapedName !== "export=" /* ExportEquals */) { @@ -119281,7 +124230,7 @@ var ts; } } else if (ts.isExportSpecifier(declaration)) { - ts.Debug.assert(declaration.name.text === "default" /* Default */); + ts.Debug.assert(declaration.name.text === "default" /* Default */, "Expected the specifier to be a default export"); return declaration.propertyName && declaration.propertyName.text; } }); @@ -119315,12 +124264,12 @@ var ts; return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier]; } default: - return ts.Debug.assertNever(fix); + return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind); } } function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports) { if (defaultImport) { - ts.Debug.assert(!clause.name); + ts.Debug.assert(!clause.name, "Default imports can't have names"); changes.insertNodeAt(sourceFile, clause.getStart(sourceFile), ts.createIdentifier(defaultImport), { suffix: ", " }); } if (namedImports.length) { @@ -119338,7 +124287,7 @@ var ts; changes.replaceNode(sourceFile, clause.namedBindings, namedImports_1); } else { - changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name), namedImports_1); + changes.insertNodeAfter(sourceFile, ts.Debug.assertDefined(clause.name, "Named import specifiers must have names"), namedImports_1); } } } @@ -119378,12 +124327,34 @@ var ts; var declarations = _a.declarations; return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); }); } - function forEachExternalModuleToImportFrom(checker, from, allSourceFiles, cb) { - forEachExternalModule(checker, allSourceFiles, function (module, sourceFile) { - if (sourceFile === undefined || sourceFile !== from && isImportablePath(from.fileName, sourceFile.fileName)) { - cb(module); + function forEachExternalModuleToImportFrom(program, host, from, filterByPackageJson, cb) { + var filteredCount = 0; + var packageJson = filterByPackageJson && createAutoImportFilter(from, program, host); + var allSourceFiles = program.getSourceFiles(); + var globalTypingsCache = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); + forEachExternalModule(program.getTypeChecker(), allSourceFiles, function (module, sourceFile) { + if (sourceFile === undefined) { + if (!packageJson || packageJson.allowsImportingAmbientModule(module, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } + } + else if (sourceFile && + sourceFile !== from && + isImportablePath(from.fileName, sourceFile.fileName, ts.hostGetCanonicalFileName(host), globalTypingsCache)) { + if (!packageJson || packageJson.allowsImportingSourceFile(sourceFile, allSourceFiles)) { + cb(module); + } + else if (packageJson) { + filteredCount++; + } } }); + if (host.log) { + host.log("forEachExternalModuleToImportFrom: filtered out " + filteredCount + " modules by package.json contents"); + } } codefix.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom; function forEachExternalModule(checker, allSourceFiles, cb) { @@ -119402,10 +124373,13 @@ var ts; * Don't include something from a `node_modules` that isn't actually reachable by a global import. * A relative import to node_modules is usually a bad idea. */ - function isImportablePath(fromPath, toPath) { + function isImportablePath(fromPath, toPath, getCanonicalFileName, globalCachePath) { // If it's in a `node_modules` but is not reachable from here via a global import, don't bother. var toNodeModules = ts.forEachAncestorDirectory(toPath, function (ancestor) { return ts.getBaseFileName(ancestor) === "node_modules" ? ancestor : undefined; }); - return toNodeModules === undefined || ts.startsWith(fromPath, ts.getDirectoryPath(toNodeModules)); + var toNodeModulesParent = toNodeModules && ts.getDirectoryPath(getCanonicalFileName(toNodeModules)); + return toNodeModulesParent === undefined + || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent) + || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent)); } function moduleSymbolToValidIdentifier(moduleSymbol, target) { return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target); @@ -119438,6 +124412,110 @@ var ts; return !ts.isStringANonContextualKeyword(res) ? res || "_" : "_" + res; } codefix.moduleSpecifierToValidIdentifier = moduleSpecifierToValidIdentifier; + function createAutoImportFilter(fromFile, program, host) { + var packageJsons = host.getPackageJsonsVisibleToFile && host.getPackageJsonsVisibleToFile(fromFile.fileName) || ts.getPackageJsonsVisibleToFile(fromFile.fileName, host); + var dependencyGroups = 1 /* Dependencies */ | 2 /* DevDependencies */ | 8 /* OptionalDependencies */; + // Mix in `getProbablySymlinks` from Program when host doesn't have it + // in order for non-Project hosts to have a symlinks cache. + var moduleSpecifierResolutionHost = { + directoryExists: ts.maybeBind(host, host.directoryExists), + fileExists: ts.maybeBind(host, host.fileExists), + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + readFile: ts.maybeBind(host, host.readFile), + useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks) || program.getProbableSymlinks, + getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation), + }; + var usesNodeCoreModules; + return { allowsImportingAmbientModule: allowsImportingAmbientModule, allowsImportingSourceFile: allowsImportingSourceFile, allowsImportingSpecifier: allowsImportingSpecifier }; + function moduleSpecifierIsCoveredByPackageJson(specifier) { + var packageName = getNodeModuleRootSpecifier(specifier); + for (var _i = 0, packageJsons_1 = packageJsons; _i < packageJsons_1.length; _i++) { + var packageJson = packageJsons_1[_i]; + if (packageJson.has(packageName, dependencyGroups) || packageJson.has(ts.getTypesPackageName(packageName), dependencyGroups)) { + return true; + } + } + return false; + } + function allowsImportingAmbientModule(moduleSymbol, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var declaringSourceFile = moduleSymbol.valueDeclaration.getSourceFile(); + var declaringNodeModuleName = getNodeModulesPackageNameFromFileName(declaringSourceFile.fileName, allSourceFiles); + if (typeof declaringNodeModuleName === "undefined") { + return true; + } + var declaredModuleSpecifier = ts.stripQuotes(moduleSymbol.getName()); + if (isAllowedCoreNodeModulesImport(declaredModuleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(declaringNodeModuleName) + || moduleSpecifierIsCoveredByPackageJson(declaredModuleSpecifier); + } + function allowsImportingSourceFile(sourceFile, allSourceFiles) { + if (!packageJsons.length) { + return true; + } + var moduleSpecifier = getNodeModulesPackageNameFromFileName(sourceFile.fileName, allSourceFiles); + if (!moduleSpecifier) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + /** + * Use for a specific module specifier that has already been resolved. + * Use `allowsImportingAmbientModule` or `allowsImportingSourceFile` to resolve + * the best module specifier for a given module _and_ determine if it’s importable. + */ + function allowsImportingSpecifier(moduleSpecifier) { + if (!packageJsons.length || isAllowedCoreNodeModulesImport(moduleSpecifier)) { + return true; + } + if (ts.pathIsRelative(moduleSpecifier) || ts.isRootedDiskPath(moduleSpecifier)) { + return true; + } + return moduleSpecifierIsCoveredByPackageJson(moduleSpecifier); + } + function isAllowedCoreNodeModulesImport(moduleSpecifier) { + // If we’re in JavaScript, it can be difficult to tell whether the user wants to import + // from Node core modules or not. We can start by seeing if the user is actually using + // any node core modules, as opposed to simply having @types/node accidentally as a + // dependency of a dependency. + if (ts.isSourceFileJS(fromFile) && ts.JsTyping.nodeCoreModules.has(moduleSpecifier)) { + if (usesNodeCoreModules === undefined) { + usesNodeCoreModules = ts.consumesNodeCoreModules(fromFile); + } + if (usesNodeCoreModules) { + return true; + } + } + return false; + } + function getNodeModulesPackageNameFromFileName(importedFileName, allSourceFiles) { + if (!ts.stringContains(importedFileName, "node_modules")) { + return undefined; + } + var specifier = ts.moduleSpecifiers.getNodeModulesPackageName(host.getCompilationSettings(), fromFile.path, importedFileName, moduleSpecifierResolutionHost, allSourceFiles, program.redirectTargetsMap); + if (!specifier) { + return undefined; + } + // Paths here are not node_modules, so we don’t care about them; + // returning anything will trigger a lookup in package.json. + if (!ts.pathIsRelative(specifier) && !ts.isRootedDiskPath(specifier)) { + return getNodeModuleRootSpecifier(specifier); + } + } + function getNodeModuleRootSpecifier(fullSpecifier) { + var components = ts.getPathComponents(ts.getPackageNameFromTypesPackageName(fullSpecifier)).slice(1); + // Scoped packages + if (ts.startsWith(components[0], "@")) { + return components[0] + "/" + components[1]; + } + return components[0]; + } + } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /* @internal */ @@ -119481,12 +124559,12 @@ var ts; var checker = context.program.getTypeChecker(); var suggestion; if (ts.isPropertyAccessExpression(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (property access)"); var containingType = checker.getTypeAtLocation(node.parent.expression); suggestion = checker.getSuggestionForNonexistentProperty(node, containingType); } else if (ts.isImportSpecifier(node.parent) && node.parent.name === node) { - ts.Debug.assert(node.kind === 73 /* Identifier */); + ts.Debug.assert(node.kind === 75 /* Identifier */, "Expected an identifier for spelling (import)"); var importDeclaration = ts.findAncestor(node, ts.isImportDeclaration); var resolvedSourceFile = getResolvedSourceFileFromImportDeclaration(sourceFile, context, importDeclaration); if (resolvedSourceFile && resolvedSourceFile.symbol) { @@ -119589,7 +124667,7 @@ var ts; }); typeDeclToMembers.forEach(function (infos, classDeclaration) { var supers = getAllSupers(classDeclaration, checker); - var _loop_12 = function (info) { + var _loop_14 = function (info) { // If some superclass added this property, don't add it again. if (supers.some(function (superClassOrInterface) { var superInfos = typeDeclToMembers.get(superClassOrInterface); @@ -119616,7 +124694,7 @@ var ts; }; for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) { var info = infos_1[_i]; - _loop_12(info); + _loop_14(info); } }); })); @@ -119677,7 +124755,7 @@ var ts; } function addMissingMemberInJs(changeTracker, declSourceFile, classDeclaration, tokenName, makeStatic) { if (makeStatic) { - if (classDeclaration.kind === 210 /* ClassExpression */) { + if (classDeclaration.kind === 213 /* ClassExpression */) { return; } var className = classDeclaration.name.getText(); @@ -119703,7 +124781,7 @@ var ts; } function getTypeNode(checker, classDeclaration, token) { var typeNode; - if (token.parent.parent.kind === 205 /* BinaryExpression */) { + if (token.parent.parent.kind === 208 /* BinaryExpression */) { var binaryExpression = token.parent.parent; var otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left; var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression))); @@ -119713,7 +124791,7 @@ var ts; var contextualType = checker.getContextualType(token.parent); typeNode = contextualType ? checker.typeToTypeNode(contextualType) : undefined; } - return typeNode || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return typeNode || ts.createKeywordTypeNode(124 /* AnyKeyword */); } function createAddPropertyDeclarationAction(context, declSourceFile, classDeclaration, makeStatic, tokenName, typeNode) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addPropertyDeclaration(t, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic); }); @@ -119722,7 +124800,7 @@ var ts; function addPropertyDeclaration(changeTracker, declSourceFile, classDeclaration, tokenName, typeNode, makeStatic) { var property = ts.createProperty( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, tokenName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); var lastProp = getNodeToInsertPropertyAfter(classDeclaration); @@ -119746,7 +124824,7 @@ var ts; } function createAddIndexSignatureAction(context, declSourceFile, classDeclaration, tokenName, typeNode) { // Index signatures cannot have the static modifier. - var stringTypeNode = ts.createKeywordTypeNode(139 /* StringKeyword */); + var stringTypeNode = ts.createKeywordTypeNode(142 /* StringKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -119766,7 +124844,7 @@ var ts; } function addMethodDeclaration(context, changeTracker, declSourceFile, typeDecl, token, callExpression, makeStatic, inJs, preferences) { var methodDeclaration = codefix.createMethodFromCallExpression(context, callExpression, token.text, inJs, makeStatic, preferences, typeDecl); - var containingMethodDeclaration = ts.getAncestor(callExpression, 157 /* MethodDeclaration */); + var containingMethodDeclaration = ts.getAncestor(callExpression, 160 /* MethodDeclaration */); if (containingMethodDeclaration && containingMethodDeclaration.parent === typeDecl) { changeTracker.insertNodeAfter(declSourceFile, containingMethodDeclaration, methodDeclaration); } @@ -119974,7 +125052,7 @@ var ts; } function getNodes(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - if (token.kind !== 101 /* ThisKeyword */) + if (token.kind !== 103 /* ThisKeyword */) return undefined; var constructor = ts.getContainingFunction(token); var superCall = findSuperCall(constructor.body); @@ -120013,7 +125091,7 @@ var ts; }); function getNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 125 /* ConstructorKeyword */); + ts.Debug.assert(token.kind === 128 /* ConstructorKeyword */, "token should be at the constructor keyword"); return token.parent; } function doChange(changes, sourceFile, ctr) { @@ -120057,6 +125135,43 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixID = "fixEnableJsxFlag"; + var errorCodes = [ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + var changes = ts.textChanges.ChangeTracker.with(context, function (changeTracker) { + return doChange(changeTracker, configFile); + }); + return [ + codefix.createCodeFixActionNoFixId(fixID, changes, ts.Diagnostics.Enable_the_jsx_flag_in_your_configuration_file) + ]; + }, + fixIds: [fixID], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes) { + var configFile = context.program.getCompilerOptions().configFile; + if (configFile === undefined) { + return undefined; + } + doChange(changes, configFile); + }); + } + }); + function doChange(changeTracker, configFile) { + codefix.setJsonCompilerOptionValue(changeTracker, configFile, "jsx", ts.createStringLiteral("react")); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -120084,14 +125199,14 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, pos); var heritageClauses = ts.getContainingClass(token).heritageClauses; var extendsToken = heritageClauses[0].getFirstToken(); - return extendsToken.kind === 87 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; + return extendsToken.kind === 89 /* ExtendsKeyword */ ? { extendsToken: extendsToken, heritageClauses: heritageClauses } : undefined; } function doChanges(changes, sourceFile, extendsToken, heritageClauses) { - changes.replaceNode(sourceFile, extendsToken, ts.createToken(110 /* ImplementsKeyword */)); + changes.replaceNode(sourceFile, extendsToken, ts.createToken(112 /* ImplementsKeyword */)); // If there is already an implements clause, replace the implements keyword with a comma. if (heritageClauses.length === 2 && - heritageClauses[0].token === 87 /* ExtendsKeyword */ && - heritageClauses[1].token === 110 /* ImplementsKeyword */) { + heritageClauses[0].token === 89 /* ExtendsKeyword */ && + heritageClauses[1].token === 112 /* ImplementsKeyword */) { var implementsToken = heritageClauses[1].getFirstToken(); var implementsFullStart = implementsToken.getFullStart(); changes.replaceRange(sourceFile, { pos: implementsFullStart, end: implementsFullStart }, ts.createToken(27 /* CommaToken */)); @@ -120178,7 +125293,7 @@ var ts; if (ts.isJSDocTemplateTag(token)) { return [createDeleteFix(ts.textChanges.ChangeTracker.with(context, function (t) { return t.delete(sourceFile, token); }), ts.Diagnostics.Remove_template_tag)]; } - if (token.kind === 28 /* LessThanToken */) { + if (token.kind === 29 /* LessThanToken */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return deleteTypeParameters(t, sourceFile, token); }); return [createDeleteFix(changes, ts.Diagnostics.Remove_type_parameters)]; } @@ -120198,7 +125313,7 @@ var ts; return [createDeleteFix(delVar, ts.Diagnostics.Remove_variable_statement)]; } var result = []; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return changeInferToUnknown(t, sourceFile, token); }); var name = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name.text; result.push(codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Replace_infer_0_with_unknown, name], fixIdInfer, ts.Diagnostics.Replace_all_unused_infer_with_unknown)); @@ -120230,7 +125345,7 @@ var ts; tryPrefixDeclaration(changes, diag.code, sourceFile, token); break; case fixIdDelete: { - if (token.kind === 128 /* InferKeyword */) + if (token.kind === 131 /* InferKeyword */) break; // Can't delete var importDecl = tryGetFullImport(token); if (importDecl) { @@ -120239,7 +125354,7 @@ var ts; else if (ts.isJSDocTemplateTag(token)) { changes.delete(sourceFile, token); } - else if (token.kind === 28 /* LessThanToken */) { + else if (token.kind === 29 /* LessThanToken */) { deleteTypeParameters(changes, sourceFile, token); } else if (!tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, /*isFixAll*/ true) && @@ -120249,7 +125364,7 @@ var ts; break; } case fixIdInfer: - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { changeInferToUnknown(changes, sourceFile, token); } break; @@ -120260,23 +125375,23 @@ var ts; }, }); function changeInferToUnknown(changes, sourceFile, token) { - changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(144 /* UnknownKeyword */)); + changes.replaceNode(sourceFile, token.parent, ts.createKeywordTypeNode(147 /* UnknownKeyword */)); } function createDeleteFix(changes, diag) { return codefix.createCodeFixAction(fixName, changes, diag, fixIdDelete, ts.Diagnostics.Delete_all_unused_declarations); } function deleteTypeParameters(changes, sourceFile, token) { - changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters)); + changes.delete(sourceFile, ts.Debug.assertDefined(ts.cast(token.parent, ts.isDeclarationWithTypeParameterChildren).typeParameters, "The type parameter to delete should exist")); } // Sometimes the diagnostic span is an entire ImportDeclaration, so we should remove the whole thing. function tryGetFullImport(token) { - return token.kind === 93 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; + return token.kind === 95 /* ImportKeyword */ ? ts.tryCast(token.parent, ts.isImportDeclaration) : undefined; } function tryDeleteFullDestructure(token, changes, sourceFile, checker, sourceFiles, isFixAll) { if (token.kind !== 18 /* OpenBraceToken */ || !ts.isObjectBindingPattern(token.parent)) return false; var decl = token.parent.parent; - if (decl.kind === 152 /* Parameter */) { + if (decl.kind === 155 /* Parameter */) { tryDeleteParameter(changes, sourceFile, decl, checker, sourceFiles, isFixAll); } else { @@ -120287,7 +125402,7 @@ var ts; function tryDeleteFullVariableStatement(sourceFile, token, changes) { var declarationList = ts.tryCast(token.parent, ts.isVariableDeclarationList); if (declarationList && declarationList.getChildren(sourceFile)[0] === token) { - changes.delete(sourceFile, declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList); + changes.delete(sourceFile, declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList); return true; } return false; @@ -120296,7 +125411,7 @@ var ts; // Don't offer to prefix a property. if (errorCode === ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code) return; - if (token.kind === 128 /* InferKeyword */) { + if (token.kind === 131 /* InferKeyword */) { token = ts.cast(token.parent, ts.isInferTypeNode).typeParameter.name; } if (ts.isIdentifier(token) && canPrefix(token)) { @@ -120305,14 +125420,14 @@ var ts; } function canPrefix(token) { switch (token.parent.kind) { - case 152 /* Parameter */: - case 151 /* TypeParameter */: + case 155 /* Parameter */: + case 154 /* TypeParameter */: return true; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var varDecl = token.parent; switch (varDecl.parent.parent.kind) { - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: return true; } } @@ -120359,26 +125474,26 @@ var ts; function mayDeleteParameter(p, checker, isFixAll) { var parent = p.parent; switch (parent.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // Don't remove a parameter if this overrides something. var symbol = checker.getSymbolAtLocation(parent.name); if (ts.isMemberSymbolInBaseType(symbol, checker)) return false; // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: return true; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: { + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: { // Can't remove a non-last parameter in a callback. Can remove a parameter in code-fix-all if future parameters are also unused. var parameters = parent.parameters; var index = parameters.indexOf(p); - ts.Debug.assert(index !== -1); + ts.Debug.assert(index !== -1, "The parameter should already be in the list"); return isFixAll - ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 73 /* Identifier */ && !p.symbol.isReferenced; }) + ? parameters.slice(index + 1).every(function (p) { return p.name.kind === 75 /* Identifier */ && !p.symbol.isReferenced; }) : index === parameters.length - 1; } - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Setter must have a parameter return false; default: @@ -120414,11 +125529,11 @@ var ts; function doChange(changes, sourceFile, start, length) { var token = ts.getTokenAtPosition(sourceFile, start); var statement = ts.findAncestor(token, ts.isStatement); - ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile)); + ts.Debug.assert(statement.getStart(sourceFile) === token.getStart(sourceFile), "token and statement should start at the same point"); var container = (ts.isBlock(statement.parent) ? statement.parent : statement).parent; if (!ts.isBlock(statement.parent) || statement === ts.first(statement.parent.statements)) { switch (container.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: if (container.elseStatement) { if (ts.isBlock(statement.parent)) { break; @@ -120429,15 +125544,15 @@ var ts; return; } // falls through - case 225 /* WhileStatement */: - case 226 /* ForStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: changes.delete(sourceFile, container); return; } } if (ts.isBlock(statement.parent)) { var end_3 = start + length; - var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; })); + var lastStatement = ts.Debug.assertDefined(lastWhere(ts.sliceAfter(statement.parent.statements, statement), function (s) { return s.pos < end_3; }), "Some statement should be last"); changes.deleteNodeRange(sourceFile, statement, lastStatement); } else { @@ -120479,7 +125594,7 @@ var ts; var statementPos = labeledStatement.statement.getStart(sourceFile); // If label is on a separate line, just delete the rest of that line, but not the indentation of the labeled statement. var end = ts.positionsAreOnSameLine(pos, statementPos, sourceFile) ? statementPos - : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 57 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); + : ts.skipTrivia(sourceFile.text, ts.findChildOfKind(labeledStatement, 58 /* ColonToken */, sourceFile).end, /*stopAfterLineBreak*/ true); changes.deleteRange(sourceFile, { pos: pos, end: end }); } })(codefix = ts.codefix || (ts.codefix = {})); @@ -120503,7 +125618,7 @@ var ts; var typeNode = info.typeNode, type = info.type; var original = typeNode.getText(sourceFile); var actions = [fix(type, fixIdPlain, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript)]; - if (typeNode.kind === 292 /* JSDocNullableType */) { + if (typeNode.kind === 295 /* JSDocNullableType */) { // for nullable types, suggest the flow-compatible `T | null | undefined` // in addition to the jsdoc/closure-compatible `T | null` actions.push(fix(checker.getNullableType(type, 32768 /* Undefined */), fixIdNullable, ts.Diagnostics.Change_all_jsdoc_style_types_to_TypeScript_and_add_undefined_to_nullable_types)); @@ -120523,7 +125638,7 @@ var ts; if (!info) return; var typeNode = info.typeNode, type = info.type; - var fixedType = typeNode.kind === 292 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; + var fixedType = typeNode.kind === 295 /* JSDocNullableType */ && fixId === fixIdNullable ? checker.getNullableType(type, 32768 /* Undefined */) : type; doChange(changes, sourceFile, typeNode, fixedType, checker); }); } @@ -120540,22 +125655,22 @@ var ts; // NOTE: Some locations are not handled yet: // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments switch (node.kind) { - case 213 /* AsExpression */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 240 /* FunctionDeclaration */: - case 159 /* GetAccessor */: - case 163 /* IndexSignature */: - case 182 /* MappedType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 195 /* TypeAssertionExpression */: - case 238 /* VariableDeclaration */: + case 216 /* AsExpression */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 243 /* FunctionDeclaration */: + case 162 /* GetAccessor */: + case 166 /* IndexSignature */: + case 185 /* MappedType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 198 /* TypeAssertionExpression */: + case 241 /* VariableDeclaration */: return true; default: return false; @@ -120584,12 +125699,15 @@ var ts; return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_async_modifier_to_containing_function, fixId, ts.Diagnostics.Add_all_missing_async_modifiers)]; }, fixIds: [fixId], - getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) { - var nodes = getNodes(diag.file, diag.start); - if (!nodes) - return; - doChange(changes, context.sourceFile, nodes); - }); }, + getAllCodeActions: function (context) { + var seen = ts.createMap(); + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { + var nodes = getNodes(diag.file, diag.start); + if (!nodes || !ts.addToSeen(seen, ts.getNodeId(nodes.insertBefore))) + return; + doChange(changes, context.sourceFile, nodes); + }); + }, }); function getReturnType(expr) { if (expr.type) { @@ -120609,14 +125727,14 @@ var ts; } var insertBefore; switch (containingFunction.kind) { - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: insertBefore = containingFunction.name; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - insertBefore = ts.findChildOfKind(containingFunction, 91 /* FunctionKeyword */, sourceFile); + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + insertBefore = ts.findChildOfKind(containingFunction, 93 /* FunctionKeyword */, sourceFile); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: insertBefore = ts.findChildOfKind(containingFunction, 20 /* OpenParenToken */, sourceFile) || ts.first(containingFunction.parameters); break; default: @@ -120631,11 +125749,11 @@ var ts; var insertBefore = _a.insertBefore, returnType = _a.returnType; if (returnType) { var entityName = ts.getEntityNameFromTypeNode(returnType); - if (!entityName || entityName.kind !== 73 /* Identifier */ || entityName.text !== "Promise") { + if (!entityName || entityName.kind !== 75 /* Identifier */ || entityName.text !== "Promise") { changes.replaceNode(sourceFile, returnType, ts.createTypeReferenceNode("Promise", ts.createNodeArray([returnType]))); } } - changes.insertModifierBefore(sourceFile, 122 /* AsyncKeyword */, insertBefore); + changes.insertModifierBefore(sourceFile, 125 /* AsyncKeyword */, insertBefore); } })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); @@ -120743,17 +125861,17 @@ var ts; var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); var optional = !!(symbol.flags & 16777216 /* Optional */); - var ambient = !!(enclosingDeclaration.flags & 4194304 /* Ambient */); + var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */); switch (declaration.kind) { - case 154 /* PropertySignature */: - case 155 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 158 /* PropertyDeclaration */: var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); out(ts.createProperty( - /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeNode, + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeNode, /*initializer*/ undefined)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: { + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: { var allAccessors = ts.getAllAccessorDeclarations(declarations, declaration); var typeNode_1 = checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context)); var orderedAccessors = allAccessors.secondAccessor @@ -120766,7 +125884,7 @@ var ts; /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(preferences))); } else { - ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration); + ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter"); var parameter = ts.getSetAccessorValueParameter(accessor); var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined; out(ts.createSetAccessor( @@ -120775,8 +125893,8 @@ var ts; } break; } - case 156 /* MethodSignature */: - case 157 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 160 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -120789,7 +125907,7 @@ var ts; break; } if (declarations.length === 1) { - ts.Debug.assert(signatures.length === 1); + ts.Debug.assert(signatures.length === 1, "One declaration implies one signature"); var signature = signatures[0]; outputMethod(signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(preferences)); break; @@ -120805,7 +125923,7 @@ var ts; outputMethod(signature, modifiers, name, createStubbedMethodBody(preferences)); } else { - ts.Debug.assert(declarations.length === signatures.length); + ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count"); out(createMethodImplementingSignatures(signatures, name, optional, modifiers, preferences)); } } @@ -120819,14 +125937,14 @@ var ts; } function signatureToMethodDeclaration(context, signature, enclosingDeclaration, modifiers, name, optional, body) { var program = context.program; - var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 157 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); + var signatureDeclaration = program.getTypeChecker().signatureToSignatureDeclaration(signature, 160 /* MethodDeclaration */, enclosingDeclaration, 1 /* NoTruncation */ | 256 /* SuppressAnyReturnType */, getNoopSymbolTrackerWithResolver(context)); if (!signatureDeclaration) { return undefined; } signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; - signatureDeclaration.questionToken = optional ? ts.createToken(56 /* QuestionToken */) : undefined; + signatureDeclaration.questionToken = optional ? ts.createToken(57 /* QuestionToken */) : undefined; signatureDeclaration.body = body; return signatureDeclaration; } @@ -120840,15 +125958,14 @@ var ts; return checker.typeToTypeNode(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(arg)), contextNode, /*flags*/ undefined, tracker); }); var names = ts.map(args, function (arg) { - return ts.isIdentifier(arg) ? arg.text : - ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; + return ts.isIdentifier(arg) ? arg.text : ts.isPropertyAccessExpression(arg) ? arg.name.text : undefined; }); var contextualType = checker.getContextualType(call); var returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return ts.createMethod( /*decorators*/ undefined, - /*modifiers*/ makeStatic ? [ts.createToken(117 /* StaticKeyword */)] : undefined, - /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(40 /* AsteriskToken */) : undefined, methodName, + /*modifiers*/ makeStatic ? [ts.createToken(119 /* StaticKeyword */)] : undefined, + /*asteriskToken*/ ts.isYieldExpression(parent) ? ts.createToken(41 /* AsteriskToken */) : undefined, methodName, /*questionToken*/ undefined, /*typeParameters*/ inJs ? undefined : ts.map(typeArguments, function (_, i) { return ts.createTypeParameterDeclaration(84 /* T */ + typeArguments.length - 1 <= 90 /* Z */ ? String.fromCharCode(84 /* T */ + i) : "T" + i); @@ -120865,8 +125982,8 @@ var ts; /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || "arg" + i, - /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, - /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(121 /* AnyKeyword */), + /*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, + /*type*/ inJs ? undefined : types && types[i] || ts.createKeywordTypeNode(124 /* AnyKeyword */), /*initializer*/ undefined); parameters.push(newParameter); } @@ -120883,22 +126000,22 @@ var ts; for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { var sig = signatures_2[_i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - if (sig.hasRestParameter) { + if (ts.signatureHasRestParameter(sig)) { someSigHasRestParameter = true; } - if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!ts.signatureHasRestParameter(sig) || ts.signatureHasRestParameter(maxArgsSignature))) { maxArgsSignature = sig; } } - var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + var maxNonRestArgs = maxArgsSignature.parameters.length - (ts.signatureHasRestParameter(maxArgsSignature) ? 1 : 0); var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; }); var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false); if (someSigHasRestParameter) { - var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(121 /* AnyKeyword */)); + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(124 /* AnyKeyword */)); var restParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", - /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(56 /* QuestionToken */) : undefined, anyArrayType, + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(57 /* QuestionToken */) : undefined, anyArrayType, /*initializer*/ undefined); parameters.push(restParameter); } @@ -120909,7 +126026,7 @@ var ts; function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, preferences) { return ts.createMethod( /*decorators*/ undefined, modifiers, - /*asteriskToken*/ undefined, name, optional ? ts.createToken(56 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); + /*asteriskToken*/ undefined, name, optional ? ts.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(preferences)); } function createStubbedMethodBody(preferences) { return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), @@ -120920,10 +126037,10 @@ var ts; } function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return ts.createToken(116 /* PublicKeyword */); + return ts.createToken(118 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return ts.createToken(115 /* ProtectedKeyword */); + return ts.createToken(117 /* ProtectedKeyword */); } return undefined; } @@ -120995,7 +126112,7 @@ var ts; }); function getActionsForUsageOfInvalidImport(context) { var sourceFile = context.sourceFile; - var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 192 /* CallExpression */ : 193 /* NewExpression */; + var targetKind = ts.Diagnostics.This_expression_is_not_callable.code === context.errorCode ? 195 /* CallExpression */ : 196 /* NewExpression */; var node = ts.findAncestor(ts.getTokenAtPosition(sourceFile, context.span.start), function (a) { return a.kind === targetKind; }); if (!node) { return []; @@ -121106,7 +126223,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties); } function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(52 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); + var property = ts.updateProperty(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer); changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property); } function getActionForAddMissingUndefinedType(context, propertyDeclaration) { @@ -121114,7 +126231,7 @@ var ts; return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties); } function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) { - var undefinedTypeNode = ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + var undefinedTypeNode = ts.createKeywordTypeNode(145 /* UndefinedKeyword */); var type = propertyDeclaration.type; // TODO: GH#18217 var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode]; changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.createUnionTypeNode(types)); @@ -121235,6 +126352,39 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "useBigintLiteral"; + var errorCodes = [ + ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code, + ]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, context.span); }); + if (changes.length > 0) { + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, ts.Diagnostics.Convert_all_to_bigint_numeric_literals)]; + } + }, + fixIds: [fixId], + getAllCodeActions: function (context) { + return codefix.codeFixAll(context, errorCodes, function (changes, diag) { return makeChange(changes, diag.file, diag); }); + }, + }); + function makeChange(changeTracker, sourceFile, span) { + var numericLiteral = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), ts.isNumericLiteral); + if (!numericLiteral) { + return; + } + // We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298 + var newText = numericLiteral.getText(sourceFile) + "n"; + changeTracker.replaceNode(sourceFile, numericLiteral, ts.createBigIntLiteral(newText)); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -121256,8 +126406,8 @@ var ts; }); function getImportTypeNode(sourceFile, pos) { var token = ts.getTokenAtPosition(sourceFile, pos); - ts.Debug.assert(token.kind === 93 /* ImportKeyword */); - ts.Debug.assert(token.parent.kind === 184 /* ImportType */); + ts.Debug.assert(token.kind === 95 /* ImportKeyword */, "This token should be an ImportKeyword"); + ts.Debug.assert(token.parent.kind === 187 /* ImportType */, "Token parent should be an ImportType"); return token.parent; } function doChange(changes, sourceFile, importType) { @@ -121309,7 +126459,7 @@ var ts; var otherMembers = members.filter(function (member) { return !ts.isIndexSignatureDeclaration(member); }); var parameter = ts.first(indexSignature.parameters); var mappedTypeParameter = ts.createTypeParameterDeclaration(ts.cast(parameter.name, ts.isIdentifier), parameter.type); - var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(134 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); + var mappedIntersectionType = ts.createMappedTypeNode(ts.hasReadonlyModifier(indexSignature) ? ts.createModifier(137 /* ReadonlyKeyword */) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type); var intersectionType = ts.createIntersectionTypeNode(__spreadArrays(ts.getAllSuperTypeNodes(container), [ mappedIntersectionType ], (otherMembers.length ? [ts.createTypeLiteralNode(otherMembers)] : ts.emptyArray))); @@ -121340,7 +126490,7 @@ var ts; }, }); function makeChange(changeTracker, sourceFile, span) { - var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 123 /* AwaitKeyword */; }); + var awaitKeyword = ts.tryCast(ts.getTokenAtPosition(sourceFile, span.start), function (node) { return node.kind === 126 /* AwaitKeyword */; }); var awaitExpression = awaitKeyword && ts.tryCast(awaitKeyword.parent, ts.isAwaitExpression); if (!awaitExpression) { return; @@ -121351,7 +126501,7 @@ var ts; var leftMostExpression = ts.getLeftmostExpression(awaitExpression.expression, /*stopAtCallExpressions*/ false); if (ts.isIdentifier(leftMostExpression)) { var precedingToken = ts.findPrecedingToken(awaitExpression.parent.pos, sourceFile); - if (precedingToken && precedingToken.kind !== 96 /* NewKeyword */) { + if (precedingToken && precedingToken.kind !== 98 /* NewKeyword */) { expressionToReplace = awaitExpression.parent; } } @@ -121362,6 +126512,40 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + var fixId = "fixConvertConstToLet"; + var errorCodes = [ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant.code]; + codefix.registerCodeFix({ + errorCodes: errorCodes, + getCodeActions: function (context) { + var sourceFile = context.sourceFile, span = context.span, program = context.program; + var variableStatement = getVariableStatement(sourceFile, span.start, program); + var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(t, sourceFile, variableStatement); }); + return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Convert_const_to_let, fixId, ts.Diagnostics.Convert_const_to_let)]; + }, + fixIds: [fixId] + }); + function getVariableStatement(sourceFile, pos, program) { + var token = ts.getTokenAtPosition(sourceFile, pos); + var checker = program.getTypeChecker(); + var symbol = checker.getSymbolAtLocation(token); + if (symbol) { + return symbol.valueDeclaration.parent.parent; + } + } + function doChange(changes, sourceFile, variableStatement) { + if (!variableStatement) { + return; + } + var start = variableStatement.getStart(); + changes.replaceRangeWithText(sourceFile, { pos: start, end: start + 5 }, "let"); + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var refactor; (function (refactor) { @@ -121378,8 +126562,8 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context)), t, context.cancellationToken); }); + ts.Debug.assert(actionName === actionNameDefaultToNamed || actionName === actionNameNamedToDefault, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, ts.Debug.assertDefined(getInfo(context), "context must have info"), t, context.cancellationToken); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; }, }); @@ -121399,16 +126583,16 @@ var ts; return undefined; } switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: { + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: { var node = exportNode; return node.name && ts.isIdentifier(node.name) ? { exportNode: node, exportName: node.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { var vs = exportNode; // Must be `export const x = something;`. if (!(vs.declarationList.flags & 2 /* Const */) || vs.declarationList.declarations.length !== 1) { @@ -121417,7 +126601,7 @@ var ts; var decl = ts.first(vs.declarationList.declarations); if (!decl.initializer) return undefined; - ts.Debug.assert(!wasDefault); + ts.Debug.assert(!wasDefault, "Can't have a default flag here"); return ts.isIdentifier(decl.name) ? { exportNode: vs, exportName: decl.name, wasDefault: wasDefault, exportingModuleSymbol: exportingModuleSymbol } : undefined; } default: @@ -121431,40 +126615,40 @@ var ts; function changeExport(exportingSourceFile, _a, changes, checker) { var wasDefault = _a.wasDefault, exportNode = _a.exportNode, exportName = _a.exportName; if (wasDefault) { - changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 81 /* DefaultKeyword */))); + changes.delete(exportingSourceFile, ts.Debug.assertDefined(ts.findModifier(exportNode, 83 /* DefaultKeyword */), "Should find a default keyword in modifier list")); } else { - var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 86 /* ExportKeyword */)); + var exportKeyword = ts.Debug.assertDefined(ts.findModifier(exportNode, 88 /* ExportKeyword */), "Should find an export keyword in modifier list"); switch (exportNode.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(81 /* DefaultKeyword */)); + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + changes.insertNodeAfter(exportingSourceFile, exportKeyword, ts.createToken(83 /* DefaultKeyword */)); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // If 'x' isn't used in this file, `export const x = 0;` --> `export default 0;` if (!ts.FindAllReferences.Core.isSymbolReferencedInFile(exportName, checker, exportingSourceFile)) { // We checked in `getInfo` that an initializer exists. - changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer))); + changes.replaceNode(exportingSourceFile, exportNode, ts.createExportDefault(ts.Debug.assertDefined(ts.first(exportNode.declarationList.declarations).initializer, "Initializer was previously known to be present"))); break; } // falls through - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // `export type T = number;` -> `type T = number; export default T;` changes.deleteModifier(exportingSourceFile, exportKeyword); changes.insertNodeAfter(exportingSourceFile, exportNode, ts.createExportDefault(ts.createIdentifier(exportName.text))); break; default: - ts.Debug.assertNever(exportNode); + ts.Debug.assertNever(exportNode, "Unexpected exportNode kind " + exportNode.kind); } } } function changeImports(program, _a, changes, cancellationToken) { var wasDefault = _a.wasDefault, exportName = _a.exportName, exportingModuleSymbol = _a.exportingModuleSymbol; var checker = program.getTypeChecker(); - var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName)); + var exportSymbol = ts.Debug.assertDefined(checker.getSymbolAtLocation(exportName), "Export name should resolve to a symbol"); ts.FindAllReferences.Core.eachExportReference(program.getSourceFiles(), checker, cancellationToken, exportSymbol, exportingModuleSymbol, exportName.text, wasDefault, function (ref) { var importingSourceFile = ref.getSourceFile(); if (wasDefault) { @@ -121478,27 +126662,27 @@ var ts; function changeDefaultToNamedImport(importingSourceFile, ref, changes, exportName) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.default` --> `a.foo` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier(exportName)); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: { + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: { var spec = parent; // `default as foo` --> `foo`, `default as bar` --> `foo as bar` changes.replaceNode(importingSourceFile, spec, makeImportSpecifier(exportName, spec.name.text)); break; } - case 251 /* ImportClause */: { + case 254 /* ImportClause */: { var clause = parent; - ts.Debug.assert(clause.name === ref); + ts.Debug.assert(clause.name === ref, "Import clause name should match provided ref"); var spec = makeImportSpecifier(exportName, ref.text); var namedBindings = clause.namedBindings; if (!namedBindings) { // `import foo from "./a";` --> `import { foo } from "./a";` changes.replaceNode(importingSourceFile, ref, ts.createNamedImports([spec])); } - else if (namedBindings.kind === 252 /* NamespaceImport */) { + else if (namedBindings.kind === 255 /* NamespaceImport */) { // `import foo, * as a from "./a";` --> `import * as a from ".a/"; import { foo } from "./a";` changes.deleteRange(importingSourceFile, { pos: ref.getStart(importingSourceFile), end: namedBindings.getStart(importingSourceFile) }); var quotePreference = ts.isStringLiteral(clause.parent.moduleSpecifier) ? ts.quotePreferenceFromString(clause.parent.moduleSpecifier, importingSourceFile) : 1 /* Double */; @@ -121519,11 +126703,11 @@ var ts; function changeNamedToDefaultImport(importingSourceFile, ref, changes) { var parent = ref.parent; switch (parent.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // `a.foo` --> `a.default` changes.replaceNode(importingSourceFile, ref, ts.createIdentifier("default")); break; - case 254 /* ImportSpecifier */: { + case 257 /* ImportSpecifier */: { // `import { foo } from "./a";` --> `import foo from "./a";` // `import { foo as bar } from "./a";` --> `import bar from "./a";` var defaultImport = ts.createIdentifier(parent.name.text); @@ -121536,7 +126720,7 @@ var ts; } break; } - case 258 /* ExportSpecifier */: { + case 261 /* ExportSpecifier */: { // `export { foo } from "./a";` --> `export { default as foo } from "./a";` // `export { foo as bar } from "./a";` --> `export { default as bar } from "./a";` // `export { foo as default } from "./a";` --> `export { default } from "./a";` @@ -121545,7 +126729,7 @@ var ts; break; } default: - ts.Debug.assertNever(parent); + ts.Debug.assertNever(parent, "Unexpected parent kind " + parent.kind); } } function makeImportSpecifier(propertyName, name) { @@ -121569,13 +126753,13 @@ var ts; var i = getImportToConvert(context); if (!i) return ts.emptyArray; - var description = i.kind === 252 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; - var actionName = i.kind === 252 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; + var description = i.kind === 255 /* NamespaceImport */ ? ts.Diagnostics.Convert_namespace_import_to_named_imports.message : ts.Diagnostics.Convert_named_imports_to_namespace_import.message; + var actionName = i.kind === 255 /* NamespaceImport */ ? actionNameNamespaceToNamed : actionNameNamedToNamespace; return [{ name: refactorName, description: description, actions: [{ name: actionName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace); - var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context))); }); + ts.Debug.assert(actionName === actionNameNamespaceToNamed || actionName === actionNameNamedToNamespace, "Unexpected action name"); + var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, ts.Debug.assertDefined(getImportToConvert(context), "Context must provide an import to convert")); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; } }); @@ -121592,7 +126776,7 @@ var ts; } function doChange(sourceFile, program, changes, toConvert) { var checker = program.getTypeChecker(); - if (toConvert.kind === 252 /* NamespaceImport */) { + if (toConvert.kind === 255 /* NamespaceImport */) { doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions())); } else { @@ -121613,7 +126797,7 @@ var ts; if (checker.resolveName(exportName, id, 67108863 /* All */, /*excludeGlobals*/ true)) { conflictingNames.set(exportName, true); } - ts.Debug.assert(parent.expression === id); + ts.Debug.assert(parent.expression === id, "Parent expression should match id"); nodesToReplace.push(parent); } }); @@ -121652,7 +126836,7 @@ var ts; }); var namespaceImportName = namespaceNameConflicts ? ts.getUniqueName(preferredName, sourceFile) : preferredName; var neededNamedImports = []; - var _loop_13 = function (element) { + var _loop_15 = function (element) { var propertyName = (element.propertyName || element.name).text; ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) { var access = ts.createPropertyAccess(ts.createIdentifier(namespaceImportName), propertyName); @@ -121671,7 +126855,7 @@ var ts; }; for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) { var element = _a[_i]; - _loop_13(element); + _loop_15(element); } changes.replaceNode(sourceFile, toConvert, ts.createNamespaceImport(ts.createIdentifier(namespaceImportName))); if (neededNamedImports.length) { @@ -121792,6 +126976,7 @@ var ts; Messages.cannotExtractRange = createMessage("Cannot extract range."); Messages.cannotExtractImport = createMessage("Cannot extract import statement."); Messages.cannotExtractSuper = createMessage("Cannot extract super call."); + Messages.cannotExtractJSDoc = createMessage("Cannot extract JSDoc."); Messages.cannotExtractEmpty = createMessage("Cannot extract empty range."); Messages.expressionExpected = createMessage("expression expected."); Messages.uselessConstantType = createMessage("No reason to extract constant of type."); @@ -121883,6 +127068,9 @@ var ts; } return { targetRange: { range: statements, facts: rangeFacts, declarations: declarations } }; } + if (ts.isJSDoc(start)) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; + } if (ts.isReturnStatement(start) && !start.expression) { // Makes no sense to extract an expression-less return statement. return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; @@ -121935,20 +127123,20 @@ var ts; function checkForStaticContext(nodeToCheck, containingClass) { var current = nodeToCheck; while (current !== containingClass) { - if (current.kind === 155 /* PropertyDeclaration */) { + if (current.kind === 158 /* PropertyDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 152 /* Parameter */) { + else if (current.kind === 155 /* Parameter */) { var ctorOrMethod = ts.getContainingFunction(current); - if (ctorOrMethod.kind === 158 /* Constructor */) { + if (ctorOrMethod.kind === 161 /* Constructor */) { rangeFacts |= RangeFacts.InStaticRegion; } break; } - else if (current.kind === 157 /* MethodDeclaration */) { + else if (current.kind === 160 /* MethodDeclaration */) { if (ts.hasModifier(current, 32 /* Static */)) { rangeFacts |= RangeFacts.InStaticRegion; } @@ -121966,13 +127154,13 @@ var ts; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); // We believe it's true because the node is from the (unmodified) tree. - ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)"); // For understanding how skipTrivia functioned: - ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)"); if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } - if (nodeToCheck.flags & 4194304 /* Ambient */) { + if (nodeToCheck.flags & 8388608 /* Ambient */) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.cannotExtractAmbientBlock)]; } // If we're in a class, see whether we're in a static region (static property initializer, static method, class constructor parameter default) @@ -121991,7 +127179,7 @@ var ts; return true; } if (ts.isDeclaration(node)) { - var declaringNode = (node.kind === 238 /* VariableDeclaration */) ? node.parent.parent : node; + var declaringNode = (node.kind === 241 /* VariableDeclaration */) ? node.parent.parent : node; if (ts.hasModifier(declaringNode, 1 /* Export */)) { // TODO: GH#18217 Silly to use `errors ||` since it's definitely not defined (see top of `visit`) // Also, if we're only pushing one error, just use `let error: Diagnostic | undefined`! @@ -122003,13 +127191,13 @@ var ts; } // Some things can't be extracted in certain situations switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractImport)); return true; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // For a super *constructor call*, we have to be extracting the entire class, // but a super *method call* simply implies a 'this' reference - if (node.parent.kind === 192 /* CallExpression */) { + if (node.parent.kind === 195 /* CallExpression */) { // Super constructor call var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217 if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) { @@ -122024,8 +127212,8 @@ var ts; } if (ts.isFunctionLikeDeclaration(node) || ts.isClassLike(node)) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: if (ts.isSourceFile(node.parent) && node.parent.externalModuleIndicator === undefined) { // You cannot extract global declarations (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.functionWillNotBeVisibleInTheNewScope)); @@ -122037,20 +127225,20 @@ var ts; } var savedPermittedJumps = permittedJumps; switch (node.kind) { - case 223 /* IfStatement */: + case 226 /* IfStatement */: permittedJumps = 0 /* None */; break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: // forbid all jumps inside try blocks permittedJumps = 0 /* None */; break; - case 219 /* Block */: - if (node.parent && node.parent.kind === 236 /* TryStatement */ && node.parent.finallyBlock === node) { + case 222 /* Block */: + if (node.parent && node.parent.kind === 239 /* TryStatement */ && node.parent.finallyBlock === node) { // allow unconditional returns from finally blocks permittedJumps = 4 /* Return */; } break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: // allow unlabeled break inside case clauses permittedJumps |= 1 /* Break */; break; @@ -122062,19 +127250,19 @@ var ts; break; } switch (node.kind) { - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 182 /* ThisType */: + case 103 /* ThisKeyword */: rangeFacts |= RangeFacts.UsesThis; break; - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { var label = node.label; (seenLabels || (seenLabels = [])).push(label.escapedText); ts.forEachChild(node, visit); seenLabels.pop(); break; } - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: { + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: { var label = node.label; if (label) { if (!ts.contains(seenLabels, label.escapedText)) { @@ -122083,20 +127271,20 @@ var ts; } } else { - if (!(permittedJumps & (node.kind === 230 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 233 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } break; } - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: rangeFacts |= RangeFacts.IsAsyncFunction; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: rangeFacts |= RangeFacts.IsGenerator; break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: if (permittedJumps & 4 /* Return */) { rangeFacts |= RangeFacts.HasReturn; } @@ -122150,7 +127338,7 @@ var ts; while (true) { current = current.parent; // A function parameter's initializer is actually in the outer scope, not the function declaration - if (current.kind === 152 /* Parameter */) { + if (current.kind === 155 /* Parameter */) { // Skip all the way to the outer scope of the function that declared this parameter current = ts.findAncestor(current, function (parent) { return ts.isFunctionLikeDeclaration(parent); }).parent; } @@ -122161,7 +127349,7 @@ var ts; // * Module/namespace or source file if (isScope(current)) { scopes.push(current); - if (current.kind === 285 /* SourceFile */) { + if (current.kind === 288 /* SourceFile */) { return scopes; } } @@ -122251,32 +127439,32 @@ var ts; } function getDescriptionForFunctionLikeDeclaration(scope) { switch (scope.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "constructor"; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return scope.name ? "function '" + scope.name.text + "'" : "anonymous function"; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return "arrow function"; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return "method '" + scope.name.getText() + "'"; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return "'get " + scope.name.getText() + "'"; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return "'set " + scope.name.getText() + "'"; default: - throw ts.Debug.assertNever(scope); + throw ts.Debug.assertNever(scope, "Unexpected scope kind " + scope.kind); } } function getDescriptionForClassLikeDeclaration(scope) { - return scope.kind === 241 /* ClassDeclaration */ + return scope.kind === 244 /* ClassDeclaration */ ? scope.name ? "class '" + scope.name.text + "'" : "anonymous class declaration" : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; } function getDescriptionForModuleLikeDeclaration(scope) { - return scope.kind === 246 /* ModuleBlock */ + return scope.kind === 249 /* ModuleBlock */ ? "namespace '" + scope.parent.name.getText() + "'" : scope.externalModuleIndicator ? 0 /* Module */ : 1 /* Global */; } @@ -122342,20 +127530,20 @@ var ts; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files - var modifiers = isJS ? [] : [ts.createToken(114 /* PrivateKeyword */)]; + var modifiers = isJS ? [] : [ts.createToken(116 /* PrivateKeyword */)]; if (range.facts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } if (range.facts & RangeFacts.IsAsyncFunction) { - modifiers.push(ts.createToken(122 /* AsyncKeyword */)); + modifiers.push(ts.createToken(125 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(122 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(40 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(125 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(41 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); } var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var minInsertionPos = (isReadonlyArray(range.range) ? ts.last(range.range) : range.range).end; @@ -122372,7 +127560,7 @@ var ts; var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference callArguments); if (range.facts & RangeFacts.IsGenerator) { - call = ts.createYield(ts.createToken(40 /* AsteriskToken */), call); + call = ts.createYield(ts.createToken(41 /* AsteriskToken */), call); } if (range.facts & RangeFacts.IsAsyncFunction) { call = ts.createAwait(call); @@ -122380,8 +127568,8 @@ var ts; if (exposedVariableDeclarations.length && !writes) { // No need to mix declarations and writes. // How could any variables be exposed if there's a return statement? - ts.Debug.assert(!returnValueProperty); - ts.Debug.assert(!(range.facts & RangeFacts.HasReturn)); + ts.Debug.assert(!returnValueProperty, "Expected no returnValueProperty"); + ts.Debug.assert(!(range.facts & RangeFacts.HasReturn), "Expected RangeFacts.HasReturn flag to be unset"); if (exposedVariableDeclarations.length === 1) { // Declaring exactly one variable: let x = newFunction(); var variableDeclaration = exposedVariableDeclarations[0]; @@ -122449,7 +127637,7 @@ var ts; if (assignments.length === 1) { // We would only have introduced a return value property if there had been // other assignments to make. - ts.Debug.assert(!returnValueProperty); + ts.Debug.assert(!returnValueProperty, "Shouldn't have returnValueProperty here"); newNodes.push(ts.createStatement(ts.createAssignment(assignments[0].name, call))); if (range.facts & RangeFacts.HasReturn) { newNodes.push(ts.createReturn()); @@ -122496,9 +127684,9 @@ var ts; while (ts.isParenthesizedTypeNode(withoutParens)) { withoutParens = withoutParens.type; } - return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 142 /* UndefinedKeyword */; }) + return ts.isUnionTypeNode(withoutParens) && ts.find(withoutParens.types, function (t) { return t.kind === 145 /* UndefinedKeyword */; }) ? clone - : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(142 /* UndefinedKeyword */)]); + : ts.createUnionTypeNode([clone, ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); } } /** @@ -122506,6 +127694,7 @@ var ts; * Stores either a list of changes that should be applied to extract a range or a list of errors */ function extractConstantInScope(node, scope, _a, rangeFacts, context) { + var _b; var substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted variable @@ -122516,16 +127705,17 @@ var ts; ? undefined : checker.typeToTypeNode(checker.getContextualType(node), scope, 1 /* NoTruncation */); // TODO: GH#18217 var initializer = transformConstantInitializer(node, substitutions); + (_b = transformFunctionInitializerAndType(variableType, initializer), variableType = _b.variableType, initializer = _b.initializer); ts.suppressLeadingAndTrailingTrivia(initializer); var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); if (ts.isClassLike(scope)) { - ts.Debug.assert(!isJS); // See CannotExtractToJSClass + ts.Debug.assert(!isJS, "Cannot extract to a JS class"); // See CannotExtractToJSClass var modifiers = []; - modifiers.push(ts.createToken(114 /* PrivateKeyword */)); + modifiers.push(ts.createToken(116 /* PrivateKeyword */)); if (rangeFacts & RangeFacts.InStaticRegion) { - modifiers.push(ts.createToken(117 /* StaticKeyword */)); + modifiers.push(ts.createToken(119 /* StaticKeyword */)); } - modifiers.push(ts.createToken(134 /* ReadonlyKeyword */)); + modifiers.push(ts.createToken(137 /* ReadonlyKeyword */)); var newVariable = ts.createProperty( /*decorators*/ undefined, modifiers, localNameText, /*questionToken*/ undefined, variableType, initializer); @@ -122554,7 +127744,7 @@ var ts; var localReference = ts.createIdentifier(localNameText); changeTracker.replaceNode(context.file, node, localReference); } - else if (node.parent.kind === 222 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { + else if (node.parent.kind === 225 /* ExpressionStatement */ && scope === ts.findAncestor(node, isScope)) { // If the parent is an expression statement and the target scope is the immediately enclosing one, // replace the statement with the declaration. var newVariableStatement = ts.createVariableStatement( @@ -122573,7 +127763,7 @@ var ts; changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariableStatement, /*blankLineBetween*/ false); } // Consume - if (node.parent.kind === 222 /* ExpressionStatement */) { + if (node.parent.kind === 225 /* ExpressionStatement */) { // If the parent is an expression statement, delete it. changeTracker.delete(context.file, node.parent); } @@ -122587,6 +127777,63 @@ var ts; var renameFilename = node.getSourceFile().fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + function transformFunctionInitializerAndType(variableType, initializer) { + // If no contextual type exists there is nothing to transfer to the function signature + if (variableType === undefined) + return { variableType: variableType, initializer: initializer }; + // Only do this for function expressions and arrow functions that are not generic + if (!ts.isFunctionExpression(initializer) && !ts.isArrowFunction(initializer) || !!initializer.typeParameters) + return { variableType: variableType, initializer: initializer }; + var functionType = checker.getTypeAtLocation(node); + var functionSignature = ts.singleOrUndefined(checker.getSignaturesOfType(functionType, 0 /* Call */)); + // If no function signature, maybe there was an error, do nothing + if (!functionSignature) + return { variableType: variableType, initializer: initializer }; + // If the function signature has generic type parameters we don't attempt to move the parameters + if (!!functionSignature.getTypeParameters()) + return { variableType: variableType, initializer: initializer }; + // We add parameter types if needed + var parameters = []; + var hasAny = false; + for (var _i = 0, _a = initializer.parameters; _i < _a.length; _i++) { + var p = _a[_i]; + if (p.type) { + parameters.push(p); + } + else { + var paramType = checker.getTypeAtLocation(p); + if (paramType === checker.getAnyType()) + hasAny = true; + parameters.push(ts.updateParameter(p, p.decorators, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, 1 /* NoTruncation */), p.initializer)); + } + } + // If a parameter was inferred as any we skip adding function parameters at all. + // Turning an implicit any (which under common settings is a error) to an explicit + // is probably actually a worse refactor outcome. + if (hasAny) + return { variableType: variableType, initializer: initializer }; + variableType = undefined; + if (ts.isArrowFunction(initializer)) { + initializer = ts.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.equalsGreaterThanToken, initializer.body); + } + else { + if (functionSignature && !!functionSignature.thisParameter) { + var firstParameter = ts.firstOrUndefined(parameters); + // If the function signature has a this parameter and if the first defined parameter is not the this parameter, we must add it + // Note: If this parameter was already there, it would have been previously updated with the type if not type was present + if ((!firstParameter || (ts.isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { + var thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); + parameters.splice(0, 0, ts.createParameter( + /* decorators */ undefined, + /* modifiers */ undefined, + /* dotDotDotToken */ undefined, "this", + /* questionToken */ undefined, checker.typeToTypeNode(thisType, scope, 1 /* NoTruncation */))); + } + } + initializer = ts.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, 1 /* NoTruncation */), initializer.body); + } + return { variableType: variableType, initializer: initializer }; + } } function getContainingVariableDeclarationIfInList(node, scope) { var prevNode; @@ -122660,7 +127907,7 @@ var ts; return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; } function visitor(node) { - if (!ignoreReturns && node.kind === 231 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { + if (!ignoreReturns && node.kind === 234 /* ReturnStatement */ && hasWritesOrVariableDeclarations) { var assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes); if (node.expression) { if (!returnValueProperty) { @@ -122723,11 +127970,11 @@ var ts; } function getNodeToInsertPropertyBefore(maxPos, scope) { var members = scope.members; - ts.Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one. + ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one. var prevMember; var allProperties = true; - for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { - var member = members_2[_i]; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var member = members_1[_i]; if (member.pos > maxPos) { return prevMember || members[0]; } @@ -122765,11 +128012,11 @@ var ts; } if (!prevStatement && ts.isCaseClause(curr)) { // We must have been in the expression of the case clause. - ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent)); + ts.Debug.assert(ts.isSwitchStatement(curr.parent.parent), "Grandparent isn't a switch statement"); return curr.parent.parent; } // There must be at least one statement since we started in one. - return ts.Debug.assertDefined(prevStatement); + return ts.Debug.assertDefined(prevStatement, "prevStatement failed to get set"); } ts.Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope"); } @@ -122838,7 +128085,7 @@ var ts; var scope = scopes_1[_i]; usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); - functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 240 /* FunctionDeclaration */ + functionErrorsPerScope.push(ts.isFunctionLikeDeclaration(scope) && scope.kind !== 243 /* FunctionDeclaration */ ? [ts.createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)] : []); var constantErrors = []; @@ -122891,7 +128138,7 @@ var ts; // If we didn't get through all the scopes, then there were some that weren't in our // parent chain (impossible at time of writing). A conservative solution would be to // copy allTypeParameterUsages into all remaining scopes. - ts.Debug.assert(i_1 === scopes.length); + ts.Debug.assert(i_1 === scopes.length, "Should have iterated all scopes"); } // If there are any declarations in the extracted block that are used in the same enclosing // lexical scope, we can't move the extraction "up" as those declarations will become unreachable @@ -122901,7 +128148,7 @@ var ts; : ts.getEnclosingBlockScopeContainer(scopes[0]); ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - var _loop_14 = function (i) { + var _loop_16 = function (i) { var scopeUsages = usagesPerScope[i]; // Special case: in the innermost scope, all usages are available. // (The computed value reflects the value at the top-level of the scope, but the @@ -122923,7 +128170,7 @@ var ts; } }); // If an expression was extracted, then there shouldn't have been any variable declarations. - ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0); + ts.Debug.assert(isReadonlyArray(targetRange.range) || exposedVariableDeclarations.length === 0, "No variable declarations expected if something was extracted"); if (hasWrite && !isReadonlyArray(targetRange.range)) { var diag = ts.createDiagnosticForNode(targetRange.range, Messages.cannotWriteInExpression); functionErrorsPerScope[i].push(diag); @@ -122941,7 +128188,7 @@ var ts; } }; for (var i = 0; i < scopes.length; i++) { - _loop_14(i); + _loop_16(i); } return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations }; function isInGenericContext(node) { @@ -123154,30 +128401,30 @@ var ts; function isExtractableExpression(node) { var parent = node.parent; switch (parent.kind) { - case 279 /* EnumMember */: + case 282 /* EnumMember */: return false; } switch (node.kind) { case 10 /* StringLiteral */: - return parent.kind !== 250 /* ImportDeclaration */ && - parent.kind !== 254 /* ImportSpecifier */; - case 209 /* SpreadElement */: - case 185 /* ObjectBindingPattern */: - case 187 /* BindingElement */: + return parent.kind !== 253 /* ImportDeclaration */ && + parent.kind !== 257 /* ImportSpecifier */; + case 212 /* SpreadElement */: + case 188 /* ObjectBindingPattern */: + case 190 /* BindingElement */: return false; - case 73 /* Identifier */: - return parent.kind !== 187 /* BindingElement */ && - parent.kind !== 254 /* ImportSpecifier */ && - parent.kind !== 258 /* ExportSpecifier */; + case 75 /* Identifier */: + return parent.kind !== 190 /* BindingElement */ && + parent.kind !== 257 /* ImportSpecifier */ && + parent.kind !== 261 /* ExportSpecifier */; } return true; } function isBlockLike(node) { switch (node.kind) { - case 219 /* Block */: - case 285 /* SourceFile */: - case 246 /* ModuleBlock */: - case 272 /* CaseClause */: + case 222 /* Block */: + case 288 /* SourceFile */: + case 249 /* ModuleBlock */: + case 275 /* CaseClause */: return true; default: return false; @@ -123193,6 +128440,7 @@ var ts; (function (refactor) { var refactorName = "Extract type"; var extractToTypeAlias = "Extract to type alias"; + var extractToInterface = "Extract to interface"; var extractToTypeDef = "Extract to typedef"; refactor.registerRefactor(refactorName, { getAvailableActions: function (context) { @@ -123202,22 +128450,34 @@ var ts; return [{ name: refactorName, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_type), - actions: [info.isJS ? { + actions: info.isJS ? [{ name: extractToTypeDef, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_typedef) - } : { + }] : ts.append([{ name: extractToTypeAlias, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_type_alias) - }] + }], info.typeElements && { + name: extractToInterface, description: ts.getLocaleSpecificMessage(ts.Diagnostics.Extract_to_interface) + }) }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === extractToTypeAlias || actionName === extractToTypeDef); var file = context.file; - var info = ts.Debug.assertDefined(getRangeToExtract(context)); - ts.Debug.assert(actionName === extractToTypeAlias && !info.isJS || actionName === extractToTypeDef && info.isJS); + var info = ts.Debug.assertDefined(getRangeToExtract(context), "Expected to find a range to extract"); var name = ts.getUniqueName("NewType", file); - var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { return info.isJS ? - doTypedefChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters) : - doTypeAliasChange(changes, file, name, info.firstStatement, info.selection, info.typeParameters); }); + var edits = ts.textChanges.ChangeTracker.with(context, function (changes) { + switch (actionName) { + case extractToTypeAlias: + ts.Debug.assert(!info.isJS, "Invalid actionName/JS combo"); + return doTypeAliasChange(changes, file, name, info); + case extractToTypeDef: + ts.Debug.assert(info.isJS, "Invalid actionName/JS combo"); + return doTypedefChange(changes, file, name, info); + case extractToInterface: + ts.Debug.assert(!info.isJS && !!info.typeElements, "Invalid actionName/JS combo"); + return doInterfaceChange(changes, file, name, info); + default: + ts.Debug.fail("Unexpected action name"); + } + }); var renameFilename = file.fileName; var renameLocation = ts.getRenameLocation(edits, renameFilename, name, /*preferLastLocation*/ false); return { edits: edits, renameFilename: renameFilename, renameLocation: renameLocation }; @@ -123232,14 +128492,36 @@ var ts; if (!selection || !ts.isTypeNode(selection)) return undefined; var checker = context.program.getTypeChecker(); - var firstStatement = ts.Debug.assertDefined(isJS ? ts.findAncestor(selection, isStatementAndHasJSDoc) : ts.findAncestor(selection, ts.isStatement)); + var firstStatement = ts.Debug.assertDefined(ts.findAncestor(selection, ts.isStatement), "Should find a statement"); var typeParameters = collectTypeParameters(checker, selection, firstStatement, file); if (!typeParameters) return undefined; - return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters }; + var typeElements = flattenTypeLiteralNodeReference(checker, selection); + return { isJS: isJS, selection: selection, firstStatement: firstStatement, typeParameters: typeParameters, typeElements: typeElements }; } - function isStatementAndHasJSDoc(n) { - return ts.isStatement(n) && ts.hasJSDocNodes(n); + function flattenTypeLiteralNodeReference(checker, node) { + if (!node) + return undefined; + if (ts.isIntersectionTypeNode(node)) { + var result = []; + var seen_1 = ts.createMap(); + for (var _i = 0, _a = node.types; _i < _a.length; _i++) { + var type = _a[_i]; + var flattenedTypeMembers = flattenTypeLiteralNodeReference(checker, type); + if (!flattenedTypeMembers || !flattenedTypeMembers.every(function (type) { return type.name && ts.addToSeen(seen_1, ts.getNameFromPropertyName(type.name)); })) { + return undefined; + } + ts.addRange(result, flattenedTypeMembers); + } + return result; + } + else if (ts.isParenthesizedTypeNode(node)) { + return flattenTypeLiteralNodeReference(checker, node.type); + } + else if (ts.isTypeLiteralNode(node)) { + return node.members; + } + return undefined; } function rangeContainsSkipTrivia(r1, node, file) { return ts.rangeContainsStartEnd(r1, ts.skipTrivia(file.text, node.pos), node.end); @@ -123287,15 +128569,26 @@ var ts; return ts.forEachChild(node, visitor); } } - function doTypeAliasChange(changes, file, name, firstStatement, selection, typeParameters) { + function doTypeAliasChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; var newTypeNode = ts.createTypeAliasDeclaration( /* decorators */ undefined, /* modifiers */ undefined, name, typeParameters.map(function (id) { return ts.updateTypeParameterDeclaration(id, id.name, id.constraint, /* defaultType */ undefined); }), selection); changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); } - function doTypedefChange(changes, file, name, firstStatement, selection, typeParameters) { - var node = ts.createNode(312 /* JSDocTypedefTag */); + function doInterfaceChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters, typeElements = info.typeElements; + var newTypeNode = ts.createInterfaceDeclaration( + /* decorators */ undefined, + /* modifiers */ undefined, name, typeParameters, + /* heritageClauses */ undefined, typeElements); + changes.insertNodeBefore(file, firstStatement, newTypeNode, /* blankLineBetween */ true); + changes.replaceNode(file, selection, ts.createTypeReferenceNode(name, typeParameters.map(function (id) { return ts.createTypeReferenceNode(id.name, /* typeArguments */ undefined); }))); + } + function doTypedefChange(changes, file, name, info) { + var firstStatement = info.firstStatement, selection = info.selection, typeParameters = info.typeParameters; + var node = ts.createNode(315 /* JSDocTypedefTag */); node.tagName = ts.createIdentifier("typedef"); // TODO: jsdoc factory https://github.com/Microsoft/TypeScript/pull/29539 node.fullName = ts.createIdentifier(name); node.name = node.fullName; @@ -123303,10 +128596,10 @@ var ts; var templates = []; ts.forEach(typeParameters, function (typeParameter) { var constraint = ts.getEffectiveConstraintOfTypeParameter(typeParameter); - var template = ts.createNode(311 /* JSDocTemplateTag */); + var template = ts.createNode(314 /* JSDocTemplateTag */); template.tagName = ts.createIdentifier("template"); template.constraint = constraint && ts.cast(constraint, ts.isJSDocTypeExpression); - var parameter = ts.createNode(151 /* TypeParameter */); + var parameter = ts.createNode(154 /* TypeParameter */); parameter.name = typeParameter.name; template.typeParameters = ts.createNodeArray([parameter]); templates.push(template); @@ -123356,10 +128649,10 @@ var ts; var modifierFlags = ts.getModifierFlags(declaration) & ~64 /* Readonly */; var accessorModifiers = isInClassLike ? !modifierFlags || modifierFlags & 8 /* Private */ - ? getModifiers(isJS, isStatic, 116 /* PublicKeyword */) + ? getModifiers(isJS, isStatic, 118 /* PublicKeyword */) : ts.createNodeArray(ts.createModifiersFromModifierFlags(modifierFlags)) : undefined; - var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 114 /* PrivateKeyword */) : undefined; + var fieldModifiers = isInClassLike ? getModifiers(isJS, isStatic, 116 /* PrivateKeyword */) : undefined; updateFieldDeclaration(changeTracker, file, declaration, fieldName, fieldModifiers); var getAccessor = generateGetAccessor(fieldName, accessorName, type, accessorModifiers, isStatic, container); ts.suppressLeadingAndTrailingTrivia(getAccessor); @@ -123397,7 +128690,7 @@ var ts; return ts.isIdentifier(fieldName) ? ts.createPropertyAccess(leftHead, fieldName) : ts.createElementAccess(leftHead, ts.createLiteral(fieldName)); } function getModifiers(isJS, isStatic, accessModifier) { - var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(117 /* StaticKeyword */) : undefined); + var modifiers = ts.append(!isJS ? [ts.createToken(accessModifier)] : undefined, isStatic ? ts.createToken(119 /* StaticKeyword */) : undefined); return modifiers && ts.createNodeArray(modifiers); } function startsWithUnderscore(name) { @@ -123420,7 +128713,7 @@ var ts; isStatic: ts.hasStaticModifier(declaration), isReadonly: ts.hasReadonlyModifier(declaration), type: ts.getTypeAnnotationNode(declaration), - container: declaration.kind === 152 /* Parameter */ ? declaration.parent.parent : declaration.parent, + container: declaration.kind === 155 /* Parameter */ ? declaration.parent.parent : declaration.parent, originalName: declaration.name.text, declaration: declaration, fieldName: fieldName, @@ -123466,24 +128759,22 @@ var ts; } } function insertAccessor(changeTracker, file, accessor, declaration, container) { - ts.isParameterPropertyDeclaration(declaration, declaration.parent) - ? changeTracker.insertNodeAtClassStart(file, container, accessor) - : ts.isPropertyAssignment(declaration) - ? changeTracker.insertNodeAfterComma(file, declaration, accessor) - : changeTracker.insertNodeAfter(file, declaration, accessor); + ts.isParameterPropertyDeclaration(declaration, declaration.parent) ? changeTracker.insertNodeAtClassStart(file, container, accessor) : + ts.isPropertyAssignment(declaration) ? changeTracker.insertNodeAfterComma(file, declaration, accessor) : + changeTracker.insertNodeAfter(file, declaration, accessor); } function updateReadonlyPropertyInitializerStatementConstructor(changeTracker, file, constructor, fieldName, originalName) { if (!constructor.body) return; constructor.body.forEachChild(function recur(node) { if (ts.isElementAccessExpression(node) && - node.expression.kind === 101 /* ThisKeyword */ && + node.expression.kind === 103 /* ThisKeyword */ && ts.isStringLiteral(node.argumentExpression) && node.argumentExpression.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.argumentExpression, ts.createStringLiteral(fieldName)); } - if (ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { + if (ts.isPropertyAccessExpression(node) && node.expression.kind === 103 /* ThisKeyword */ && node.name.text === originalName && ts.isWriteAccess(node)) { changeTracker.replaceNode(file, node.name, ts.createIdentifier(fieldName)); } if (!ts.isFunctionLike(node) && !ts.isClassLike(node)) { @@ -123508,7 +128799,7 @@ var ts; return [{ name: refactorName, description: description, actions: [{ name: refactorName, description: description }] }]; }, getEditsForAction: function (context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Wrong refactor invoked"); var statements = ts.Debug.assertDefined(getStatementsToMove(context)); var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, statements, t, context.host, context.preferences); }); return { edits: edits, renameFilename: undefined, renameLocation: undefined }; @@ -123565,11 +128856,11 @@ var ts; } function isPureImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return true; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return !ts.hasModifier(node, 1 /* Export */); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return node.declarationList.declarations.every(function (d) { return !!d.initializer && ts.isRequireCall(d.initializer, /*checkArgumentIsStringLiteralLike*/ true); }); default: return false; @@ -123622,10 +128913,10 @@ var ts; } function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) { var checker = program.getTypeChecker(); - var _loop_15 = function (sourceFile) { + var _loop_17 = function (sourceFile) { if (sourceFile === oldFile) return "continue"; - var _loop_16 = function (statement) { + var _loop_18 = function (statement) { forEachImportInStatement(statement, function (importNode) { if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol) return; @@ -123647,25 +128938,25 @@ var ts; }; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - _loop_16(statement); + _loop_18(statement); } }; for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { var sourceFile = _a[_i]; - _loop_15(sourceFile); + _loop_17(sourceFile); } } function getNamespaceLikeImport(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 252 /* NamespaceImport */ ? + case 253 /* ImportDeclaration */: + return node.importClause && node.importClause.namedBindings && node.importClause.namedBindings.kind === 255 /* NamespaceImport */ ? node.importClause.namedBindings.name : undefined; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node.name; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.tryCast(node.name, ts.isIdentifier); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function updateNamespaceLikeImport(changes, sourceFile, checker, movedSymbols, newModuleName, newModuleSpecifier, oldImportId, oldImportNode) { @@ -123693,20 +128984,20 @@ var ts; var newNamespaceId = ts.createIdentifier(newNamespaceName); var newModuleString = ts.createLiteral(newModuleSpecifier); switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(newNamespaceId)), newModuleString); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, newNamespaceId, ts.createExternalModuleReference(newModuleString)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.createVariableDeclaration(newNamespaceId, /*type*/ undefined, createRequireCall(newModuleString)); default: - return ts.Debug.assertNever(node); + return ts.Debug.assertNever(node, "Unexpected node kind " + node.kind); } } function moduleSpecifierFromImport(i) { - return (i.kind === 250 /* ImportDeclaration */ ? i.moduleSpecifier - : i.kind === 249 /* ImportEqualsDeclaration */ ? i.moduleReference.expression + return (i.kind === 253 /* ImportDeclaration */ ? i.moduleSpecifier + : i.kind === 252 /* ImportEqualsDeclaration */ ? i.moduleReference.expression : i.initializer.arguments[0]); } function forEachImportInStatement(statement, cb) { @@ -123748,7 +129039,7 @@ var ts; return ts.makeImportIfNecessary(defaultImport, specifiers, path, quotePreference); } else { - ts.Debug.assert(!defaultImport); // If there's a default export, it should have been an es6 module. + ts.Debug.assert(!defaultImport, "No default import should exist"); // If there's a default export, it should have been an es6 module. var bindingElements = imports.map(function (i) { return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, i); }); return bindingElements.length ? makeVariableStatement(ts.createObjectBindingPattern(bindingElements), /*type*/ undefined, createRequireCall(ts.createLiteral(path))) @@ -123776,19 +129067,19 @@ var ts; } function deleteUnusedImports(sourceFile, importDecl, changes, isUnused) { switch (importDecl.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (isUnused(importDecl.name)) { changes.delete(sourceFile, importDecl); } break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: deleteUnusedImportsInVariableDeclaration(sourceFile, importDecl, changes, isUnused); break; default: - ts.Debug.assertNever(importDecl); + ts.Debug.assertNever(importDecl, "Unexpected import decl kind " + importDecl.kind); } } function deleteUnusedImportsInDeclaration(sourceFile, importDecl, changes, isUnused) { @@ -123797,7 +129088,7 @@ var ts; var _a = importDecl.importClause, name = _a.name, namedBindings = _a.namedBindings; var defaultUnused = !name || isUnused(name); var namedBindingsUnused = !namedBindings || - (namedBindings.kind === 252 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); + (namedBindings.kind === 255 /* NamespaceImport */ ? isUnused(namedBindings.name) : namedBindings.elements.length !== 0 && namedBindings.elements.every(function (e) { return isUnused(e.name); })); if (defaultUnused && namedBindingsUnused) { changes.delete(sourceFile, importDecl); } @@ -123809,7 +129100,7 @@ var ts; if (namedBindingsUnused) { changes.replaceNode(sourceFile, importDecl.importClause, ts.updateImportClause(importDecl.importClause, name, /*namedBindings*/ undefined)); } - else if (namedBindings.kind === 253 /* NamedImports */) { + else if (namedBindings.kind === 256 /* NamedImports */) { for (var _i = 0, _b = namedBindings.elements; _i < _b.length; _i++) { var element = _b[_i]; if (isUnused(element.name)) @@ -123822,14 +129113,14 @@ var ts; function deleteUnusedImportsInVariableDeclaration(sourceFile, varDecl, changes, isUnused) { var name = varDecl.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: if (isUnused(name)) { changes.delete(sourceFile, name); } break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: if (name.elements.every(function (e) { return ts.isIdentifier(e.name) && isUnused(e.name); })) { changes.delete(sourceFile, ts.isVariableDeclarationList(varDecl.parent) && varDecl.parent.declarations.length === 1 ? varDecl.parent.parent : varDecl); } @@ -123903,7 +129194,7 @@ var ts; for (var _i = 0, toMove_1 = toMove; _i < toMove_1.length; _i++) { var statement = toMove_1[_i]; forEachTopLevelDeclaration(statement, function (decl) { - movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol)); + movedSymbols.add(ts.Debug.assertDefined(ts.isExpressionStatement(decl) ? checker.getSymbolAtLocation(decl.expression.left) : decl.symbol, "Need a symbol here")); }); } for (var _a = 0, toMove_2 = toMove; _a < toMove_2.length; _a++) { @@ -123956,13 +129247,13 @@ var ts; // Below should all be utilities function isInImport(decl) { switch (decl.kind) { - case 249 /* ImportEqualsDeclaration */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: + case 252 /* ImportEqualsDeclaration */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: return true; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.isVariableDeclaration(decl.parent.parent) && isVariableDeclarationInImport(decl.parent.parent); default: return false; @@ -123974,7 +129265,7 @@ var ts; } function filterImport(i, moduleSpecifier, keep) { switch (i.kind) { - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { var clause = i.importClause; if (!clause) return undefined; @@ -123984,18 +129275,18 @@ var ts; ? ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(defaultImport, namedBindings), moduleSpecifier) : undefined; } - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return keep(i.name) ? i : undefined; - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { var name = filterBindingName(i.name, keep); return name ? makeVariableStatement(name, i.type, createRequireCall(moduleSpecifier), i.parent.flags) : undefined; } default: - return ts.Debug.assertNever(i); + return ts.Debug.assertNever(i, "Unexpected import kind " + i.kind); } } function filterNamedBindings(namedBindings, keep) { - if (namedBindings.kind === 252 /* NamespaceImport */) { + if (namedBindings.kind === 255 /* NamespaceImport */) { return keep(namedBindings.name) ? namedBindings : undefined; } else { @@ -124005,11 +129296,11 @@ var ts; } function filterBindingName(name, keep) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return keep(name) ? name : undefined; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return name; - case 185 /* ObjectBindingPattern */: { + case 188 /* ObjectBindingPattern */: { // We can't handle nested destructurings or property names well here, so just copy them all. var newElements = name.elements.filter(function (prop) { return prop.propertyName || !ts.isIdentifier(prop.name) || keep(prop.name); }); return newElements.length ? ts.createObjectBindingPattern(newElements) : undefined; @@ -124061,18 +129352,18 @@ var ts; return ts.isVariableDeclaration(node) ? node.parent.parent.parent : node.parent; } function isTopLevelDeclarationStatement(node) { - ts.Debug.assert(ts.isSourceFile(node.parent)); + ts.Debug.assert(ts.isSourceFile(node.parent), "Node parent should be a SourceFile"); return isNonVariableTopLevelDeclaration(node) || ts.isVariableStatement(node); } function isNonVariableTopLevelDeclaration(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -124080,17 +129371,17 @@ var ts; } function forEachTopLevelDeclaration(statement, cb) { switch (statement.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return cb(statement); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.firstDefined(statement.declarationList.declarations, function (decl) { return forEachTopLevelDeclarationInBindingName(decl.name, cb); }); - case 222 /* ExpressionStatement */: { + case 225 /* ExpressionStatement */: { var expression = statement.expression; return ts.isBinaryExpression(expression) && ts.getAssignmentDeclarationKind(expression) === 1 /* ExportsProperty */ ? cb(statement) @@ -124100,13 +129391,13 @@ var ts; } function forEachTopLevelDeclarationInBindingName(name, cb) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cb(ts.cast(name.parent, function (x) { return ts.isVariableDeclaration(x) || ts.isBindingElement(x); })); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.firstDefined(name.elements, function (em) { return ts.isOmittedExpression(em) ? undefined : forEachTopLevelDeclarationInBindingName(em.name, cb); }); default: - return ts.Debug.assertNever(name); + return ts.Debug.assertNever(name, "Unexpected name kind " + name.kind); } } function nameOfTopLevelDeclaration(d) { @@ -124114,9 +129405,9 @@ var ts; } function getTopLevelDeclarationStatement(d) { switch (d.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return d.parent.parent; - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getTopLevelDeclarationStatement(ts.cast(d.parent.parent, function (p) { return ts.isVariableDeclaration(p) || ts.isBindingElement(p); })); default: return d; @@ -124147,28 +129438,28 @@ var ts; return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d) { - var modifiers = ts.concatenate([ts.createModifier(86 /* ExportKeyword */)], d.modifiers); + var modifiers = ts.concatenate([ts.createModifier(88 /* ExportKeyword */)], d.modifiers); switch (d.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(d, modifiers, d.declarationList); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.name, d.moduleReference); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(d); + return ts.Debug.assertNever(d, "Unexpected declaration kind " + d.kind); } } function addCommonjsExport(decl) { @@ -124176,26 +129467,26 @@ var ts; } function getNamesToExportInCommonJS(decl) { switch (decl.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: return [decl.name.text]; // TODO: GH#18217 - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.mapDefined(decl.declarationList.declarations, function (d) { return ts.isIdentifier(d.name) ? d.name.text : undefined; }); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.emptyArray; - case 222 /* ExpressionStatement */: - return ts.Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` + case 225 /* ExpressionStatement */: + return ts.Debug.fail("Can't export an ExpressionStatement"); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: - return ts.Debug.assertNever(decl); + return ts.Debug.assertNever(decl, "Unexpected decl kind " + decl.kind); } } /** Creates `exports.x = x;` */ function createExportAssignment(name) { - return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 60 /* EqualsToken */, ts.createIdentifier(name))); + return ts.createExpressionStatement(ts.createBinary(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.createIdentifier(name)), 62 /* EqualsToken */, ts.createIdentifier(name))); } })(refactor = ts.refactor || (ts.refactor = {})); })(ts || (ts = {})); @@ -124318,7 +129609,7 @@ var ts; }]; } function getEditsForAction(context, actionName) { - ts.Debug.assert(actionName === refactorName); + ts.Debug.assert(actionName === refactorName, "Unexpected action name"); var file = context.file, startPosition = context.startPosition, program = context.program, cancellationToken = context.cancellationToken, host = context.host; var functionDeclaration = getFunctionDeclarationAtPosition(file, startPosition, program.getTypeChecker()); if (!functionDeclaration || !cancellationToken) @@ -124457,15 +129748,15 @@ var ts; var parent = functionReference.parent; switch (parent.kind) { // foo(...) or super(...) or new Foo(...) - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: var callOrNewExpression = ts.tryCast(parent, ts.isCallOrNewExpression); if (callOrNewExpression && callOrNewExpression.expression === functionReference) { return callOrNewExpression; } break; // x.foo(...) - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.parent && propertyAccessExpression.name === functionReference) { var callOrNewExpression_1 = ts.tryCast(propertyAccessExpression.parent, ts.isCallOrNewExpression); @@ -124475,7 +129766,7 @@ var ts; } break; // x["foo"](...) - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.parent && elementAccessExpression.argumentExpression === functionReference) { var callOrNewExpression_2 = ts.tryCast(elementAccessExpression.parent, ts.isCallOrNewExpression); @@ -124494,14 +129785,14 @@ var ts; var parent = reference.parent; switch (parent.kind) { // `C.foo` - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: var propertyAccessExpression = ts.tryCast(parent, ts.isPropertyAccessExpression); if (propertyAccessExpression && propertyAccessExpression.expression === reference) { return propertyAccessExpression; } break; // `C["foo"]` - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var elementAccessExpression = ts.tryCast(parent, ts.isElementAccessExpression); if (elementAccessExpression && elementAccessExpression.expression === reference) { return elementAccessExpression; @@ -124543,11 +129834,11 @@ var ts; if (!isValidParameterNodeArray(functionDeclaration.parameters, checker)) return false; switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return hasNameOrDefault(functionDeclaration) && isSingleImplementation(functionDeclaration, checker); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return isSingleImplementation(functionDeclaration, checker); - case 158 /* Constructor */: + case 161 /* Constructor */: if (ts.isClassDeclaration(functionDeclaration.parent)) { return hasNameOrDefault(functionDeclaration.parent) && isSingleImplementation(functionDeclaration, checker); } @@ -124555,8 +129846,8 @@ var ts; return isValidVariableDeclaration(functionDeclaration.parent.parent) && isSingleImplementation(functionDeclaration, checker); } - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return isValidVariableDeclaration(functionDeclaration.parent); } return false; @@ -124566,7 +129857,7 @@ var ts; } function hasNameOrDefault(functionOrClassDeclaration) { if (!functionOrClassDeclaration.name) { - var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 81 /* DefaultKeyword */); + var defaultKeyword = ts.findModifier(functionOrClassDeclaration, 83 /* DefaultKeyword */); return !!defaultKeyword; } return true; @@ -124681,7 +129972,7 @@ var ts; parameterType = getTypeNode(parameterDeclaration); } var propertySignature = ts.createPropertySignature( - /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(56 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, + /*modifiers*/ undefined, getParameterName(parameterDeclaration), isOptionalParameter(parameterDeclaration) ? ts.createToken(57 /* QuestionToken */) : parameterDeclaration.questionToken, parameterType, /*initializer*/ undefined); ts.suppressLeadingAndTrailingTrivia(propertySignature); copyComments(parameterDeclaration.name, propertySignature.name); @@ -124727,15 +130018,15 @@ var ts; } function getClassNames(constructorDeclaration) { switch (constructorDeclaration.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = constructorDeclaration.parent; if (classDeclaration.name) return [classDeclaration.name]; // If the class declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 81 /* DefaultKeyword */), "Nameless class declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(classDeclaration, 83 /* DefaultKeyword */), "Nameless class declaration should be a default export"); return [defaultModifier]; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var classExpression = constructorDeclaration.parent; var variableDeclaration = constructorDeclaration.parent.parent; var className = classExpression.name; @@ -124746,30 +130037,30 @@ var ts; } function getFunctionNames(functionDeclaration) { switch (functionDeclaration.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (functionDeclaration.name) return [functionDeclaration.name]; // If the function declaration doesn't have a name, it should have a default modifier. // We validated this in `isValidFunctionDeclaration` through `hasNameOrDefault` - var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 81 /* DefaultKeyword */), "Nameless function declaration should be a default export"); + var defaultModifier = ts.Debug.assertDefined(ts.findModifier(functionDeclaration, 83 /* DefaultKeyword */), "Nameless function declaration should be a default export"); return [defaultModifier]; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return [functionDeclaration.name]; - case 158 /* Constructor */: - var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 125 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); - if (functionDeclaration.parent.kind === 210 /* ClassExpression */) { + case 161 /* Constructor */: + var ctrKeyword = ts.Debug.assertDefined(ts.findChildOfKind(functionDeclaration, 128 /* ConstructorKeyword */, functionDeclaration.getSourceFile()), "Constructor declaration should have constructor keyword"); + if (functionDeclaration.parent.kind === 213 /* ClassExpression */) { var variableDeclaration = functionDeclaration.parent.parent; return [variableDeclaration.name, ctrKeyword]; } return [ctrKeyword]; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return [functionDeclaration.parent.name]; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (functionDeclaration.name) return [functionDeclaration.name, functionDeclaration.parent.name]; return [functionDeclaration.parent.name]; default: - return ts.Debug.assertNever(functionDeclaration); + return ts.Debug.assertNever(functionDeclaration, "Unexpected function declaration kind " + functionDeclaration.kind); } } })(convertParamsToDestructuredObject = refactor.convertParamsToDestructuredObject || (refactor.convertParamsToDestructuredObject = {})); @@ -124781,10 +130072,10 @@ var ts; ts.servicesVersion = "0.8"; function createNode(kind, pos, end, parent) { var node = ts.isNodeKind(kind) ? new NodeObject(kind, pos, end) : - kind === 73 /* Identifier */ ? new IdentifierObject(73 /* Identifier */, pos, end) : + kind === 75 /* Identifier */ ? new IdentifierObject(75 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; - node.flags = parent.flags & 12679168 /* ContextFlags */; + node.flags = parent.flags & 25358336 /* ContextFlags */; return node; } var NodeObject = /** @class */ (function () { @@ -124798,7 +130089,7 @@ var ts; this.kind = kind; } NodeObject.prototype.assertHasRealPosition = function (message) { - // tslint:disable-next-line:debug-assert + // eslint-disable-next-line debug-assert ts.Debug.assert(!ts.positionIsSynthesized(this.pos) && !ts.positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); }; NodeObject.prototype.getSourceFile = function () { @@ -124855,8 +130146,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 289 /* FirstJSDocNode */ || kid.kind > 313 /* LastJSDocNode */; }); - return child.kind < 149 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 292 /* FirstJSDocNode */ || kid.kind > 316 /* LastJSDocNode */; }); + return child.kind < 152 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -124867,7 +130158,7 @@ var ts; if (!child) { return undefined; } - return child.kind < 149 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 152 /* FirstNode */ ? child : child.getLastToken(sourceFile); }; NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { return ts.forEachChild(this, cbNode, cbNodeArray); @@ -124913,7 +130204,7 @@ var ts; var token = ts.scanner.scan(); var textPos = ts.scanner.getTextPos(); if (textPos <= end) { - if (token === 73 /* Identifier */) { + if (token === 75 /* Identifier */) { ts.Debug.fail("Did not expect " + ts.Debug.formatSyntaxKind(parent.kind) + " to have an Identifier in its trivia"); } nodes.push(createNode(token, pos, textPos, parent)); @@ -124925,7 +130216,7 @@ var ts; } } function createSyntaxList(nodes, parent) { - var list = createNode(314 /* SyntaxList */, nodes.pos, nodes.end, parent); + var list = createNode(317 /* SyntaxList */, nodes.pos, nodes.end, parent); list._children = []; var pos = nodes.pos; for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { @@ -125048,7 +130339,9 @@ var ts; var IdentifierObject = /** @class */ (function (_super) { __extends(IdentifierObject, _super); function IdentifierObject(_kind, pos, end) { - return _super.call(this, pos, end) || this; + var _this = _super.call(this, pos, end) || this; + _this.kind = 75 /* Identifier */; + return _this; } Object.defineProperty(IdentifierObject.prototype, "text", { get: function () { @@ -125059,7 +130352,7 @@ var ts; }); return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 73 /* Identifier */; + IdentifierObject.prototype.kind = 75 /* Identifier */; var TypeObject = /** @class */ (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -125095,9 +130388,15 @@ var ts; TypeObject.prototype.getBaseTypes = function () { return this.isClassOrInterface() ? this.checker.getBaseTypes(this) : undefined; }; + TypeObject.prototype.isNullableType = function () { + return this.checker.isNullableType(this); + }; TypeObject.prototype.getNonNullableType = function () { return this.checker.getNonNullableType(this); }; + TypeObject.prototype.getNonOptionalType = function () { + return this.checker.getNonOptionalType(this); + }; TypeObject.prototype.getConstraint = function () { return this.checker.getBaseConstraintOfType(this); }; @@ -125131,11 +130430,25 @@ var ts; TypeObject.prototype.isClass = function () { return !!(ts.getObjectFlags(this) & 1 /* Class */); }; + Object.defineProperty(TypeObject.prototype, "typeArguments", { + /** + * This polyfills `referenceType.typeArguments` for API consumers + */ + get: function () { + if (ts.getObjectFlags(this) & 4 /* Reference */) { + return this.checker.getTypeArguments(this); + } + return undefined; + }, + enumerable: true, + configurable: true + }); return TypeObject; }()); var SignatureObject = /** @class */ (function () { - function SignatureObject(checker) { + function SignatureObject(checker, flags) { this.checker = checker; + this.flags = flags; } SignatureObject.prototype.getDeclaration = function () { return this.declaration; @@ -125173,13 +130486,12 @@ var ts; return ts.emptyArray; var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations); if (doc.length === 0 || declarations.some(hasJSDocInheritDocTag)) { - for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { - var declaration = declarations_4[_i]; + ts.forEachUnique(declarations, function (declaration) { var inheritedDocs = findInheritedJSDocComments(declaration, declaration.symbol.name, checker); // TODO: GH#18217 // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs if (inheritedDocs) doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc); - } + }); } return doc; } @@ -125202,7 +130514,9 @@ var ts; var SourceFileObject = /** @class */ (function (_super) { __extends(SourceFileObject, _super); function SourceFileObject(kind, pos, end) { - return _super.call(this, kind, pos, end) || this; + var _this = _super.call(this, kind, pos, end) || this; + _this.kind = 288 /* SourceFile */; + return _this; } SourceFileObject.prototype.update = function (newText, textChangeRange) { return ts.updateSourceFile(this, newText, textChangeRange); @@ -125260,10 +130574,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -125283,31 +130597,31 @@ var ts; } ts.forEachChild(node, visit); break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 258 /* ExportSpecifier */: - case 254 /* ImportSpecifier */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 169 /* TypeLiteral */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 261 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 172 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } // falls through - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: { + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -125318,19 +130632,19 @@ var ts; } } // falls through - case 279 /* EnumMember */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 282 /* EnumMember */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: addDeclaration(node); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // Handle named exports case e.g.: // export {a, b as B} from "mod"; if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -125342,7 +130656,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -125351,7 +130665,7 @@ var ts; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) !== 0 /* None */) { addDeclaration(node); } @@ -125548,7 +130862,7 @@ var ts; return sourceFile; } ts.createLanguageServiceSourceFile = createLanguageServiceSourceFile; - ts.disableIncrementalParsing = false; + ts.disableIncrementalParsing = false; // eslint-disable-line prefer-const function updateLanguageServiceSourceFile(sourceFile, scriptSnapshot, version, textChangeRange, aggressiveChecks) { // If we were given a text change range, and our version or open-ness changed, then // incrementally parse this file. @@ -125668,10 +130982,10 @@ var ts; useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; }, getCurrentDirectory: function () { return currentDirectory; }, getProgram: getProgram, - fileExists: host.fileExists && (function (f) { return host.fileExists(f); }), - readFile: host.readFile && (function (f, encoding) { return host.readFile(f, encoding); }), - getDocumentPositionMapper: host.getDocumentPositionMapper && (function (generatedFileName, sourceFileName) { return host.getDocumentPositionMapper(generatedFileName, sourceFileName); }), - getSourceFileLike: host.getSourceFileLike && (function (f) { return host.getSourceFileLike(f); }), + fileExists: ts.maybeBind(host, host.fileExists), + readFile: ts.maybeBind(host, host.readFile), + getDocumentPositionMapper: ts.maybeBind(host, host.getDocumentPositionMapper), + getSourceFileLike: ts.maybeBind(host, host.getSourceFileLike), log: log }); function getValidSourceFile(fileName) { @@ -125767,6 +131081,12 @@ var ts; return host.resolveTypeReferenceDirectives.apply(host, args); }; } + if (host.setResolvedProjectReferenceCallbacks) { + compilerHost.setResolvedProjectReferenceCallbacks = function (callbacks) { return host.setResolvedProjectReferenceCallbacks(callbacks); }; + } + if (host.useSourceOfProjectReferenceRedirect) { + compilerHost.useSourceOfProjectReferenceRedirect = function () { return host.useSourceOfProjectReferenceRedirect(); }; + } var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); var options = { rootNames: rootFileNames, @@ -125927,7 +131247,7 @@ var ts; } function getCompletionEntrySymbol(fileName, position, name, source) { synchronizeHostData(); - return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }); + return ts.Completions.getCompletionEntrySymbol(program, log, getValidSourceFile(fileName), position, { name: name, source: source }, host); } function getQuickInfoAtPosition(fileName, position) { synchronizeHostData(); @@ -125971,15 +131291,15 @@ var ts; } function shouldGetType(sourceFile, node, position) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return !ts.isLabelName(node) && !ts.isTagName(node); - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: // Don't return quickInfo if inside the comment in `a/**/.b` return !ts.isInComment(sourceFile, position); - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 99 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 101 /* SuperKeyword */: return true; default: return false; @@ -126052,12 +131372,11 @@ var ts; var sourceFiles = fileName ? [getValidSourceFile(fileName)] : program.getSourceFiles(); return ts.NavigateTo.getNavigateToItems(sourceFiles, program.getTypeChecker(), cancellationToken, searchValue, maxResultCount, excludeDtsFiles); } - function getEmitOutput(fileName, emitOnlyDtsFiles) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function getEmitOutput(fileName, emitOnlyDtsFiles, forceDtsEmit) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); - return ts.getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers); + return ts.getFileEmitOutput(program, sourceFile, !!emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit); } // Signature help /** @@ -126081,16 +131400,16 @@ var ts; return undefined; } switch (node.kind) { - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: case 10 /* StringLiteral */: - case 88 /* FalseKeyword */: - case 103 /* TrueKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 101 /* ThisKeyword */: - case 179 /* ThisType */: - case 73 /* Identifier */: + case 90 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 103 /* ThisKeyword */: + case 182 /* ThisType */: + case 75 /* Identifier */: break; // Cant create the text span default: @@ -126106,7 +131425,7 @@ var ts; // If this is name of a module declarations, check if this is right side of dotted module name // If parent of the module declaration which is parent of this node is module declaration and its body is the module declaration that this node is name of // Then this name is name from dotted module - if (nodeForStartPos.parent.parent.kind === 245 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 248 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -126171,7 +131490,7 @@ var ts; _a[18 /* OpenBraceToken */] = 19 /* CloseBraceToken */, _a[20 /* OpenParenToken */] = 21 /* CloseParenToken */, _a[22 /* OpenBracketToken */] = 23 /* CloseBracketToken */, - _a[30 /* GreaterThanToken */] = 28 /* LessThanToken */, + _a[31 /* GreaterThanToken */] = 29 /* LessThanToken */, _a)); braceMatching.forEach(function (value, key) { return braceMatching.set(value.toString(), Number(key)); }); function getBraceMatchingAtPosition(fileName, position) { @@ -126295,7 +131614,7 @@ var ts; var token = ts.findPrecedingToken(position, sourceFile); if (!token) return undefined; - var element = token.kind === 30 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent + var element = token.kind === 31 /* GreaterThanToken */ && ts.isJsxOpeningElement(token.parent) ? token.parent.parent : ts.isJsxText(token) ? token.parent : undefined; if (element && isUnclosedTag(element)) { return { newText: "" }; @@ -126558,7 +131877,7 @@ var ts; */ function literalIsName(node) { return ts.isDeclarationName(node) || - node.parent.kind === 260 /* ExternalModuleReference */ || + node.parent.kind === 263 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node); } @@ -126574,14 +131893,15 @@ var ts; function getContainingObjectLiteralElementWorker(node) { switch (node.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 150 /* ComputedPropertyName */) { + if (node.parent.kind === 153 /* ComputedPropertyName */) { return ts.isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 189 /* ObjectLiteralExpression */ || node.parent.parent.kind === 269 /* JsxAttributes */) && + (node.parent.parent.kind === 192 /* ObjectLiteralExpression */ || node.parent.parent.kind === 272 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -126623,7 +131943,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 191 /* ElementAccessExpression */ && + node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** @@ -126670,7 +131990,7 @@ var ts; tokenAtLocation = preceding; } // Cannot set breakpoint in ambient declarations - if (tokenAtLocation.flags & 4194304 /* Ambient */) { + if (tokenAtLocation.flags & 8388608 /* Ambient */) { return undefined; } // Get the span in the node based on its syntax @@ -126703,114 +132023,114 @@ var ts; if (node) { var parent = node.parent; switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 238 /* VariableDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return spanInVariableDeclaration(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return spanInParameterDeclaration(node); - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return spanInBlock(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInBlock(node.block); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 224 /* DoStatement */: + case 227 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return spanInForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 236 /* TryStatement */: + case 239 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 187 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 190 /* BindingElement */: // span on complete node return textSpan(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 153 /* Decorator */: + case 156 /* Decorator */: return spanInNodeArray(parent.decorators); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return undefined; // Tokens: case 26 /* SemicolonToken */: @@ -126828,19 +132148,19 @@ var ts; return spanInOpenParenToken(node); case 21 /* CloseParenToken */: return spanInCloseParenToken(node); - case 57 /* ColonToken */: + case 58 /* ColonToken */: return spanInColonToken(node); - case 30 /* GreaterThanToken */: - case 28 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 29 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return spanInWhileKeyword(node); - case 84 /* ElseKeyword */: - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + case 86 /* ElseKeyword */: + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return spanInNextNode(node); - case 148 /* OfKeyword */: + case 151 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -126852,14 +132172,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // `a` or `...c` or `d: x` from // `[a, b, ...c]` or `{ a, b }` or `{ d: x }` from destructuring pattern - if ((node.kind === 73 /* Identifier */ || - node.kind === 209 /* SpreadElement */ || - node.kind === 276 /* PropertyAssignment */ || - node.kind === 277 /* ShorthandPropertyAssignment */) && + if ((node.kind === 75 /* Identifier */ || + node.kind === 212 /* SpreadElement */ || + node.kind === 279 /* PropertyAssignment */ || + node.kind === 280 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(parent)) { return textSpan(node); } - if (node.kind === 205 /* BinaryExpression */) { + if (node.kind === 208 /* BinaryExpression */) { var _a = node, left = _a.left, operatorToken = _a.operatorToken; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -126868,7 +132188,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(left); } - if (operatorToken.kind === 60 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { + if (operatorToken.kind === 62 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of // [a = expression, b, c] = someExpression or @@ -126881,22 +132201,22 @@ var ts; } if (ts.isExpressionNode(node)) { switch (parent.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 153 /* Decorator */: + case 156 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return textSpan(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (node.parent.operatorToken.kind === 27 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -126905,21 +132225,21 @@ var ts; } } switch (node.parent.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // If this is name of property assignment, set breakpoint in the initializer if (node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: // Breakpoint in type assertion goes to its operand if (node.parent.type === node) { return spanInNextNode(node.parent.type); } break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: { + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: { // initializer of variable/parameter declaration go to previous node var _b = node.parent, initializer = _b.initializer, type = _b.type; if (initializer === node || type === node || ts.isAssignmentOperator(node.kind)) { @@ -126927,7 +132247,7 @@ var ts; } break; } - case 205 /* BinaryExpression */: { + case 208 /* BinaryExpression */: { var left = node.parent.left; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(left) && node !== left) { // If initializer of destructuring assignment move to previous token @@ -126957,7 +132277,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 227 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 230 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } var parent = variableDeclaration.parent; @@ -126969,7 +132289,7 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - parent.parent.kind === 228 /* ForOfStatement */) { + parent.parent.kind === 231 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } if (ts.isVariableDeclarationList(variableDeclaration.parent) && @@ -127010,7 +132330,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 241 /* ClassDeclaration */ && functionDeclaration.kind !== 158 /* Constructor */); + (functionDeclaration.parent.kind === 244 /* ClassDeclaration */ && functionDeclaration.kind !== 161 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -127033,26 +132353,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - // falls through // Set on parent if on same line otherwise on first statement - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 227 /* ForInStatement */: + // falls through + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 230 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); // Set span on previous token if it starts on same line otherwise on the first statement of the block - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } // Default action is to set on first statement return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 242 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -127077,21 +132397,21 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 187 /* BindingElement */) { + if (bindingPattern.parent.kind === 190 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 186 /* ArrayBindingPattern */ && node.kind !== 185 /* ObjectBindingPattern */); - var elements = node.kind === 188 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 211 /* OmittedExpression */ ? element : undefined; }); + ts.Debug.assert(node.kind !== 189 /* ArrayBindingPattern */ && node.kind !== 188 /* ObjectBindingPattern */); + var elements = node.kind === 191 /* ArrayLiteralExpression */ ? node.elements : node.properties; + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 214 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -127099,18 +132419,18 @@ var ts; // just nested element in another destructuring assignment // set breakpoint on assignment when parent is destructuring assignment // Otherwise set breakpoint for this element - return textSpan(node.parent.kind === 205 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 208 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -127118,25 +132438,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } // falls through - case 244 /* EnumDeclaration */: - case 241 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 219 /* Block */: + case 222 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } // falls through - case 275 /* CatchClause */: + case 278 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -127144,7 +132464,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -127160,7 +132480,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: // Breakpoint in last binding element or binding pattern if it contains no elements var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); @@ -127175,12 +132495,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 224 /* DoStatement */ || // Go to while keyword and do action instead - node.parent.kind === 192 /* CallExpression */ || - node.parent.kind === 193 /* NewExpression */) { + if (node.parent.kind === 227 /* DoStatement */ || // Go to while keyword and do action instead + node.parent.kind === 195 /* CallExpression */ || + node.parent.kind === 196 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 196 /* ParenthesizedExpression */) { + if (node.parent.kind === 199 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -127189,21 +132509,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 196 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 199 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -127213,20 +132533,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ || - node.parent.kind === 152 /* Parameter */) { + node.parent.kind === 279 /* PropertyAssignment */ || + node.parent.kind === 155 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 195 /* TypeAssertionExpression */) { + if (node.parent.kind === 198 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 224 /* DoStatement */) { + if (node.parent.kind === 227 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -127234,7 +132554,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.kind === 231 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -127279,10 +132599,9 @@ var ts; // limitations under the License. // /* @internal */ -var debugObjectHost = (function () { return this; })(); +var debugObjectHost = (function () { return this; })(); // eslint-disable-line prefer-const // We need to use 'null' to interface with the managed side. -/* tslint:disable:no-null-keyword */ -/* tslint:disable:no-in-operator */ +/* eslint-disable no-in-operator */ /* @internal */ var ts; (function (ts) { @@ -127304,9 +132623,11 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + /* eslint-disable no-null/no-null */ if (encoded === null) { return null; // TODO: GH#18217 } + /* eslint-enable no-null/no-null */ var decoded = JSON.parse(encoded); // TODO: GH#18217 return ts.createTextChangeRange(ts.createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); }; @@ -127377,6 +132698,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); + // eslint-disable-next-line no-null/no-null if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } @@ -127405,6 +132727,7 @@ var ts; return this.shimHost.getScriptVersion(fileName); }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { + /* eslint-disable no-null/no-null */ var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; @@ -127416,6 +132739,7 @@ var ts; this.log(e.description || "diagnosticMessages.generated.json has invalid JSON format"); return null; } + /* eslint-enable no-null/no-null */ }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); @@ -127559,13 +132883,13 @@ var ts; LanguageServiceShimObject.prototype.dispose = function (dummy) { this.logger.log("dispose()"); this.languageService.dispose(); - this.languageService = null; + this.languageService = null; // eslint-disable-line no-null/no-null // force a GC if (debugObjectHost && debugObjectHost.CollectGarbage) { debugObjectHost.CollectGarbage(); this.logger.log("CollectGarbage()"); } - this.logger = null; + this.logger = null; // eslint-disable-line no-null/no-null _super.prototype.dispose.call(this, dummy); }; /// REFRESH @@ -127573,13 +132897,14 @@ var ts; * Update the list of scripts known to the compiler */ LanguageServiceShimObject.prototype.refresh = function (throwOnError) { - this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; }); + this.forwardJSONCall("refresh(" + throwOnError + ")", function () { return null; } // eslint-disable-line no-null/no-null + ); }; LanguageServiceShimObject.prototype.cleanupSemanticCache = function () { var _this = this; this.forwardJSONCall("cleanupSemanticCache()", function () { _this.languageService.cleanupSemanticCache(); - return null; + return null; // eslint-disable-line no-null/no-null }); }; LanguageServiceShimObject.prototype.realizeDiagnostics = function (diagnostics) { @@ -128037,8 +133362,7 @@ var ts; module.exports = ts; } })(ts || (ts = {})); -/* tslint:enable:no-in-operator */ -/* tslint:enable:no-null */ +/* eslint-enable no-in-operator */ /// TODO: this is used by VS, clean this up on both sides of the interface /* @internal */ var TypeScript; diff --git a/node_modules/typescript/lib/typingsInstaller.js b/node_modules/typescript/lib/typingsInstaller.js index d8bd3fffc..ad34e548d 100644 --- a/node_modules/typescript/lib/typingsInstaller.js +++ b/node_modules/typescript/lib/typingsInstaller.js @@ -81,9 +81,9 @@ var ts; (function (ts) { // WARNING: The script `configureNightly.ts` uses a regexp to parse out these values. // If changing the text in this section, be sure to test `configureNightly` too. - ts.versionMajorMinor = "3.6"; + ts.versionMajorMinor = "3.7"; /** The version of the TypeScript compiler release */ - ts.version = ts.versionMajorMinor + ".4"; + ts.version = ts.versionMajorMinor + ".2"; })(ts || (ts = {})); (function (ts) { /* @internal */ @@ -96,22 +96,32 @@ var ts; })(ts || (ts = {})); /* @internal */ (function (ts) { - ts.emptyArray = []; - /** Create a MapLike with good performance. */ - function createDictionaryObject() { - var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword - // Using 'delete' on an object causes V8 to put the object in dictionary mode. - // This disables creation of hidden classes, which are expensive when an object is - // constantly changing shape. - map.__ = undefined; - delete map.__; - return map; + /** + * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). + */ + function tryGetNativeMap() { + // Internet Explorer's Map doesn't support iteration, so don't use it. + // eslint-disable-next-line no-in-operator + return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined; } - /** Create a new map. If a template object is provided, the map will copy entries from it. */ + ts.tryGetNativeMap = tryGetNativeMap; +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + ts.emptyArray = []; + ts.Map = ts.tryGetNativeMap() || (function () { + // NOTE: createMapShim will be defined for typescriptServices.js but not for tsc.js, so we must test for it. + if (typeof ts.createMapShim === "function") { + return ts.createMapShim(); + } + throw new Error("TypeScript requires an environment that provides a compatible native Map implementation."); + })(); + /** Create a new map. */ function createMap() { - return new ts.MapCtr(); + return new ts.Map(); } ts.createMap = createMap; + /** Create a new map from an array of entries. */ function createMapFromEntries(entries) { var map = createMap(); for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { @@ -121,8 +131,9 @@ var ts; return map; } ts.createMapFromEntries = createMapFromEntries; + /** Create a new map from a template object is provided, the map will copy entries from it. */ function createMapFromTemplate(template) { - var map = new ts.MapCtr(); + var map = new ts.Map(); // Copies keys/values from template. Note that for..in will not throw if // template is undefined, and instead will just exit the loop. for (var key in template) { @@ -133,147 +144,6 @@ var ts; return map; } ts.createMapFromTemplate = createMapFromTemplate; - // Internet Explorer's Map doesn't support iteration, so don't use it. - // tslint:disable-next-line no-in-operator variable-name - ts.MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); - // Keep the class inside a function so it doesn't get compiled if it's not used. - function shimMap() { - var MapIterator = /** @class */ (function () { - function MapIterator(currentEntry, selector) { - this.currentEntry = currentEntry; - this.selector = selector; - } - MapIterator.prototype.next = function () { - // Navigate to the next entry. - while (this.currentEntry) { - var skipNext = !!this.currentEntry.skipNext; - this.currentEntry = this.currentEntry.nextEntry; - if (!skipNext) { - break; - } - } - if (this.currentEntry) { - return { value: this.selector(this.currentEntry.key, this.currentEntry.value), done: false }; - } - else { - return { value: undefined, done: true }; - } - }; - return MapIterator; - }()); - return /** @class */ (function () { - function class_1() { - this.data = createDictionaryObject(); - this.size = 0; - // Create a first (stub) map entry that will not contain a key - // and value but serves as starting point for iterators. - this.firstEntry = {}; - // When the map is empty, the last entry is the same as the - // first one. - this.lastEntry = this.firstEntry; - } - class_1.prototype.get = function (key) { - var entry = this.data[key]; - return entry && entry.value; - }; - class_1.prototype.set = function (key, value) { - if (!this.has(key)) { - this.size++; - // Create a new entry that will be appended at the - // end of the linked list. - var newEntry = { - key: key, - value: value - }; - this.data[key] = newEntry; - // Adjust the references. - var previousLastEntry = this.lastEntry; - previousLastEntry.nextEntry = newEntry; - newEntry.previousEntry = previousLastEntry; - this.lastEntry = newEntry; - } - else { - this.data[key].value = value; - } - return this; - }; - class_1.prototype.has = function (key) { - // tslint:disable-next-line:no-in-operator - return key in this.data; - }; - class_1.prototype.delete = function (key) { - if (this.has(key)) { - this.size--; - var entry = this.data[key]; - delete this.data[key]; - // Adjust the linked list references of the neighbor entries. - var previousEntry = entry.previousEntry; - previousEntry.nextEntry = entry.nextEntry; - if (entry.nextEntry) { - entry.nextEntry.previousEntry = previousEntry; - } - // When the deleted entry was the last one, we need to - // adjust the lastEntry reference. - if (this.lastEntry === entry) { - this.lastEntry = previousEntry; - } - // Adjust the forward reference of the deleted entry - // in case an iterator still references it. This allows us - // to throw away the entry, but when an active iterator - // (which points to the current entry) continues, it will - // navigate to the entry that originally came before the - // current one and skip it. - entry.previousEntry = undefined; - entry.nextEntry = previousEntry; - entry.skipNext = true; - return true; - } - return false; - }; - class_1.prototype.clear = function () { - this.data = createDictionaryObject(); - this.size = 0; - // Reset the linked list. Note that we must adjust the forward - // references of the deleted entries to ensure iterators stuck - // in the middle of the list don't continue with deleted entries, - // but can continue with new entries added after the clear() - // operation. - var firstEntry = this.firstEntry; - var currentEntry = firstEntry.nextEntry; - while (currentEntry) { - var nextEntry = currentEntry.nextEntry; - currentEntry.previousEntry = undefined; - currentEntry.nextEntry = firstEntry; - currentEntry.skipNext = true; - currentEntry = nextEntry; - } - firstEntry.nextEntry = undefined; - this.lastEntry = firstEntry; - }; - class_1.prototype.keys = function () { - return new MapIterator(this.firstEntry, function (key) { return key; }); - }; - class_1.prototype.values = function () { - return new MapIterator(this.firstEntry, function (_key, value) { return value; }); - }; - class_1.prototype.entries = function () { - return new MapIterator(this.firstEntry, function (key, value) { return [key, value]; }); - }; - class_1.prototype.forEach = function (action) { - var iterator = this.entries(); - while (true) { - var iterResult = iterator.next(); - if (iterResult.done) { - break; - } - var _a = iterResult.value, key = _a[0], value = _a[1]; - action(value, key); - } - }; - return class_1; - }()); - } - ts.shimMap = shimMap; function length(array) { return array ? array.length : 0; } @@ -295,6 +165,21 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ function firstDefined(array, callback) { if (array === undefined) { @@ -848,6 +733,7 @@ var ts; // equality comparison case true: // relational comparison + // falls through case 0 /* EqualTo */: continue; case -1 /* LessThan */: @@ -1388,6 +1274,12 @@ var ts; return fn ? fn.bind(obj) : undefined; } ts.maybeBind = maybeBind; + function mapMap(map, f) { + var result = createMap(); + map.forEach(function (t, key) { return result.set.apply(result, (f(t, key))); }); + return result; + } + ts.mapMap = mapMap; function createMultiMap() { var map = createMap(); map.add = multiMapAdd; @@ -1447,7 +1339,7 @@ var ts; } ts.cast = cast; /** Does nothing. */ - function noop(_) { } // tslint:disable-line no-empty + function noop(_) { } ts.noop = noop; /** Do nothing and return false */ function returnFalse() { return false; } @@ -1481,7 +1373,7 @@ var ts; } ts.memoize = memoize; function compose(a, b, c, d, e) { - if (e) { + if (!!e) { var args_2 = []; for (var i = 0; i < arguments.length; i++) { args_2[i] = arguments[i]; @@ -1833,20 +1725,6 @@ var ts; return str.indexOf(substring) !== -1; } ts.stringContains = stringContains; - function fileExtensionIs(path, extension) { - return path.length > extension.length && endsWith(path, extension); - } - ts.fileExtensionIs = fileExtensionIs; - function fileExtensionIsOneOf(path, extensions) { - for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { - var extension = extensions_1[_i]; - if (fileExtensionIs(path, extension)) { - return true; - } - } - return false; - } - ts.fileExtensionIsOneOf = fileExtensionIsOneOf; /** * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ @@ -1955,11 +1833,33 @@ var ts; return function (arg) { return f(arg) && g(arg); }; } ts.and = and; - function or(f, g) { - return function (arg) { return f(arg) || g(arg); }; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function (arg) { + for (var _i = 0, fs_1 = fs; _i < fs_1.length; _i++) { + var f = fs_1[_i]; + if (f(arg)) { + return true; + } + } + return false; + }; } ts.or = or; - function assertType(_) { } // tslint:disable-line no-empty + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } ts.assertType = assertType; function singleElementArray(t) { return t === undefined ? undefined : [t]; @@ -2036,8 +1936,10 @@ var ts; (function (ts) { var Debug; (function (Debug) { + /* eslint-disable prefer-const */ Debug.currentAssertionLevel = 0 /* None */; Debug.isDebugging = false; + /* eslint-enable prefer-const */ function shouldAssert(level) { return Debug.currentAssertionLevel >= level; } @@ -2086,6 +1988,7 @@ var ts; } Debug.fail = fail; function assertDefined(value, message) { + // eslint-disable-next-line no-null/no-null if (value === undefined || value === null) return fail(message); return value; @@ -2101,7 +2004,7 @@ var ts; Debug.assertEachDefined = assertEachDefined; function assertNever(member, message, stackCrawlMark) { if (message === void 0) { message = "Illegal value:"; } - var detail = typeof member === "object" && "kind" in member && "pos" in member && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); return fail(message + " " + detail, stackCrawlMark || assertNever); } Debug.assertNever = assertNever; @@ -2209,6 +2112,9 @@ var ts; Debug.assertNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } : ts.noop; + Debug.assertNotNode = shouldAssert(1 /* Normal */) + ? function (node, test, message) { return assert(test === undefined || !test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " should not have passed test '" + getFunctionName(test) + "'."; }, Debug.assertNode); } + : ts.noop; Debug.assertOptionalNode = shouldAssert(1 /* Normal */) ? function (node, test, message) { return assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, Debug.assertOptionalNode); } : ts.noop; @@ -2219,6 +2125,33 @@ var ts; ? function (node, message) { return assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, Debug.assertMissingNode); } : ts.noop; var isDebugInfoEnabled = false; + var extendedDebugModule; + function extendedDebug() { + enableDebugInfo(); + if (!extendedDebugModule) { + throw new Error("Debugging helpers could not be loaded."); + } + return extendedDebugModule; + } + function printControlFlowGraph(flowNode) { + return console.log(formatControlFlowGraph(flowNode)); + } + Debug.printControlFlowGraph = printControlFlowGraph; + function formatControlFlowGraph(flowNode) { + return extendedDebug().formatControlFlowGraph(flowNode); + } + Debug.formatControlFlowGraph = formatControlFlowGraph; + function attachFlowNodeDebugInfo(flowNode) { + if (isDebugInfoEnabled) { + if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line no-in-operator + Object.defineProperties(flowNode, { + __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, + __debugToString: { value: function () { return formatControlFlowGraph(this); } } + }); + } + } + } + Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo; /** * Injects debug information into frequently used types. */ @@ -2262,6 +2195,20 @@ var ts; }); } } + // attempt to load extended debugging information + try { + if (ts.sys && ts.sys.require) { + var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath())); + var result = ts.sys.require(basePath, "./compiler-debug"); + if (!result.error) { + result.module.init(ts); + extendedDebugModule = result.module; + } + } + } + catch (_a) { + // do nothing + } isDebugInfoEnabled = true; } Debug.enableDebugInfo = enableDebugInfo; @@ -2418,15 +2365,13 @@ var ts; try { // require() will throw an exception if the module is not installed // It may also return undefined if not installed properly - etwModule = require("@microsoft/typescript-etw"); // tslint:disable-line:no-implicit-dependencies + etwModule = require("@microsoft/typescript-etw"); } catch (e) { etwModule = undefined; } /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; - var args = typeof process === "undefined" ? [] : process.argv; - ts.perfLogger.logInfoEvent("Starting TypeScript v" + ts.versionMajorMinor + " with command line: " + JSON.stringify(args)); })(ts || (ts = {})); /* @internal */ var ts; @@ -2828,360 +2773,366 @@ var ts; SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 28] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 29] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 30] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 31] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 32] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 33] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 34] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 35] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 36] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 37] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 38] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 39] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 40] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 41] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 42] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 43] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 44] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 45] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 46] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 49] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 50] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 51] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 52] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 53] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 54] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 55] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 56] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 57] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 58] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ - SyntaxKind[SyntaxKind["BacktickToken"] = 59] = "BacktickToken"; + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 60] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 61] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 62] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 63] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 64] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 65] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 66] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 67] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 68] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 69] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 70] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 71] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 72] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 62] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 63] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 64] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 65] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 66] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 67] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 68] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 69] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 70] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 72] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 73] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 74] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 73] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 75] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 74] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 75] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 76] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 77] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 78] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 79] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 80] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 81] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 82] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 83] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 84] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 85] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 86] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 87] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 88] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 89] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 90] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 91] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 92] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 93] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 94] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 95] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 96] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 97] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 98] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 99] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 100] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 101] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 102] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 103] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 104] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 105] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 106] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 107] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 108] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 109] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 76] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 77] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 78] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 79] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 80] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 81] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 82] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 83] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 84] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 85] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 86] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 87] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 88] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 89] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 90] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 91] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 92] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 93] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 94] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 95] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 96] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 97] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 98] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 99] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 100] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 101] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 102] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 103] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 104] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 105] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 106] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 107] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 108] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 109] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 110] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 111] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 110] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 111] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 112] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 113] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 114] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 115] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 116] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 117] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 118] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 112] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 113] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 114] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 115] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 116] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 117] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 118] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 119] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 120] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 119] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 120] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 121] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 122] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 123] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 124] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 125] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 126] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 127] = "GetKeyword"; - SyntaxKind[SyntaxKind["InferKeyword"] = 128] = "InferKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 129] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 130] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 131] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 132] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 133] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 134] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 135] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 136] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 137] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 138] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 139] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 140] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 141] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 142] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["UniqueKeyword"] = 143] = "UniqueKeyword"; - SyntaxKind[SyntaxKind["UnknownKeyword"] = 144] = "UnknownKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 145] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 146] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["BigIntKeyword"] = 147] = "BigIntKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 148] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 121] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 122] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 123] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 124] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 125] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 126] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 127] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 128] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 129] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 130] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 131] = "InferKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 132] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 133] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 134] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 135] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 136] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 137] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 138] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 139] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 140] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 141] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 142] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 143] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 144] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 145] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 146] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 147] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 148] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 149] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 150] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 151] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 149] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 150] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 152] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 153] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 151] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 152] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 153] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 154] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 155] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 156] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 154] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 155] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 156] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 157] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 158] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 159] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 160] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 161] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 162] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 163] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 157] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 158] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 159] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 160] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 161] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 162] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 163] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 164] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 165] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 166] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 164] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 165] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 166] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 167] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 168] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 169] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 170] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 171] = "TupleType"; - SyntaxKind[SyntaxKind["OptionalType"] = 172] = "OptionalType"; - SyntaxKind[SyntaxKind["RestType"] = 173] = "RestType"; - SyntaxKind[SyntaxKind["UnionType"] = 174] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 175] = "IntersectionType"; - SyntaxKind[SyntaxKind["ConditionalType"] = 176] = "ConditionalType"; - SyntaxKind[SyntaxKind["InferType"] = 177] = "InferType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 178] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 179] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 180] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 181] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 182] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 183] = "LiteralType"; - SyntaxKind[SyntaxKind["ImportType"] = 184] = "ImportType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 167] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 168] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 169] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 170] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 171] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 172] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 173] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 174] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 175] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 176] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 177] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 178] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 179] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 180] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 181] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 182] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 183] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 184] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 185] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 186] = "LiteralType"; + SyntaxKind[SyntaxKind["ImportType"] = 187] = "ImportType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 185] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 186] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 187] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 188] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 189] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 190] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 188] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 189] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 190] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 191] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 192] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 193] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 194] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 195] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 196] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 197] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 198] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 199] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 200] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 201] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 202] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 203] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 204] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 205] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 206] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 207] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 208] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 209] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 210] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 211] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 212] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 213] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 214] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 215] = "MetaProperty"; - SyntaxKind[SyntaxKind["SyntheticExpression"] = 216] = "SyntheticExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 191] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 192] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 193] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 194] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 195] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 196] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 197] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 198] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 199] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 200] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 201] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 202] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 203] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 204] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 205] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 206] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 207] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 208] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 209] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 210] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 211] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 212] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 213] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 214] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 215] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 216] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 217] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 218] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 219] = "SyntheticExpression"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 217] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 218] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 220] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 221] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 219] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 220] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 221] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 222] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 223] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 224] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 225] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 226] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 227] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 228] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 229] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 230] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 231] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 232] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 233] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 234] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 235] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 236] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 237] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 238] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 239] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 240] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 241] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 242] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 243] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 244] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 245] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 246] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 247] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 248] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 249] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 250] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 251] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 252] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 253] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 254] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 255] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 256] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 257] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 258] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 259] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 222] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 223] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 224] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 225] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 226] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 227] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 228] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 229] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 230] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 231] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 232] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 233] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 234] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 235] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 236] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 237] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 238] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 239] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 240] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 241] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 242] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 243] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 244] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 245] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 246] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 247] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 248] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 249] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 250] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 251] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 252] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 253] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 254] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 255] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 256] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 257] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 258] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 259] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 260] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 261] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 262] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 260] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 263] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 261] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 262] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 263] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 264] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxFragment"] = 265] = "JsxFragment"; - SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 266] = "JsxOpeningFragment"; - SyntaxKind[SyntaxKind["JsxClosingFragment"] = 267] = "JsxClosingFragment"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 268] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 269] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 270] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 271] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 264] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 265] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 266] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 267] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 268] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 269] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 270] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 271] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 272] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 273] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 274] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 272] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 273] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 274] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 275] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 275] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 276] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 277] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 278] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 276] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 277] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 278] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 279] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 280] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 281] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 279] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 282] = "EnumMember"; // Unparsed - SyntaxKind[SyntaxKind["UnparsedPrologue"] = 280] = "UnparsedPrologue"; - SyntaxKind[SyntaxKind["UnparsedPrepend"] = 281] = "UnparsedPrepend"; - SyntaxKind[SyntaxKind["UnparsedText"] = 282] = "UnparsedText"; - SyntaxKind[SyntaxKind["UnparsedInternalText"] = 283] = "UnparsedInternalText"; - SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 284] = "UnparsedSyntheticReference"; + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 283] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 284] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 285] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 286] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 287] = "UnparsedSyntheticReference"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 285] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 286] = "Bundle"; - SyntaxKind[SyntaxKind["UnparsedSource"] = 287] = "UnparsedSource"; - SyntaxKind[SyntaxKind["InputFiles"] = 288] = "InputFiles"; + SyntaxKind[SyntaxKind["SourceFile"] = 288] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 289] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 290] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 291] = "InputFiles"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 289] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 292] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 290] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 293] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 291] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 292] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 293] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 294] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 295] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 296] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 294] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 295] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 296] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 297] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 298] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 299] = "JSDocVariadicType"; // https://jsdoc.app/about-namepaths.html - SyntaxKind[SyntaxKind["JSDocNamepathType"] = 297] = "JSDocNamepathType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 298] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 299] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocSignature"] = 300] = "JSDocSignature"; - SyntaxKind[SyntaxKind["JSDocTag"] = 301] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 302] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 303] = "JSDocAuthorTag"; - SyntaxKind[SyntaxKind["JSDocClassTag"] = 304] = "JSDocClassTag"; - SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 305] = "JSDocCallbackTag"; - SyntaxKind[SyntaxKind["JSDocEnumTag"] = 306] = "JSDocEnumTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 307] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 308] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocThisTag"] = 309] = "JSDocThisTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 310] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 311] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 312] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 313] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 300] = "JSDocNamepathType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 301] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 302] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 303] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocTag"] = 304] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 305] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 306] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 307] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 308] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 309] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 310] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 311] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 312] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 313] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 314] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 315] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 316] = "JSDocPropertyTag"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 314] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 317] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 315] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 316] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["CommaListExpression"] = 317] = "CommaListExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 318] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 319] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 318] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 319] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 320] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 321] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 322] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 323] = "SyntheticReferenceExpression"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 320] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 324] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 60] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 72] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 61] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 72] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 74] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 109] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 74] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 148] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 110] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 118] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 164] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 184] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 62] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 74] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 63] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 74] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 76] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 111] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 76] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 151] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 112] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 120] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 167] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 187] = "LastTypeNode"; SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 72] = "LastPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 74] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 148] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 151] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 28] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 72] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 149] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 289] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 313] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 301] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 313] = "LastJSDocTagNode"; - /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 119] = "FirstContextualKeyword"; - /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 148] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 74] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 224] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 240] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 152] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 292] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 316] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 304] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 316] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 121] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 151] = "LastContextualKeyword"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -3191,20 +3142,21 @@ var ts; NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; - NodeFlags[NodeFlags["ExportContext"] = 32] = "ExportContext"; - NodeFlags[NodeFlags["ContainsThis"] = 64] = "ContainsThis"; - NodeFlags[NodeFlags["HasImplicitReturn"] = 128] = "HasImplicitReturn"; - NodeFlags[NodeFlags["HasExplicitReturn"] = 256] = "HasExplicitReturn"; - NodeFlags[NodeFlags["GlobalAugmentation"] = 512] = "GlobalAugmentation"; - NodeFlags[NodeFlags["HasAsyncFunctions"] = 1024] = "HasAsyncFunctions"; - NodeFlags[NodeFlags["DisallowInContext"] = 2048] = "DisallowInContext"; - NodeFlags[NodeFlags["YieldContext"] = 4096] = "YieldContext"; - NodeFlags[NodeFlags["DecoratorContext"] = 8192] = "DecoratorContext"; - NodeFlags[NodeFlags["AwaitContext"] = 16384] = "AwaitContext"; - NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError"; - NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile"; - NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError"; - NodeFlags[NodeFlags["HasAggregatedChildData"] = 262144] = "HasAggregatedChildData"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 65536] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 131072] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 262144] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 524288] = "HasAggregatedChildData"; // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. @@ -3214,23 +3166,23 @@ var ts; // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport"; - /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta"; - NodeFlags[NodeFlags["JSDoc"] = 2097152] = "JSDoc"; - /* @internal */ NodeFlags[NodeFlags["Ambient"] = 4194304] = "Ambient"; - /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 8388608] = "InWithStatement"; - NodeFlags[NodeFlags["JsonFile"] = 16777216] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 1048576] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 2097152] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile"; NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; - NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 384] = "ReachabilityCheckFlags"; - NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 1408] = "ReachabilityAndEmitFlags"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; // Parsing context flags - NodeFlags[NodeFlags["ContextFlags"] = 12679168] = "ContextFlags"; + NodeFlags[NodeFlags["ContextFlags"] = 25358336] = "ContextFlags"; // Exclude these flags when parsing a Type - NodeFlags[NodeFlags["TypeExcludesFlags"] = 20480] = "TypeExcludesFlags"; + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; // Represents all flags that are potentially set once and // never cleared on SourceFiles which get re-used in between incremental parses. // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. - /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags"; + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 3145728] = "PermanentlySetIncrementalFlags"; })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); var ModifierFlags; (function (ModifierFlags) { @@ -3269,7 +3221,10 @@ var ts; (function (RelationComparisonResult) { RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; - RelationComparisonResult[RelationComparisonResult["FailedAndReported"] = 3] = "FailedAndReported"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); /*@internal*/ var GeneratedIdentifierFlags; @@ -3311,6 +3266,7 @@ var ts; /* @internal */ TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; })(TokenFlags = ts.TokenFlags || (ts.TokenFlags = {})); + // NOTE: Ensure this is up-to-date with src/debug/debug.ts var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; @@ -3322,12 +3278,13 @@ var ts; FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; - FlowFlags[FlowFlags["Referenced"] = 512] = "Referenced"; - FlowFlags[FlowFlags["Shared"] = 1024] = "Shared"; - FlowFlags[FlowFlags["PreFinally"] = 2048] = "PreFinally"; - FlowFlags[FlowFlags["AfterFinally"] = 4096] = "AfterFinally"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["Referenced"] = 1024] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 2048] = "Shared"; + FlowFlags[FlowFlags["PreFinally"] = 4096] = "PreFinally"; + FlowFlags[FlowFlags["AfterFinally"] = 8192] = "AfterFinally"; /** @internal */ - FlowFlags[FlowFlags["Cached"] = 8192] = "Cached"; + FlowFlags[FlowFlags["Cached"] = 16384] = "Cached"; FlowFlags[FlowFlags["Label"] = 12] = "Label"; FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); @@ -3337,6 +3294,13 @@ var ts; return OperationCanceledException; }()); ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var RefFileKind; + (function (RefFileKind) { + RefFileKind[RefFileKind["Import"] = 0] = "Import"; + RefFileKind[RefFileKind["ReferenceFile"] = 1] = "ReferenceFile"; + RefFileKind[RefFileKind["TypeReferenceDirective"] = 2] = "TypeReferenceDirective"; + })(RefFileKind = ts.RefFileKind || (ts.RefFileKind = {})); /* @internal */ var StructureIsReused; (function (StructureIsReused) { @@ -3357,6 +3321,10 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; // When build skipped because passed in project is invalid ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped"; + /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); /* @internal */ var UnionReduction; @@ -3365,6 +3333,14 @@ var ts; UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + /* @internal */ + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + ContextFlags[ContextFlags["Completion"] = 4] = "Completion"; + })(ContextFlags = ts.ContextFlags || (ts.ContextFlags = {})); // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! var NodeBuilderFlags; (function (NodeBuilderFlags) { @@ -3422,7 +3398,6 @@ var ts; TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; - // even though `T` can't be accessed in the current scope. // Error Handling TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; // TypeFormatFlags exclusive @@ -3472,27 +3447,40 @@ var ts; (function (TypePredicateKind) { TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; + TypePredicateKind[TypePredicateKind["AssertsThis"] = 2] = "AssertsThis"; + TypePredicateKind[TypePredicateKind["AssertsIdentifier"] = 3] = "AssertsIdentifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { + // The TypeReferenceNode could not be resolved. + // The type name should be emitted using a safe fallback. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; - // should be emitted using a safe fallback. - TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a type with a constructor // function that can be reached at runtime (e.g. a `class` // declaration or a `var` declaration for the static side // of a type, such as the global `Promise` type in lib.d.ts). + TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue"; + // The TypeReferenceNode resolves to a Void-like, Nullable, or Never type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType"; + // The TypeReferenceNode resolves to a Number-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType"; + // The TypeReferenceNode resolves to a BigInt-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType"; + // The TypeReferenceNode resolves to a String-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType"; + // The TypeReferenceNode resolves to a Boolean-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType"; + // The TypeReferenceNode resolves to an Array-like type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType"; + // The TypeReferenceNode resolves to the ESSymbol type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType"; + // The TypeReferenceNode resolved to the global Promise constructor symbol. TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise"; + // The TypeReferenceNode resolves to a Function type or a type with call signatures. TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature"; - // with call signatures. + // The TypeReferenceNode resolves to any other type. TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType"; })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {})); var SymbolFlags; @@ -3563,11 +3551,15 @@ var ts; SymbolFlags[SymbolFlags["PropertyOrAccessor"] = 98308] = "PropertyOrAccessor"; SymbolFlags[SymbolFlags["ClassMember"] = 106500] = "ClassMember"; /* @internal */ + SymbolFlags[SymbolFlags["ExportSupportsDefaultModifier"] = 112] = "ExportSupportsDefaultModifier"; + /* @internal */ + SymbolFlags[SymbolFlags["ExportDoesNotSupportDefaultModifier"] = -113] = "ExportDoesNotSupportDefaultModifier"; + /* @internal */ // The set of things we consider semantically classifiable. Used to speed up the LS during // classification. SymbolFlags[SymbolFlags["Classifiable"] = 2885600] = "Classifiable"; /* @internal */ - SymbolFlags[SymbolFlags["LateBindingContainer"] = 6240] = "LateBindingContainer"; + SymbolFlags[SymbolFlags["LateBindingContainer"] = 6256] = "LateBindingContainer"; })(SymbolFlags = ts.SymbolFlags || (ts.SymbolFlags = {})); /* @internal */ var EnumKind; @@ -3790,6 +3782,18 @@ var ts; SignatureKind[SignatureKind["Call"] = 0] = "Call"; SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; })(SignatureKind = ts.SignatureKind || (ts.SignatureKind = {})); + /* @internal */ + var SignatureFlags; + (function (SignatureFlags) { + SignatureFlags[SignatureFlags["None"] = 0] = "None"; + SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter"; + SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes"; + SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall"; + // We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us + // attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when + // instantiating the return type. + SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags"; + })(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {})); var IndexKind; (function (IndexKind) { IndexKind[IndexKind["String"] = 0] = "String"; @@ -4685,7 +4689,7 @@ var ts; /*@internal*/ ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; /*@internal*/ - ts.sysLog = ts.noop; + ts.sysLog = ts.noop; // eslint-disable-line prefer-const /** * Watch the directory recursively using host provided method to watch child directories * that means if this is recursive watcher, watch the children directories as well @@ -4790,6 +4794,32 @@ var ts; } } ts.createRecursiveDirectoryWatcher = createRecursiveDirectoryWatcher; + function recursiveCreateDirectory(directoryPath, sys) { + var basePath = ts.getDirectoryPath(directoryPath); + var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); + if (shouldCreateParent) { + recursiveCreateDirectory(basePath, sys); + } + if (shouldCreateParent || !sys.directoryExists(directoryPath)) { + sys.createDirectory(directoryPath); + } + } + /** + * patch writefile to create folder before writing the file + */ + /*@internal*/ + function patchWriteFileEnsuringDirectory(sys) { + // patch writefile to create folder before writing the file + var originalWriteFile = sys.writeFile; + sys.writeFile = function (path, data, writeBom) { + var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); + if (directoryPath && !sys.directoryExists(directoryPath)) { + recursiveCreateDirectory(directoryPath, sys); + } + originalWriteFile.call(sys, path, data, writeBom); + }; + } + ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory; function getNodeMajorVersion() { if (typeof process === "undefined") { return undefined; @@ -4806,12 +4836,14 @@ var ts; } ts.getNodeMajorVersion = getNodeMajorVersion; // TODO: GH#18217 this is used as if it's certainly defined in many places. + // eslint-disable-next-line prefer-const ts.sys = (function () { // NodeJS detects "\uFEFF" at the start of the string and *replaces* it with the actual // byte order mark from the specified encoding. Using any other byte order mark does // not actually work. var byteOrderMarkIndicator = "\uFEFF"; function getNodeSystem() { + var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/; var _fs = require("fs"); var _path = require("path"); var _os = require("os"); @@ -4823,6 +4855,8 @@ var ts; catch (_a) { _crypto = undefined; } + var activeSession; + var profilePath = "./profile.cpuprofile"; var Buffer = require("buffer").Buffer; var nodeVersion = getNodeMajorVersion(); var isNode4OrLater = nodeVersion >= 4; @@ -4904,8 +4938,10 @@ var ts; return 0; }, exit: function (exitCode) { - process.exit(exitCode); + disableCPUProfiler(function () { return process.exit(exitCode); }); }, + enableCPUProfiler: enableCPUProfiler, + disableCPUProfiler: disableCPUProfiler, realpath: realpath, debugMode: ts.some(process.execArgv, function (arg) { return /^--(inspect|debug)(-brk)?(=\d+)?$/i.test(arg); }), tryEnableSourceMapsForHost: function () { @@ -4929,8 +4965,101 @@ var ts; bufferFrom: bufferFrom, base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); }, base64encode: function (input) { return bufferFrom(input).toString("base64"); }, + require: function (baseDir, moduleName) { + try { + var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem); + return { module: require(modulePath), modulePath: modulePath, error: undefined }; + } + catch (error) { + return { module: undefined, modulePath: undefined, error: error }; + } + } }; return nodeSystem; + /** + * Uses the builtin inspector APIs to capture a CPU profile + * See https://nodejs.org/api/inspector.html#inspector_example_usage for details + */ + function enableCPUProfiler(path, cb) { + if (activeSession) { + cb(); + return false; + } + var inspector = require("inspector"); + if (!inspector || !inspector.Session) { + cb(); + return false; + } + var session = new inspector.Session(); + session.connect(); + session.post("Profiler.enable", function () { + session.post("Profiler.start", function () { + activeSession = session; + profilePath = path; + cb(); + }); + }); + return true; + } + /** + * Strips non-TS paths from the profile, so users with private projects shouldn't + * need to worry about leaking paths by submitting a cpu profile to us + */ + function cleanupPaths(profile) { + var externalFileCounter = 0; + var remappedPaths = ts.createMap(); + var normalizedDir = ts.normalizeSlashes(__dirname); + // Windows rooted dir names need an extra `/` prepended to be valid file:/// urls + var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir; + for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.callFrame.url) { + var url = ts.normalizeSlashes(node.callFrame.url); + if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) { + node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), /*isAbsolutePathAnUrl*/ true); + } + else if (!nativePattern.test(url)) { + node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url); + externalFileCounter++; + } + } + } + return profile; + } + function disableCPUProfiler(cb) { + if (activeSession && activeSession !== "stopping") { + var s_1 = activeSession; + activeSession.post("Profiler.stop", function (err, _a) { + var profile = _a.profile; + if (!err) { + try { + if (_fs.statSync(profilePath).isDirectory()) { + profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile"); + } + } + catch (_b) { + // do nothing and ignore fallible fs operation + } + try { + _fs.mkdirSync(_path.dirname(profilePath), { recursive: true }); + } + catch (_c) { + // do nothing and ignore fallible fs operation + } + _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile))); + } + activeSession = undefined; + s_1.disconnect(); + cb(); + }); + activeSession = "stopping"; + return true; + } + else { + cb(); + return false; + } + } function bufferFrom(input, encoding) { // See https://github.com/Microsoft/TypeScript/issues/25652 return Buffer.from && Buffer.from !== Int8Array.from @@ -4983,6 +5112,7 @@ var ts; if (fsSupportsRecursive) { return watchDirectoryUsingFsWatch; } + // defer watchDirectoryRecursively as it depends on `ts.createMap()` which may not be usable yet. var watchDirectory = tscWatchDirectory === "RecursiveDirectoryUsingFsWatchFile" ? createWatchDirectoryUsing(fsWatchFile) : tscWatchDirectory === "RecursiveDirectoryUsingDynamicPriorityPolling" ? @@ -5402,16 +5532,6 @@ var ts; realpath: realpath }; } - function recursiveCreateDirectory(directoryPath, sys) { - var basePath = ts.getDirectoryPath(directoryPath); - var shouldCreateParent = basePath !== "" && directoryPath !== basePath && !sys.directoryExists(basePath); - if (shouldCreateParent) { - recursiveCreateDirectory(basePath, sys); - } - if (shouldCreateParent || !sys.directoryExists(directoryPath)) { - sys.createDirectory(directoryPath); - } - } var sys; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); @@ -5423,14 +5543,7 @@ var ts; } if (sys) { // patch writefile to create folder before writing the file - var originalWriteFile_1 = sys.writeFile; - sys.writeFile = function (path, data, writeBom) { - var directoryPath = ts.getDirectoryPath(ts.normalizeSlashes(path)); - if (directoryPath && !sys.directoryExists(directoryPath)) { - recursiveCreateDirectory(directoryPath, sys); - } - originalWriteFile_1.call(sys, path, data, writeBom); - }; + patchWriteFileEnsuringDirectory(sys); } return sys; })(); @@ -5444,370 +5557,1044 @@ var ts; ts.Debug.isDebugging = true; } })(ts || (ts = {})); -// -// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' /* @internal */ var ts; (function (ts) { - function diag(code, category, key, message, reportsUnnecessary) { - return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary }; + /** + * Internally, we represent paths as strings with '/' as the directory separator. + * When we make system calls (eg: LanguageServiceHost.getDirectory()), + * we expect the host to correctly handle paths in our specified format. + */ + ts.directorySeparator = "/"; + var altDirectorySeparator = "\\"; + var urlSchemeSeparator = "://"; + var backslashRegExp = /\\/g; + //// Path Tests + /** + * Determines whether a charCode corresponds to `/` or `\`. + */ + function isAnyDirectorySeparator(charCode) { + return charCode === 47 /* slash */ || charCode === 92 /* backslash */; } - // tslint:disable-next-line variable-name - ts.Diagnostics = { - Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), - Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), - _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), - A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), - Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), - Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), - An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), - Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), - A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), - A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), - Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), - A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), - An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), - An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), - An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), - An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), - An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), - An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), - An_index_signature_parameter_type_must_be_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_string_or_number_1023", "An index signature parameter type must be 'string' or 'number'."), - readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), - Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), - _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), - _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), - _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), - super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), - Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), - Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), - A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), - Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), - _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), - _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), - _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), - _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), - _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), - A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), - Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), - A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), - A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), - A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), - A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), - A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), - A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), - A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), - Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), - Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), - An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), - The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), - A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), - The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), - Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), - Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), - An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), - The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), - In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), - Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), - Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), - _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), - _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), - A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), - Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), - Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), - _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), - _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), - Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), - Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), - Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), - An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), - A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), - An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), - _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), - Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), - Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), - Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), - with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), - delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), - A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), - A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), - A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), - Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), - A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), - Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), - Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), - A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), - Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), - A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), - A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), - An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), - An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), - An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), - An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), - Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), - Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), - Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), - Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), - Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), - Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), - Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), - Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), - case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), - Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), - Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), - Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), - Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), - Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), - Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), - Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), - Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), - Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), - String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), - Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), - or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), - Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), - Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), - Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), - File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), - new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: diag(1150, ts.DiagnosticCategory.Error, "new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead_1150", "'new T[]' cannot be used to create an array. Use 'new Array()' instead."), - const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), - const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), - let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), - Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), - Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), - An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), - A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), - Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), - A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), - A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), - extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), - extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), - Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), - implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), - Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), - Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), - Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), - Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), - Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), - Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), - A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), - An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), - Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), - Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), - A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), - A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), - Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), - The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), - The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), - An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), - Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), - An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), - Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), - Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), - Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), - An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), - Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), - Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), - Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), - Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), - Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), - All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), - Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), - A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), - Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), - Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), - Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), - Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), - Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), - Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), - Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), - An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), - _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), - Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), - Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), - Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), - Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), - A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), - A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), - A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), - An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), - An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), - An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), - An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), - A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), - The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), - The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), - Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), - Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), - Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), - Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), - abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), - _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), - Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), - Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), - An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), - A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), - A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), - A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), - Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), - _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), - A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), - A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), - A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), - A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), - Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), - Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), - Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), - with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), - await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), - can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), - The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), - Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), - Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), - Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), - A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), - An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), - A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), - Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), - Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), - Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), - Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext_1323", "Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'."), - Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), - Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), - Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), - String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), - Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), - _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), - A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), - A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), - A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), - unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), - unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), - unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), - An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), - An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), - infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), - Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), - Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), - Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), - The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), - A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), - An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), - This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), - use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), - Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), - use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), - Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), - An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), - A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), - A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), - readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), - A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), - Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), - Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), - Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), - Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), - Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), - Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), - Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), - File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), - Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), - Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), - An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), - Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), - A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), - An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), - Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), - Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), - Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), - Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), - Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), - Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), - Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), - Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), - Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), - Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), - Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), - Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), - Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), - Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), - Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), - Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), - Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), - Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), - this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), - this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), - this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), - this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), - super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), - super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), - Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), - super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: diag(2338, ts.DiagnosticCategory.Error, "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class."), - Property_0_does_not_exist_on_type_1: diag(2339, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."), - Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), - Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), - An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), - This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1_2343", "This syntax requires an imported helper named '{1}', but module '{0}' has no exported member '{1}'."), - Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), - Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), - Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), - Untyped_function_calls_may_not_accept_type_arguments: diag(2347, ts.DiagnosticCategory.Error, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."), - Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, ts.DiagnosticCategory.Error, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"), - This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."), - Only_a_void_function_can_be_called_with_the_new_keyword: diag(2350, ts.DiagnosticCategory.Error, "Only_a_void_function_can_be_called_with_the_new_keyword_2350", "Only a void function can be called with the 'new' keyword."), - This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."), - Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, ts.DiagnosticCategory.Error, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."), - Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), - This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), - A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), - An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), - The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), - The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), - The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), - The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), - The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), - The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), - The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), - Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), - Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), - This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), - Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), - A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), - A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), - A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."), - Parameter_0_cannot_be_referenced_in_its_initializer: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_be_referenced_in_its_initializer_2372", "Parameter '{0}' cannot be referenced in its initializer."), - Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it."), - Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."), - Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."), - A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties."), - Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), - A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), - Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), - get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), - A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), - Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), - Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), - Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."), - Overload_signatures_must_all_be_public_private_or_protected: diag(2385, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."), - Overload_signatures_must_all_be_optional_or_required: diag(2386, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_optional_or_required_2386", "Overload signatures must all be optional or required."), - Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."), - Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."), - Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."), - Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."), - Function_implementation_is_missing_or_not_immediately_following_the_declaration: diag(2391, ts.DiagnosticCategory.Error, "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", "Function implementation is missing or not immediately following the declaration."), - Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."), - Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."), + ts.isAnyDirectorySeparator = isAnyDirectorySeparator; + /** + * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.). + */ + function isUrl(path) { + return getEncodedRootLength(path) < 0; + } + ts.isUrl = isUrl; + /** + * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path + * like `c:`, `c:\` or `c:/`). + */ + function isRootedDiskPath(path) { + return getEncodedRootLength(path) > 0; + } + ts.isRootedDiskPath = isRootedDiskPath; + /** + * Determines whether a path consists only of a path root. + */ + function isDiskPathRoot(path) { + var rootLength = getEncodedRootLength(path); + return rootLength > 0 && rootLength === path.length; + } + ts.isDiskPathRoot = isDiskPathRoot; + /** + * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.). + * + * ```ts + * // POSIX + * pathIsAbsolute("/path/to/file.ext") === true + * // DOS + * pathIsAbsolute("c:/path/to/file.ext") === true + * // URL + * pathIsAbsolute("file:///path/to/file.ext") === true + * // Non-absolute + * pathIsAbsolute("path/to/file.ext") === false + * pathIsAbsolute("./path/to/file.ext") === false + * ``` + */ + function pathIsAbsolute(path) { + return getEncodedRootLength(path) !== 0; + } + ts.pathIsAbsolute = pathIsAbsolute; + /** + * Determines whether a path starts with a relative path component (i.e. `.` or `..`). + */ + function pathIsRelative(path) { + return /^\.\.?($|[\\/])/.test(path); + } + ts.pathIsRelative = pathIsRelative; + function hasExtension(fileName) { + return ts.stringContains(getBaseFileName(fileName), "."); + } + ts.hasExtension = hasExtension; + function fileExtensionIs(path, extension) { + return path.length > extension.length && ts.endsWith(path, extension); + } + ts.fileExtensionIs = fileExtensionIs; + function fileExtensionIsOneOf(path, extensions) { + for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { + var extension = extensions_1[_i]; + if (fileExtensionIs(path, extension)) { + return true; + } + } + return false; + } + ts.fileExtensionIsOneOf = fileExtensionIsOneOf; + /** + * Determines whether a path has a trailing separator (`/` or `\\`). + */ + function hasTrailingDirectorySeparator(path) { + return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1)); + } + ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; + //// Path Parsing + function isVolumeCharacter(charCode) { + return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || + (charCode >= 65 /* A */ && charCode <= 90 /* Z */); + } + function getFileUrlVolumeSeparatorEnd(url, start) { + var ch0 = url.charCodeAt(start); + if (ch0 === 58 /* colon */) + return start + 1; + if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { + var ch2 = url.charCodeAt(start + 2); + if (ch2 === 97 /* a */ || ch2 === 65 /* A */) + return start + 3; + } + return -1; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * If the root is part of a URL, the twos-complement of the root length is returned. + */ + function getEncodedRootLength(path) { + if (!path) + return 0; + var ch0 = path.charCodeAt(0); + // POSIX or UNC + if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { + if (path.charCodeAt(1) !== ch0) + return 1; // POSIX: "/" (or non-normalized "\") + var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); + if (p1 < 0) + return path.length; // UNC: "//server" or "\\server" + return p1 + 1; // UNC: "//server/" or "\\server\" + } + // DOS + if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { + var ch2 = path.charCodeAt(2); + if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) + return 3; // DOS: "c:/" or "c:\" + if (path.length === 2) + return 2; // DOS: "c:" (but not "c:d") + } + // URL + var schemeEnd = path.indexOf(urlSchemeSeparator); + if (schemeEnd !== -1) { + var authorityStart = schemeEnd + urlSchemeSeparator.length; + var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); + if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" + // For local "file" URLs, include the leading DOS volume (if present). + // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a + // special case interpreted as "the machine from which the URL is being interpreted". + var scheme = path.slice(0, schemeEnd); + var authority = path.slice(authorityStart, authorityEnd); + if (scheme === "file" && (authority === "" || authority === "localhost") && + isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { + var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); + if (volumeSeparatorEnd !== -1) { + if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { + // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" + return ~(volumeSeparatorEnd + 1); + } + if (volumeSeparatorEnd === path.length) { + // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" + // but not "file:///c:d" or "file:///c%3ad" + return ~volumeSeparatorEnd; + } + } + } + return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" + } + return ~path.length; // URL: "file://server", "http://server" + } + // relative + return 0; + } + /** + * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). + * + * For example: + * ```ts + * getRootLength("a") === 0 // "" + * getRootLength("/") === 1 // "/" + * getRootLength("c:") === 2 // "c:" + * getRootLength("c:d") === 0 // "" + * getRootLength("c:/") === 3 // "c:/" + * getRootLength("c:\\") === 3 // "c:\\" + * getRootLength("//server") === 7 // "//server" + * getRootLength("//server/share") === 8 // "//server/" + * getRootLength("\\\\server") === 7 // "\\\\server" + * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" + * getRootLength("file:///path") === 8 // "file:///" + * getRootLength("file:///c:") === 10 // "file:///c:" + * getRootLength("file:///c:d") === 8 // "file:///" + * getRootLength("file:///c:/path") === 11 // "file:///c:/" + * getRootLength("file://server") === 13 // "file://server" + * getRootLength("file://server/path") === 14 // "file://server/" + * getRootLength("http://server") === 13 // "http://server" + * getRootLength("http://server/path") === 14 // "http://server/" + * ``` + */ + function getRootLength(path) { + var rootLength = getEncodedRootLength(path); + return rootLength < 0 ? ~rootLength : rootLength; + } + ts.getRootLength = getRootLength; + function getDirectoryPath(path) { + path = normalizeSlashes(path); + // If the path provided is itself the root, then return it. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return path; + // return the leading portion of the path up to the last (non-terminal) directory separator + // but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); + } + ts.getDirectoryPath = getDirectoryPath; + function getBaseFileName(path, extensions, ignoreCase) { + path = normalizeSlashes(path); + // if the path provided is itself the root, then it has not file name. + var rootLength = getRootLength(path); + if (rootLength === path.length) + return ""; + // return the trailing portion of the path starting after the last (non-terminal) directory + // separator but not including any trailing directory separator. + path = removeTrailingDirectorySeparator(path); + var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); + var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; + return extension ? name.slice(0, name.length - extension.length) : name; + } + ts.getBaseFileName = getBaseFileName; + function tryGetExtensionFromPath(path, extension, stringEqualityComparer) { + if (!ts.startsWith(extension, ".")) + extension = "." + extension; + if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) { + var pathExtension = path.slice(path.length - extension.length); + if (stringEqualityComparer(pathExtension, extension)) { + return pathExtension; + } + } + } + function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { + if (typeof extensions === "string") { + return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || ""; + } + for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { + var extension = extensions_2[_i]; + var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer); + if (result) + return result; + } + return ""; + } + function getAnyExtensionFromPath(path, extensions, ignoreCase) { + // Retrieves any string from the final "." onwards from a base file name. + // Unlike extensionFromPath, which throws an exception on unrecognized extensions. + if (extensions) { + return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); + } + var baseFileName = getBaseFileName(path); + var extensionIndex = baseFileName.lastIndexOf("."); + if (extensionIndex >= 0) { + return baseFileName.substring(extensionIndex); + } + return ""; + } + ts.getAnyExtensionFromPath = getAnyExtensionFromPath; + function pathComponents(path, rootLength) { + var root = path.substring(0, rootLength); + var rest = path.substring(rootLength).split(ts.directorySeparator); + if (rest.length && !ts.lastOrUndefined(rest)) + rest.pop(); + return __spreadArrays([root], rest); + } + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is not normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * // POSIX + * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"] + * getPathComponents("/path/to/") === ["/", "path", "to"] + * getPathComponents("/") === ["/"] + * // DOS + * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"] + * getPathComponents("c:/path/to/") === ["c:/", "path", "to"] + * getPathComponents("c:/") === ["c:/"] + * getPathComponents("c:") === ["c:"] + * // URL + * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"] + * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"] + * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"] + * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"] + * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"] + * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"] + * getPathComponents("file://server/") === ["file://server/"] + * getPathComponents("file://server") === ["file://server"] + * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"] + * getPathComponents("file:///path/to/") === ["file:///", "path", "to"] + * getPathComponents("file:///") === ["file:///"] + * getPathComponents("file://") === ["file://"] + */ + function getPathComponents(path, currentDirectory) { + if (currentDirectory === void 0) { currentDirectory = ""; } + path = combinePaths(currentDirectory, path); + return pathComponents(path, getRootLength(path)); + } + ts.getPathComponents = getPathComponents; + //// Path Formatting + /** + * Formats a parsed path consisting of a root component (at index 0) and zero or more path + * segments (at indices > 0). + * + * ```ts + * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext" + * ``` + */ + function getPathFromPathComponents(pathComponents) { + if (pathComponents.length === 0) + return ""; + var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]); + return root + pathComponents.slice(1).join(ts.directorySeparator); + } + ts.getPathFromPathComponents = getPathFromPathComponents; + //// Path Normalization + /** + * Normalize path separators, converting `\` into `/`. + */ + function normalizeSlashes(path) { + return path.replace(backslashRegExp, ts.directorySeparator); + } + ts.normalizeSlashes = normalizeSlashes; + /** + * Reduce an array of path components to a more simplified path by navigating any + * `"."` or `".."` entries in the path. + */ + function reducePathComponents(components) { + if (!ts.some(components)) + return []; + var reduced = [components[0]]; + for (var i = 1; i < components.length; i++) { + var component = components[i]; + if (!component) + continue; + if (component === ".") + continue; + if (component === "..") { + if (reduced.length > 1) { + if (reduced[reduced.length - 1] !== "..") { + reduced.pop(); + continue; + } + } + else if (reduced[0]) + continue; + } + reduced.push(component); + } + return reduced; + } + ts.reducePathComponents = reducePathComponents; + /** + * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified. + * + * ```ts + * // Non-rooted + * combinePaths("path", "to", "file.ext") === "path/to/file.ext" + * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext" + * // POSIX + * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext" + * combinePaths("/path", "/to", "file.ext") === "/to/file.ext" + * // DOS + * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext" + * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext" + * // URL + * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext" + * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext" + * ``` + */ + function combinePaths(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + if (path) + path = normalizeSlashes(path); + for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { + var relativePath = paths_1[_a]; + if (!relativePath) + continue; + relativePath = normalizeSlashes(relativePath); + if (!path || getRootLength(relativePath) !== 0) { + path = relativePath; + } + else { + path = ensureTrailingDirectorySeparator(path) + relativePath; + } + } + return path; + } + ts.combinePaths = combinePaths; + /** + * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any + * `.` and `..` path components are resolved. Trailing directory separators are preserved. + * + * ```ts + * resolvePath("/path", "to", "file.ext") === "path/to/file.ext" + * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/" + * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext" + * ``` + */ + function resolvePath(path) { + var paths = []; + for (var _i = 1; _i < arguments.length; _i++) { + paths[_i - 1] = arguments[_i]; + } + return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : normalizeSlashes(path)); + } + ts.resolvePath = resolvePath; + /** + * Parse a path into an array containing a root component (at index 0) and zero or more path + * components (at indices > 0). The result is normalized. + * If the path is relative, the root component is `""`. + * If the path is absolute, the root component includes the first path separator (`/`). + * + * ```ts + * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"] + */ + function getNormalizedPathComponents(path, currentDirectory) { + return reducePathComponents(getPathComponents(path, currentDirectory)); + } + ts.getNormalizedPathComponents = getNormalizedPathComponents; + function getNormalizedAbsolutePath(fileName, currentDirectory) { + return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; + function normalizePath(path) { + path = normalizeSlashes(path); + var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path))); + return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized; + } + ts.normalizePath = normalizePath; + function getPathWithoutRoot(pathComponents) { + if (pathComponents.length === 0) + return ""; + return pathComponents.slice(1).join(ts.directorySeparator); + } + function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { + return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + } + ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; + function toPath(fileName, basePath, getCanonicalFileName) { + var nonCanonicalizedPath = isRootedDiskPath(fileName) + ? normalizePath(fileName) + : getNormalizedAbsolutePath(fileName, basePath); + return getCanonicalFileName(nonCanonicalizedPath); + } + ts.toPath = toPath; + function normalizePathAndParts(path) { + path = normalizeSlashes(path); + var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); + if (parts.length) { + var joinedParts = root + parts.join(ts.directorySeparator); + return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; + } + else { + return { path: root, parts: parts }; + } + } + ts.normalizePathAndParts = normalizePathAndParts; + function removeTrailingDirectorySeparator(path) { + if (hasTrailingDirectorySeparator(path)) { + return path.substr(0, path.length - 1); + } + return path; + } + ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; + function ensureTrailingDirectorySeparator(path) { + if (!hasTrailingDirectorySeparator(path)) { + return path + ts.directorySeparator; + } + return path; + } + ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; + /** + * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed + * with `./` or `../`) so as not to be confused with an unprefixed module name. + * + * ```ts + * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext" + * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext" + * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext" + * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext" + * ``` + */ + function ensurePathIsNonModuleName(path) { + return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path; + } + ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; + function changeAnyExtension(path, ext, extensions, ignoreCase) { + var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); + return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; + } + ts.changeAnyExtension = changeAnyExtension; + //// Path Comparisons + // check path for these segments: '', '.'. '..' + var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; + function comparePathsWorker(a, b, componentComparer) { + if (a === b) + return 0 /* EqualTo */; + if (a === undefined) + return -1 /* LessThan */; + if (b === undefined) + return 1 /* GreaterThan */; + // NOTE: Performance optimization - shortcut if the root segments differ as there would be no + // need to perform path reduction. + var aRoot = a.substring(0, getRootLength(a)); + var bRoot = b.substring(0, getRootLength(b)); + var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); + if (result !== 0 /* EqualTo */) { + return result; + } + // NOTE: Performance optimization - shortcut if there are no relative path segments in + // the non-root portion of the path + var aRest = a.substring(aRoot.length); + var bRest = b.substring(bRoot.length); + if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { + return componentComparer(aRest, bRest); + } + // The path contains a relative path segment. Normalize the paths and perform a slower component + // by component comparison. + var aComponents = reducePathComponents(getPathComponents(a)); + var bComponents = reducePathComponents(getPathComponents(b)); + var sharedLength = Math.min(aComponents.length, bComponents.length); + for (var i = 1; i < sharedLength; i++) { + var result_1 = componentComparer(aComponents[i], bComponents[i]); + if (result_1 !== 0 /* EqualTo */) { + return result_1; + } + } + return ts.compareValues(aComponents.length, bComponents.length); + } + /** + * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively. + */ + function comparePathsCaseSensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + } + ts.comparePathsCaseSensitive = comparePathsCaseSensitive; + /** + * Performs a case-insensitive comparison of two paths. + */ + function comparePathsCaseInsensitive(a, b) { + return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + } + ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; + function comparePaths(a, b, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + a = combinePaths(currentDirectory, a); + b = combinePaths(currentDirectory, b); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + } + ts.comparePaths = comparePaths; + function containsPath(parent, child, currentDirectory, ignoreCase) { + if (typeof currentDirectory === "string") { + parent = combinePaths(currentDirectory, parent); + child = combinePaths(currentDirectory, child); + } + else if (typeof currentDirectory === "boolean") { + ignoreCase = currentDirectory; + } + if (parent === undefined || child === undefined) + return false; + if (parent === child) + return true; + var parentComponents = reducePathComponents(getPathComponents(parent)); + var childComponents = reducePathComponents(getPathComponents(child)); + if (childComponents.length < parentComponents.length) { + return false; + } + var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; + for (var i = 0; i < parentComponents.length; i++) { + var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; + if (!equalityComparer(parentComponents[i], childComponents[i])) { + return false; + } + } + return true; + } + ts.containsPath = containsPath; + /** + * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback. + * Comparison is case-sensitive between the canonical paths. + * + * @deprecated Use `containsPath` if possible. + */ + function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { + var canonicalFileName = getCanonicalFileName(fileName); + var canonicalDirectoryName = getCanonicalFileName(directoryName); + return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); + } + ts.startsWithDirectory = startsWithDirectory; + //// Relative Paths + function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { + var fromComponents = reducePathComponents(getPathComponents(from)); + var toComponents = reducePathComponents(getPathComponents(to)); + var start; + for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { + var fromComponent = getCanonicalFileName(fromComponents[start]); + var toComponent = getCanonicalFileName(toComponents[start]); + var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; + if (!comparer(fromComponent, toComponent)) + break; + } + if (start === 0) { + return toComponents; + } + var components = toComponents.slice(start); + var relative = []; + for (; start < fromComponents.length; start++) { + relative.push(".."); + } + return __spreadArrays([""], relative, components); + } + ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; + function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { + ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); + var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; + var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; + var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathFromDirectory = getRelativePathFromDirectory; + function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { + return !isRootedDiskPath(absoluteOrRelativePath) + ? absoluteOrRelativePath + : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + } + ts.convertToRelativePath = convertToRelativePath; + function getRelativePathFromFile(from, to, getCanonicalFileName) { + return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName)); + } + ts.getRelativePathFromFile = getRelativePathFromFile; + function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { + var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); + var firstComponent = pathComponents[0]; + if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) { + var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; + pathComponents[0] = prefix + firstComponent; + } + return getPathFromPathComponents(pathComponents); + } + ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; + function forEachAncestorDirectory(directory, callback) { + while (true) { + var result = callback(directory); + if (result !== undefined) { + return result; + } + var parentPath = getDirectoryPath(directory); + if (parentPath === directory) { + return undefined; + } + directory = parentPath; + } + } + ts.forEachAncestorDirectory = forEachAncestorDirectory; +})(ts || (ts = {})); +// +// generated from './diagnosticInformationMap.generated.ts' by 'src/compiler' +/* @internal */ +var ts; +(function (ts) { + function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid) { + return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid }; + } + ts.Diagnostics = { + Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."), + Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."), + _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."), + A_file_cannot_have_a_reference_to_itself: diag(1006, ts.DiagnosticCategory.Error, "A_file_cannot_have_a_reference_to_itself_1006", "A file cannot have a reference to itself."), + Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."), + Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."), + An_element_access_expression_should_take_an_argument: diag(1011, ts.DiagnosticCategory.Error, "An_element_access_expression_should_take_an_argument_1011", "An element access expression should take an argument."), + Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."), + A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma: diag(1013, ts.DiagnosticCategory.Error, "A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma_1013", "A rest parameter or binding pattern may not have a trailing comma."), + A_rest_parameter_must_be_last_in_a_parameter_list: diag(1014, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_last_in_a_parameter_list_1014", "A rest parameter must be last in a parameter list."), + Parameter_cannot_have_question_mark_and_initializer: diag(1015, ts.DiagnosticCategory.Error, "Parameter_cannot_have_question_mark_and_initializer_1015", "Parameter cannot have question mark and initializer."), + A_required_parameter_cannot_follow_an_optional_parameter: diag(1016, ts.DiagnosticCategory.Error, "A_required_parameter_cannot_follow_an_optional_parameter_1016", "A required parameter cannot follow an optional parameter."), + An_index_signature_cannot_have_a_rest_parameter: diag(1017, ts.DiagnosticCategory.Error, "An_index_signature_cannot_have_a_rest_parameter_1017", "An index signature cannot have a rest parameter."), + An_index_signature_parameter_cannot_have_an_accessibility_modifier: diag(1018, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018", "An index signature parameter cannot have an accessibility modifier."), + An_index_signature_parameter_cannot_have_a_question_mark: diag(1019, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_a_question_mark_1019", "An index signature parameter cannot have a question mark."), + An_index_signature_parameter_cannot_have_an_initializer: diag(1020, ts.DiagnosticCategory.Error, "An_index_signature_parameter_cannot_have_an_initializer_1020", "An index signature parameter cannot have an initializer."), + An_index_signature_must_have_a_type_annotation: diag(1021, ts.DiagnosticCategory.Error, "An_index_signature_must_have_a_type_annotation_1021", "An index signature must have a type annotation."), + An_index_signature_parameter_must_have_a_type_annotation: diag(1022, ts.DiagnosticCategory.Error, "An_index_signature_parameter_must_have_a_type_annotation_1022", "An index signature parameter must have a type annotation."), + An_index_signature_parameter_type_must_be_either_string_or_number: diag(1023, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_must_be_either_string_or_number_1023", "An index signature parameter type must be either 'string' or 'number'."), + readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature: diag(1024, ts.DiagnosticCategory.Error, "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024", "'readonly' modifier can only appear on a property declaration or index signature."), + Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."), + _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."), + _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."), + _0_modifier_cannot_appear_on_a_class_element: diag(1031, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_class_element_1031", "'{0}' modifier cannot appear on a class element."), + super_must_be_followed_by_an_argument_list_or_member_access: diag(1034, ts.DiagnosticCategory.Error, "super_must_be_followed_by_an_argument_list_or_member_access_1034", "'super' must be followed by an argument list or member access."), + Only_ambient_modules_can_use_quoted_names: diag(1035, ts.DiagnosticCategory.Error, "Only_ambient_modules_can_use_quoted_names_1035", "Only ambient modules can use quoted names."), + Statements_are_not_allowed_in_ambient_contexts: diag(1036, ts.DiagnosticCategory.Error, "Statements_are_not_allowed_in_ambient_contexts_1036", "Statements are not allowed in ambient contexts."), + A_declare_modifier_cannot_be_used_in_an_already_ambient_context: diag(1038, ts.DiagnosticCategory.Error, "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038", "A 'declare' modifier cannot be used in an already ambient context."), + Initializers_are_not_allowed_in_ambient_contexts: diag(1039, ts.DiagnosticCategory.Error, "Initializers_are_not_allowed_in_ambient_contexts_1039", "Initializers are not allowed in ambient contexts."), + _0_modifier_cannot_be_used_in_an_ambient_context: diag(1040, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_in_an_ambient_context_1040", "'{0}' modifier cannot be used in an ambient context."), + _0_modifier_cannot_be_used_with_a_class_declaration: diag(1041, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_a_class_declaration_1041", "'{0}' modifier cannot be used with a class declaration."), + _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."), + _0_modifier_cannot_appear_on_a_data_property: diag(1043, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_data_property_1043", "'{0}' modifier cannot appear on a data property."), + _0_modifier_cannot_appear_on_a_module_or_namespace_element: diag(1044, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044", "'{0}' modifier cannot appear on a module or namespace element."), + A_0_modifier_cannot_be_used_with_an_interface_declaration: diag(1045, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045", "A '{0}' modifier cannot be used with an interface declaration."), + Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier: diag(1046, ts.DiagnosticCategory.Error, "Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier_1046", "Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier."), + A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."), + A_rest_parameter_cannot_have_an_initializer: diag(1048, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_have_an_initializer_1048", "A rest parameter cannot have an initializer."), + A_set_accessor_must_have_exactly_one_parameter: diag(1049, ts.DiagnosticCategory.Error, "A_set_accessor_must_have_exactly_one_parameter_1049", "A 'set' accessor must have exactly one parameter."), + A_set_accessor_cannot_have_an_optional_parameter: diag(1051, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_an_optional_parameter_1051", "A 'set' accessor cannot have an optional parameter."), + A_set_accessor_parameter_cannot_have_an_initializer: diag(1052, ts.DiagnosticCategory.Error, "A_set_accessor_parameter_cannot_have_an_initializer_1052", "A 'set' accessor parameter cannot have an initializer."), + A_set_accessor_cannot_have_rest_parameter: diag(1053, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_rest_parameter_1053", "A 'set' accessor cannot have rest parameter."), + A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."), + Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: diag(1055, ts.DiagnosticCategory.Error, "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value."), + Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: diag(1056, ts.DiagnosticCategory.Error, "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", "Accessors are only available when targeting ECMAScript 5 and higher."), + An_async_function_or_method_must_have_a_valid_awaitable_return_type: diag(1057, ts.DiagnosticCategory.Error, "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", "An async function or method must have a valid awaitable return type."), + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1058, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", "The return type of an async function must either be a valid promise or must not contain a callable 'then' member."), + A_promise_must_have_a_then_method: diag(1059, ts.DiagnosticCategory.Error, "A_promise_must_have_a_then_method_1059", "A promise must have a 'then' method."), + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: diag(1060, ts.DiagnosticCategory.Error, "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", "The first parameter of the 'then' method of a promise must be a callback."), + Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."), + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: diag(1062, ts.DiagnosticCategory.Error, "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", "Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method."), + An_export_assignment_cannot_be_used_in_a_namespace: diag(1063, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_namespace_1063", "An export assignment cannot be used in a namespace."), + The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type: diag(1064, ts.DiagnosticCategory.Error, "The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type_1064", "The return type of an async function or method must be the global Promise type."), + In_ambient_enum_declarations_member_initializer_must_be_constant_expression: diag(1066, ts.DiagnosticCategory.Error, "In_ambient_enum_declarations_member_initializer_must_be_constant_expression_1066", "In ambient enum declarations member initializer must be constant expression."), + Unexpected_token_A_constructor_method_accessor_or_property_was_expected: diag(1068, ts.DiagnosticCategory.Error, "Unexpected_token_A_constructor_method_accessor_or_property_was_expected_1068", "Unexpected token. A constructor, method, accessor, or property was expected."), + Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces: diag(1069, ts.DiagnosticCategory.Error, "Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces_1069", "Unexpected token. A type parameter name was expected without curly braces."), + _0_modifier_cannot_appear_on_a_type_member: diag(1070, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_type_member_1070", "'{0}' modifier cannot appear on a type member."), + _0_modifier_cannot_appear_on_an_index_signature: diag(1071, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_an_index_signature_1071", "'{0}' modifier cannot appear on an index signature."), + A_0_modifier_cannot_be_used_with_an_import_declaration: diag(1079, ts.DiagnosticCategory.Error, "A_0_modifier_cannot_be_used_with_an_import_declaration_1079", "A '{0}' modifier cannot be used with an import declaration."), + Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."), + Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0: diag(1085, ts.DiagnosticCategory.Error, "Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0_1085", "Octal literals are not available when targeting ECMAScript 5 and higher. Use the syntax '{0}'."), + _0_modifier_cannot_appear_on_a_constructor_declaration: diag(1089, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_constructor_declaration_1089", "'{0}' modifier cannot appear on a constructor declaration."), + _0_modifier_cannot_appear_on_a_parameter: diag(1090, ts.DiagnosticCategory.Error, "_0_modifier_cannot_appear_on_a_parameter_1090", "'{0}' modifier cannot appear on a parameter."), + Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement: diag(1091, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement_1091", "Only a single variable declaration is allowed in a 'for...in' statement."), + Type_parameters_cannot_appear_on_a_constructor_declaration: diag(1092, ts.DiagnosticCategory.Error, "Type_parameters_cannot_appear_on_a_constructor_declaration_1092", "Type parameters cannot appear on a constructor declaration."), + Type_annotation_cannot_appear_on_a_constructor_declaration: diag(1093, ts.DiagnosticCategory.Error, "Type_annotation_cannot_appear_on_a_constructor_declaration_1093", "Type annotation cannot appear on a constructor declaration."), + An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."), + A_set_accessor_cannot_have_a_return_type_annotation: diag(1095, ts.DiagnosticCategory.Error, "A_set_accessor_cannot_have_a_return_type_annotation_1095", "A 'set' accessor cannot have a return type annotation."), + An_index_signature_must_have_exactly_one_parameter: diag(1096, ts.DiagnosticCategory.Error, "An_index_signature_must_have_exactly_one_parameter_1096", "An index signature must have exactly one parameter."), + _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."), + Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."), + Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."), + Invalid_use_of_0_in_strict_mode: diag(1100, ts.DiagnosticCategory.Error, "Invalid_use_of_0_in_strict_mode_1100", "Invalid use of '{0}' in strict mode."), + with_statements_are_not_allowed_in_strict_mode: diag(1101, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_strict_mode_1101", "'with' statements are not allowed in strict mode."), + delete_cannot_be_called_on_an_identifier_in_strict_mode: diag(1102, ts.DiagnosticCategory.Error, "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", "'delete' cannot be called on an identifier in strict mode."), + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: diag(1103, ts.DiagnosticCategory.Error, "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", "A 'for-await-of' statement is only allowed within an async function or async generator."), + A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: diag(1104, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", "A 'continue' statement can only be used within an enclosing iteration statement."), + A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: diag(1105, ts.DiagnosticCategory.Error, "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", "A 'break' statement can only be used within an enclosing iteration or switch statement."), + Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."), + A_return_statement_can_only_be_used_within_a_function_body: diag(1108, ts.DiagnosticCategory.Error, "A_return_statement_can_only_be_used_within_a_function_body_1108", "A 'return' statement can only be used within a function body."), + Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."), + Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."), + A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: diag(1113, ts.DiagnosticCategory.Error, "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", "A 'default' clause cannot appear more than once in a 'switch' statement."), + Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."), + A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: diag(1115, ts.DiagnosticCategory.Error, "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", "A 'continue' statement can only jump to a label of an enclosing iteration statement."), + A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: diag(1116, ts.DiagnosticCategory.Error, "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", "A 'break' statement can only jump to a label of an enclosing statement."), + An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: diag(1117, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", "An object literal cannot have multiple properties with the same name in strict mode."), + An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name: diag(1118, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name_1118", "An object literal cannot have multiple get/set accessors with the same name."), + An_object_literal_cannot_have_property_and_accessor_with_the_same_name: diag(1119, ts.DiagnosticCategory.Error, "An_object_literal_cannot_have_property_and_accessor_with_the_same_name_1119", "An object literal cannot have property and accessor with the same name."), + An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."), + Octal_literals_are_not_allowed_in_strict_mode: diag(1121, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_strict_mode_1121", "Octal literals are not allowed in strict mode."), + Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."), + Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."), + Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."), + Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."), + Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."), + Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."), + Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."), + case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."), + Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."), + Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."), + Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."), + Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."), + Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."), + Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."), + Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."), + Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."), + Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."), + String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."), + Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."), + or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."), + Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."), + Import_declarations_in_a_namespace_cannot_reference_a_module: diag(1147, ts.DiagnosticCategory.Error, "Import_declarations_in_a_namespace_cannot_reference_a_module_1147", "Import declarations in a namespace cannot reference a module."), + Cannot_use_imports_exports_or_module_augmentations_when_module_is_none: diag(1148, ts.DiagnosticCategory.Error, "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", "Cannot use imports, exports, or module augmentations when '--module' is 'none'."), + File_name_0_differs_from_already_included_file_name_1_only_in_casing: diag(1149, ts.DiagnosticCategory.Error, "File_name_0_differs_from_already_included_file_name_1_only_in_casing_1149", "File name '{0}' differs from already included file name '{1}' only in casing."), + const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."), + const_declarations_can_only_be_declared_inside_a_block: diag(1156, ts.DiagnosticCategory.Error, "const_declarations_can_only_be_declared_inside_a_block_1156", "'const' declarations can only be declared inside a block."), + let_declarations_can_only_be_declared_inside_a_block: diag(1157, ts.DiagnosticCategory.Error, "let_declarations_can_only_be_declared_inside_a_block_1157", "'let' declarations can only be declared inside a block."), + Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."), + Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."), + An_object_member_cannot_be_declared_optional: diag(1162, ts.DiagnosticCategory.Error, "An_object_member_cannot_be_declared_optional_1162", "An object member cannot be declared optional."), + A_yield_expression_is_only_allowed_in_a_generator_body: diag(1163, ts.DiagnosticCategory.Error, "A_yield_expression_is_only_allowed_in_a_generator_body_1163", "A 'yield' expression is only allowed in a generator body."), + Computed_property_names_are_not_allowed_in_enums: diag(1164, ts.DiagnosticCategory.Error, "Computed_property_names_are_not_allowed_in_enums_1164", "Computed property names are not allowed in enums."), + A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1165, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_t_1165", "A computed property name in an ambient context must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1166, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_class_property_declaration_must_refer_to_an_expression_whose_type_is_a_1166", "A computed property name in a class property declaration must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1168, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_ty_1168", "A computed property name in a method overload must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1169, ts.DiagnosticCategory.Error, "A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_1169", "A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type: diag(1170, ts.DiagnosticCategory.Error, "A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type__1170", "A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type."), + A_comma_expression_is_not_allowed_in_a_computed_property_name: diag(1171, ts.DiagnosticCategory.Error, "A_comma_expression_is_not_allowed_in_a_computed_property_name_1171", "A comma expression is not allowed in a computed property name."), + extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."), + extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."), + Classes_can_only_extend_a_single_class: diag(1174, ts.DiagnosticCategory.Error, "Classes_can_only_extend_a_single_class_1174", "Classes can only extend a single class."), + implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."), + Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."), + Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."), + Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."), + Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."), + Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."), + Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."), + A_destructuring_declaration_must_have_an_initializer: diag(1182, ts.DiagnosticCategory.Error, "A_destructuring_declaration_must_have_an_initializer_1182", "A destructuring declaration must have an initializer."), + An_implementation_cannot_be_declared_in_ambient_contexts: diag(1183, ts.DiagnosticCategory.Error, "An_implementation_cannot_be_declared_in_ambient_contexts_1183", "An implementation cannot be declared in ambient contexts."), + Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."), + Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."), + A_rest_element_cannot_have_an_initializer: diag(1186, ts.DiagnosticCategory.Error, "A_rest_element_cannot_have_an_initializer_1186", "A rest element cannot have an initializer."), + A_parameter_property_may_not_be_declared_using_a_binding_pattern: diag(1187, ts.DiagnosticCategory.Error, "A_parameter_property_may_not_be_declared_using_a_binding_pattern_1187", "A parameter property may not be declared using a binding pattern."), + Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement: diag(1188, ts.DiagnosticCategory.Error, "Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement_1188", "Only a single variable declaration is allowed in a 'for...of' statement."), + The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer: diag(1189, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer_1189", "The variable declaration of a 'for...in' statement cannot have an initializer."), + The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer: diag(1190, ts.DiagnosticCategory.Error, "The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer_1190", "The variable declaration of a 'for...of' statement cannot have an initializer."), + An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."), + Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."), + An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."), + Export_declarations_are_not_permitted_in_a_namespace: diag(1194, ts.DiagnosticCategory.Error, "Export_declarations_are_not_permitted_in_a_namespace_1194", "Export declarations are not permitted in a namespace."), + Catch_clause_variable_cannot_have_a_type_annotation: diag(1196, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_a_type_annotation_1196", "Catch clause variable cannot have a type annotation."), + Catch_clause_variable_cannot_have_an_initializer: diag(1197, ts.DiagnosticCategory.Error, "Catch_clause_variable_cannot_have_an_initializer_1197", "Catch clause variable cannot have an initializer."), + An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), + Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), + Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), + Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), + Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), + Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), + All_files_must_be_modules_when_the_isolatedModules_flag_is_provided: diag(1208, ts.DiagnosticCategory.Error, "All_files_must_be_modules_when_the_isolatedModules_flag_is_provided_1208", "All files must be modules when the '--isolatedModules' flag is provided."), + Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: diag(1210, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", "Invalid use of '{0}'. Class definitions are automatically in strict mode."), + A_class_declaration_without_the_default_modifier_must_have_a_name: diag(1211, ts.DiagnosticCategory.Error, "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", "A class declaration without the 'default' modifier must have a name."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode: diag(1212, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", "Identifier expected. '{0}' is a reserved word in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: diag(1213, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode."), + Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode: diag(1214, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode_1214", "Identifier expected. '{0}' is a reserved word in strict mode. Modules are automatically in strict mode."), + Invalid_use_of_0_Modules_are_automatically_in_strict_mode: diag(1215, ts.DiagnosticCategory.Error, "Invalid_use_of_0_Modules_are_automatically_in_strict_mode_1215", "Invalid use of '{0}'. Modules are automatically in strict mode."), + Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules: diag(1216, ts.DiagnosticCategory.Error, "Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules_1216", "Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules."), + Export_assignment_is_not_supported_when_module_flag_is_system: diag(1218, ts.DiagnosticCategory.Error, "Export_assignment_is_not_supported_when_module_flag_is_system_1218", "Export assignment is not supported when '--module' flag is 'system'."), + Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning: diag(1219, ts.DiagnosticCategory.Error, "Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_t_1219", "Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning."), + Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher: diag(1220, ts.DiagnosticCategory.Error, "Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher_1220", "Generators are only available when targeting ECMAScript 2015 or higher."), + Generators_are_not_allowed_in_an_ambient_context: diag(1221, ts.DiagnosticCategory.Error, "Generators_are_not_allowed_in_an_ambient_context_1221", "Generators are not allowed in an ambient context."), + An_overload_signature_cannot_be_declared_as_a_generator: diag(1222, ts.DiagnosticCategory.Error, "An_overload_signature_cannot_be_declared_as_a_generator_1222", "An overload signature cannot be declared as a generator."), + _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."), + Signature_0_must_be_a_type_predicate: diag(1224, ts.DiagnosticCategory.Error, "Signature_0_must_be_a_type_predicate_1224", "Signature '{0}' must be a type predicate."), + Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."), + Type_predicate_0_is_not_assignable_to_1: diag(1226, ts.DiagnosticCategory.Error, "Type_predicate_0_is_not_assignable_to_1_1226", "Type predicate '{0}' is not assignable to '{1}'."), + Parameter_0_is_not_in_the_same_position_as_parameter_1: diag(1227, ts.DiagnosticCategory.Error, "Parameter_0_is_not_in_the_same_position_as_parameter_1_1227", "Parameter '{0}' is not in the same position as parameter '{1}'."), + A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods: diag(1228, ts.DiagnosticCategory.Error, "A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods_1228", "A type predicate is only allowed in return type position for functions and methods."), + A_type_predicate_cannot_reference_a_rest_parameter: diag(1229, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_a_rest_parameter_1229", "A type predicate cannot reference a rest parameter."), + A_type_predicate_cannot_reference_element_0_in_a_binding_pattern: diag(1230, ts.DiagnosticCategory.Error, "A_type_predicate_cannot_reference_element_0_in_a_binding_pattern_1230", "A type predicate cannot reference element '{0}' in a binding pattern."), + An_export_assignment_can_only_be_used_in_a_module: diag(1231, ts.DiagnosticCategory.Error, "An_export_assignment_can_only_be_used_in_a_module_1231", "An export assignment can only be used in a module."), + An_import_declaration_can_only_be_used_in_a_namespace_or_module: diag(1232, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232", "An import declaration can only be used in a namespace or module."), + An_export_declaration_can_only_be_used_in_a_module: diag(1233, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_in_a_module_1233", "An export declaration can only be used in a module."), + An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file: diag(1234, ts.DiagnosticCategory.Error, "An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file_1234", "An ambient module declaration is only allowed at the top level in a file."), + A_namespace_declaration_is_only_allowed_in_a_namespace_or_module: diag(1235, ts.DiagnosticCategory.Error, "A_namespace_declaration_is_only_allowed_in_a_namespace_or_module_1235", "A namespace declaration is only allowed in a namespace or module."), + The_return_type_of_a_property_decorator_function_must_be_either_void_or_any: diag(1236, ts.DiagnosticCategory.Error, "The_return_type_of_a_property_decorator_function_must_be_either_void_or_any_1236", "The return type of a property decorator function must be either 'void' or 'any'."), + The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any: diag(1237, ts.DiagnosticCategory.Error, "The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any_1237", "The return type of a parameter decorator function must be either 'void' or 'any'."), + Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression: diag(1238, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression_1238", "Unable to resolve signature of class decorator when called as an expression."), + Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression: diag(1239, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression_1239", "Unable to resolve signature of parameter decorator when called as an expression."), + Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression: diag(1240, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression_1240", "Unable to resolve signature of property decorator when called as an expression."), + Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression: diag(1241, ts.DiagnosticCategory.Error, "Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression_1241", "Unable to resolve signature of method decorator when called as an expression."), + abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration: diag(1242, ts.DiagnosticCategory.Error, "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242", "'abstract' modifier can only appear on a class, method, or property declaration."), + _0_modifier_cannot_be_used_with_1_modifier: diag(1243, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_with_1_modifier_1243", "'{0}' modifier cannot be used with '{1}' modifier."), + Abstract_methods_can_only_appear_within_an_abstract_class: diag(1244, ts.DiagnosticCategory.Error, "Abstract_methods_can_only_appear_within_an_abstract_class_1244", "Abstract methods can only appear within an abstract class."), + Method_0_cannot_have_an_implementation_because_it_is_marked_abstract: diag(1245, ts.DiagnosticCategory.Error, "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245", "Method '{0}' cannot have an implementation because it is marked abstract."), + An_interface_property_cannot_have_an_initializer: diag(1246, ts.DiagnosticCategory.Error, "An_interface_property_cannot_have_an_initializer_1246", "An interface property cannot have an initializer."), + A_type_literal_property_cannot_have_an_initializer: diag(1247, ts.DiagnosticCategory.Error, "A_type_literal_property_cannot_have_an_initializer_1247", "A type literal property cannot have an initializer."), + A_class_member_cannot_have_the_0_keyword: diag(1248, ts.DiagnosticCategory.Error, "A_class_member_cannot_have_the_0_keyword_1248", "A class member cannot have the '{0}' keyword."), + A_decorator_can_only_decorate_a_method_implementation_not_an_overload: diag(1249, ts.DiagnosticCategory.Error, "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249", "A decorator can only decorate a method implementation, not an overload."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5: diag(1250, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_1250", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_definitions_are_automatically_in_strict_mode: diag(1251, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Class_d_1251", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Class definitions are automatically in strict mode."), + Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode: diag(1252, ts.DiagnosticCategory.Error, "Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_1252", "Function declarations are not allowed inside blocks in strict mode when targeting 'ES3' or 'ES5'. Modules are automatically in strict mode."), + _0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag: diag(1253, ts.DiagnosticCategory.Error, "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253", "'{0}' tag cannot be used independently as a top level JSDoc tag."), + A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference: diag(1254, ts.DiagnosticCategory.Error, "A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_refere_1254", "A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference."), + A_definite_assignment_assertion_is_not_permitted_in_this_context: diag(1255, ts.DiagnosticCategory.Error, "A_definite_assignment_assertion_is_not_permitted_in_this_context_1255", "A definite assignment assertion '!' is not permitted in this context."), + A_rest_element_must_be_last_in_a_tuple_type: diag(1256, ts.DiagnosticCategory.Error, "A_rest_element_must_be_last_in_a_tuple_type_1256", "A rest element must be last in a tuple type."), + A_required_element_cannot_follow_an_optional_element: diag(1257, ts.DiagnosticCategory.Error, "A_required_element_cannot_follow_an_optional_element_1257", "A required element cannot follow an optional element."), + Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation: diag(1258, ts.DiagnosticCategory.Error, "Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation_1258", "Definite assignment assertions can only be used along with a type annotation."), + Module_0_can_only_be_default_imported_using_the_1_flag: diag(1259, ts.DiagnosticCategory.Error, "Module_0_can_only_be_default_imported_using_the_1_flag_1259", "Module '{0}' can only be default-imported using the '{1}' flag"), + Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."), + with_statements_are_not_allowed_in_an_async_function_block: diag(1300, ts.DiagnosticCategory.Error, "with_statements_are_not_allowed_in_an_async_function_block_1300", "'with' statements are not allowed in an async function block."), + await_expression_is_only_allowed_within_an_async_function: diag(1308, ts.DiagnosticCategory.Error, "await_expression_is_only_allowed_within_an_async_function_1308", "'await' expression is only allowed within an async function."), + can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment: diag(1312, ts.DiagnosticCategory.Error, "can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment_1312", "'=' can only be used in an object literal property inside a destructuring assignment."), + The_body_of_an_if_statement_cannot_be_the_empty_statement: diag(1313, ts.DiagnosticCategory.Error, "The_body_of_an_if_statement_cannot_be_the_empty_statement_1313", "The body of an 'if' statement cannot be the empty statement."), + Global_module_exports_may_only_appear_in_module_files: diag(1314, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_module_files_1314", "Global module exports may only appear in module files."), + Global_module_exports_may_only_appear_in_declaration_files: diag(1315, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_in_declaration_files_1315", "Global module exports may only appear in declaration files."), + Global_module_exports_may_only_appear_at_top_level: diag(1316, ts.DiagnosticCategory.Error, "Global_module_exports_may_only_appear_at_top_level_1316", "Global module exports may only appear at top level."), + A_parameter_property_cannot_be_declared_using_a_rest_parameter: diag(1317, ts.DiagnosticCategory.Error, "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", "A parameter property cannot be declared using a rest parameter."), + An_abstract_accessor_cannot_have_an_implementation: diag(1318, ts.DiagnosticCategory.Error, "An_abstract_accessor_cannot_have_an_implementation_1318", "An abstract accessor cannot have an implementation."), + A_default_export_can_only_be_used_in_an_ECMAScript_style_module: diag(1319, ts.DiagnosticCategory.Error, "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", "A default export can only be used in an ECMAScript-style module."), + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1320, ts.DiagnosticCategory.Error, "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member."), + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1321, ts.DiagnosticCategory.Error, "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member."), + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: diag(1322, ts.DiagnosticCategory.Error, "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member."), + Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd: diag(1323, ts.DiagnosticCategory.Error, "Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd_1323", "Dynamic imports are only supported when the '--module' flag is set to 'esnext', 'commonjs', 'amd', 'system', or 'umd'."), + Dynamic_import_must_have_one_specifier_as_an_argument: diag(1324, ts.DiagnosticCategory.Error, "Dynamic_import_must_have_one_specifier_as_an_argument_1324", "Dynamic import must have one specifier as an argument."), + Specifier_of_dynamic_import_cannot_be_spread_element: diag(1325, ts.DiagnosticCategory.Error, "Specifier_of_dynamic_import_cannot_be_spread_element_1325", "Specifier of dynamic import cannot be spread element."), + Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments"), + String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."), + Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_literal: diag(1328, ts.DiagnosticCategory.Error, "Property_value_can_only_be_string_literal_numeric_literal_true_false_null_object_literal_or_array_li_1328", "Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal."), + _0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write_0: diag(1329, ts.DiagnosticCategory.Error, "_0_accepts_too_few_arguments_to_be_used_as_a_decorator_here_Did_you_mean_to_call_it_first_and_write__1329", "'{0}' accepts too few arguments to be used as a decorator here. Did you mean to call it first and write '@{0}()'?"), + A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly: diag(1330, ts.DiagnosticCategory.Error, "A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly_1330", "A property of an interface or type literal whose type is a 'unique symbol' type must be 'readonly'."), + A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly: diag(1331, ts.DiagnosticCategory.Error, "A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly_1331", "A property of a class whose type is a 'unique symbol' type must be both 'static' and 'readonly'."), + A_variable_whose_type_is_a_unique_symbol_type_must_be_const: diag(1332, ts.DiagnosticCategory.Error, "A_variable_whose_type_is_a_unique_symbol_type_must_be_const_1332", "A variable whose type is a 'unique symbol' type must be 'const'."), + unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name: diag(1333, ts.DiagnosticCategory.Error, "unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name_1333", "'unique symbol' types may not be used on a variable declaration with a binding name."), + unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement: diag(1334, ts.DiagnosticCategory.Error, "unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement_1334", "'unique symbol' types are only allowed on variables in a variable statement."), + unique_symbol_types_are_not_allowed_here: diag(1335, ts.DiagnosticCategory.Error, "unique_symbol_types_are_not_allowed_here_1335", "'unique symbol' types are not allowed here."), + An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead: diag(1336, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336", "An index signature parameter type cannot be a type alias. Consider writing '[{0}: {1}]: {2}' instead."), + An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead: diag(1337, ts.DiagnosticCategory.Error, "An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead_1337", "An index signature parameter type cannot be a union type. Consider using a mapped object type instead."), + infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type: diag(1338, ts.DiagnosticCategory.Error, "infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type_1338", "'infer' declarations are only permitted in the 'extends' clause of a conditional type."), + Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here: diag(1339, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339", "Module '{0}' does not refer to a value, but is used as a value here."), + Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0: diag(1340, ts.DiagnosticCategory.Error, "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0_1340", "Module '{0}' does not refer to a type, but is used as a type here. Did you mean 'typeof import('{0}')'?"), + Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."), + The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system: diag(1343, ts.DiagnosticCategory.Error, "The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system_1343", "The 'import.meta' meta-property is only allowed when the '--module' option is 'esnext' or 'system'."), + A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."), + An_expression_of_type_void_cannot_be_tested_for_truthiness: diag(1345, ts.DiagnosticCategory.Error, "An_expression_of_type_void_cannot_be_tested_for_truthiness_1345", "An expression of type 'void' cannot be tested for truthiness"), + This_parameter_is_not_allowed_with_use_strict_directive: diag(1346, ts.DiagnosticCategory.Error, "This_parameter_is_not_allowed_with_use_strict_directive_1346", "This parameter is not allowed with 'use strict' directive."), + use_strict_directive_cannot_be_used_with_non_simple_parameter_list: diag(1347, ts.DiagnosticCategory.Error, "use_strict_directive_cannot_be_used_with_non_simple_parameter_list_1347", "'use strict' directive cannot be used with non-simple parameter list."), + Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."), + use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."), + Print_the_final_configuration_instead_of_building: diag(1350, ts.DiagnosticCategory.Message, "Print_the_final_configuration_instead_of_building_1350", "Print the final configuration instead of building."), + An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal: diag(1351, ts.DiagnosticCategory.Error, "An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal_1351", "An identifier or keyword cannot immediately follow a numeric literal."), + A_bigint_literal_cannot_use_exponential_notation: diag(1352, ts.DiagnosticCategory.Error, "A_bigint_literal_cannot_use_exponential_notation_1352", "A bigint literal cannot use exponential notation."), + A_bigint_literal_must_be_an_integer: diag(1353, ts.DiagnosticCategory.Error, "A_bigint_literal_must_be_an_integer_1353", "A bigint literal must be an integer."), + readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types: diag(1354, ts.DiagnosticCategory.Error, "readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types_1354", "'readonly' type modifier is only permitted on array and tuple literal types."), + A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals: diag(1355, ts.DiagnosticCategory.Error, "A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array__1355", "A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals."), + Did_you_mean_to_mark_this_function_as_async: diag(1356, ts.DiagnosticCategory.Error, "Did_you_mean_to_mark_this_function_as_async_1356", "Did you mean to mark this function as 'async'?"), + An_enum_member_name_must_be_followed_by_a_or: diag(1357, ts.DiagnosticCategory.Error, "An_enum_member_name_must_be_followed_by_a_or_1357", "An enum member name must be followed by a ',', '=', or '}'."), + Tagged_template_expressions_are_not_permitted_in_an_optional_chain: diag(1358, ts.DiagnosticCategory.Error, "Tagged_template_expressions_are_not_permitted_in_an_optional_chain_1358", "Tagged template expressions are not permitted in an optional chain."), + Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here: diag(1359, ts.DiagnosticCategory.Error, "Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here_1359", "Identifier expected. '{0}' is a reserved word that cannot be used here."), + The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."), + The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."), + Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signature_return_types_0_and_1_are_incompatible: diag(2203, ts.DiagnosticCategory.Error, "Construct_signature_return_types_0_and_1_are_incompatible_2203", "Construct signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2204, ts.DiagnosticCategory.Error, "Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2204", "Call signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true), + Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."), + Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."), + Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."), + Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."), + Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."), + Module_0_has_no_exported_member_1: diag(2305, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_2305", "Module '{0}' has no exported member '{1}'."), + File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."), + Cannot_find_module_0: diag(2307, ts.DiagnosticCategory.Error, "Cannot_find_module_0_2307", "Cannot find module '{0}'."), + Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambiguity: diag(2308, ts.DiagnosticCategory.Error, "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308", "Module {0} has already exported a member named '{1}'. Consider explicitly re-exporting to resolve the ambiguity."), + An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements: diag(2309, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309", "An export assignment cannot be used in a module with other exported elements."), + Type_0_recursively_references_itself_as_a_base_type: diag(2310, ts.DiagnosticCategory.Error, "Type_0_recursively_references_itself_as_a_base_type_2310", "Type '{0}' recursively references itself as a base type."), + A_class_may_only_extend_another_class: diag(2311, ts.DiagnosticCategory.Error, "A_class_may_only_extend_another_class_2311", "A class may only extend another class."), + An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2312, ts.DiagnosticCategory.Error, "An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312", "An interface can only extend an object type or intersection of object types with statically known members."), + Type_parameter_0_has_a_circular_constraint: diag(2313, ts.DiagnosticCategory.Error, "Type_parameter_0_has_a_circular_constraint_2313", "Type parameter '{0}' has a circular constraint."), + Generic_type_0_requires_1_type_argument_s: diag(2314, ts.DiagnosticCategory.Error, "Generic_type_0_requires_1_type_argument_s_2314", "Generic type '{0}' requires {1} type argument(s)."), + Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."), + Global_type_0_must_be_a_class_or_interface_type: diag(2316, ts.DiagnosticCategory.Error, "Global_type_0_must_be_a_class_or_interface_type_2316", "Global type '{0}' must be a class or interface type."), + Global_type_0_must_have_1_type_parameter_s: diag(2317, ts.DiagnosticCategory.Error, "Global_type_0_must_have_1_type_parameter_s_2317", "Global type '{0}' must have {1} type parameter(s)."), + Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."), + Named_property_0_of_types_1_and_2_are_not_identical: diag(2319, ts.DiagnosticCategory.Error, "Named_property_0_of_types_1_and_2_are_not_identical_2319", "Named property '{0}' of types '{1}' and '{2}' are not identical."), + Interface_0_cannot_simultaneously_extend_types_1_and_2: diag(2320, ts.DiagnosticCategory.Error, "Interface_0_cannot_simultaneously_extend_types_1_and_2_2320", "Interface '{0}' cannot simultaneously extend types '{1}' and '{2}'."), + Excessive_stack_depth_comparing_types_0_and_1: diag(2321, ts.DiagnosticCategory.Error, "Excessive_stack_depth_comparing_types_0_and_1_2321", "Excessive stack depth comparing types '{0}' and '{1}'."), + Type_0_is_not_assignable_to_type_1: diag(2322, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_2322", "Type '{0}' is not assignable to type '{1}'."), + Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."), + Property_0_is_missing_in_type_1: diag(2324, ts.DiagnosticCategory.Error, "Property_0_is_missing_in_type_1_2324", "Property '{0}' is missing in type '{1}'."), + Property_0_is_private_in_type_1_but_not_in_type_2: diag(2325, ts.DiagnosticCategory.Error, "Property_0_is_private_in_type_1_but_not_in_type_2_2325", "Property '{0}' is private in type '{1}' but not in type '{2}'."), + Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."), + Property_0_is_optional_in_type_1_but_required_in_type_2: diag(2327, ts.DiagnosticCategory.Error, "Property_0_is_optional_in_type_1_but_required_in_type_2_2327", "Property '{0}' is optional in type '{1}' but required in type '{2}'."), + Types_of_parameters_0_and_1_are_incompatible: diag(2328, ts.DiagnosticCategory.Error, "Types_of_parameters_0_and_1_are_incompatible_2328", "Types of parameters '{0}' and '{1}' are incompatible."), + Index_signature_is_missing_in_type_0: diag(2329, ts.DiagnosticCategory.Error, "Index_signature_is_missing_in_type_0_2329", "Index signature is missing in type '{0}'."), + Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."), + this_cannot_be_referenced_in_a_module_or_namespace_body: diag(2331, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_module_or_namespace_body_2331", "'this' cannot be referenced in a module or namespace body."), + this_cannot_be_referenced_in_current_location: diag(2332, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_current_location_2332", "'this' cannot be referenced in current location."), + this_cannot_be_referenced_in_constructor_arguments: diag(2333, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_constructor_arguments_2333", "'this' cannot be referenced in constructor arguments."), + this_cannot_be_referenced_in_a_static_property_initializer: diag(2334, ts.DiagnosticCategory.Error, "this_cannot_be_referenced_in_a_static_property_initializer_2334", "'this' cannot be referenced in a static property initializer."), + super_can_only_be_referenced_in_a_derived_class: diag(2335, ts.DiagnosticCategory.Error, "super_can_only_be_referenced_in_a_derived_class_2335", "'super' can only be referenced in a derived class."), + super_cannot_be_referenced_in_constructor_arguments: diag(2336, ts.DiagnosticCategory.Error, "super_cannot_be_referenced_in_constructor_arguments_2336", "'super' cannot be referenced in constructor arguments."), + Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors: diag(2337, ts.DiagnosticCategory.Error, "Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors_2337", "Super calls are not permitted outside constructors or in nested functions inside constructors."), + super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class: diag(2338, ts.DiagnosticCategory.Error, "super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_der_2338", "'super' property access is permitted only in a constructor, member function, or member accessor of a derived class."), + Property_0_does_not_exist_on_type_1: diag(2339, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_2339", "Property '{0}' does not exist on type '{1}'."), + Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword: diag(2340, ts.DiagnosticCategory.Error, "Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword_2340", "Only public and protected methods of the base class are accessible via the 'super' keyword."), + Property_0_is_private_and_only_accessible_within_class_1: diag(2341, ts.DiagnosticCategory.Error, "Property_0_is_private_and_only_accessible_within_class_1_2341", "Property '{0}' is private and only accessible within class '{1}'."), + An_index_expression_argument_must_be_of_type_string_number_symbol_or_any: diag(2342, ts.DiagnosticCategory.Error, "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342", "An index expression argument must be of type 'string', 'number', 'symbol', or 'any'."), + This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0: diag(2343, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_ve_2343", "This syntax requires an imported helper named '{1}' which does not exist in '{0}'. Consider upgrading your version of '{0}'."), + Type_0_does_not_satisfy_the_constraint_1: diag(2344, ts.DiagnosticCategory.Error, "Type_0_does_not_satisfy_the_constraint_1_2344", "Type '{0}' does not satisfy the constraint '{1}'."), + Argument_of_type_0_is_not_assignable_to_parameter_of_type_1: diag(2345, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_2345", "Argument of type '{0}' is not assignable to parameter of type '{1}'."), + Call_target_does_not_contain_any_signatures: diag(2346, ts.DiagnosticCategory.Error, "Call_target_does_not_contain_any_signatures_2346", "Call target does not contain any signatures."), + Untyped_function_calls_may_not_accept_type_arguments: diag(2347, ts.DiagnosticCategory.Error, "Untyped_function_calls_may_not_accept_type_arguments_2347", "Untyped function calls may not accept type arguments."), + Value_of_type_0_is_not_callable_Did_you_mean_to_include_new: diag(2348, ts.DiagnosticCategory.Error, "Value_of_type_0_is_not_callable_Did_you_mean_to_include_new_2348", "Value of type '{0}' is not callable. Did you mean to include 'new'?"), + This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."), + Only_a_void_function_can_be_called_with_the_new_keyword: diag(2350, ts.DiagnosticCategory.Error, "Only_a_void_function_can_be_called_with_the_new_keyword_2350", "Only a void function can be called with the 'new' keyword."), + This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."), + Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the_other_If_this_was_intentional_convert_the_expression_to_unknown_first: diag(2352, ts.DiagnosticCategory.Error, "Conversion_of_type_0_to_type_1_may_be_a_mistake_because_neither_type_sufficiently_overlaps_with_the__2352", "Conversion of type '{0}' to type '{1}' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first."), + Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1: diag(2353, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1_2353", "Object literal may only specify known properties, and '{0}' does not exist in type '{1}'."), + This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found: diag(2354, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found_2354", "This syntax requires an imported helper but module '{0}' cannot be found."), + A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value: diag(2355, ts.DiagnosticCategory.Error, "A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value_2355", "A function whose declared type is neither 'void' nor 'any' must return a value."), + An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2356, ts.DiagnosticCategory.Error, "An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type_2356", "An arithmetic operand must be of type 'any', 'number', 'bigint' or an enum type."), + The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access: diag(2357, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access_2357", "The operand of an increment or decrement operator must be a variable or a property access."), + The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2358, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter."), + The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: diag(2359, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type."), + The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: diag(2360, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'."), + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter."), + The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2362, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2362", "The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type: diag(2363, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_bigint_or_an_enum_type_2363", "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."), + The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: diag(2364, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", "The left-hand side of an assignment expression must be a variable or a property access."), + Operator_0_cannot_be_applied_to_types_1_and_2: diag(2365, ts.DiagnosticCategory.Error, "Operator_0_cannot_be_applied_to_types_1_and_2_2365", "Operator '{0}' cannot be applied to types '{1}' and '{2}'."), + Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: diag(2366, ts.DiagnosticCategory.Error, "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", "Function lacks ending return statement and return type does not include 'undefined'."), + This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap: diag(2367, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap_2367", "This condition will always return '{0}' since the types '{1}' and '{2}' have no overlap."), + Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."), + A_parameter_property_is_only_allowed_in_a_constructor_implementation: diag(2369, ts.DiagnosticCategory.Error, "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", "A parameter property is only allowed in a constructor implementation."), + A_rest_parameter_must_be_of_an_array_type: diag(2370, ts.DiagnosticCategory.Error, "A_rest_parameter_must_be_of_an_array_type_2370", "A rest parameter must be of an array type."), + A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: diag(2371, ts.DiagnosticCategory.Error, "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", "A parameter initializer is only allowed in a function or constructor implementation."), + Parameter_0_cannot_be_referenced_in_its_initializer: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_be_referenced_in_its_initializer_2372", "Parameter '{0}' cannot be referenced in its initializer."), + Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Initializer of parameter '{0}' cannot reference identifier '{1}' declared after it."), + Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."), + Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."), + A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_proper_2376", "A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties."), + Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."), + A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."), + Getter_and_setter_accessors_do_not_agree_in_visibility: diag(2379, ts.DiagnosticCategory.Error, "Getter_and_setter_accessors_do_not_agree_in_visibility_2379", "Getter and setter accessors do not agree in visibility."), + get_and_set_accessor_must_have_the_same_type: diag(2380, ts.DiagnosticCategory.Error, "get_and_set_accessor_must_have_the_same_type_2380", "'get' and 'set' accessor must have the same type."), + A_signature_with_an_implementation_cannot_use_a_string_literal_type: diag(2381, ts.DiagnosticCategory.Error, "A_signature_with_an_implementation_cannot_use_a_string_literal_type_2381", "A signature with an implementation cannot use a string literal type."), + Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature: diag(2382, ts.DiagnosticCategory.Error, "Specialized_overload_signature_is_not_assignable_to_any_non_specialized_signature_2382", "Specialized overload signature is not assignable to any non-specialized signature."), + Overload_signatures_must_all_be_exported_or_non_exported: diag(2383, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_exported_or_non_exported_2383", "Overload signatures must all be exported or non-exported."), + Overload_signatures_must_all_be_ambient_or_non_ambient: diag(2384, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_ambient_or_non_ambient_2384", "Overload signatures must all be ambient or non-ambient."), + Overload_signatures_must_all_be_public_private_or_protected: diag(2385, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_public_private_or_protected_2385", "Overload signatures must all be public, private or protected."), + Overload_signatures_must_all_be_optional_or_required: diag(2386, ts.DiagnosticCategory.Error, "Overload_signatures_must_all_be_optional_or_required_2386", "Overload signatures must all be optional or required."), + Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."), + Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."), + Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."), + Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."), + Function_implementation_is_missing_or_not_immediately_following_the_declaration: diag(2391, ts.DiagnosticCategory.Error, "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391", "Function implementation is missing or not immediately following the declaration."), + Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."), + Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."), This_overload_signature_is_not_compatible_with_its_implementation_signature: diag(2394, ts.DiagnosticCategory.Error, "This_overload_signature_is_not_compatible_with_its_implementation_signature_2394", "This overload signature is not compatible with its implementation signature."), Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local: diag(2395, ts.DiagnosticCategory.Error, "Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local_2395", "Individual declarations in merged declaration '{0}' must be all exported or all local."), Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters: diag(2396, ts.DiagnosticCategory.Error, "Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters_2396", "Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters."), @@ -5835,7 +6622,6 @@ var ts; Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."), A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members: diag(2422, ts.DiagnosticCategory.Error, "A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_memb_2422", "A class can only implement an object type or intersection of object types with statically known members."), Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2423, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_access_2423", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member accessor."), - Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2424, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property."), Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2425, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_functi_2425", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member function."), Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function: diag(2426, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_functi_2426", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member function."), Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."), @@ -6005,6 +6791,11 @@ var ts; JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: diag(2607, ts.DiagnosticCategory.Error, "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", "JSX element class does not support attributes because it does not have a '{0}' property."), The_global_type_JSX_0_may_not_have_more_than_one_property: diag(2608, ts.DiagnosticCategory.Error, "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", "The global type 'JSX.{0}' may not have more than one property."), JSX_spread_child_must_be_an_array_type: diag(2609, ts.DiagnosticCategory.Error, "JSX_spread_child_must_be_an_array_type_2609", "JSX spread child must be an array type."), + Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property: diag(2610, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_proper_2610", "Class '{0}' defines instance member accessor '{1}', but extended class '{2}' defines it as instance member property."), + Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor: diag(2611, ts.DiagnosticCategory.Error, "Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_access_2611", "Class '{0}' defines instance member property '{1}', but extended class '{2}' defines it as instance member accessor."), + Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration: diag(2612, ts.DiagnosticCategory.Error, "Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_2612", "Property '{0}' will overwrite the base property in '{1}'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration."), + Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead: diag(2613, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead_2613", "Module '{0}' has no default export. Did you mean to use 'import { {1} } from {0}' instead?"), + Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead: diag(2614, ts.DiagnosticCategory.Error, "Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead_2614", "Module '{0}' has no exported member '{1}'. Did you mean to use 'import {1} from {0}' instead?"), Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: diag(2649, ts.DiagnosticCategory.Error, "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", "Cannot augment module '{0}' with value exports because it resolves to a non-module entity."), A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: diag(2651, ts.DiagnosticCategory.Error, "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums."), Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: diag(2652, ts.DiagnosticCategory.Error, "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead."), @@ -6127,6 +6918,14 @@ var ts; The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."), Overload_0_of_1_2_gave_the_following_error: diag(2772, ts.DiagnosticCategory.Error, "Overload_0_of_1_2_gave_the_following_error_2772", "Overload {0} of {1}, '{2}', gave the following error."), Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"), + This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead: diag(2774, ts.DiagnosticCategory.Error, "This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it__2774", "This condition will always return true since the function is always defined. Did you mean to call it instead?"), + Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation: diag(2775, ts.DiagnosticCategory.Error, "Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation_2775", "Assertions require every name in the call target to be declared with an explicit type annotation."), + Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name: diag(2776, ts.DiagnosticCategory.Error, "Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name_2776", "Assertions require the call target to be an identifier or qualified name."), + The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access: diag(2777, ts.DiagnosticCategory.Error, "The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access_2777", "The operand of an increment or decrement operator may not be an optional property access."), + The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access: diag(2778, ts.DiagnosticCategory.Error, "The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access_2778", "The target of an object rest assignment may not be an optional property access."), + The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access: diag(2779, ts.DiagnosticCategory.Error, "The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access_2779", "The left-hand side of an assignment expression may not be an optional property access."), + The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access: diag(2780, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access_2780", "The left-hand side of a 'for...in' statement may not be an optional property access."), + The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access: diag(2781, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access_2781", "The left-hand side of a 'for...of' statement may not be an optional property access."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -6213,6 +7012,11 @@ var ts; Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1: diag(4103, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1_4103", "Type parameter '{0}' of exported mapped object type is using private name '{1}'."), The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1: diag(4104, ts.DiagnosticCategory.Error, "The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1_4104", "The type '{0}' is 'readonly' and cannot be assigned to the mutable type '{1}'."), Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter: diag(4105, ts.DiagnosticCategory.Error, "Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter_4105", "Private or protected member '{0}' cannot be accessed on a type parameter."), + Parameter_0_of_accessor_has_or_is_using_private_name_1: diag(4106, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_private_name_1_4106", "Parameter '{0}' of accessor has or is using private name '{1}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2: diag(4107, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2_4107", "Parameter '{0}' of accessor has or is using name '{1}' from private module '{2}'."), + Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: diag(4108, ts.DiagnosticCategory.Error, "Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named_4108", "Parameter '{0}' of accessor has or is using name '{1}' from external module '{2}' but cannot be named."), + Type_arguments_for_0_circularly_reference_themselves: diag(4109, ts.DiagnosticCategory.Error, "Type_arguments_for_0_circularly_reference_themselves_4109", "Type arguments for '{0}' circularly reference themselves."), + Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."), The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."), Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."), File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."), @@ -6223,6 +7027,7 @@ var ts; Could_not_write_file_0_Colon_1: diag(5033, ts.DiagnosticCategory.Error, "Could_not_write_file_0_Colon_1_5033", "Could not write file '{0}': {1}."), Option_project_cannot_be_mixed_with_source_files_on_a_command_line: diag(5042, ts.DiagnosticCategory.Error, "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", "Option 'project' cannot be mixed with source files on a command line."), Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: diag(5047, ts.DiagnosticCategory.Error, "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher."), + Option_0_cannot_be_specified_when_option_target_is_ES3: diag(5048, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_when_option_target_is_ES3_5048", "Option '{0}' cannot be specified when option 'target' is 'ES3'."), Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: diag(5051, ts.DiagnosticCategory.Error, "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided."), Option_0_cannot_be_specified_without_specifying_option_1: diag(5052, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_without_specifying_option_1_5052", "Option '{0}' cannot be specified without specifying option '{1}'."), Option_0_cannot_be_specified_with_option_1: diag(5053, ts.DiagnosticCategory.Error, "Option_0_cannot_be_specified_with_option_1_5053", "Option '{0}' cannot be specified with option '{1}'."), @@ -6248,6 +7053,7 @@ var ts; Build_option_0_requires_a_value_of_type_1: diag(5073, ts.DiagnosticCategory.Error, "Build_option_0_requires_a_value_of_type_1_5073", "Build option '{0}' requires a value of type {1}."), Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified: diag(5074, ts.DiagnosticCategory.Error, "Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBui_5074", "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified."), _0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2: diag(5075, ts.DiagnosticCategory.Error, "_0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_5075", "'{0}' is assignable to the constraint of type '{1}', but '{1}' could be instantiated with a different subtype of constraint '{2}'."), + _0_and_1_operations_cannot_be_mixed_without_parentheses: diag(5076, ts.DiagnosticCategory.Error, "_0_and_1_operations_cannot_be_mixed_without_parentheses_5076", "'{0}' and '{1}' operations cannot be mixed without parentheses."), Generates_a_sourcemap_for_each_corresponding_d_ts_file: diag(6000, ts.DiagnosticCategory.Message, "Generates_a_sourcemap_for_each_corresponding_d_ts_file_6000", "Generates a sourcemap for each corresponding '.d.ts' file."), Concatenate_and_emit_output_to_single_file: diag(6001, ts.DiagnosticCategory.Message, "Concatenate_and_emit_output_to_single_file_6001", "Concatenate and emit output to single file."), Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."), @@ -6435,6 +7241,7 @@ var ts; All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", /*reportsUnnecessary*/ true), Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0: diag(6200, ts.DiagnosticCategory.Error, "Definitions_of_the_following_identifiers_conflict_with_those_in_another_file_Colon_0_6200", "Definitions of the following identifiers conflict with those in another file: {0}"), Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."), + Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."), and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."), All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused"), @@ -6453,9 +7260,11 @@ var ts; Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2: diag(6218, ts.DiagnosticCategory.Message, "Module_name_0_was_successfully_resolved_to_1_with_Package_ID_2_6218", "======== Module name '{0}' was successfully resolved to '{1}' with Package ID '{2}'. ========"), Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3: diag(6219, ts.DiagnosticCategory.Message, "Type_reference_directive_0_was_successfully_resolved_to_1_with_Package_ID_2_primary_Colon_3_6219", "======== Type reference directive '{0}' was successfully resolved to '{1}' with Package ID '{2}', primary: {3}. ========"), package_json_had_a_falsy_0_field: diag(6220, ts.DiagnosticCategory.Message, "package_json_had_a_falsy_0_field_6220", "'package.json' had a falsy '{0}' field."), + Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects: diag(6221, ts.DiagnosticCategory.Message, "Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects_6221", "Disable use of source files instead of declaration files from referenced projects."), + Emit_class_fields_with_Define_instead_of_Set: diag(6222, ts.DiagnosticCategory.Message, "Emit_class_fields_with_Define_instead_of_Set_6222", "Emit class fields with Define instead of Set."), + Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."), Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"), Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"), - Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0: diag(6202, ts.DiagnosticCategory.Error, "Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0_6202", "Project references may not form a circular graph. Cycle detected: {0}"), Composite_projects_may_not_disable_declaration_emit: diag(6304, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_declaration_emit_6304", "Composite projects may not disable declaration emit."), Output_file_0_has_not_been_built_from_source_file_1: diag(6305, ts.DiagnosticCategory.Error, "Output_file_0_has_not_been_built_from_source_file_1_6305", "Output file '{0}' has not been built from source file '{1}'."), Referenced_project_0_must_have_setting_composite_Colon_true: diag(6306, ts.DiagnosticCategory.Error, "Referenced_project_0_must_have_setting_composite_Colon_true_6306", "Referenced project '{0}' must have setting \"composite\": true."), @@ -6494,9 +7303,12 @@ var ts; Composite_projects_may_not_disable_incremental_compilation: diag(6379, ts.DiagnosticCategory.Error, "Composite_projects_may_not_disable_incremental_compilation_6379", "Composite projects may not disable incremental compilation."), Specify_file_to_store_incremental_compilation_information: diag(6380, ts.DiagnosticCategory.Message, "Specify_file_to_store_incremental_compilation_information_6380", "Specify file to store incremental compilation information"), Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2: diag(6381, ts.DiagnosticCategory.Message, "Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_curren_6381", "Project '{0}' is out of date because output for it was generated with version '{1}' that differs with current version '{2}'"), + Skipping_build_of_project_0_because_its_dependency_1_was_not_built: diag(6382, ts.DiagnosticCategory.Message, "Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382", "Skipping build of project '{0}' because its dependency '{1}' was not built"), + Project_0_can_t_be_built_because_its_dependency_1_was_not_built: diag(6383, ts.DiagnosticCategory.Message, "Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383", "Project '{0}' can't be built because its dependency '{1}' was not built"), The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1: diag(6500, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_property_0_which_is_declared_here_on_type_1_6500", "The expected type comes from property '{0}' which is declared here on type '{1}'"), The_expected_type_comes_from_this_index_signature: diag(6501, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_this_index_signature_6501", "The expected type comes from this index signature."), The_expected_type_comes_from_the_return_type_of_this_signature: diag(6502, ts.DiagnosticCategory.Message, "The_expected_type_comes_from_the_return_type_of_this_signature_6502", "The expected type comes from the return type of this signature."), + Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing: diag(6503, ts.DiagnosticCategory.Message, "Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing_6503", "Print names of files that are part of the compilation and then stop processing."), Variable_0_implicitly_has_an_1_type: diag(7005, ts.DiagnosticCategory.Error, "Variable_0_implicitly_has_an_1_type_7005", "Variable '{0}' implicitly has an '{1}' type."), Parameter_0_implicitly_has_an_1_type: diag(7006, ts.DiagnosticCategory.Error, "Parameter_0_implicitly_has_an_1_type_7006", "Parameter '{0}' implicitly has an '{1}' type."), Member_0_implicitly_has_an_1_type: diag(7008, ts.DiagnosticCategory.Error, "Member_0_implicitly_has_an_1_type_7008", "Member '{0}' implicitly has an '{1}' type."), @@ -6580,6 +7392,8 @@ var ts; Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), + Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."), + Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."), JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."), JSX_elements_cannot_have_multiple_attributes_with_the_same_name: diag(17001, ts.DiagnosticCategory.Error, "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001", "JSX elements cannot have multiple attributes with the same name."), Expected_corresponding_JSX_closing_tag_for_0: diag(17002, ts.DiagnosticCategory.Error, "Expected_corresponding_JSX_closing_tag_for_0_17002", "Expected corresponding JSX closing tag for '{0}'."), @@ -6609,6 +7423,7 @@ var ts; require_call_may_be_converted_to_an_import: diag(80005, ts.DiagnosticCategory.Suggestion, "require_call_may_be_converted_to_an_import_80005", "'require' call may be converted to an import."), This_may_be_converted_to_an_async_function: diag(80006, ts.DiagnosticCategory.Suggestion, "This_may_be_converted_to_an_async_function_80006", "This may be converted to an async function."), await_has_no_effect_on_the_type_of_this_expression: diag(80007, ts.DiagnosticCategory.Suggestion, "await_has_no_effect_on_the_type_of_this_expression_80007", "'await' has no effect on the type of this expression."), + Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers: diag(80008, ts.DiagnosticCategory.Suggestion, "Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accur_80008", "Numeric literals with absolute values equal to 2^53 or greater are too large to be represented accurately as integers."), Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"), Make_super_call_the_first_statement_in_the_constructor: diag(90002, ts.DiagnosticCategory.Message, "Make_super_call_the_first_statement_in_the_constructor_90002", "Make 'super()' call the first statement in the constructor"), Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"), @@ -6726,6 +7541,14 @@ var ts; Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"), Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"), Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"), + Enable_the_jsx_flag_in_your_configuration_file: diag(95088, ts.DiagnosticCategory.Message, "Enable_the_jsx_flag_in_your_configuration_file_95088", "Enable the '--jsx' flag in your configuration file"), + Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"), + Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"), + Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"), + Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"), + Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"), + Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"), + Prefix_all_incorrect_property_declarations_with_declare: diag(95095, ts.DiagnosticCategory.Message, "Prefix_all_incorrect_property_declarations_with_declare_95095", "Prefix all incorrect property declarations with 'declare'"), No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."), Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."), JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"), @@ -6736,94 +7559,95 @@ var ts; var _a; /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 73 /* Identifier */; + return token >= 75 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; /* @internal */ function tokenIsIdentifierOrKeywordOrGreaterThan(token) { - return token === 30 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); + return token === 31 /* GreaterThanToken */ || tokenIsIdentifierOrKeyword(token); } ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan; var textToKeywordObj = (_a = { - abstract: 119 /* AbstractKeyword */, - any: 121 /* AnyKeyword */, - as: 120 /* AsKeyword */, - bigint: 147 /* BigIntKeyword */, - boolean: 124 /* BooleanKeyword */, - break: 74 /* BreakKeyword */, - case: 75 /* CaseKeyword */, - catch: 76 /* CatchKeyword */, - class: 77 /* ClassKeyword */, - continue: 79 /* ContinueKeyword */, - const: 78 /* ConstKeyword */ + abstract: 121 /* AbstractKeyword */, + any: 124 /* AnyKeyword */, + as: 122 /* AsKeyword */, + asserts: 123 /* AssertsKeyword */, + bigint: 150 /* BigIntKeyword */, + boolean: 127 /* BooleanKeyword */, + break: 76 /* BreakKeyword */, + case: 77 /* CaseKeyword */, + catch: 78 /* CatchKeyword */, + class: 79 /* ClassKeyword */, + continue: 81 /* ContinueKeyword */, + const: 80 /* ConstKeyword */ }, - _a["" + "constructor"] = 125 /* ConstructorKeyword */, - _a.debugger = 80 /* DebuggerKeyword */, - _a.declare = 126 /* DeclareKeyword */, - _a.default = 81 /* DefaultKeyword */, - _a.delete = 82 /* DeleteKeyword */, - _a.do = 83 /* DoKeyword */, - _a.else = 84 /* ElseKeyword */, - _a.enum = 85 /* EnumKeyword */, - _a.export = 86 /* ExportKeyword */, - _a.extends = 87 /* ExtendsKeyword */, - _a.false = 88 /* FalseKeyword */, - _a.finally = 89 /* FinallyKeyword */, - _a.for = 90 /* ForKeyword */, - _a.from = 145 /* FromKeyword */, - _a.function = 91 /* FunctionKeyword */, - _a.get = 127 /* GetKeyword */, - _a.if = 92 /* IfKeyword */, - _a.implements = 110 /* ImplementsKeyword */, - _a.import = 93 /* ImportKeyword */, - _a.in = 94 /* InKeyword */, - _a.infer = 128 /* InferKeyword */, - _a.instanceof = 95 /* InstanceOfKeyword */, - _a.interface = 111 /* InterfaceKeyword */, - _a.is = 129 /* IsKeyword */, - _a.keyof = 130 /* KeyOfKeyword */, - _a.let = 112 /* LetKeyword */, - _a.module = 131 /* ModuleKeyword */, - _a.namespace = 132 /* NamespaceKeyword */, - _a.never = 133 /* NeverKeyword */, - _a.new = 96 /* NewKeyword */, - _a.null = 97 /* NullKeyword */, - _a.number = 136 /* NumberKeyword */, - _a.object = 137 /* ObjectKeyword */, - _a.package = 113 /* PackageKeyword */, - _a.private = 114 /* PrivateKeyword */, - _a.protected = 115 /* ProtectedKeyword */, - _a.public = 116 /* PublicKeyword */, - _a.readonly = 134 /* ReadonlyKeyword */, - _a.require = 135 /* RequireKeyword */, - _a.global = 146 /* GlobalKeyword */, - _a.return = 98 /* ReturnKeyword */, - _a.set = 138 /* SetKeyword */, - _a.static = 117 /* StaticKeyword */, - _a.string = 139 /* StringKeyword */, - _a.super = 99 /* SuperKeyword */, - _a.switch = 100 /* SwitchKeyword */, - _a.symbol = 140 /* SymbolKeyword */, - _a.this = 101 /* ThisKeyword */, - _a.throw = 102 /* ThrowKeyword */, - _a.true = 103 /* TrueKeyword */, - _a.try = 104 /* TryKeyword */, - _a.type = 141 /* TypeKeyword */, - _a.typeof = 105 /* TypeOfKeyword */, - _a.undefined = 142 /* UndefinedKeyword */, - _a.unique = 143 /* UniqueKeyword */, - _a.unknown = 144 /* UnknownKeyword */, - _a.var = 106 /* VarKeyword */, - _a.void = 107 /* VoidKeyword */, - _a.while = 108 /* WhileKeyword */, - _a.with = 109 /* WithKeyword */, - _a.yield = 118 /* YieldKeyword */, - _a.async = 122 /* AsyncKeyword */, - _a.await = 123 /* AwaitKeyword */, - _a.of = 148 /* OfKeyword */, + _a["" + "constructor"] = 128 /* ConstructorKeyword */, + _a.debugger = 82 /* DebuggerKeyword */, + _a.declare = 129 /* DeclareKeyword */, + _a.default = 83 /* DefaultKeyword */, + _a.delete = 84 /* DeleteKeyword */, + _a.do = 85 /* DoKeyword */, + _a.else = 86 /* ElseKeyword */, + _a.enum = 87 /* EnumKeyword */, + _a.export = 88 /* ExportKeyword */, + _a.extends = 89 /* ExtendsKeyword */, + _a.false = 90 /* FalseKeyword */, + _a.finally = 91 /* FinallyKeyword */, + _a.for = 92 /* ForKeyword */, + _a.from = 148 /* FromKeyword */, + _a.function = 93 /* FunctionKeyword */, + _a.get = 130 /* GetKeyword */, + _a.if = 94 /* IfKeyword */, + _a.implements = 112 /* ImplementsKeyword */, + _a.import = 95 /* ImportKeyword */, + _a.in = 96 /* InKeyword */, + _a.infer = 131 /* InferKeyword */, + _a.instanceof = 97 /* InstanceOfKeyword */, + _a.interface = 113 /* InterfaceKeyword */, + _a.is = 132 /* IsKeyword */, + _a.keyof = 133 /* KeyOfKeyword */, + _a.let = 114 /* LetKeyword */, + _a.module = 134 /* ModuleKeyword */, + _a.namespace = 135 /* NamespaceKeyword */, + _a.never = 136 /* NeverKeyword */, + _a.new = 98 /* NewKeyword */, + _a.null = 99 /* NullKeyword */, + _a.number = 139 /* NumberKeyword */, + _a.object = 140 /* ObjectKeyword */, + _a.package = 115 /* PackageKeyword */, + _a.private = 116 /* PrivateKeyword */, + _a.protected = 117 /* ProtectedKeyword */, + _a.public = 118 /* PublicKeyword */, + _a.readonly = 137 /* ReadonlyKeyword */, + _a.require = 138 /* RequireKeyword */, + _a.global = 149 /* GlobalKeyword */, + _a.return = 100 /* ReturnKeyword */, + _a.set = 141 /* SetKeyword */, + _a.static = 119 /* StaticKeyword */, + _a.string = 142 /* StringKeyword */, + _a.super = 101 /* SuperKeyword */, + _a.switch = 102 /* SwitchKeyword */, + _a.symbol = 143 /* SymbolKeyword */, + _a.this = 103 /* ThisKeyword */, + _a.throw = 104 /* ThrowKeyword */, + _a.true = 105 /* TrueKeyword */, + _a.try = 106 /* TryKeyword */, + _a.type = 144 /* TypeKeyword */, + _a.typeof = 107 /* TypeOfKeyword */, + _a.undefined = 145 /* UndefinedKeyword */, + _a.unique = 146 /* UniqueKeyword */, + _a.unknown = 147 /* UnknownKeyword */, + _a.var = 108 /* VarKeyword */, + _a.void = 109 /* VoidKeyword */, + _a.while = 110 /* WhileKeyword */, + _a.with = 111 /* WithKeyword */, + _a.yield = 120 /* YieldKeyword */, + _a.async = 125 /* AsyncKeyword */, + _a.await = 126 /* AwaitKeyword */, + _a.of = 151 /* OfKeyword */, _a); var textToKeyword = ts.createMapFromTemplate(textToKeywordObj); - var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 28 /* LessThanToken */, ">": 30 /* GreaterThanToken */, "<=": 31 /* LessThanEqualsToken */, ">=": 32 /* GreaterThanEqualsToken */, "==": 33 /* EqualsEqualsToken */, "!=": 34 /* ExclamationEqualsToken */, "===": 35 /* EqualsEqualsEqualsToken */, "!==": 36 /* ExclamationEqualsEqualsToken */, "=>": 37 /* EqualsGreaterThanToken */, "+": 38 /* PlusToken */, "-": 39 /* MinusToken */, "**": 41 /* AsteriskAsteriskToken */, "*": 40 /* AsteriskToken */, "/": 42 /* SlashToken */, "%": 43 /* PercentToken */, "++": 44 /* PlusPlusToken */, "--": 45 /* MinusMinusToken */, "<<": 46 /* LessThanLessThanToken */, ">": 47 /* GreaterThanGreaterThanToken */, ">>>": 48 /* GreaterThanGreaterThanGreaterThanToken */, "&": 49 /* AmpersandToken */, "|": 50 /* BarToken */, "^": 51 /* CaretToken */, "!": 52 /* ExclamationToken */, "~": 53 /* TildeToken */, "&&": 54 /* AmpersandAmpersandToken */, "||": 55 /* BarBarToken */, "?": 56 /* QuestionToken */, ":": 57 /* ColonToken */, "=": 60 /* EqualsToken */, "+=": 61 /* PlusEqualsToken */, "-=": 62 /* MinusEqualsToken */, "*=": 63 /* AsteriskEqualsToken */, "**=": 64 /* AsteriskAsteriskEqualsToken */, "/=": 65 /* SlashEqualsToken */, "%=": 66 /* PercentEqualsToken */, "<<=": 67 /* LessThanLessThanEqualsToken */, ">>=": 68 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 70 /* AmpersandEqualsToken */, "|=": 71 /* BarEqualsToken */, "^=": 72 /* CaretEqualsToken */, "@": 58 /* AtToken */, "`": 59 /* BacktickToken */ })); + var textToToken = ts.createMapFromTemplate(__assign(__assign({}, textToKeywordObj), { "{": 18 /* OpenBraceToken */, "}": 19 /* CloseBraceToken */, "(": 20 /* OpenParenToken */, ")": 21 /* CloseParenToken */, "[": 22 /* OpenBracketToken */, "]": 23 /* CloseBracketToken */, ".": 24 /* DotToken */, "...": 25 /* DotDotDotToken */, ";": 26 /* SemicolonToken */, ",": 27 /* CommaToken */, "<": 29 /* LessThanToken */, ">": 31 /* GreaterThanToken */, "<=": 32 /* LessThanEqualsToken */, ">=": 33 /* GreaterThanEqualsToken */, "==": 34 /* EqualsEqualsToken */, "!=": 35 /* ExclamationEqualsToken */, "===": 36 /* EqualsEqualsEqualsToken */, "!==": 37 /* ExclamationEqualsEqualsToken */, "=>": 38 /* EqualsGreaterThanToken */, "+": 39 /* PlusToken */, "-": 40 /* MinusToken */, "**": 42 /* AsteriskAsteriskToken */, "*": 41 /* AsteriskToken */, "/": 43 /* SlashToken */, "%": 44 /* PercentToken */, "++": 45 /* PlusPlusToken */, "--": 46 /* MinusMinusToken */, "<<": 47 /* LessThanLessThanToken */, ">": 48 /* GreaterThanGreaterThanToken */, ">>>": 49 /* GreaterThanGreaterThanGreaterThanToken */, "&": 50 /* AmpersandToken */, "|": 51 /* BarToken */, "^": 52 /* CaretToken */, "!": 53 /* ExclamationToken */, "~": 54 /* TildeToken */, "&&": 55 /* AmpersandAmpersandToken */, "||": 56 /* BarBarToken */, "?": 57 /* QuestionToken */, "??": 60 /* QuestionQuestionToken */, "?.": 28 /* QuestionDotToken */, ":": 58 /* ColonToken */, "=": 62 /* EqualsToken */, "+=": 63 /* PlusEqualsToken */, "-=": 64 /* MinusEqualsToken */, "*=": 65 /* AsteriskEqualsToken */, "**=": 66 /* AsteriskAsteriskEqualsToken */, "/=": 67 /* SlashEqualsToken */, "%=": 68 /* PercentEqualsToken */, "<<=": 69 /* LessThanLessThanEqualsToken */, ">>=": 70 /* GreaterThanGreaterThanEqualsToken */, ">>>=": 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */, "&=": 72 /* AmpersandEqualsToken */, "|=": 73 /* BarEqualsToken */, "^=": 74 /* CaretEqualsToken */, "@": 59 /* AtToken */, "`": 61 /* BacktickToken */ })); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers IdentifierStart :: @@ -7087,6 +7911,7 @@ var ts; case 32 /* space */: case 47 /* slash */: // starts of normal trivia + // falls through case 60 /* lessThan */: case 124 /* bar */: case 61 /* equals */: @@ -7439,7 +8264,7 @@ var ts; var tokenFlags; var inJSDocType = 0; setText(text, start, length); - return { + var scanner = { getStartPos: function () { return startPos; }, getTextPos: function () { return pos; }, getToken: function () { return token; }, @@ -7449,8 +8274,8 @@ var ts; hasUnicodeEscape: function () { return (tokenFlags & 1024 /* UnicodeEscape */) !== 0; }, hasExtendedUnicodeEscape: function () { return (tokenFlags & 8 /* ExtendedUnicodeEscape */) !== 0; }, hasPrecedingLineBreak: function () { return (tokenFlags & 1 /* PrecedingLineBreak */) !== 0; }, - isIdentifier: function () { return token === 73 /* Identifier */ || token > 109 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */; }, + isIdentifier: function () { return token === 75 /* Identifier */ || token > 111 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */; }, isUnterminated: function () { return (tokenFlags & 4 /* Unterminated */) !== 0; }, getTokenFlags: function () { return tokenFlags; }, reScanGreaterToken: reScanGreaterToken, @@ -7460,6 +8285,7 @@ var ts; scanJsxAttributeValue: scanJsxAttributeValue, reScanJsxToken: reScanJsxToken, reScanLessThanToken: reScanLessThanToken, + reScanQuestionToken: reScanQuestionToken, scanJsxToken: scanJsxToken, scanJsDocToken: scanJsDocToken, scan: scan, @@ -7474,6 +8300,15 @@ var ts; lookAhead: lookAhead, scanRange: scanRange, }; + if (ts.Debug.isDebugging) { + Object.defineProperty(scanner, "__debugShowCurrentPositionInText", { + get: function () { + var text = scanner.getText(); + return text.slice(0, scanner.getStartPos()) + "║" + text.slice(scanner.getStartPos()); + }, + }); + } + return scanner; function error(message, errPos, length) { if (errPos === void 0) { errPos = pos; } if (onError) { @@ -7922,7 +8757,7 @@ var ts; } } } - return token = 73 /* Identifier */; + return token = 75 /* Identifier */; } function scanBinaryOrOctalDigits(base) { var value = ""; @@ -7986,7 +8821,7 @@ var ts; function scan() { var _a; startPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; var asteriskSeen = false; while (true) { tokenPos = pos; @@ -8057,12 +8892,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 36 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 37 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 34 /* ExclamationEqualsToken */; + return pos += 2, token = 35 /* ExclamationEqualsToken */; } pos++; - return token = 52 /* ExclamationToken */; + return token = 53 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -8071,19 +8906,19 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 66 /* PercentEqualsToken */; + return pos += 2, token = 68 /* PercentEqualsToken */; } pos++; - return token = 43 /* PercentToken */; + return token = 44 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 54 /* AmpersandAmpersandToken */; + return pos += 2, token = 55 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 70 /* AmpersandEqualsToken */; + return pos += 2, token = 72 /* AmpersandEqualsToken */; } pos++; - return token = 49 /* AmpersandToken */; + return token = 50 /* AmpersandToken */; case 40 /* openParen */: pos++; return token = 20 /* OpenParenToken */; @@ -8092,13 +8927,13 @@ var ts; return token = 21 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* AsteriskEqualsToken */; + return pos += 2, token = 65 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 66 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 41 /* AsteriskAsteriskToken */; + return pos += 2, token = 42 /* AsteriskAsteriskToken */; } pos++; if (inJSDocType && !asteriskSeen && (tokenFlags & 1 /* PrecedingLineBreak */)) { @@ -8106,28 +8941,28 @@ var ts; asteriskSeen = true; continue; } - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 44 /* PlusPlusToken */; + return pos += 2, token = 45 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 61 /* PlusEqualsToken */; + return pos += 2, token = 63 /* PlusEqualsToken */; } pos++; - return token = 38 /* PlusToken */; + return token = 39 /* PlusToken */; case 44 /* comma */: pos++; return token = 27 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 45 /* MinusMinusToken */; + return pos += 2, token = 46 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* MinusEqualsToken */; + return pos += 2, token = 64 /* MinusEqualsToken */; } pos++; - return token = 39 /* MinusToken */; + return token = 40 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber().value; @@ -8188,10 +9023,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* SlashEqualsToken */; + return pos += 2, token = 67 /* SlashEqualsToken */; } pos++; - return token = 42 /* SlashToken */; + return token = 43 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -8249,7 +9084,7 @@ var ts; return token; case 58 /* colon */: pos++; - return token = 57 /* ColonToken */; + return token = 58 /* ColonToken */; case 59 /* semicolon */: pos++; return token = 26 /* SemicolonToken */; @@ -8265,20 +9100,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 67 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 69 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 46 /* LessThanLessThanToken */; + return pos += 2, token = 47 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 31 /* LessThanEqualsToken */; + return pos += 2, token = 32 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 29 /* LessThanSlashToken */; + return pos += 2, token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8291,15 +9126,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 35 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 36 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 33 /* EqualsEqualsToken */; + return pos += 2, token = 34 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 37 /* EqualsGreaterThanToken */; + return pos += 2, token = 38 /* EqualsGreaterThanToken */; } pos++; - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -8311,10 +9146,18 @@ var ts; } } pos++; - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 56 /* QuestionToken */; + if (text.charCodeAt(pos) === 46 /* dot */ && !isDigit(text.charCodeAt(pos + 1))) { + pos++; + return token = 28 /* QuestionDotToken */; + } + if (text.charCodeAt(pos) === 63 /* question */) { + pos++; + return token = 60 /* QuestionQuestionToken */; + } + return token = 57 /* QuestionToken */; case 91 /* openBracket */: pos++; return token = 22 /* OpenBracketToken */; @@ -8323,10 +9166,10 @@ var ts; return token = 23 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 72 /* CaretEqualsToken */; + return pos += 2, token = 74 /* CaretEqualsToken */; } pos++; - return token = 51 /* CaretToken */; + return token = 52 /* CaretToken */; case 123 /* openBrace */: pos++; return token = 18 /* OpenBraceToken */; @@ -8341,22 +9184,22 @@ var ts; } } if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 55 /* BarBarToken */; + return pos += 2, token = 56 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 71 /* BarEqualsToken */; + return pos += 2, token = 73 /* BarEqualsToken */; } pos++; - return token = 50 /* BarToken */; + return token = 51 /* BarToken */; case 125 /* closeBrace */: pos++; return token = 19 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 53 /* TildeToken */; + return token = 54 /* TildeToken */; case 64 /* at */: pos++; - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 92 /* backslash */: var extendedCookedChar = peekExtendedUnicodeEscape(); if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) { @@ -8402,29 +9245,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 30 /* GreaterThanToken */) { + if (token === 31 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 48 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 49 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 70 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 47 /* GreaterThanGreaterThanToken */; + return token = 48 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 32 /* GreaterThanEqualsToken */; + return token = 33 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 42 /* SlashToken */ || token === 65 /* SlashEqualsToken */) { + if (token === 43 /* SlashToken */ || token === 67 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -8486,12 +9329,17 @@ var ts; return token = scanJsxToken(); } function reScanLessThanToken() { - if (token === 46 /* LessThanLessThanToken */) { + if (token === 47 /* LessThanLessThanToken */) { pos = tokenPos + 1; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } return token; } + function reScanQuestionToken() { + ts.Debug.assert(token === 60 /* QuestionQuestionToken */, "'reScanQuestionToken' should only be called on a '??'"); + pos = tokenPos + 1; + return token = 57 /* QuestionToken */; + } function scanJsxToken() { startPos = tokenPos = pos; if (pos >= end) { @@ -8501,10 +9349,10 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 29 /* LessThanSlashToken */; + return token = 30 /* LessThanSlashToken */; } pos++; - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; @@ -8580,7 +9428,7 @@ var ts; } function scanJsDocToken() { startPos = tokenPos = pos; - tokenFlags = 0; + tokenFlags = 0 /* None */; if (pos >= end) { return token = 1 /* EndOfFileToken */; } @@ -8596,13 +9444,13 @@ var ts; } return token = 5 /* WhitespaceTrivia */; case 64 /* at */: - return token = 58 /* AtToken */; + return token = 59 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: tokenFlags |= 1 /* PrecedingLineBreak */; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: - return token = 40 /* AsteriskToken */; + return token = 41 /* AsteriskToken */; case 123 /* openBrace */: return token = 18 /* OpenBraceToken */; case 125 /* closeBrace */: @@ -8612,17 +9460,17 @@ var ts; case 93 /* closeBracket */: return token = 23 /* CloseBracketToken */; case 60 /* lessThan */: - return token = 28 /* LessThanToken */; + return token = 29 /* LessThanToken */; case 62 /* greaterThan */: - return token = 30 /* GreaterThanToken */; + return token = 31 /* GreaterThanToken */; case 61 /* equals */: - return token = 60 /* EqualsToken */; + return token = 62 /* EqualsToken */; case 44 /* comma */: return token = 27 /* CommaToken */; case 46 /* dot */: return token = 24 /* DotToken */; case 96 /* backtick */: - return token = 59 /* BacktickToken */; + return token = 61 /* BacktickToken */; case 92 /* backslash */: pos--; var extendedCookedChar = peekExtendedUnicodeEscape(); @@ -8644,7 +9492,7 @@ var ts; } if (isIdentifierStart(ch, languageVersion)) { var char = ch; - while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion)) + while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45 /* minus */) pos += charSize(char); tokenValue = text.substring(tokenPos, pos); if (char === 92 /* backslash */) { @@ -8725,7 +9573,7 @@ var ts; tokenPos = textPos; token = 0 /* Unknown */; tokenValue = undefined; - tokenFlags = 0; + tokenFlags = 0 /* None */; } function setInJSDocType(inType) { inJSDocType += inType ? 1 : -1; @@ -8796,7 +9644,7 @@ var ts; ts.getDeclarationOfKind = getDeclarationOfKind; /** Create a new escaped identifier map. */ function createUnderscoreEscapedMap() { - return new ts.MapCtr(); + return new ts.Map(); } ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap; function hasEntries(map) { @@ -8838,6 +9686,8 @@ var ts; getColumn: function () { return 0; }, getIndent: function () { return 0; }, isAtStartOfLine: function () { return false; }, + hasTrailingComment: function () { return false; }, + hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); }, // Completely ignore indentation for string writers. And map newlines to // a single space. writeLine: function () { return str += " "; }, @@ -8850,13 +9700,6 @@ var ts; reportPrivateInBaseOfClassExpression: ts.noop, }; } - function toPath(fileName, basePath, getCanonicalFileName) { - var nonCanonicalizedPath = ts.isRootedDiskPath(fileName) - ? ts.normalizePath(fileName) - : ts.getNormalizedAbsolutePath(fileName, basePath); - return getCanonicalFileName(nonCanonicalizedPath); - } - ts.toPath = toPath; function changesAffectModuleResolution(oldOptions, newOptions) { return oldOptions.configFilePath !== newOptions.configFilePath || optionsHaveModuleResolutionChanges(oldOptions, newOptions); @@ -8925,7 +9768,7 @@ var ts; } ts.copyEntries = copyEntries; function arrayToSet(array, makeKey) { - return ts.arrayToMap(array, makeKey || (function (s) { return s; }), function () { return true; }); + return ts.arrayToMap(array, makeKey || (function (s) { return s; }), ts.returnTrue); } ts.arrayToSet = arrayToSet; function cloneMap(map) { @@ -9013,28 +9856,28 @@ var ts; // Returns true if this node contains a parse error anywhere underneath it. function containsParseError(node) { aggregateChildData(node); - return (node.flags & 131072 /* ThisNodeOrAnySubNodesHasError */) !== 0; + return (node.flags & 262144 /* ThisNodeOrAnySubNodesHasError */) !== 0; } ts.containsParseError = containsParseError; function aggregateChildData(node) { - if (!(node.flags & 262144 /* HasAggregatedChildData */)) { + if (!(node.flags & 524288 /* HasAggregatedChildData */)) { // A node is considered to contain a parse error if: // a) the parser explicitly marked that it had an error // b) any of it's children reported that it had an error. - var thisNodeOrAnySubNodesHasError = ((node.flags & 32768 /* ThisNodeHasError */) !== 0) || + var thisNodeOrAnySubNodesHasError = ((node.flags & 65536 /* ThisNodeHasError */) !== 0) || ts.forEachChild(node, containsParseError); // If so, mark ourselves accordingly. if (thisNodeOrAnySubNodesHasError) { - node.flags |= 131072 /* ThisNodeOrAnySubNodesHasError */; + node.flags |= 262144 /* ThisNodeOrAnySubNodesHasError */; } // Also mark that we've propagated the child information to this node. This way we can // always consult the bit directly on this node without needing to check its children // again. - node.flags |= 262144 /* HasAggregatedChildData */; + node.flags |= 524288 /* HasAggregatedChildData */; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 285 /* SourceFile */) { + while (node && node.kind !== 288 /* SourceFile */) { node = node.parent; } return node; @@ -9042,11 +9885,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return true; } return false; @@ -9214,7 +10057,7 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 314 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 317 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); @@ -9233,7 +10076,7 @@ var ts; } ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile; function isJSDocTypeExpressionOrChild(node) { - return node.kind === 289 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); + return node.kind === 292 /* JSDocTypeExpression */ || (node.parent && isJSDocTypeExpressionOrChild(node.parent)); } function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) { if (includeTrivia === void 0) { includeTrivia = false; } @@ -9301,10 +10144,8 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return "`" + rawText + "`"; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings return "`" + rawText + "${"; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings return "}" + rawText + "${"; case 17 /* TemplateTail */: return "}" + rawText + "`"; @@ -9335,7 +10176,7 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 238 /* VariableDeclaration */ && node.parent.kind === 275 /* CatchClause */; + return node.kind === 241 /* VariableDeclaration */ && node.parent.kind === 278 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { @@ -9367,16 +10208,16 @@ var ts; ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 245 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 248 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 285 /* SourceFile */ || - node.kind === 245 /* ModuleDeclaration */ || + return node.kind === 288 /* SourceFile */ || + node.kind === 248 /* ModuleDeclaration */ || ts.isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; function isGlobalScopeAugmentation(module) { - return !!(module.flags & 512 /* GlobalAugmentation */); + return !!(module.flags & 1024 /* GlobalAugmentation */); } ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation; function isExternalModuleAugmentation(node) { @@ -9388,9 +10229,9 @@ var ts; // - defined in the top level scope and source file is an external module // - defined inside ambient module declaration located in the top level scope and source file not an external module switch (node.parent.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.isExternalModule(node.parent); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -9443,22 +10284,22 @@ var ts; ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile; function isBlockScope(node, parentNode) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 275 /* CatchClause */: - case 245 /* ModuleDeclaration */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 278 /* CatchClause */: + case 248 /* ModuleDeclaration */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 219 /* Block */: + case 222 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return !ts.isFunctionLike(parentNode); @@ -9468,9 +10309,9 @@ var ts; ts.isBlockScope = isBlockScope; function isDeclarationWithTypeParameters(node) { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 300 /* JSDocSignature */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 303 /* JSDocSignature */: return true; default: ts.assertType(node); @@ -9480,25 +10321,25 @@ var ts; ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function isDeclarationWithTypeParameterChildren(node) { switch (node.kind) { - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: ts.assertType(node); @@ -9508,8 +10349,8 @@ var ts; ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren; function isAnyImportSyntax(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: return true; default: return false; @@ -9518,15 +10359,15 @@ var ts; ts.isAnyImportSyntax = isAnyImportSyntax; function isLateVisibilityPaintedStatement(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 220 /* VariableStatement */: - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 224 /* VariableStatement */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -9556,13 +10397,13 @@ var ts; ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: if (isStringOrNumericLiteralLike(name.expression)) return ts.escapeLeadingUnderscores(name.expression.text); return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames"); @@ -9573,11 +10414,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); default: throw ts.Debug.assertNever(name); @@ -9622,7 +10463,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 219 /* Block */) { + if (node.body && node.body.kind === 222 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -9636,7 +10477,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: var pos_1 = ts.skipTrivia(sourceFile.text, 0, /*stopAfterLineBreak*/ false); if (pos_1 === sourceFile.text.length) { // file is empty - return span for the beginning of the file @@ -9645,32 +10486,38 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 243 /* TypeAliasDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 246 /* TypeAliasDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: errorNode = node.name; break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + var start = ts.skipTrivia(sourceFile.text, node.pos); + var end = node.statements.length > 0 ? node.statements[0].pos : node.end; + return ts.createTextSpanFromBounds(start, end); } if (errorNode === undefined) { // If we don't have a better node, then just set the error on the first token of // construct. return getSpanOfTokenAtPosition(sourceFile, node.pos); } + ts.Debug.assert(!ts.isJSDoc(errorNode)); var isMissing = nodeIsMissing(errorNode); var pos = isMissing || ts.isJsxText(node) ? errorNode.pos @@ -9712,16 +10559,16 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 99 /* SuperKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 101 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isImportCall(n) { - return n.kind === 192 /* CallExpression */ && n.expression.kind === 93 /* ImportKeyword */; + return n.kind === 195 /* CallExpression */ && n.expression.kind === 95 /* ImportKeyword */; } ts.isImportCall = isImportCall; function isImportMeta(n) { return ts.isMetaProperty(n) - && n.keywordToken === 93 /* ImportKeyword */ + && n.keywordToken === 95 /* ImportKeyword */ && n.name.escapedText === "meta"; } ts.isImportMeta = isImportMeta; @@ -9730,7 +10577,7 @@ var ts; } ts.isLiteralImportTypeNode = isLiteralImportTypeNode; function isPrologueDirective(node) { - return node.kind === 222 /* ExpressionStatement */ + return node.kind === 225 /* ExpressionStatement */ && node.expression.kind === 10 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -9739,11 +10586,11 @@ var ts; } ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 152 /* Parameter */ || - node.kind === 151 /* TypeParameter */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 198 /* ArrowFunction */ || - node.kind === 196 /* ParenthesizedExpression */) ? + var commentRanges = (node.kind === 155 /* Parameter */ || + node.kind === 154 /* TypeParameter */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 201 /* ArrowFunction */ || + node.kind === 199 /* ParenthesizedExpression */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : ts.getLeadingCommentRanges(text, node.pos); // True if the comment starts with '/**' but not if it is '/**/' @@ -9759,48 +10606,48 @@ var ts; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; var defaultLibReferenceRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (164 /* FirstTypeNode */ <= node.kind && node.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= node.kind && node.kind <= 187 /* LastTypeNode */) { return true; } switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: return true; - case 107 /* VoidKeyword */: - return node.parent.kind !== 201 /* VoidExpression */; - case 212 /* ExpressionWithTypeArguments */: + case 109 /* VoidKeyword */: + return node.parent.kind !== 204 /* VoidExpression */; + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 151 /* TypeParameter */: - return node.parent.kind === 182 /* MappedType */ || node.parent.kind === 177 /* InferType */; + case 154 /* TypeParameter */: + return node.parent.kind === 185 /* MappedType */ || node.parent.kind === 180 /* InferType */; // Identifiers and qualified names may be type nodes, depending on their context. Climb // above them to find the lowest container - case 73 /* Identifier */: + case 75 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node) { node = node.parent; } // At this point, node is either a qualified name or an identifier - ts.Debug.assert(node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */ || node.kind === 190 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + ts.Debug.assert(node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */ || node.kind === 193 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); // falls through - case 149 /* QualifiedName */: - case 190 /* PropertyAccessExpression */: - case 101 /* ThisKeyword */: { + case 152 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + case 103 /* ThisKeyword */: { var parent = node.parent; - if (parent.kind === 168 /* TypeQuery */) { + if (parent.kind === 171 /* TypeQuery */) { return false; } - if (parent.kind === 184 /* ImportType */) { + if (parent.kind === 187 /* ImportType */) { return !parent.isTypeOf; } // Do not recursively call isPartOfTypeNode on the parent. In the example: @@ -9809,40 +10656,40 @@ var ts; // // Calling isPartOfTypeNode would consider the qualified name A.B a type node. // Only C and A.B.C are type nodes. - if (164 /* FirstTypeNode */ <= parent.kind && parent.kind <= 184 /* LastTypeNode */) { + if (167 /* FirstTypeNode */ <= parent.kind && parent.kind <= 187 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return node === parent.constraint; - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return node === parent.constraint; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return node === parent.type; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node === parent.type; - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return node === parent.type; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return node === parent.type; - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return ts.contains(parent.typeArguments, node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -9867,23 +10714,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitor(node); - case 247 /* CaseBlock */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 250 /* CaseBlock */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -9893,26 +10740,26 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } return; - case 244 /* EnumDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 247 /* EnumDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // These are not allowed inside a generator now, but eventually they may be allowed // as local types. Regardless, any yield statements contained within them should be // skipped in this traversal. return; default: if (ts.isFunctionLike(node)) { - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // Note that we will not include methods/accessors of a class because they would require // first descending into the class. This is by design. traverse(node.name.expression); @@ -9935,10 +10782,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 170 /* ArrayType */) { + if (node && node.kind === 173 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 165 /* TypeReference */) { + else if (node && node.kind === 168 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -9948,12 +10795,12 @@ var ts; ts.getRestParameterElementType = getRestParameterElementType; function getMembersOfDeclaration(node) { switch (node.kind) { - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 169 /* TypeLiteral */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 172 /* TypeLiteral */: return node.members; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return node.properties; } } @@ -9961,14 +10808,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 187 /* BindingElement */: - case 279 /* EnumMember */: - case 152 /* Parameter */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 277 /* ShorthandPropertyAssignment */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 282 /* EnumMember */: + case 155 /* Parameter */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 280 /* ShorthandPropertyAssignment */: + case 241 /* VariableDeclaration */: return true; } } @@ -9980,8 +10827,8 @@ var ts; } ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor; function isVariableDeclarationInVariableStatement(node) { - return node.parent.kind === 239 /* VariableDeclarationList */ - && node.parent.parent.kind === 220 /* VariableStatement */; + return node.parent.kind === 242 /* VariableDeclarationList */ + && node.parent.parent.kind === 224 /* VariableStatement */; } ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement; function isValidESSymbolDeclaration(node) { @@ -9992,13 +10839,13 @@ var ts; ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return true; } return false; @@ -10009,7 +10856,7 @@ var ts; if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 234 /* LabeledStatement */) { + if (node.statement.kind !== 237 /* LabeledStatement */) { return node.statement; } node = node.statement; @@ -10017,17 +10864,17 @@ var ts; } ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 219 /* Block */ && ts.isFunctionLike(node.parent); + return node && node.kind === 222 /* Block */ && ts.isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 157 /* MethodDeclaration */ && node.parent.kind === 189 /* ObjectLiteralExpression */; + return node && node.kind === 160 /* MethodDeclaration */ && node.parent.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 157 /* MethodDeclaration */ && - (node.parent.kind === 189 /* ObjectLiteralExpression */ || - node.parent.kind === 210 /* ClassExpression */); + return node.kind === 160 /* MethodDeclaration */ && + (node.parent.kind === 192 /* ObjectLiteralExpression */ || + node.parent.kind === 213 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -10040,7 +10887,7 @@ var ts; ts.isThisTypePredicate = isThisTypePredicate; function getPropertyAssignment(objectLiteral, key, key2) { return objectLiteral.properties.filter(function (property) { - if (property.kind === 276 /* PropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */) { var propName = getTextOfPropertyName(property.name); return key === propName || (!!key2 && key2 === propName); } @@ -10081,14 +10928,14 @@ var ts; } ts.getContainingClass = getContainingClass; function getThisContainer(node, includeArrowFunctions) { - ts.Debug.assert(node.kind !== 285 /* SourceFile */); + ts.Debug.assert(node.kind !== 288 /* SourceFile */); while (true) { node = node.parent; if (!node) { return ts.Debug.fail(); // If we never pass in a SourceFile, this should be unreachable, since we'll stop when we reach that. } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // If the grandparent node is an object literal (as opposed to a class), // then the computed property is not a 'this' container. // A computed property name in a class needs to be a this container @@ -10103,9 +10950,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10116,26 +10963,26 @@ var ts; node = node.parent; } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } // falls through - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 245 /* ModuleDeclaration */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 244 /* EnumDeclaration */: - case 285 /* SourceFile */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 248 /* ModuleDeclaration */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 247 /* EnumDeclaration */: + case 288 /* SourceFile */: return node; } } @@ -10145,9 +10992,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: return container; } } @@ -10169,27 +11016,27 @@ var ts; return node; } switch (node.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: node = node.parent; break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (!stopOnFunctions) { continue; } // falls through - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return node; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 152 /* Parameter */ && ts.isClassElement(node.parent.parent)) { + if (node.parent.kind === 155 /* Parameter */ && ts.isClassElement(node.parent.parent)) { // If the decorator's parent is a Parameter, we resolve the this container from // the grandparent class declaration. node = node.parent.parent; @@ -10205,21 +11052,21 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 197 /* FunctionExpression */ || func.kind === 198 /* ArrowFunction */) { + if (func.kind === 200 /* FunctionExpression */ || func.kind === 201 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 196 /* ParenthesizedExpression */) { + while (parent.kind === 199 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 192 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 195 /* CallExpression */ && parent.expression === prev) { return parent; } } } ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperOrSuperProperty(node) { - return node.kind === 99 /* SuperKeyword */ + return node.kind === 101 /* SuperKeyword */ || isSuperProperty(node); } ts.isSuperOrSuperProperty = isSuperOrSuperProperty; @@ -10228,8 +11075,8 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 99 /* SuperKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 101 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; /** @@ -10237,20 +11084,20 @@ var ts; */ function isThisProperty(node) { var kind = node.kind; - return (kind === 190 /* PropertyAccessExpression */ || kind === 191 /* ElementAccessExpression */) - && node.expression.kind === 101 /* ThisKeyword */; + return (kind === 193 /* PropertyAccessExpression */ || kind === 194 /* ElementAccessExpression */) + && node.expression.kind === 103 /* ThisKeyword */; } ts.isThisProperty = isThisProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: return node; } return undefined; @@ -10258,10 +11105,10 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function getInvokedExpression(node) { switch (node.kind) { - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return node.tag; - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return node.tagName; default: return node.expression; @@ -10270,25 +11117,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node, parent, grandparent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // classes are valid targets return true; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return parent.kind === 241 /* ClassDeclaration */; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + return parent.kind === 244 /* ClassDeclaration */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // if this method has a body and its parent is a class declaration, this is a valid target. return node.body !== undefined - && parent.kind === 241 /* ClassDeclaration */; - case 152 /* Parameter */: + && parent.kind === 244 /* ClassDeclaration */; + case 155 /* Parameter */: // if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target; return parent.body !== undefined - && (parent.kind === 158 /* Constructor */ - || parent.kind === 157 /* MethodDeclaration */ - || parent.kind === 160 /* SetAccessor */) - && grandparent.kind === 241 /* ClassDeclaration */; + && (parent.kind === 161 /* Constructor */ + || parent.kind === 160 /* MethodDeclaration */ + || parent.kind === 163 /* SetAccessor */) + && grandparent.kind === 244 /* ClassDeclaration */; } return false; } @@ -10304,10 +11151,10 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node, parent) { switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); }); // TODO: GH#18217 - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); }); // TODO: GH#18217 default: return false; @@ -10316,9 +11163,9 @@ var ts; ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 263 /* JsxOpeningElement */ || - parent.kind === 262 /* JsxSelfClosingElement */ || - parent.kind === 264 /* JsxClosingElement */) { + if (parent.kind === 266 /* JsxOpeningElement */ || + parent.kind === 265 /* JsxSelfClosingElement */ || + parent.kind === 267 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -10326,57 +11173,57 @@ var ts; ts.isJSXTagName = isJSXTagName; function isExpressionNode(node) { switch (node.kind) { - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 13 /* RegularExpressionLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 213 /* AsExpression */: - case 195 /* TypeAssertionExpression */: - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 205 /* BinaryExpression */: - case 206 /* ConditionalExpression */: - case 209 /* SpreadElement */: - case 207 /* TemplateExpression */: - case 14 /* NoSubstitutionTemplateLiteral */: - case 211 /* OmittedExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 208 /* YieldExpression */: - case 202 /* AwaitExpression */: - case 215 /* MetaProperty */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 216 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 208 /* BinaryExpression */: + case 209 /* ConditionalExpression */: + case 212 /* SpreadElement */: + case 210 /* TemplateExpression */: + case 214 /* OmittedExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 211 /* YieldExpression */: + case 205 /* AwaitExpression */: + case 218 /* MetaProperty */: return true; - case 149 /* QualifiedName */: - while (node.parent.kind === 149 /* QualifiedName */) { + case 152 /* QualifiedName */: + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node); - case 73 /* Identifier */: - if (node.parent.kind === 168 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node); + case 75 /* Identifier */: + if (node.parent.kind === 171 /* TypeQuery */ || isJSXTagName(node)) { return true; } // falls through case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 101 /* ThisKeyword */: + case 14 /* NoSubstitutionTemplateLiteral */: + case 103 /* ThisKeyword */: return isInExpressionContext(node); default: return false; @@ -10386,49 +11233,49 @@ var ts; function isInExpressionContext(node) { var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 190 /* BindingElement */: return parent.initializer === node; - case 222 /* ExpressionStatement */: - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 231 /* ReturnStatement */: - case 232 /* WithStatement */: - case 233 /* SwitchStatement */: - case 272 /* CaseClause */: - case 235 /* ThrowStatement */: + case 225 /* ExpressionStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 234 /* ReturnStatement */: + case 235 /* WithStatement */: + case 236 /* SwitchStatement */: + case 275 /* CaseClause */: + case 238 /* ThrowStatement */: return parent.expression === node; - case 226 /* ForStatement */: + case 229 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 239 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 242 /* VariableDeclarationList */) || forInStatement.expression === node; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return node === parent.expression; - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return node === parent.expression; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return node === parent.expression; - case 153 /* Decorator */: - case 271 /* JsxExpression */: - case 270 /* JsxSpreadAttribute */: - case 278 /* SpreadAssignment */: + case 156 /* Decorator */: + case 274 /* JsxExpression */: + case 273 /* JsxSpreadAttribute */: + case 281 /* SpreadAssignment */: return true; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return parent.objectAssignmentInitializer === node; default: return isExpressionNode(parent); @@ -10436,7 +11283,7 @@ var ts; } ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -10445,7 +11292,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 260 /* ExternalModuleReference */; + return node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 263 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJS(file) { @@ -10457,15 +11304,15 @@ var ts; } ts.isSourceFileNotJS = isSourceFileNotJS; function isInJSFile(node) { - return !!node && !!(node.flags & 65536 /* JavaScriptFile */); + return !!node && !!(node.flags & 131072 /* JavaScriptFile */); } ts.isInJSFile = isInJSFile; function isInJsonFile(node) { - return !!node && !!(node.flags & 16777216 /* JsonFile */); + return !!node && !!(node.flags & 33554432 /* JsonFile */); } ts.isInJsonFile = isInJsonFile; function isInJSDoc(node) { - return !!node && !!(node.flags & 2097152 /* JSDoc */); + return !!node && !!(node.flags & 4194304 /* JSDoc */); } ts.isInJSDoc = isInJSDoc; function isJSDocIndexSignature(node) { @@ -10473,22 +11320,22 @@ var ts; ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && node.typeArguments && node.typeArguments.length === 2 && - (node.typeArguments[0].kind === 139 /* StringKeyword */ || node.typeArguments[0].kind === 136 /* NumberKeyword */); + (node.typeArguments[0].kind === 142 /* StringKeyword */ || node.typeArguments[0].kind === 139 /* NumberKeyword */); } ts.isJSDocIndexSignature = isJSDocIndexSignature; - function isRequireCall(callExpression, checkArgumentIsStringLiteralLike) { - if (callExpression.kind !== 192 /* CallExpression */) { + function isRequireCall(callExpression, requireStringLiteralLikeArgument) { + if (callExpression.kind !== 195 /* CallExpression */) { return false; } var _a = callExpression, expression = _a.expression, args = _a.arguments; - if (expression.kind !== 73 /* Identifier */ || expression.escapedText !== "require") { + if (expression.kind !== 75 /* Identifier */ || expression.escapedText !== "require") { return false; } if (args.length !== 1) { return false; } var arg = args[0]; - return !checkArgumentIsStringLiteralLike || ts.isStringLiteralLike(arg); + return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg); } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { @@ -10512,21 +11359,25 @@ var ts; name = node.parent.name; decl = node.parent; } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.right === node) { - name = node.parent.left; - decl = name; - } - else if (ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 55 /* BarBarToken */) { - if (ts.isVariableDeclaration(node.parent.parent) && node.parent.parent.initializer === node.parent) { - name = node.parent.parent.name; - decl = node.parent.parent; - } - else if (ts.isBinaryExpression(node.parent.parent) && node.parent.parent.operatorToken.kind === 60 /* EqualsToken */ && node.parent.parent.right === node.parent) { - name = node.parent.parent.left; + else if (ts.isBinaryExpression(node.parent)) { + var parentNode = node.parent; + var parentNodeOperator = node.parent.operatorToken.kind; + if (parentNodeOperator === 62 /* EqualsToken */ && parentNode.right === node) { + name = parentNode.left; decl = name; } - if (!name || !isEntityNameExpression(name) || !isSameEntityName(name, node.parent.left)) { - return undefined; + else if (parentNodeOperator === 56 /* BarBarToken */ || parentNodeOperator === 60 /* QuestionQuestionToken */) { + if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) { + name = parentNode.parent.name; + decl = parentNode.parent; + } + else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 /* EqualsToken */ && parentNode.parent.right === parentNode) { + name = parentNode.parent.left; + decl = name; + } + if (!name || !isBindableStaticNameExpression(name) || !isSameEntityName(name, parentNode.left)) { + return undefined; + } } } if (!name || !getExpandoInitializer(node, isPrototypeAccess(name))) { @@ -10536,13 +11387,14 @@ var ts; } ts.getDeclarationOfExpando = getDeclarationOfExpando; function isAssignmentDeclaration(decl) { - return ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); + return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl); } ts.isAssignmentDeclaration = isAssignmentDeclaration; /** Get the initializer, taking into account defaulted Javascript initializers */ function getEffectiveInitializer(node) { if (isInJSFile(node) && node.initializer && - ts.isBinaryExpression(node.initializer) && node.initializer.operatorToken.kind === 55 /* BarBarToken */ && + ts.isBinaryExpression(node.initializer) && + (node.initializer.operatorToken.kind === 56 /* BarBarToken */ || node.initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) && node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) { return node.initializer.right; } @@ -10556,14 +11408,20 @@ var ts; } ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer; function hasExpandoValueProperty(node, isPrototypeAssignment) { - return ts.forEach(node.properties, function (p) { return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.escapedText === "value" && p.initializer && getExpandoInitializer(p.initializer, isPrototypeAssignment); }); + return ts.forEach(node.properties, function (p) { + return ts.isPropertyAssignment(p) && + ts.isIdentifier(p.name) && + p.name.escapedText === "value" && + p.initializer && + getExpandoInitializer(p.initializer, isPrototypeAssignment); + }); } /** * Get the assignment 'initializer' -- the righthand side-- when the initializer is container-like (See getExpandoInitializer). * We treat the right hand side of assignments with container-like initalizers as declarations. */ function getAssignedExpandoInitializer(node) { - if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */) { var isPrototypeAssignment = isPrototypeAccess(node.parent.left); return getExpandoInitializer(node.parent.right, isPrototypeAssignment) || getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment); @@ -10589,11 +11447,11 @@ var ts; function getExpandoInitializer(initializer, isPrototypeAssignment) { if (ts.isCallExpression(initializer)) { var e = skipParentheses(initializer.expression); - return e.kind === 197 /* FunctionExpression */ || e.kind === 198 /* ArrowFunction */ ? initializer : undefined; + return e.kind === 200 /* FunctionExpression */ || e.kind === 201 /* ArrowFunction */ ? initializer : undefined; } - if (initializer.kind === 197 /* FunctionExpression */ || - initializer.kind === 210 /* ClassExpression */ || - initializer.kind === 198 /* ArrowFunction */) { + if (initializer.kind === 200 /* FunctionExpression */ || + initializer.kind === 213 /* ClassExpression */ || + initializer.kind === 201 /* ArrowFunction */) { return initializer; } if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) { @@ -10610,14 +11468,16 @@ var ts; * 'window.', 'global.' or 'self.' The second Lhs is otherwise ignored by the binder and checker. */ function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) { - var e = ts.isBinaryExpression(initializer) && initializer.operatorToken.kind === 55 /* BarBarToken */ && getExpandoInitializer(initializer.right, isPrototypeAssignment); + var e = ts.isBinaryExpression(initializer) + && (initializer.operatorToken.kind === 56 /* BarBarToken */ || initializer.operatorToken.kind === 60 /* QuestionQuestionToken */) + && getExpandoInitializer(initializer.right, isPrototypeAssignment); if (e && isSameEntityName(name, initializer.left)) { return e; } } function isDefaultedExpandoInitializer(node) { var name = ts.isVariableDeclaration(node.parent) ? node.parent.name : - ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 60 /* EqualsToken */ ? node.parent.left : + ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 /* EqualsToken */ ? node.parent.left : undefined; return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left); } @@ -10625,8 +11485,8 @@ var ts; /** Given an expando initializer, return its declaration name, or the left-hand side of the assignment if it's part of an assignment declaration. */ function getNameOfExpando(node) { if (ts.isBinaryExpression(node.parent)) { - var parent = (node.parent.operatorToken.kind === 55 /* BarBarToken */ && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; - if (parent.operatorToken.kind === 60 /* EqualsToken */ && ts.isIdentifier(parent.left)) { + var parent = ((node.parent.operatorToken.kind === 56 /* BarBarToken */ || node.parent.operatorToken.kind === 60 /* QuestionQuestionToken */) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent; + if (parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isIdentifier(parent.left)) { return parent.left; } } @@ -10645,19 +11505,20 @@ var ts; * my.app = self.my.app || class { } */ function isSameEntityName(name, initializer) { - if (ts.isIdentifier(name) && ts.isIdentifier(initializer)) { - return name.escapedText === initializer.escapedText; + if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) { + return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(name); } - if (ts.isIdentifier(name) && ts.isPropertyAccessExpression(initializer)) { - return (initializer.expression.kind === 101 /* ThisKeyword */ || + if (ts.isIdentifier(name) && (isLiteralLikeAccess(initializer))) { + return (initializer.expression.kind === 103 /* ThisKeyword */ || ts.isIdentifier(initializer.expression) && (initializer.expression.escapedText === "window" || initializer.expression.escapedText === "self" || initializer.expression.escapedText === "global")) && - isSameEntityName(name, initializer.name); + isSameEntityName(name, getNameOrArgument(initializer)); } - if (ts.isPropertyAccessExpression(name) && ts.isPropertyAccessExpression(initializer)) { - return name.name.escapedText === initializer.name.escapedText && isSameEntityName(name.expression, initializer.expression); + if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) { + return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer) + && isSameEntityName(name.expression, initializer.expression); } return false; } @@ -10672,10 +11533,13 @@ var ts; return ts.isIdentifier(node) && node.escapedText === "exports"; } ts.isExportsIdentifier = isExportsIdentifier; - function isModuleExportsPropertyAccessExpression(node) { - return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.expression) && node.expression.escapedText === "module" && node.name.escapedText === "exports"; + function isModuleExportsAccessExpression(node) { + return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node)) + && ts.isIdentifier(node.expression) + && node.expression.escapedText === "module" + && getElementOrPropertyAccessName(node) === "exports"; } - ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; + ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getAssignmentDeclarationKind(expr) { @@ -10690,60 +11554,129 @@ var ts; ts.idText(expr.expression.expression) === "Object" && ts.idText(expr.expression.name) === "defineProperty" && isStringOrNumericLiteralLike(expr.arguments[1]) && - isEntityNameExpression(expr.arguments[0]); + isBindableStaticNameExpression(expr.arguments[0], /*excludeThisKeyword*/ true); } ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall; + /** x.y OR x[0] */ + function isLiteralLikeAccess(node) { + return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node); + } + ts.isLiteralLikeAccess = isLiteralLikeAccess; + /** x[0] OR x['a'] OR x[Symbol.y] */ + function isLiteralLikeElementAccess(node) { + return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) || + isWellKnownSymbolSyntactically(node.argumentExpression)); + } + ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess; + /** Any series of property and element accesses. */ + function isBindableStaticAccessExpression(node, excludeThisKeyword) { + return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */ || isBindableStaticNameExpression(node.expression, /*excludeThisKeyword*/ true)) + || isBindableStaticElementAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression; + /** Any series of property and element accesses, ending in a literal element access */ + function isBindableStaticElementAccessExpression(node, excludeThisKeyword) { + return isLiteralLikeElementAccess(node) + && ((!excludeThisKeyword && node.expression.kind === 103 /* ThisKeyword */) || + isEntityNameExpression(node.expression) || + isBindableStaticAccessExpression(node.expression, /*excludeThisKeyword*/ true)); + } + ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression; + function isBindableStaticNameExpression(node, excludeThisKeyword) { + return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword); + } + ts.isBindableStaticNameExpression = isBindableStaticNameExpression; + function getNameOrArgument(expr) { + if (ts.isPropertyAccessExpression(expr)) { + return expr.name; + } + return expr.argumentExpression; + } + ts.getNameOrArgument = getNameOrArgument; function getAssignmentDeclarationKindWorker(expr) { if (ts.isCallExpression(expr)) { if (!isBindableObjectDefinePropertyCall(expr)) { return 0 /* None */; } var entityName = expr.arguments[0]; - if (isExportsIdentifier(entityName) || isModuleExportsPropertyAccessExpression(entityName)) { + if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) { return 8 /* ObjectDefinePropertyExports */; } - if (ts.isPropertyAccessExpression(entityName) && entityName.name.escapedText === "prototype" && isEntityNameExpression(entityName.expression)) { + if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") { return 9 /* ObjectDefinePrototypeProperty */; } return 7 /* ObjectDefinePropertyValue */; } - if (expr.operatorToken.kind !== 60 /* EqualsToken */ || - !ts.isPropertyAccessExpression(expr.left)) { + if (expr.operatorToken.kind !== 62 /* EqualsToken */ || !isAccessExpression(expr.left)) { return 0 /* None */; } - var lhs = expr.left; - if (isEntityNameExpression(lhs.expression) && lhs.name.escapedText === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { + if (isBindableStaticNameExpression(expr.left.expression, /*excludeThisKeyword*/ true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) { // F.prototype = { ... } return 6 /* Prototype */; } - return getAssignmentDeclarationPropertyAccessKind(lhs); + return getAssignmentDeclarationPropertyAccessKind(expr.left); } + /** + * Does not handle signed numeric names like `a[+0]` - handling those would require handling prefix unary expressions + * throughout late binding handling as well, which is awkward (but ultimately probably doable if there is demand) + */ + /* @internal */ + function getElementOrPropertyAccessArgumentExpressionOrName(node) { + if (ts.isPropertyAccessExpression(node)) { + return node.name; + } + var arg = skipParentheses(node.argumentExpression); + if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) { + return arg; + } + return node; + } + ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName; + function getElementOrPropertyAccessName(node) { + var name = getElementOrPropertyAccessArgumentExpressionOrName(node); + if (name) { + if (ts.isIdentifier(name)) { + return name.escapedText; + } + if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) { + return ts.escapeLeadingUnderscores(name.text); + } + } + if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) { + return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name)); + } + return undefined; + } + ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName; function getAssignmentDeclarationPropertyAccessKind(lhs) { - if (lhs.expression.kind === 101 /* ThisKeyword */) { + if (lhs.expression.kind === 103 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (isModuleExportsPropertyAccessExpression(lhs)) { + else if (isModuleExportsAccessExpression(lhs)) { // module.exports = expr return 2 /* ModuleExports */; } - else if (isEntityNameExpression(lhs.expression)) { + else if (isBindableStaticNameExpression(lhs.expression, /*excludeThisKeyword*/ true)) { if (isPrototypeAccess(lhs.expression)) { // F.G....prototype.x = expr return 3 /* PrototypeProperty */; } var nextToLast = lhs; - while (ts.isPropertyAccessExpression(nextToLast.expression)) { + while (!ts.isIdentifier(nextToLast.expression)) { nextToLast = nextToLast.expression; } - ts.Debug.assert(ts.isIdentifier(nextToLast.expression)); var id = nextToLast.expression; - if (id.escapedText === "exports" || - id.escapedText === "module" && nextToLast.name.escapedText === "exports") { - // exports.name = expr OR module.exports.name = expr + if ((id.escapedText === "exports" || + id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") && + // ExportsProperty does not support binding with computed names + isBindableStaticAccessExpression(lhs)) { + // exports.name = expr OR module.exports.name = expr OR exports["name"] = expr ... return 1 /* ExportsProperty */; } - // F.G...x = expr - return 5 /* Property */; + if (isBindableStaticNameExpression(lhs, /*excludeThisKeyword*/ true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs) && lhs.expression.kind !== 103 /* ThisKeyword */)) { + // F.G...x = expr + return 5 /* Property */; + } } return 0 /* None */; } @@ -10761,7 +11694,8 @@ var ts; ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment; function isSpecialPropertyDeclaration(expr) { return isInJSFile(expr) && - expr.parent && expr.parent.kind === 222 /* ExpressionStatement */ && + expr.parent && expr.parent.kind === 225 /* ExpressionStatement */ && + (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) && !!ts.getJSDocTypeTag(expr.parent); } ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration; @@ -10770,7 +11704,7 @@ var ts; return false; } var decl = symbol.valueDeclaration; - return decl.kind === 240 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); + return decl.kind === 243 /* FunctionDeclaration */ || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer); } ts.isFunctionSymbol = isFunctionSymbol; function importFromModuleSpecifier(node) { @@ -10779,14 +11713,14 @@ var ts; ts.importFromModuleSpecifier = importFromModuleSpecifier; function tryGetImportFromModuleSpecifier(node) { switch (node.parent.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.parent; - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return node.parent.parent; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return isImportCall(node.parent) || isRequireCall(node.parent, /*checkArg*/ false) ? node.parent : undefined; - case 183 /* LiteralType */: + case 186 /* LiteralType */: ts.Debug.assert(ts.isStringLiteral(node)); return ts.tryCast(node.parent.parent, ts.isImportTypeNode); default: @@ -10796,12 +11730,12 @@ var ts; ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier; function getExternalModuleName(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return node.moduleSpecifier; - case 249 /* ImportEqualsDeclaration */: - return node.moduleReference.kind === 260 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; - case 184 /* ImportType */: + case 252 /* ImportEqualsDeclaration */: + return node.moduleReference.kind === 263 /* ExternalModuleReference */ ? node.moduleReference.expression : undefined; + case 187 /* ImportType */: return isLiteralImportTypeNode(node) ? node.argument.literal : undefined; default: return ts.Debug.assertNever(node); @@ -10810,11 +11744,11 @@ var ts; ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return undefined; default: return ts.Debug.assertNever(node); @@ -10822,19 +11756,19 @@ var ts; } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 250 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; + return node.kind === 253 /* ImportDeclaration */ && !!node.importClause && !!node.importClause.name; } ts.isDefaultImport = isDefaultImport; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 152 /* Parameter */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 277 /* ShorthandPropertyAssignment */: - case 276 /* PropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 155 /* Parameter */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 280 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -10848,7 +11782,7 @@ var ts; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function isJSDocTypeAlias(node) { - return node.kind === 312 /* JSDocTypedefTag */ || node.kind === 305 /* JSDocCallbackTag */ || node.kind === 306 /* JSDocEnumTag */; + return node.kind === 315 /* JSDocTypedefTag */ || node.kind === 308 /* JSDocCallbackTag */ || node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocTypeAlias = isJSDocTypeAlias; function isTypeAlias(node) { @@ -10858,7 +11792,7 @@ var ts; function getSourceOfAssignment(node) { return ts.isExpressionStatement(node) && node.expression && ts.isBinaryExpression(node.expression) && - node.expression.operatorToken.kind === 60 /* EqualsToken */ + node.expression.operatorToken.kind === 62 /* EqualsToken */ ? node.expression.right : undefined; } @@ -10867,18 +11801,18 @@ var ts; ts.isBinaryExpression(node.expression) && getAssignmentDeclarationKind(node.expression) !== 0 /* None */ && ts.isBinaryExpression(node.expression.right) && - node.expression.right.operatorToken.kind === 55 /* BarBarToken */ + (node.expression.right.operatorToken.kind === 56 /* BarBarToken */ || node.expression.right.operatorToken.kind === 60 /* QuestionQuestionToken */) ? node.expression.right.right : undefined; } function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: var v = getSingleVariableOfVariableStatement(node); return v && v.initializer; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return node.initializer; } } @@ -10889,7 +11823,7 @@ var ts; function getNestedModuleDeclaration(node) { return ts.isModuleDeclaration(node) && node.body && - node.body.kind === 245 /* ModuleDeclaration */ + node.body.kind === 248 /* ModuleDeclaration */ ? node.body : undefined; } @@ -10904,11 +11838,11 @@ var ts; if (ts.hasJSDocNodes(node)) { result = ts.append(result, ts.last(node.jsDoc)); } - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { result = ts.addRange(result, ts.getJSDocParameterTags(node)); break; } - if (node.kind === 151 /* TypeParameter */) { + if (node.kind === 154 /* TypeParameter */) { result = ts.addRange(result, ts.getJSDocTypeParameterTags(node)); break; } @@ -10919,12 +11853,12 @@ var ts; ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getNextJSDocCommentLocation(node) { var parent = node.parent; - if (parent.kind === 276 /* PropertyAssignment */ || - parent.kind === 255 /* ExportAssignment */ || - parent.kind === 155 /* PropertyDeclaration */ || - parent.kind === 222 /* ExpressionStatement */ && node.kind === 190 /* PropertyAccessExpression */ || + if (parent.kind === 279 /* PropertyAssignment */ || + parent.kind === 258 /* ExportAssignment */ || + parent.kind === 158 /* PropertyDeclaration */ || + parent.kind === 225 /* ExpressionStatement */ && node.kind === 193 /* PropertyAccessExpression */ || getNestedModuleDeclaration(parent) || - ts.isBinaryExpression(node) && node.operatorToken.kind === 60 /* EqualsToken */) { + ts.isBinaryExpression(node) && node.operatorToken.kind === 62 /* EqualsToken */) { return parent; } // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. @@ -10935,7 +11869,7 @@ var ts; // var x = function(name) { return name.length; } else if (parent.parent && (getSingleVariableOfVariableStatement(parent.parent) === node || - ts.isBinaryExpression(parent) && parent.operatorToken.kind === 60 /* EqualsToken */)) { + ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62 /* EqualsToken */)) { return parent.parent; } else if (parent.parent && parent.parent.parent && @@ -10958,7 +11892,7 @@ var ts; if (!decl) { return undefined; } - var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 73 /* Identifier */ && p.name.escapedText === name; }); + var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 75 /* Identifier */ && p.name.escapedText === name; }); return parameter && parameter.symbol; } ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc; @@ -10983,7 +11917,7 @@ var ts; function getTypeParameterFromJsDoc(node) { var name = node.name.escapedText; var typeParameters = node.parent.parent.parent.typeParameters; - return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); + return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; function hasRestParameter(s) { @@ -10993,7 +11927,7 @@ var ts; ts.hasRestParameter = hasRestParameter; function isRestParameter(node) { var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type; - return node.dotDotDotToken !== undefined || !!type && type.kind === 296 /* JSDocVariadicType */; + return node.dotDotDotToken !== undefined || !!type && type.kind === 299 /* JSDocVariadicType */; } ts.isRestParameter = isRestParameter; var AssignmentKind; @@ -11006,31 +11940,31 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 60 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 62 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 44 /* PlusPlusToken */ || unaryOperator === 45 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + return unaryOperator === 45 /* PlusPlusToken */ || unaryOperator === 46 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 196 /* ParenthesizedExpression */: - case 188 /* ArrayLiteralExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 191 /* ArrayLiteralExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: node = parent; break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -11057,22 +11991,22 @@ var ts; */ function isNodeWithPossibleHoistedDeclaration(node) { switch (node.kind) { - case 219 /* Block */: - case 220 /* VariableStatement */: - case 232 /* WithStatement */: - case 223 /* IfStatement */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 234 /* LabeledStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 236 /* TryStatement */: - case 275 /* CatchClause */: + case 222 /* Block */: + case 224 /* VariableStatement */: + case 235 /* WithStatement */: + case 226 /* IfStatement */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 237 /* LabeledStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 239 /* TryStatement */: + case 278 /* CatchClause */: return true; } return false; @@ -11089,33 +12023,33 @@ var ts; return node; } function walkUpParenthesizedTypes(node) { - return walkUp(node, 178 /* ParenthesizedType */); + return walkUp(node, 181 /* ParenthesizedType */); } ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes; function walkUpParenthesizedExpressions(node) { - return walkUp(node, 196 /* ParenthesizedExpression */); + return walkUp(node, 199 /* ParenthesizedExpression */); } ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions; function skipParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } return node; } ts.skipParentheses = skipParentheses; function skipParenthesesUp(node) { - while (node.kind === 196 /* ParenthesizedExpression */) { + while (node.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return node; } // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { return false; } node = walkUpParenthesizedExpressions(node.parent); - return node && node.kind === 199 /* DeleteExpression */; + return node && node.kind === 202 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -11137,11 +12071,12 @@ var ts; var parent = name.parent; switch (name.kind) { case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: if (ts.isComputedPropertyName(parent)) return parent.parent; // falls through - case 73 /* Identifier */: + case 75 /* Identifier */: if (ts.isDeclaration(parent)) { return parent.name === name ? parent : undefined; } @@ -11164,8 +12099,8 @@ var ts; } ts.getDeclarationFromName = getDeclarationFromName; function isLiteralComputedPropertyDeclarationName(node) { - return (node.kind === 10 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 150 /* ComputedPropertyName */ && + return isStringOrNumericLiteralLike(node) && + node.parent.kind === 153 /* ComputedPropertyName */ && ts.isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -11173,32 +12108,32 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 279 /* EnumMember */: - case 276 /* PropertyAssignment */: - case 190 /* PropertyAccessExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 282 /* EnumMember */: + case 279 /* PropertyAssignment */: + case 193 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: // Name on right hand side of dot in a type query or type reference if (parent.right === node) { - while (parent.kind === 149 /* QualifiedName */) { + while (parent.kind === 152 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 168 /* TypeQuery */ || parent.kind === 165 /* TypeReference */; + return parent.kind === 171 /* TypeQuery */ || parent.kind === 168 /* TypeReference */; } return false; - case 187 /* BindingElement */: - case 254 /* ImportSpecifier */: + case 190 /* BindingElement */: + case 257 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 258 /* ExportSpecifier */: - case 268 /* JsxAttribute */: + case 261 /* ExportSpecifier */: + case 271 /* JsxAttribute */: // Any name in an export specifier or JSX Attribute return true; } @@ -11214,22 +12149,39 @@ var ts; // export = // export default // module.exports = + // {} + // {name: } function isAliasSymbolDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 248 /* NamespaceExportDeclaration */ || - node.kind === 251 /* ImportClause */ && !!node.name || - node.kind === 252 /* NamespaceImport */ || - node.kind === 254 /* ImportSpecifier */ || - node.kind === 258 /* ExportSpecifier */ || - node.kind === 255 /* ExportAssignment */ && exportAssignmentIsAlias(node) || - ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node); + return node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 251 /* NamespaceExportDeclaration */ || + node.kind === 254 /* ImportClause */ && !!node.name || + node.kind === 255 /* NamespaceImport */ || + node.kind === 257 /* ImportSpecifier */ || + node.kind === 261 /* ExportSpecifier */ || + node.kind === 258 /* ExportAssignment */ && exportAssignmentIsAlias(node) || + ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 /* ModuleExports */ && exportAssignmentIsAlias(node) || + ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */ && isAliasableExpression(node.parent.right) || + node.kind === 280 /* ShorthandPropertyAssignment */ || + node.kind === 279 /* PropertyAssignment */ && isAliasableExpression(node.initializer); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; - function exportAssignmentIsAlias(node) { - var e = ts.isExportAssignment(node) ? node.expression : node.right; + function isAliasableExpression(e) { return isEntityNameExpression(e) || ts.isClassExpression(e); } + function exportAssignmentIsAlias(node) { + var e = getExportAssignmentExpression(node); + return isAliasableExpression(e); + } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; + function getExportAssignmentExpression(node) { + return ts.isExportAssignment(node) ? node.expression : node.right; + } + ts.getExportAssignmentExpression = getExportAssignmentExpression; + function getPropertyAssignmentAliasLikeExpression(node) { + return node.kind === 280 /* ShorthandPropertyAssignment */ ? node.name : node.kind === 279 /* PropertyAssignment */ ? node.initializer : + node.parent.right; + } + ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression; function getEffectiveBaseTypeNode(node) { var baseType = getClassExtendsHeritageElement(node); if (baseType && isInJSFile(node)) { @@ -11243,24 +12195,24 @@ var ts; } ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode; function getClassExtendsHeritageElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 110 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 112 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; /** Returns the node in an `extends` or `implements` clause of a class or interface. */ function getAllSuperTypeNodes(node) { - return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray - : ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray - : ts.emptyArray; + return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray : + ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getClassImplementsHeritageClauseElements(node)) || ts.emptyArray : + ts.emptyArray; } ts.getAllSuperTypeNodes = getAllSuperTypeNodes; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 87 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 89 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -11287,11 +12239,11 @@ var ts; } ts.getAncestor = getAncestor; function isKeyword(token) { - return 74 /* FirstKeyword */ <= token && token <= 148 /* LastKeyword */; + return 76 /* FirstKeyword */ <= token && token <= 151 /* LastKeyword */; } ts.isKeyword = isKeyword; function isContextualKeyword(token) { - return 119 /* FirstContextualKeyword */ <= token && token <= 148 /* LastContextualKeyword */; + return 121 /* FirstContextualKeyword */ <= token && token <= 151 /* LastContextualKeyword */; } ts.isContextualKeyword = isContextualKeyword; function isNonContextualKeyword(token) { @@ -11299,7 +12251,7 @@ var ts; } ts.isNonContextualKeyword = isNonContextualKeyword; function isFutureReservedKeyword(token) { - return 110 /* FirstFutureReservedWord */ <= token && token <= 118 /* LastFutureReservedWord */; + return 112 /* FirstFutureReservedWord */ <= token && token <= 120 /* LastFutureReservedWord */; } ts.isFutureReservedKeyword = isFutureReservedKeyword; function isStringANonContextualKeyword(name) { @@ -11307,6 +12259,11 @@ var ts; return token !== undefined && isNonContextualKeyword(token); } ts.isStringANonContextualKeyword = isStringANonContextualKeyword; + function isStringAKeyword(name) { + var token = ts.stringToToken(name); + return token !== undefined && isKeyword(token); + } + ts.isStringAKeyword = isStringAKeyword; function isIdentifierANonContextualKeyword(_a) { var originalKeywordKind = _a.originalKeywordKind; return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind); @@ -11330,14 +12287,14 @@ var ts; } var flags = 0 /* Normal */; switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 160 /* MethodDeclaration */: if (node.asteriskToken) { flags |= 1 /* Generator */; } // falls through - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: if (hasModifier(node, 256 /* Async */)) { flags |= 2 /* Async */; } @@ -11351,10 +12308,10 @@ var ts; ts.getFunctionFlags = getFunctionFlags; function isAsyncFunction(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: return node.body !== undefined && node.asteriskToken === undefined && hasModifier(node, 256 /* Async */); @@ -11367,7 +12324,7 @@ var ts; } ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike; function isSignedNumericLiteral(node) { - return ts.isPrefixUnaryExpression(node) && (node.operator === 38 /* PlusToken */ || node.operator === 39 /* MinusToken */) && ts.isNumericLiteral(node.operand); + return ts.isPrefixUnaryExpression(node) && (node.operator === 39 /* PlusToken */ || node.operator === 40 /* MinusToken */) && ts.isNumericLiteral(node.operand); } ts.isSignedNumericLiteral = isSignedNumericLiteral; /** @@ -11387,10 +12344,13 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 150 /* ComputedPropertyName */ && - !isStringOrNumericLiteralLike(name.expression) && - !isSignedNumericLiteral(name.expression) && - !isWellKnownSymbolSyntactically(name.expression); + if (!(name.kind === 153 /* ComputedPropertyName */ || name.kind === 194 /* ElementAccessExpression */)) { + return false; + } + var expr = ts.isElementAccessExpression(name) ? name.argumentExpression : name.expression; + return !isStringOrNumericLiteralLike(expr) && + !isSignedNumericLiteral(expr) && + !isWellKnownSymbolSyntactically(expr); } ts.isDynamicName = isDynamicName; /** @@ -11404,12 +12364,12 @@ var ts; ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return name.escapedText; case 10 /* StringLiteral */: case 8 /* NumericLiteral */: return ts.escapeLeadingUnderscores(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); @@ -11425,7 +12385,7 @@ var ts; ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode; function isPropertyNameLiteral(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: @@ -11436,11 +12396,11 @@ var ts; } ts.isPropertyNameLiteral = isPropertyNameLiteral; function getTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? ts.idText(node) : node.text; + return node.kind === 75 /* Identifier */ ? ts.idText(node) : node.text; } ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral; function getEscapedTextOfIdentifierOrLiteral(node) { - return node.kind === 73 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); + return node.kind === 75 /* Identifier */ ? node.escapedText : ts.escapeLeadingUnderscores(node.text); } ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral; function getPropertyNameForKnownSymbolName(symbolName) { @@ -11455,7 +12415,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "Symbol"; + return node.kind === 75 /* Identifier */ && node.escapedText === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -11464,11 +12424,11 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 152 /* Parameter */; + return root.kind === 155 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 187 /* BindingElement */) { + while (node.kind === 190 /* BindingElement */) { node = node.parent.parent; } return node; @@ -11476,15 +12436,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 197 /* FunctionExpression */ - || kind === 240 /* FunctionDeclaration */ - || kind === 198 /* ArrowFunction */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 245 /* ModuleDeclaration */ - || kind === 285 /* SourceFile */; + return kind === 161 /* Constructor */ + || kind === 200 /* FunctionExpression */ + || kind === 243 /* FunctionDeclaration */ + || kind === 201 /* ArrowFunction */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 248 /* ModuleDeclaration */ + || kind === 288 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(range) { @@ -11503,38 +12463,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: return 1 /* Right */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operator) { - case 41 /* AsteriskAsteriskToken */: - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 42 /* AsteriskAsteriskToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 1 /* Right */; } } @@ -11543,15 +12503,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 193 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 196 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 205 /* BinaryExpression */) { + if (expression.kind === 208 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 203 /* PrefixUnaryExpression */ || expression.kind === 204 /* PostfixUnaryExpression */) { + else if (expression.kind === 206 /* PrefixUnaryExpression */ || expression.kind === 207 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -11561,73 +12521,73 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return 0; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return 1; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return 2; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return 4; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (operatorKind) { case 27 /* CommaToken */: return 0; - case 60 /* EqualsToken */: - case 61 /* PlusEqualsToken */: - case 62 /* MinusEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 63 /* AsteriskEqualsToken */: - case 65 /* SlashEqualsToken */: - case 66 /* PercentEqualsToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 70 /* AmpersandEqualsToken */: - case 72 /* CaretEqualsToken */: - case 71 /* BarEqualsToken */: + case 62 /* EqualsToken */: + case 63 /* PlusEqualsToken */: + case 64 /* MinusEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: + case 67 /* SlashEqualsToken */: + case 68 /* PercentEqualsToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 72 /* AmpersandEqualsToken */: + case 74 /* CaretEqualsToken */: + case 73 /* BarEqualsToken */: return 3; default: return getBinaryOperatorPrecedence(operatorKind); } - case 203 /* PrefixUnaryExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 199 /* DeleteExpression */: - case 202 /* AwaitExpression */: + case 206 /* PrefixUnaryExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 202 /* DeleteExpression */: + case 205 /* AwaitExpression */: return 16; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return 17; - case 192 /* CallExpression */: + case 195 /* CallExpression */: return 18; - case 193 /* NewExpression */: + case 196 /* NewExpression */: return hasArguments ? 19 : 18; - case 194 /* TaggedTemplateExpression */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 197 /* TaggedTemplateExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 19; - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 73 /* Identifier */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 75 /* Identifier */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 210 /* ClassExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: case 13 /* RegularExpressionLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 196 /* ParenthesizedExpression */: - case 211 /* OmittedExpression */: + case 210 /* TemplateExpression */: + case 199 /* ParenthesizedExpression */: + case 214 /* OmittedExpression */: return 20; default: return -1; @@ -11636,41 +12596,43 @@ var ts; ts.getOperatorPrecedence = getOperatorPrecedence; function getBinaryOperatorPrecedence(kind) { switch (kind) { - case 55 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: + return 4; + case 56 /* BarBarToken */: return 5; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return 6; - case 50 /* BarToken */: + case 51 /* BarToken */: return 7; - case 51 /* CaretToken */: + case 52 /* CaretToken */: return 8; - case 49 /* AmpersandToken */: + case 50 /* AmpersandToken */: return 9; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return 10; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: - case 95 /* InstanceOfKeyword */: - case 94 /* InKeyword */: - case 120 /* AsKeyword */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: + case 97 /* InstanceOfKeyword */: + case 96 /* InKeyword */: + case 122 /* AsKeyword */: return 11; - case 46 /* LessThanLessThanToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: + case 47 /* LessThanLessThanToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 38 /* PlusToken */: - case 39 /* MinusToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: return 13; - case 40 /* AsteriskToken */: - case 42 /* SlashToken */: - case 43 /* PercentToken */: + case 41 /* AsteriskToken */: + case 43 /* SlashToken */: + case 44 /* PercentToken */: return 14; - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return 15; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -11788,22 +12750,23 @@ var ts; } ts.escapeString = escapeString; /** - * Strip off existed single quotes or double quotes from a given string + * Strip off existed surrounding single quotes, double quotes, or backticks from a given string * * @return non-quoted string */ function stripQuotes(name) { var length = name.length; - if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && startsWithQuote(name)) { + if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) { return name.substring(1, length - 1); } return name; } ts.stripQuotes = stripQuotes; - function startsWithQuote(name) { - return isSingleOrDoubleQuote(name.charCodeAt(0)); + function isQuoteOrBacktick(charCode) { + return charCode === 39 /* singleQuote */ || + charCode === 34 /* doubleQuote */ || + charCode === 96 /* backtick */; } - ts.startsWithQuote = startsWithQuote; function getReplacement(c, offset, input) { if (c.charCodeAt(0) === 0 /* nullCharacter */) { var lookAhead = input.charCodeAt(offset + c.length); @@ -11854,6 +12817,7 @@ var ts; var lineStart; var lineCount; var linePos; + var hasTrailingComment = false; function updateLineCountAndPosFor(s) { var lineStartsOfS = ts.computeLineStarts(s); if (lineStartsOfS.length > 1) { @@ -11865,7 +12829,7 @@ var ts; lineStart = false; } } - function write(s) { + function writeText(s) { if (s && s.length) { if (lineStart) { s = getIndentString(indent) + s; @@ -11875,17 +12839,29 @@ var ts; updateLineCountAndPosFor(s); } } + function write(s) { + if (s) + hasTrailingComment = false; + writeText(s); + } + function writeComment(s) { + if (s) + hasTrailingComment = true; + writeText(s); + } function reset() { output = ""; indent = 0; lineStart = true; lineCount = 0; linePos = 0; + hasTrailingComment = false; } function rawWrite(s) { if (s !== undefined) { output += s; updateLineCountAndPosFor(s); + hasTrailingComment = false; } } function writeLiteral(s) { @@ -11899,6 +12875,7 @@ var ts; lineCount++; linePos = output.length; lineStart = true; + hasTrailingComment = false; } } function getTextPosWithWriteLine() { @@ -11918,6 +12895,8 @@ var ts; getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; }, getText: function () { return output; }, isAtStartOfLine: function () { return lineStart; }, + hasTrailingComment: function () { return hasTrailingComment; }, + hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); }, clear: reset, reportInaccessibleThisError: ts.noop, reportPrivateInBaseOfClassExpression: ts.noop, @@ -11932,12 +12911,12 @@ var ts; writeStringLiteral: write, writeSymbol: function (s, _) { return write(s); }, writeTrailingSemicolon: write, - writeComment: write, + writeComment: writeComment, getTextPosWithWriteLine: getTextPosWithWriteLine }; } ts.createTextWriter = createTextWriter; - function getTrailingSemicolonOmittingWriter(writer) { + function getTrailingSemicolonDeferringWriter(writer) { var pendingTrailingSemicolon = false; function commitPendingTrailingSemicolon() { if (pendingTrailingSemicolon) { @@ -12001,7 +12980,7 @@ var ts; writer.decreaseIndent(); } }); } - ts.getTrailingSemicolonOmittingWriter = getTrailingSemicolonOmittingWriter; + ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter; function getResolvedExternalModuleName(host, file, referenceFile) { return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName); } @@ -12019,7 +12998,7 @@ var ts; */ function getExternalModuleNameFromPath(host, fileName, referencePath) { var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); }; - var dir = toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); + var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName); var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory()); var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); var extensionless = ts.removeFileExtension(relativePath); @@ -12142,11 +13121,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return !!node && node.kind === 73 /* Identifier */ && identifierIsThisKeyword(node); + return !!node && node.kind === 75 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 101 /* ThisKeyword */; + return id.originalKeywordKind === 103 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -12157,10 +13136,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 160 /* SetAccessor */) { + else if (accessor.kind === 163 /* SetAccessor */) { setAccessor = accessor; } else { @@ -12180,10 +13159,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 159 /* GetAccessor */ && !getAccessor) { + if (member.kind === 162 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 160 /* SetAccessor */ && !setAccessor) { + if (member.kind === 163 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -12229,7 +13208,7 @@ var ts; ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations; /** template tags are only available when a typedef isn't already using them */ function isNonTypeAliasTemplate(tag) { - return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 298 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); + return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 301 /* JSDocComment */ && tag.parent.tags.some(isJSDocTypeAlias)); } /** * Gets the effective type annotation of the value parameter of a set accessor. If the node @@ -12469,7 +13448,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 73 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 75 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } return flags; @@ -12477,29 +13456,29 @@ var ts; ts.getModifierFlagsNoCache = getModifierFlagsNoCache; function modifierToFlag(token) { switch (token) { - case 117 /* StaticKeyword */: return 32 /* Static */; - case 116 /* PublicKeyword */: return 4 /* Public */; - case 115 /* ProtectedKeyword */: return 16 /* Protected */; - case 114 /* PrivateKeyword */: return 8 /* Private */; - case 119 /* AbstractKeyword */: return 128 /* Abstract */; - case 86 /* ExportKeyword */: return 1 /* Export */; - case 126 /* DeclareKeyword */: return 2 /* Ambient */; - case 78 /* ConstKeyword */: return 2048 /* Const */; - case 81 /* DefaultKeyword */: return 512 /* Default */; - case 122 /* AsyncKeyword */: return 256 /* Async */; - case 134 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 119 /* StaticKeyword */: return 32 /* Static */; + case 118 /* PublicKeyword */: return 4 /* Public */; + case 117 /* ProtectedKeyword */: return 16 /* Protected */; + case 116 /* PrivateKeyword */: return 8 /* Private */; + case 121 /* AbstractKeyword */: return 128 /* Abstract */; + case 88 /* ExportKeyword */: return 1 /* Export */; + case 129 /* DeclareKeyword */: return 2 /* Ambient */; + case 80 /* ConstKeyword */: return 2048 /* Const */; + case 83 /* DefaultKeyword */: return 512 /* Default */; + case 125 /* AsyncKeyword */: return 256 /* Async */; + case 137 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 55 /* BarBarToken */ - || token === 54 /* AmpersandAmpersandToken */ - || token === 52 /* ExclamationToken */; + return token === 56 /* BarBarToken */ + || token === 55 /* AmpersandAmpersandToken */ + || token === 53 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 60 /* FirstAssignment */ && token <= 72 /* LastAssignment */; + return token >= 62 /* FirstAssignment */ && token <= 74 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ @@ -12512,14 +13491,14 @@ var ts; return ts.isExpressionWithTypeArguments(node) && ts.isHeritageClause(node.parent) && ts.isClassLike(node.parent.parent) - ? { class: node.parent.parent, isImplements: node.parent.token === 110 /* ImplementsKeyword */ } + ? { class: node.parent.parent, isImplements: node.parent.token === 112 /* ImplementsKeyword */ } : undefined; } ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments; function isAssignmentExpression(node, excludeCompoundAssignment) { return ts.isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 60 /* EqualsToken */ + ? node.operatorToken.kind === 62 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && ts.isLeftHandSideExpression(node.left); } @@ -12527,8 +13506,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 189 /* ObjectLiteralExpression */ - || kind === 188 /* ArrayLiteralExpression */; + return kind === 192 /* ObjectLiteralExpression */ + || kind === 191 /* ArrayLiteralExpression */; } return false; } @@ -12538,9 +13517,32 @@ var ts; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; function isEntityNameExpression(node) { - return node.kind === 73 /* Identifier */ || isPropertyAccessEntityNameExpression(node); + return node.kind === 75 /* Identifier */ || isPropertyAccessEntityNameExpression(node); } ts.isEntityNameExpression = isEntityNameExpression; + function getFirstIdentifier(node) { + switch (node.kind) { + case 75 /* Identifier */: + return node; + case 152 /* QualifiedName */: + do { + node = node.left; + } while (node.kind !== 75 /* Identifier */); + return node; + case 193 /* PropertyAccessExpression */: + do { + node = node.expression; + } while (node.kind !== 75 /* Identifier */); + return node; + } + } + ts.getFirstIdentifier = getFirstIdentifier; + function isDottedName(node) { + return node.kind === 75 /* Identifier */ || node.kind === 103 /* ThisKeyword */ || + node.kind === 193 /* PropertyAccessExpression */ && isDottedName(node.expression) || + node.kind === 199 /* ParenthesizedExpression */ && isDottedName(node.expression); + } + ts.isDottedName = isDottedName; function isPropertyAccessEntityNameExpression(node) { return ts.isPropertyAccessExpression(node) && isEntityNameExpression(node.expression); } @@ -12556,21 +13558,21 @@ var ts; } ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString; function isPrototypeAccess(node) { - return ts.isPropertyAccessExpression(node) && node.name.escapedText === "prototype"; + return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype"; } ts.isPrototypeAccess = isPrototypeAccess; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 149 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 152 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; function isEmptyObjectLiteral(expression) { - return expression.kind === 189 /* ObjectLiteralExpression */ && + return expression.kind === 192 /* ObjectLiteralExpression */ && expression.properties.length === 0; } ts.isEmptyObjectLiteral = isEmptyObjectLiteral; function isEmptyArrayLiteral(expression) { - return expression.kind === 188 /* ArrayLiteralExpression */ && + return expression.kind === 191 /* ArrayLiteralExpression */ && expression.elements.length === 0; } ts.isEmptyArrayLiteral = isEmptyArrayLiteral; @@ -12868,8 +13870,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 244 /* EnumDeclaration */: - case 245 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -12946,35 +13948,35 @@ var ts; if (!parent) return 0 /* Read */; switch (parent.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return accessKind(parent); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var operator = parent.operator; - return operator === 44 /* PlusPlusToken */ || operator === 45 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; - case 205 /* BinaryExpression */: + return operator === 45 /* PlusPlusToken */ || operator === 46 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 208 /* BinaryExpression */: var _a = parent, left = _a.left, operatorToken = _a.operatorToken; return left === node && isAssignmentOperator(operatorToken.kind) ? - operatorToken.kind === 60 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() + operatorToken.kind === 62 /* EqualsToken */ ? 1 /* Write */ : writeOrReadWrite() : 0 /* Read */; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return parent.name !== node ? 0 /* Read */ : accessKind(parent); - case 276 /* PropertyAssignment */: { + case 279 /* PropertyAssignment */: { var parentAccess = accessKind(parent.parent); // In `({ x: varname }) = { x: 1 }`, the left `x` is a read, the right `x` is a write. return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess; } - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // Assume it's the local variable being accessed, since we don't check public properties for --noUnusedLocals. return node === parent.objectAssignmentInitializer ? 0 /* Read */ : accessKind(parent.parent); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return accessKind(parent); default: return 0 /* Read */; } function writeOrReadWrite() { // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. - return parent.parent && skipParenthesesUp(parent.parent).kind === 222 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + return parent.parent && skipParenthesesUp(parent.parent).kind === 225 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; } } function reverseAccessKind(a) { @@ -13053,21 +14055,6 @@ var ts; }); } ts.mutateMap = mutateMap; - /** Calls `callback` on `directory` and every ancestor directory it has, returning the first defined result. */ - function forEachAncestorDirectory(directory, callback) { - while (true) { - var result = callback(directory); - if (result !== undefined) { - return result; - } - var parentPath = ts.getDirectoryPath(directory); - if (parentPath === directory) { - return undefined; - } - directory = parentPath; - } - } - ts.forEachAncestorDirectory = forEachAncestorDirectory; // Return true if the given type is the constructor type for an abstract class function isAbstractConstructorType(type) { return !!(getObjectFlags(type) & 16 /* Anonymous */) && !!type.symbol && isAbstractConstructorSymbol(type.symbol); @@ -13094,7 +14081,7 @@ var ts; } ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures; function forSomeAncestorDirectory(directory, callback) { - return !!forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); + return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; }); } ts.forSomeAncestorDirectory = forSomeAncestorDirectory; function isUMDExportSymbol(symbol) { @@ -13138,32 +14125,32 @@ var ts; } ts.isObjectTypeDeclaration = isObjectTypeDeclaration; function isTypeNodeKind(kind) { - return (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) - || kind === 121 /* AnyKeyword */ - || kind === 144 /* UnknownKeyword */ - || kind === 136 /* NumberKeyword */ - || kind === 147 /* BigIntKeyword */ - || kind === 137 /* ObjectKeyword */ - || kind === 124 /* BooleanKeyword */ - || kind === 139 /* StringKeyword */ - || kind === 140 /* SymbolKeyword */ - || kind === 101 /* ThisKeyword */ - || kind === 107 /* VoidKeyword */ - || kind === 142 /* UndefinedKeyword */ - || kind === 97 /* NullKeyword */ - || kind === 133 /* NeverKeyword */ - || kind === 212 /* ExpressionWithTypeArguments */ - || kind === 290 /* JSDocAllType */ - || kind === 291 /* JSDocUnknownType */ - || kind === 292 /* JSDocNullableType */ - || kind === 293 /* JSDocNonNullableType */ - || kind === 294 /* JSDocOptionalType */ - || kind === 295 /* JSDocFunctionType */ - || kind === 296 /* JSDocVariadicType */; + return (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) + || kind === 124 /* AnyKeyword */ + || kind === 147 /* UnknownKeyword */ + || kind === 139 /* NumberKeyword */ + || kind === 150 /* BigIntKeyword */ + || kind === 140 /* ObjectKeyword */ + || kind === 127 /* BooleanKeyword */ + || kind === 142 /* StringKeyword */ + || kind === 143 /* SymbolKeyword */ + || kind === 103 /* ThisKeyword */ + || kind === 109 /* VoidKeyword */ + || kind === 145 /* UndefinedKeyword */ + || kind === 99 /* NullKeyword */ + || kind === 136 /* NeverKeyword */ + || kind === 215 /* ExpressionWithTypeArguments */ + || kind === 293 /* JSDocAllType */ + || kind === 294 /* JSDocUnknownType */ + || kind === 295 /* JSDocNullableType */ + || kind === 296 /* JSDocNonNullableType */ + || kind === 297 /* JSDocOptionalType */ + || kind === 298 /* JSDocFunctionType */ + || kind === 299 /* JSDocVariadicType */; } ts.isTypeNodeKind = isTypeNodeKind; function isAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */ || node.kind === 191 /* ElementAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */ || node.kind === 194 /* ElementAccessExpression */; } ts.isAccessExpression = isAccessExpression; function isBundleFileTextLike(section) { @@ -13176,6 +14163,10 @@ var ts; } } ts.isBundleFileTextLike = isBundleFileTextLike; + function getDotOrQuestionDotToken(node) { + return node.questionDotToken || ts.createNode(24 /* DotToken */, node.expression.end, node.name.pos); + } + ts.getDotOrQuestionDotToken = getDotOrQuestionDotToken; })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -13283,7 +14274,7 @@ var ts; return { span: span, newLength: newLength }; } ts.createTextChangeRange = createTextChangeRange; - ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); + ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0); // eslint-disable-line prefer-const /** * Called to merge all the changes that occurred across several versions of a script snapshot * into a single change. i.e. if a user keeps making successive edits to a script we will @@ -13400,9 +14391,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 151 /* TypeParameter */) { + if (d && d.kind === 154 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 242 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 245 /* InterfaceDeclaration */) { return current; } } @@ -13410,7 +14401,7 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node, parent) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 158 /* Constructor */; + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && parent.kind === 161 /* Constructor */; } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function isEmptyBindingPattern(node) { @@ -13440,14 +14431,14 @@ var ts; node = walkUpBindingElementsAndPatterns(node); } var flags = getFlags(node); - if (node.kind === 238 /* VariableDeclaration */) { + if (node.kind === 241 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 239 /* VariableDeclarationList */) { + if (node && node.kind === 242 /* VariableDeclarationList */) { flags |= getFlags(node); node = node.parent; } - if (node && node.kind === 220 /* VariableStatement */) { + if (node && node.kind === 224 /* VariableStatement */) { flags |= getFlags(node); } return flags; @@ -13511,7 +14502,8 @@ var ts; return false; } try { - // tslint:disable-next-line no-unnecessary-qualifier (making clear this is a global mutation!) + // making clear this is a global mutation! + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier ts.localizedDiagnosticMessages = JSON.parse(fileContents); } catch (_a) { @@ -13593,30 +14585,30 @@ var ts; } // Covers remaining cases (returning undefined if none match). switch (hostNode.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (hostNode.declarationList && hostNode.declarationList.declarations[0]) { return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); } break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: var expr = hostNode.expression; - if (expr.kind === 205 /* BinaryExpression */ && expr.operatorToken.kind === 60 /* EqualsToken */) { + if (expr.kind === 208 /* BinaryExpression */ && expr.operatorToken.kind === 62 /* EqualsToken */) { expr = expr.left; } switch (expr.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return expr.name; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: var arg = expr.argumentExpression; if (ts.isIdentifier(arg)) { return arg; } } break; - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { return getDeclarationIdentifier(hostNode.expression); } - case 234 /* LabeledStatement */: { + case 237 /* LabeledStatement */: { if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { return getDeclarationIdentifier(hostNode.statement); } @@ -13628,6 +14620,17 @@ var ts; var name = getNameOfDeclaration(node); return name && ts.isIdentifier(name) ? name : undefined; } + /** @internal */ + function nodeHasName(statement, name) { + if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) { + return true; + } + if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) { + return true; + } + return false; + } + ts.nodeHasName = nodeHasName; function getNameOfJSDocTypedef(declaration) { return declaration.name || nameForNamelessJSDocTypedef(declaration); } @@ -13640,41 +14643,46 @@ var ts; /** @internal */ function getNonAssignedNameOfDeclaration(declaration) { switch (declaration.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return declaration; - case 313 /* JSDocPropertyTag */: - case 307 /* JSDocParameterTag */: { + case 316 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: { var name = declaration.name; - if (name.kind === 149 /* QualifiedName */) { + if (name.kind === 152 /* QualifiedName */) { return name.right; } break; } - case 192 /* CallExpression */: - case 205 /* BinaryExpression */: { - var expr = declaration; - switch (ts.getAssignmentDeclarationKind(expr)) { + case 195 /* CallExpression */: + case 208 /* BinaryExpression */: { + var expr_1 = declaration; + switch (ts.getAssignmentDeclarationKind(expr_1)) { case 1 /* ExportsProperty */: case 4 /* ThisProperty */: case 5 /* Property */: case 3 /* PrototypeProperty */: - return expr.left.name; + return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left); case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: - return expr.arguments[1]; + return expr_1.arguments[1]; default: return undefined; } } - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return getNameOfJSDocTypedef(declaration); - case 306 /* JSDocEnumTag */: + case 309 /* JSDocEnumTag */: return nameForNamelessJSDocTypedef(declaration); - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { var expression = declaration.expression; return ts.isIdentifier(expression) ? expression : undefined; } + case 194 /* ElementAccessExpression */: + var expr = declaration; + if (ts.isBindableStaticElementAccessExpression(expr)) { + return expr.argumentExpression; + } } return declaration.name; } @@ -13697,8 +14705,8 @@ var ts; if (ts.isIdentifier(node.parent.left)) { return node.parent.left; } - else if (ts.isPropertyAccessExpression(node.parent.left)) { - return node.parent.left.name; + else if (ts.isAccessExpression(node.parent.left)) { + return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left); } } else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) { @@ -13876,7 +14884,7 @@ var ts; return ts.emptyArray; } if (ts.isJSDocTypeAlias(node)) { - ts.Debug.assert(node.parent.kind === 298 /* JSDocComment */); + ts.Debug.assert(node.parent.kind === 301 /* JSDocComment */); return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; }); } if (node.typeParameters) { @@ -13896,10 +14904,9 @@ var ts; } ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations; function getEffectiveConstraintOfTypeParameter(node) { - return node.constraint ? node.constraint - : ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] - ? node.parent.constraint - : undefined; + return node.constraint ? node.constraint : + ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint : + undefined; } ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter; })(ts || (ts = {})); @@ -13944,198 +14951,230 @@ var ts; } ts.isTemplateTail = isTemplateTail; function isIdentifier(node) { - return node.kind === 73 /* Identifier */; + return node.kind === 75 /* Identifier */; } ts.isIdentifier = isIdentifier; // Names function isQualifiedName(node) { - return node.kind === 149 /* QualifiedName */; + return node.kind === 152 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 150 /* ComputedPropertyName */; + return node.kind === 153 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; // Signature elements function isTypeParameterDeclaration(node) { - return node.kind === 151 /* TypeParameter */; + return node.kind === 154 /* TypeParameter */; } ts.isTypeParameterDeclaration = isTypeParameterDeclaration; function isParameter(node) { - return node.kind === 152 /* Parameter */; + return node.kind === 155 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 153 /* Decorator */; + return node.kind === 156 /* Decorator */; } ts.isDecorator = isDecorator; // TypeMember function isPropertySignature(node) { - return node.kind === 154 /* PropertySignature */; + return node.kind === 157 /* PropertySignature */; } ts.isPropertySignature = isPropertySignature; function isPropertyDeclaration(node) { - return node.kind === 155 /* PropertyDeclaration */; + return node.kind === 158 /* PropertyDeclaration */; } ts.isPropertyDeclaration = isPropertyDeclaration; function isMethodSignature(node) { - return node.kind === 156 /* MethodSignature */; + return node.kind === 159 /* MethodSignature */; } ts.isMethodSignature = isMethodSignature; function isMethodDeclaration(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isConstructorDeclaration(node) { - return node.kind === 158 /* Constructor */; + return node.kind === 161 /* Constructor */; } ts.isConstructorDeclaration = isConstructorDeclaration; function isGetAccessorDeclaration(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; } ts.isGetAccessorDeclaration = isGetAccessorDeclaration; function isSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessorDeclaration = isSetAccessorDeclaration; function isCallSignatureDeclaration(node) { - return node.kind === 161 /* CallSignature */; + return node.kind === 164 /* CallSignature */; } ts.isCallSignatureDeclaration = isCallSignatureDeclaration; function isConstructSignatureDeclaration(node) { - return node.kind === 162 /* ConstructSignature */; + return node.kind === 165 /* ConstructSignature */; } ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration; function isIndexSignatureDeclaration(node) { - return node.kind === 163 /* IndexSignature */; + return node.kind === 166 /* IndexSignature */; } ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration; /* @internal */ function isGetOrSetAccessorDeclaration(node) { - return node.kind === 160 /* SetAccessor */ || node.kind === 159 /* GetAccessor */; + return node.kind === 163 /* SetAccessor */ || node.kind === 162 /* GetAccessor */; } ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration; // Type function isTypePredicateNode(node) { - return node.kind === 164 /* TypePredicate */; + return node.kind === 167 /* TypePredicate */; } ts.isTypePredicateNode = isTypePredicateNode; function isTypeReferenceNode(node) { - return node.kind === 165 /* TypeReference */; + return node.kind === 168 /* TypeReference */; } ts.isTypeReferenceNode = isTypeReferenceNode; function isFunctionTypeNode(node) { - return node.kind === 166 /* FunctionType */; + return node.kind === 169 /* FunctionType */; } ts.isFunctionTypeNode = isFunctionTypeNode; function isConstructorTypeNode(node) { - return node.kind === 167 /* ConstructorType */; + return node.kind === 170 /* ConstructorType */; } ts.isConstructorTypeNode = isConstructorTypeNode; function isTypeQueryNode(node) { - return node.kind === 168 /* TypeQuery */; + return node.kind === 171 /* TypeQuery */; } ts.isTypeQueryNode = isTypeQueryNode; function isTypeLiteralNode(node) { - return node.kind === 169 /* TypeLiteral */; + return node.kind === 172 /* TypeLiteral */; } ts.isTypeLiteralNode = isTypeLiteralNode; function isArrayTypeNode(node) { - return node.kind === 170 /* ArrayType */; + return node.kind === 173 /* ArrayType */; } ts.isArrayTypeNode = isArrayTypeNode; function isTupleTypeNode(node) { - return node.kind === 171 /* TupleType */; + return node.kind === 174 /* TupleType */; } ts.isTupleTypeNode = isTupleTypeNode; function isUnionTypeNode(node) { - return node.kind === 174 /* UnionType */; + return node.kind === 177 /* UnionType */; } ts.isUnionTypeNode = isUnionTypeNode; function isIntersectionTypeNode(node) { - return node.kind === 175 /* IntersectionType */; + return node.kind === 178 /* IntersectionType */; } ts.isIntersectionTypeNode = isIntersectionTypeNode; function isConditionalTypeNode(node) { - return node.kind === 176 /* ConditionalType */; + return node.kind === 179 /* ConditionalType */; } ts.isConditionalTypeNode = isConditionalTypeNode; function isInferTypeNode(node) { - return node.kind === 177 /* InferType */; + return node.kind === 180 /* InferType */; } ts.isInferTypeNode = isInferTypeNode; function isParenthesizedTypeNode(node) { - return node.kind === 178 /* ParenthesizedType */; + return node.kind === 181 /* ParenthesizedType */; } ts.isParenthesizedTypeNode = isParenthesizedTypeNode; function isThisTypeNode(node) { - return node.kind === 179 /* ThisType */; + return node.kind === 182 /* ThisType */; } ts.isThisTypeNode = isThisTypeNode; function isTypeOperatorNode(node) { - return node.kind === 180 /* TypeOperator */; + return node.kind === 183 /* TypeOperator */; } ts.isTypeOperatorNode = isTypeOperatorNode; function isIndexedAccessTypeNode(node) { - return node.kind === 181 /* IndexedAccessType */; + return node.kind === 184 /* IndexedAccessType */; } ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode; function isMappedTypeNode(node) { - return node.kind === 182 /* MappedType */; + return node.kind === 185 /* MappedType */; } ts.isMappedTypeNode = isMappedTypeNode; function isLiteralTypeNode(node) { - return node.kind === 183 /* LiteralType */; + return node.kind === 186 /* LiteralType */; } ts.isLiteralTypeNode = isLiteralTypeNode; function isImportTypeNode(node) { - return node.kind === 184 /* ImportType */; + return node.kind === 187 /* ImportType */; } ts.isImportTypeNode = isImportTypeNode; // Binding patterns function isObjectBindingPattern(node) { - return node.kind === 185 /* ObjectBindingPattern */; + return node.kind === 188 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isArrayBindingPattern(node) { - return node.kind === 186 /* ArrayBindingPattern */; + return node.kind === 189 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isBindingElement(node) { - return node.kind === 187 /* BindingElement */; + return node.kind === 190 /* BindingElement */; } ts.isBindingElement = isBindingElement; // Expression function isArrayLiteralExpression(node) { - return node.kind === 188 /* ArrayLiteralExpression */; + return node.kind === 191 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 189 /* ObjectLiteralExpression */; + return node.kind === 192 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 190 /* PropertyAccessExpression */; + return node.kind === 193 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessChain(node) { + return isPropertyAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isPropertyAccessChain = isPropertyAccessChain; function isElementAccessExpression(node) { - return node.kind === 191 /* ElementAccessExpression */; + return node.kind === 194 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; + function isElementAccessChain(node) { + return isElementAccessExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isElementAccessChain = isElementAccessChain; function isCallExpression(node) { - return node.kind === 192 /* CallExpression */; + return node.kind === 195 /* CallExpression */; } ts.isCallExpression = isCallExpression; + function isCallChain(node) { + return isCallExpression(node) && !!(node.flags & 32 /* OptionalChain */); + } + ts.isCallChain = isCallChain; + function isOptionalChain(node) { + var kind = node.kind; + return !!(node.flags & 32 /* OptionalChain */) && + (kind === 193 /* PropertyAccessExpression */ + || kind === 194 /* ElementAccessExpression */ + || kind === 195 /* CallExpression */); + } + ts.isOptionalChain = isOptionalChain; + /** + * Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`). + */ + /* @internal */ + function isExpressionOfOptionalChainRoot(node) { + return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node; + } + ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot; + function isNullishCoalesce(node) { + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */; + } + ts.isNullishCoalesce = isNullishCoalesce; function isNewExpression(node) { - return node.kind === 193 /* NewExpression */; + return node.kind === 196 /* NewExpression */; } ts.isNewExpression = isNewExpression; function isTaggedTemplateExpression(node) { - return node.kind === 194 /* TaggedTemplateExpression */; + return node.kind === 197 /* TaggedTemplateExpression */; } ts.isTaggedTemplateExpression = isTaggedTemplateExpression; function isTypeAssertion(node) { - return node.kind === 195 /* TypeAssertionExpression */; + return node.kind === 198 /* TypeAssertionExpression */; } ts.isTypeAssertion = isTypeAssertion; function isConstTypeReference(node) { @@ -14144,376 +15183,376 @@ var ts; } ts.isConstTypeReference = isConstTypeReference; function isParenthesizedExpression(node) { - return node.kind === 196 /* ParenthesizedExpression */; + return node.kind === 199 /* ParenthesizedExpression */; } ts.isParenthesizedExpression = isParenthesizedExpression; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 316 /* PartiallyEmittedExpression */) { + while (node.kind === 319 /* PartiallyEmittedExpression */) { node = node.expression; } return node; } ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions; function isFunctionExpression(node) { - return node.kind === 197 /* FunctionExpression */; + return node.kind === 200 /* FunctionExpression */; } ts.isFunctionExpression = isFunctionExpression; function isArrowFunction(node) { - return node.kind === 198 /* ArrowFunction */; + return node.kind === 201 /* ArrowFunction */; } ts.isArrowFunction = isArrowFunction; function isDeleteExpression(node) { - return node.kind === 199 /* DeleteExpression */; + return node.kind === 202 /* DeleteExpression */; } ts.isDeleteExpression = isDeleteExpression; function isTypeOfExpression(node) { - return node.kind === 200 /* TypeOfExpression */; + return node.kind === 203 /* TypeOfExpression */; } ts.isTypeOfExpression = isTypeOfExpression; function isVoidExpression(node) { - return node.kind === 201 /* VoidExpression */; + return node.kind === 204 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isAwaitExpression(node) { - return node.kind === 202 /* AwaitExpression */; + return node.kind === 205 /* AwaitExpression */; } ts.isAwaitExpression = isAwaitExpression; function isPrefixUnaryExpression(node) { - return node.kind === 203 /* PrefixUnaryExpression */; + return node.kind === 206 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function isPostfixUnaryExpression(node) { - return node.kind === 204 /* PostfixUnaryExpression */; + return node.kind === 207 /* PostfixUnaryExpression */; } ts.isPostfixUnaryExpression = isPostfixUnaryExpression; function isBinaryExpression(node) { - return node.kind === 205 /* BinaryExpression */; + return node.kind === 208 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 206 /* ConditionalExpression */; + return node.kind === 209 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isTemplateExpression(node) { - return node.kind === 207 /* TemplateExpression */; + return node.kind === 210 /* TemplateExpression */; } ts.isTemplateExpression = isTemplateExpression; function isYieldExpression(node) { - return node.kind === 208 /* YieldExpression */; + return node.kind === 211 /* YieldExpression */; } ts.isYieldExpression = isYieldExpression; function isSpreadElement(node) { - return node.kind === 209 /* SpreadElement */; + return node.kind === 212 /* SpreadElement */; } ts.isSpreadElement = isSpreadElement; function isClassExpression(node) { - return node.kind === 210 /* ClassExpression */; + return node.kind === 213 /* ClassExpression */; } ts.isClassExpression = isClassExpression; function isOmittedExpression(node) { - return node.kind === 211 /* OmittedExpression */; + return node.kind === 214 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isAsExpression(node) { - return node.kind === 213 /* AsExpression */; + return node.kind === 216 /* AsExpression */; } ts.isAsExpression = isAsExpression; function isNonNullExpression(node) { - return node.kind === 214 /* NonNullExpression */; + return node.kind === 217 /* NonNullExpression */; } ts.isNonNullExpression = isNonNullExpression; function isMetaProperty(node) { - return node.kind === 215 /* MetaProperty */; + return node.kind === 218 /* MetaProperty */; } ts.isMetaProperty = isMetaProperty; // Misc function isTemplateSpan(node) { - return node.kind === 217 /* TemplateSpan */; + return node.kind === 220 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; function isSemicolonClassElement(node) { - return node.kind === 218 /* SemicolonClassElement */; + return node.kind === 221 /* SemicolonClassElement */; } ts.isSemicolonClassElement = isSemicolonClassElement; // Block function isBlock(node) { - return node.kind === 219 /* Block */; + return node.kind === 222 /* Block */; } ts.isBlock = isBlock; function isVariableStatement(node) { - return node.kind === 220 /* VariableStatement */; + return node.kind === 224 /* VariableStatement */; } ts.isVariableStatement = isVariableStatement; function isEmptyStatement(node) { - return node.kind === 221 /* EmptyStatement */; + return node.kind === 223 /* EmptyStatement */; } ts.isEmptyStatement = isEmptyStatement; function isExpressionStatement(node) { - return node.kind === 222 /* ExpressionStatement */; + return node.kind === 225 /* ExpressionStatement */; } ts.isExpressionStatement = isExpressionStatement; function isIfStatement(node) { - return node.kind === 223 /* IfStatement */; + return node.kind === 226 /* IfStatement */; } ts.isIfStatement = isIfStatement; function isDoStatement(node) { - return node.kind === 224 /* DoStatement */; + return node.kind === 227 /* DoStatement */; } ts.isDoStatement = isDoStatement; function isWhileStatement(node) { - return node.kind === 225 /* WhileStatement */; + return node.kind === 228 /* WhileStatement */; } ts.isWhileStatement = isWhileStatement; function isForStatement(node) { - return node.kind === 226 /* ForStatement */; + return node.kind === 229 /* ForStatement */; } ts.isForStatement = isForStatement; function isForInStatement(node) { - return node.kind === 227 /* ForInStatement */; + return node.kind === 230 /* ForInStatement */; } ts.isForInStatement = isForInStatement; function isForOfStatement(node) { - return node.kind === 228 /* ForOfStatement */; + return node.kind === 231 /* ForOfStatement */; } ts.isForOfStatement = isForOfStatement; function isContinueStatement(node) { - return node.kind === 229 /* ContinueStatement */; + return node.kind === 232 /* ContinueStatement */; } ts.isContinueStatement = isContinueStatement; function isBreakStatement(node) { - return node.kind === 230 /* BreakStatement */; + return node.kind === 233 /* BreakStatement */; } ts.isBreakStatement = isBreakStatement; function isBreakOrContinueStatement(node) { - return node.kind === 230 /* BreakStatement */ || node.kind === 229 /* ContinueStatement */; + return node.kind === 233 /* BreakStatement */ || node.kind === 232 /* ContinueStatement */; } ts.isBreakOrContinueStatement = isBreakOrContinueStatement; function isReturnStatement(node) { - return node.kind === 231 /* ReturnStatement */; + return node.kind === 234 /* ReturnStatement */; } ts.isReturnStatement = isReturnStatement; function isWithStatement(node) { - return node.kind === 232 /* WithStatement */; + return node.kind === 235 /* WithStatement */; } ts.isWithStatement = isWithStatement; function isSwitchStatement(node) { - return node.kind === 233 /* SwitchStatement */; + return node.kind === 236 /* SwitchStatement */; } ts.isSwitchStatement = isSwitchStatement; function isLabeledStatement(node) { - return node.kind === 234 /* LabeledStatement */; + return node.kind === 237 /* LabeledStatement */; } ts.isLabeledStatement = isLabeledStatement; function isThrowStatement(node) { - return node.kind === 235 /* ThrowStatement */; + return node.kind === 238 /* ThrowStatement */; } ts.isThrowStatement = isThrowStatement; function isTryStatement(node) { - return node.kind === 236 /* TryStatement */; + return node.kind === 239 /* TryStatement */; } ts.isTryStatement = isTryStatement; function isDebuggerStatement(node) { - return node.kind === 237 /* DebuggerStatement */; + return node.kind === 240 /* DebuggerStatement */; } ts.isDebuggerStatement = isDebuggerStatement; function isVariableDeclaration(node) { - return node.kind === 238 /* VariableDeclaration */; + return node.kind === 241 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 239 /* VariableDeclarationList */; + return node.kind === 242 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isFunctionDeclaration(node) { - return node.kind === 240 /* FunctionDeclaration */; + return node.kind === 243 /* FunctionDeclaration */; } ts.isFunctionDeclaration = isFunctionDeclaration; function isClassDeclaration(node) { - return node.kind === 241 /* ClassDeclaration */; + return node.kind === 244 /* ClassDeclaration */; } ts.isClassDeclaration = isClassDeclaration; function isInterfaceDeclaration(node) { - return node.kind === 242 /* InterfaceDeclaration */; + return node.kind === 245 /* InterfaceDeclaration */; } ts.isInterfaceDeclaration = isInterfaceDeclaration; function isTypeAliasDeclaration(node) { - return node.kind === 243 /* TypeAliasDeclaration */; + return node.kind === 246 /* TypeAliasDeclaration */; } ts.isTypeAliasDeclaration = isTypeAliasDeclaration; function isEnumDeclaration(node) { - return node.kind === 244 /* EnumDeclaration */; + return node.kind === 247 /* EnumDeclaration */; } ts.isEnumDeclaration = isEnumDeclaration; function isModuleDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */; + return node.kind === 248 /* ModuleDeclaration */; } ts.isModuleDeclaration = isModuleDeclaration; function isModuleBlock(node) { - return node.kind === 246 /* ModuleBlock */; + return node.kind === 249 /* ModuleBlock */; } ts.isModuleBlock = isModuleBlock; function isCaseBlock(node) { - return node.kind === 247 /* CaseBlock */; + return node.kind === 250 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isNamespaceExportDeclaration(node) { - return node.kind === 248 /* NamespaceExportDeclaration */; + return node.kind === 251 /* NamespaceExportDeclaration */; } ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration; function isImportEqualsDeclaration(node) { - return node.kind === 249 /* ImportEqualsDeclaration */; + return node.kind === 252 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportDeclaration(node) { - return node.kind === 250 /* ImportDeclaration */; + return node.kind === 253 /* ImportDeclaration */; } ts.isImportDeclaration = isImportDeclaration; function isImportClause(node) { - return node.kind === 251 /* ImportClause */; + return node.kind === 254 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamespaceImport(node) { - return node.kind === 252 /* NamespaceImport */; + return node.kind === 255 /* NamespaceImport */; } ts.isNamespaceImport = isNamespaceImport; function isNamedImports(node) { - return node.kind === 253 /* NamedImports */; + return node.kind === 256 /* NamedImports */; } ts.isNamedImports = isNamedImports; function isImportSpecifier(node) { - return node.kind === 254 /* ImportSpecifier */; + return node.kind === 257 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isExportAssignment(node) { - return node.kind === 255 /* ExportAssignment */; + return node.kind === 258 /* ExportAssignment */; } ts.isExportAssignment = isExportAssignment; function isExportDeclaration(node) { - return node.kind === 256 /* ExportDeclaration */; + return node.kind === 259 /* ExportDeclaration */; } ts.isExportDeclaration = isExportDeclaration; function isNamedExports(node) { - return node.kind === 257 /* NamedExports */; + return node.kind === 260 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 258 /* ExportSpecifier */; + return node.kind === 261 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isMissingDeclaration(node) { - return node.kind === 259 /* MissingDeclaration */; + return node.kind === 262 /* MissingDeclaration */; } ts.isMissingDeclaration = isMissingDeclaration; // Module References function isExternalModuleReference(node) { - return node.kind === 260 /* ExternalModuleReference */; + return node.kind === 263 /* ExternalModuleReference */; } ts.isExternalModuleReference = isExternalModuleReference; // JSX function isJsxElement(node) { - return node.kind === 261 /* JsxElement */; + return node.kind === 264 /* JsxElement */; } ts.isJsxElement = isJsxElement; function isJsxSelfClosingElement(node) { - return node.kind === 262 /* JsxSelfClosingElement */; + return node.kind === 265 /* JsxSelfClosingElement */; } ts.isJsxSelfClosingElement = isJsxSelfClosingElement; function isJsxOpeningElement(node) { - return node.kind === 263 /* JsxOpeningElement */; + return node.kind === 266 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 264 /* JsxClosingElement */; + return node.kind === 267 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxFragment(node) { - return node.kind === 265 /* JsxFragment */; + return node.kind === 268 /* JsxFragment */; } ts.isJsxFragment = isJsxFragment; function isJsxOpeningFragment(node) { - return node.kind === 266 /* JsxOpeningFragment */; + return node.kind === 269 /* JsxOpeningFragment */; } ts.isJsxOpeningFragment = isJsxOpeningFragment; function isJsxClosingFragment(node) { - return node.kind === 267 /* JsxClosingFragment */; + return node.kind === 270 /* JsxClosingFragment */; } ts.isJsxClosingFragment = isJsxClosingFragment; function isJsxAttribute(node) { - return node.kind === 268 /* JsxAttribute */; + return node.kind === 271 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; function isJsxAttributes(node) { - return node.kind === 269 /* JsxAttributes */; + return node.kind === 272 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxSpreadAttribute(node) { - return node.kind === 270 /* JsxSpreadAttribute */; + return node.kind === 273 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxExpression(node) { - return node.kind === 271 /* JsxExpression */; + return node.kind === 274 /* JsxExpression */; } ts.isJsxExpression = isJsxExpression; // Clauses function isCaseClause(node) { - return node.kind === 272 /* CaseClause */; + return node.kind === 275 /* CaseClause */; } ts.isCaseClause = isCaseClause; function isDefaultClause(node) { - return node.kind === 273 /* DefaultClause */; + return node.kind === 276 /* DefaultClause */; } ts.isDefaultClause = isDefaultClause; function isHeritageClause(node) { - return node.kind === 274 /* HeritageClause */; + return node.kind === 277 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 275 /* CatchClause */; + return node.kind === 278 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 276 /* PropertyAssignment */; + return node.kind === 279 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 277 /* ShorthandPropertyAssignment */; + return node.kind === 280 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isSpreadAssignment(node) { - return node.kind === 278 /* SpreadAssignment */; + return node.kind === 281 /* SpreadAssignment */; } ts.isSpreadAssignment = isSpreadAssignment; // Enum function isEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 285 /* SourceFile */; + return node.kind === 288 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isBundle(node) { - return node.kind === 286 /* Bundle */; + return node.kind === 289 /* Bundle */; } ts.isBundle = isBundle; function isUnparsedSource(node) { - return node.kind === 287 /* UnparsedSource */; + return node.kind === 290 /* UnparsedSource */; } ts.isUnparsedSource = isUnparsedSource; function isUnparsedPrepend(node) { - return node.kind === 281 /* UnparsedPrepend */; + return node.kind === 284 /* UnparsedPrepend */; } ts.isUnparsedPrepend = isUnparsedPrepend; function isUnparsedTextLike(node) { switch (node.kind) { - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return true; default: return false; @@ -14522,105 +15561,105 @@ var ts; ts.isUnparsedTextLike = isUnparsedTextLike; function isUnparsedNode(node) { return isUnparsedTextLike(node) || - node.kind === 280 /* UnparsedPrologue */ || - node.kind === 284 /* UnparsedSyntheticReference */; + node.kind === 283 /* UnparsedPrologue */ || + node.kind === 287 /* UnparsedSyntheticReference */; } ts.isUnparsedNode = isUnparsedNode; // JSDoc function isJSDocTypeExpression(node) { - return node.kind === 289 /* JSDocTypeExpression */; + return node.kind === 292 /* JSDocTypeExpression */; } ts.isJSDocTypeExpression = isJSDocTypeExpression; function isJSDocAllType(node) { - return node.kind === 290 /* JSDocAllType */; + return node.kind === 293 /* JSDocAllType */; } ts.isJSDocAllType = isJSDocAllType; function isJSDocUnknownType(node) { - return node.kind === 291 /* JSDocUnknownType */; + return node.kind === 294 /* JSDocUnknownType */; } ts.isJSDocUnknownType = isJSDocUnknownType; function isJSDocNullableType(node) { - return node.kind === 292 /* JSDocNullableType */; + return node.kind === 295 /* JSDocNullableType */; } ts.isJSDocNullableType = isJSDocNullableType; function isJSDocNonNullableType(node) { - return node.kind === 293 /* JSDocNonNullableType */; + return node.kind === 296 /* JSDocNonNullableType */; } ts.isJSDocNonNullableType = isJSDocNonNullableType; function isJSDocOptionalType(node) { - return node.kind === 294 /* JSDocOptionalType */; + return node.kind === 297 /* JSDocOptionalType */; } ts.isJSDocOptionalType = isJSDocOptionalType; function isJSDocFunctionType(node) { - return node.kind === 295 /* JSDocFunctionType */; + return node.kind === 298 /* JSDocFunctionType */; } ts.isJSDocFunctionType = isJSDocFunctionType; function isJSDocVariadicType(node) { - return node.kind === 296 /* JSDocVariadicType */; + return node.kind === 299 /* JSDocVariadicType */; } ts.isJSDocVariadicType = isJSDocVariadicType; function isJSDoc(node) { - return node.kind === 298 /* JSDocComment */; + return node.kind === 301 /* JSDocComment */; } ts.isJSDoc = isJSDoc; function isJSDocAuthorTag(node) { - return node.kind === 303 /* JSDocAuthorTag */; + return node.kind === 306 /* JSDocAuthorTag */; } ts.isJSDocAuthorTag = isJSDocAuthorTag; function isJSDocAugmentsTag(node) { - return node.kind === 302 /* JSDocAugmentsTag */; + return node.kind === 305 /* JSDocAugmentsTag */; } ts.isJSDocAugmentsTag = isJSDocAugmentsTag; function isJSDocClassTag(node) { - return node.kind === 304 /* JSDocClassTag */; + return node.kind === 307 /* JSDocClassTag */; } ts.isJSDocClassTag = isJSDocClassTag; function isJSDocEnumTag(node) { - return node.kind === 306 /* JSDocEnumTag */; + return node.kind === 309 /* JSDocEnumTag */; } ts.isJSDocEnumTag = isJSDocEnumTag; function isJSDocThisTag(node) { - return node.kind === 309 /* JSDocThisTag */; + return node.kind === 312 /* JSDocThisTag */; } ts.isJSDocThisTag = isJSDocThisTag; function isJSDocParameterTag(node) { - return node.kind === 307 /* JSDocParameterTag */; + return node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocParameterTag = isJSDocParameterTag; function isJSDocReturnTag(node) { - return node.kind === 308 /* JSDocReturnTag */; + return node.kind === 311 /* JSDocReturnTag */; } ts.isJSDocReturnTag = isJSDocReturnTag; function isJSDocTypeTag(node) { - return node.kind === 310 /* JSDocTypeTag */; + return node.kind === 313 /* JSDocTypeTag */; } ts.isJSDocTypeTag = isJSDocTypeTag; function isJSDocTemplateTag(node) { - return node.kind === 311 /* JSDocTemplateTag */; + return node.kind === 314 /* JSDocTemplateTag */; } ts.isJSDocTemplateTag = isJSDocTemplateTag; function isJSDocTypedefTag(node) { - return node.kind === 312 /* JSDocTypedefTag */; + return node.kind === 315 /* JSDocTypedefTag */; } ts.isJSDocTypedefTag = isJSDocTypedefTag; function isJSDocPropertyTag(node) { - return node.kind === 313 /* JSDocPropertyTag */; + return node.kind === 316 /* JSDocPropertyTag */; } ts.isJSDocPropertyTag = isJSDocPropertyTag; function isJSDocPropertyLikeTag(node) { - return node.kind === 313 /* JSDocPropertyTag */ || node.kind === 307 /* JSDocParameterTag */; + return node.kind === 316 /* JSDocPropertyTag */ || node.kind === 310 /* JSDocParameterTag */; } ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag; function isJSDocTypeLiteral(node) { - return node.kind === 299 /* JSDocTypeLiteral */; + return node.kind === 302 /* JSDocTypeLiteral */; } ts.isJSDocTypeLiteral = isJSDocTypeLiteral; function isJSDocCallbackTag(node) { - return node.kind === 305 /* JSDocCallbackTag */; + return node.kind === 308 /* JSDocCallbackTag */; } ts.isJSDocCallbackTag = isJSDocCallbackTag; function isJSDocSignature(node) { - return node.kind === 300 /* JSDocSignature */; + return node.kind === 303 /* JSDocSignature */; } ts.isJSDocSignature = isJSDocSignature; })(ts || (ts = {})); @@ -14631,7 +15670,7 @@ var ts; (function (ts) { /* @internal */ function isSyntaxList(n) { - return n.kind === 314 /* SyntaxList */; + return n.kind === 317 /* SyntaxList */; } ts.isSyntaxList = isSyntaxList; /* @internal */ @@ -14641,7 +15680,7 @@ var ts; ts.isNode = isNode; /* @internal */ function isNodeKind(kind) { - return kind >= 149 /* FirstNode */; + return kind >= 152 /* FirstNode */; } ts.isNodeKind = isNodeKind; /** @@ -14650,7 +15689,7 @@ var ts; * Literals are considered tokens, except TemplateLiteral, but does include TemplateHead/Middle/Tail. */ function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 148 /* LastToken */; + return n.kind >= 0 /* FirstToken */ && n.kind <= 151 /* LastToken */; } ts.isToken = isToken; // Node Arrays @@ -14703,17 +15742,17 @@ var ts; /* @internal */ function isModifierKind(token) { switch (token) { - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 81 /* DefaultKeyword */: - case 86 /* ExportKeyword */: - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 117 /* StaticKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 83 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 119 /* StaticKeyword */: return true; } return false; @@ -14726,7 +15765,7 @@ var ts; ts.isParameterPropertyModifier = isParameterPropertyModifier; /* @internal */ function isClassMemberModifier(idToken) { - return isParameterPropertyModifier(idToken) || idToken === 117 /* StaticKeyword */; + return isParameterPropertyModifier(idToken) || idToken === 119 /* StaticKeyword */; } ts.isClassMemberModifier = isClassMemberModifier; function isModifier(node) { @@ -14735,23 +15774,23 @@ var ts; ts.isModifier = isModifier; function isEntityName(node) { var kind = node.kind; - return kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ + return kind === 75 /* Identifier */ || kind === 10 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 150 /* ComputedPropertyName */; + || kind === 153 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isBindingName(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 185 /* ObjectBindingPattern */ - || kind === 186 /* ArrayBindingPattern */; + return kind === 75 /* Identifier */ + || kind === 188 /* ObjectBindingPattern */ + || kind === 189 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Functions @@ -14766,13 +15805,13 @@ var ts; ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; default: return false; @@ -14781,14 +15820,14 @@ var ts; /* @internal */ function isFunctionLikeKind(kind) { switch (kind) { - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 167 /* ConstructorType */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 170 /* ConstructorType */: return true; default: return isFunctionLikeDeclarationKind(kind); @@ -14803,29 +15842,29 @@ var ts; // Classes function isClassElement(node) { var kind = node.kind; - return kind === 158 /* Constructor */ - || kind === 155 /* PropertyDeclaration */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 163 /* IndexSignature */ - || kind === 218 /* SemicolonClassElement */; + return kind === 161 /* Constructor */ + || kind === 158 /* PropertyDeclaration */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 166 /* IndexSignature */ + || kind === 221 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isClassLike(node) { - return node && (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */); + return node && (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */); } ts.isClassLike = isClassLike; function isAccessor(node) { - return node && (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */); + return node && (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */); } ts.isAccessor = isAccessor; /* @internal */ function isMethodOrAccessor(node) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; default: return false; @@ -14835,11 +15874,11 @@ var ts; // Type members function isTypeElement(node) { var kind = node.kind; - return kind === 162 /* ConstructSignature */ - || kind === 161 /* CallSignature */ - || kind === 154 /* PropertySignature */ - || kind === 156 /* MethodSignature */ - || kind === 163 /* IndexSignature */; + return kind === 165 /* ConstructSignature */ + || kind === 164 /* CallSignature */ + || kind === 157 /* PropertySignature */ + || kind === 159 /* MethodSignature */ + || kind === 166 /* IndexSignature */; } ts.isTypeElement = isTypeElement; function isClassOrTypeElement(node) { @@ -14848,12 +15887,12 @@ var ts; ts.isClassOrTypeElement = isClassOrTypeElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 276 /* PropertyAssignment */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 278 /* SpreadAssignment */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 279 /* PropertyAssignment */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 281 /* SpreadAssignment */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type @@ -14868,8 +15907,8 @@ var ts; ts.isTypeNode = isTypeNode; function isFunctionOrConstructorTypeNode(node) { switch (node.kind) { - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return true; } return false; @@ -14880,8 +15919,8 @@ var ts; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 186 /* ArrayBindingPattern */ - || kind === 185 /* ObjectBindingPattern */; + return kind === 189 /* ArrayBindingPattern */ + || kind === 188 /* ObjectBindingPattern */; } return false; } @@ -14889,15 +15928,15 @@ var ts; /* @internal */ function isAssignmentPattern(node) { var kind = node.kind; - return kind === 188 /* ArrayLiteralExpression */ - || kind === 189 /* ObjectLiteralExpression */; + return kind === 191 /* ArrayLiteralExpression */ + || kind === 192 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; /* @internal */ function isArrayBindingElement(node) { var kind = node.kind; - return kind === 187 /* BindingElement */ - || kind === 211 /* OmittedExpression */; + return kind === 190 /* BindingElement */ + || kind === 214 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -14906,9 +15945,9 @@ var ts; /* @internal */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: return true; } return false; @@ -14929,8 +15968,8 @@ var ts; /* @internal */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return true; } return false; @@ -14942,8 +15981,8 @@ var ts; /* @internal */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return true; } return false; @@ -14952,26 +15991,26 @@ var ts; /* @internal */ function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */ - || kind === 184 /* ImportType */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */ + || kind === 187 /* ImportType */; } ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode; // Expression function isPropertyAccessOrQualifiedName(node) { var kind = node.kind; - return kind === 190 /* PropertyAccessExpression */ - || kind === 149 /* QualifiedName */; + return kind === 193 /* PropertyAccessExpression */ + || kind === 152 /* QualifiedName */; } ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isCallLikeExpression(node) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 194 /* TaggedTemplateExpression */: - case 153 /* Decorator */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 197 /* TaggedTemplateExpression */: + case 156 /* Decorator */: return true; default: return false; @@ -14979,12 +16018,12 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function isCallOrNewExpression(node) { - return node.kind === 192 /* CallExpression */ || node.kind === 193 /* NewExpression */; + return node.kind === 195 /* CallExpression */ || node.kind === 196 /* NewExpression */; } ts.isCallOrNewExpression = isCallOrNewExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 207 /* TemplateExpression */ + return kind === 210 /* TemplateExpression */ || kind === 14 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; @@ -14995,34 +16034,34 @@ var ts; ts.isLeftHandSideExpression = isLeftHandSideExpression; function isLeftHandSideExpressionKind(kind) { switch (kind) { - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - case 193 /* NewExpression */: - case 192 /* CallExpression */: - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: - case 194 /* TaggedTemplateExpression */: - case 188 /* ArrayLiteralExpression */: - case 196 /* ParenthesizedExpression */: - case 189 /* ObjectLiteralExpression */: - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 73 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 196 /* NewExpression */: + case 195 /* CallExpression */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: + case 197 /* TaggedTemplateExpression */: + case 191 /* ArrayLiteralExpression */: + case 199 /* ParenthesizedExpression */: + case 192 /* ObjectLiteralExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 75 /* Identifier */: case 13 /* RegularExpressionLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 207 /* TemplateExpression */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 103 /* TrueKeyword */: - case 99 /* SuperKeyword */: - case 214 /* NonNullExpression */: - case 215 /* MetaProperty */: - case 93 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression + case 210 /* TemplateExpression */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 105 /* TrueKeyword */: + case 101 /* SuperKeyword */: + case 217 /* NonNullExpression */: + case 218 /* MetaProperty */: + case 95 /* ImportKeyword */: // technically this is only an Expression if it's in a CallExpression return true; default: return false; @@ -15035,13 +16074,13 @@ var ts; ts.isUnaryExpression = isUnaryExpression; function isUnaryExpressionKind(kind) { switch (kind) { - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 195 /* TypeAssertionExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 198 /* TypeAssertionExpression */: return true; default: return isLeftHandSideExpressionKind(kind); @@ -15050,11 +16089,11 @@ var ts; /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 44 /* PlusPlusToken */ || - expr.operator === 45 /* MinusMinusToken */; + case 206 /* PrefixUnaryExpression */: + return expr.operator === 45 /* PlusPlusToken */ || + expr.operator === 46 /* MinusMinusToken */; default: return false; } @@ -15071,15 +16110,15 @@ var ts; ts.isExpression = isExpression; function isExpressionKind(kind) { switch (kind) { - case 206 /* ConditionalExpression */: - case 208 /* YieldExpression */: - case 198 /* ArrowFunction */: - case 205 /* BinaryExpression */: - case 209 /* SpreadElement */: - case 213 /* AsExpression */: - case 211 /* OmittedExpression */: - case 317 /* CommaListExpression */: - case 316 /* PartiallyEmittedExpression */: + case 209 /* ConditionalExpression */: + case 211 /* YieldExpression */: + case 201 /* ArrowFunction */: + case 208 /* BinaryExpression */: + case 212 /* SpreadElement */: + case 216 /* AsExpression */: + case 214 /* OmittedExpression */: + case 320 /* CommaListExpression */: + case 319 /* PartiallyEmittedExpression */: return true; default: return isUnaryExpressionKind(kind); @@ -15087,21 +16126,26 @@ var ts; } function isAssertionExpression(node) { var kind = node.kind; - return kind === 195 /* TypeAssertionExpression */ - || kind === 213 /* AsExpression */; + return kind === 198 /* TypeAssertionExpression */ + || kind === 216 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; /* @internal */ function isPartiallyEmittedExpression(node) { - return node.kind === 316 /* PartiallyEmittedExpression */; + return node.kind === 319 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; /* @internal */ function isNotEmittedStatement(node) { - return node.kind === 315 /* NotEmittedStatement */; + return node.kind === 318 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; /* @internal */ + function isSyntheticReference(node) { + return node.kind === 323 /* SyntheticReferenceExpression */; + } + ts.isSyntheticReference = isSyntheticReference; + /* @internal */ function isNotEmittedOrPartiallyEmittedNode(node) { return isNotEmittedStatement(node) || isPartiallyEmittedExpression(node); @@ -15109,21 +16153,42 @@ var ts; ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return true; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; /* @internal */ + function isScopeMarker(node) { + return ts.isExportAssignment(node) || ts.isExportDeclaration(node); + } + ts.isScopeMarker = isScopeMarker; + /* @internal */ + function hasScopeMarker(statements) { + return ts.some(statements, isScopeMarker); + } + ts.hasScopeMarker = hasScopeMarker; + /* @internal */ + function needsScopeMarker(result) { + return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); + } + ts.needsScopeMarker = needsScopeMarker; + /* @internal */ + function isExternalModuleIndicator(result) { + // Exported top-level member indicates moduleness + return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); + } + ts.isExternalModuleIndicator = isExternalModuleIndicator; + /* @internal */ function isForInOrOfStatement(node) { - return node.kind === 227 /* ForInStatement */ || node.kind === 228 /* ForOfStatement */; + return node.kind === 230 /* ForInStatement */ || node.kind === 231 /* ForOfStatement */; } ts.isForInOrOfStatement = isForInOrOfStatement; // Element @@ -15147,113 +16212,113 @@ var ts; /* @internal */ function isModuleBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */ - || kind === 73 /* Identifier */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */ + || kind === 75 /* Identifier */; } ts.isModuleBody = isModuleBody; /* @internal */ function isNamespaceBody(node) { var kind = node.kind; - return kind === 246 /* ModuleBlock */ - || kind === 245 /* ModuleDeclaration */; + return kind === 249 /* ModuleBlock */ + || kind === 248 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; /* @internal */ function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 73 /* Identifier */ - || kind === 245 /* ModuleDeclaration */; + return kind === 75 /* Identifier */ + || kind === 248 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; /* @internal */ function isNamedImportBindings(node) { var kind = node.kind; - return kind === 253 /* NamedImports */ - || kind === 252 /* NamespaceImport */; + return kind === 256 /* NamedImports */ + || kind === 255 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; /* @internal */ function isModuleOrEnumDeclaration(node) { - return node.kind === 245 /* ModuleDeclaration */ || node.kind === 244 /* EnumDeclaration */; + return node.kind === 248 /* ModuleDeclaration */ || node.kind === 247 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 198 /* ArrowFunction */ - || kind === 187 /* BindingElement */ - || kind === 241 /* ClassDeclaration */ - || kind === 210 /* ClassExpression */ - || kind === 158 /* Constructor */ - || kind === 244 /* EnumDeclaration */ - || kind === 279 /* EnumMember */ - || kind === 258 /* ExportSpecifier */ - || kind === 240 /* FunctionDeclaration */ - || kind === 197 /* FunctionExpression */ - || kind === 159 /* GetAccessor */ - || kind === 251 /* ImportClause */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 254 /* ImportSpecifier */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 268 /* JsxAttribute */ - || kind === 157 /* MethodDeclaration */ - || kind === 156 /* MethodSignature */ - || kind === 245 /* ModuleDeclaration */ - || kind === 248 /* NamespaceExportDeclaration */ - || kind === 252 /* NamespaceImport */ - || kind === 152 /* Parameter */ - || kind === 276 /* PropertyAssignment */ - || kind === 155 /* PropertyDeclaration */ - || kind === 154 /* PropertySignature */ - || kind === 160 /* SetAccessor */ - || kind === 277 /* ShorthandPropertyAssignment */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 151 /* TypeParameter */ - || kind === 238 /* VariableDeclaration */ - || kind === 312 /* JSDocTypedefTag */ - || kind === 305 /* JSDocCallbackTag */ - || kind === 313 /* JSDocPropertyTag */; + return kind === 201 /* ArrowFunction */ + || kind === 190 /* BindingElement */ + || kind === 244 /* ClassDeclaration */ + || kind === 213 /* ClassExpression */ + || kind === 161 /* Constructor */ + || kind === 247 /* EnumDeclaration */ + || kind === 282 /* EnumMember */ + || kind === 261 /* ExportSpecifier */ + || kind === 243 /* FunctionDeclaration */ + || kind === 200 /* FunctionExpression */ + || kind === 162 /* GetAccessor */ + || kind === 254 /* ImportClause */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 257 /* ImportSpecifier */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 271 /* JsxAttribute */ + || kind === 160 /* MethodDeclaration */ + || kind === 159 /* MethodSignature */ + || kind === 248 /* ModuleDeclaration */ + || kind === 251 /* NamespaceExportDeclaration */ + || kind === 255 /* NamespaceImport */ + || kind === 155 /* Parameter */ + || kind === 279 /* PropertyAssignment */ + || kind === 158 /* PropertyDeclaration */ + || kind === 157 /* PropertySignature */ + || kind === 163 /* SetAccessor */ + || kind === 280 /* ShorthandPropertyAssignment */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 154 /* TypeParameter */ + || kind === 241 /* VariableDeclaration */ + || kind === 315 /* JSDocTypedefTag */ + || kind === 308 /* JSDocCallbackTag */ + || kind === 316 /* JSDocPropertyTag */; } function isDeclarationStatementKind(kind) { - return kind === 240 /* FunctionDeclaration */ - || kind === 259 /* MissingDeclaration */ - || kind === 241 /* ClassDeclaration */ - || kind === 242 /* InterfaceDeclaration */ - || kind === 243 /* TypeAliasDeclaration */ - || kind === 244 /* EnumDeclaration */ - || kind === 245 /* ModuleDeclaration */ - || kind === 250 /* ImportDeclaration */ - || kind === 249 /* ImportEqualsDeclaration */ - || kind === 256 /* ExportDeclaration */ - || kind === 255 /* ExportAssignment */ - || kind === 248 /* NamespaceExportDeclaration */; + return kind === 243 /* FunctionDeclaration */ + || kind === 262 /* MissingDeclaration */ + || kind === 244 /* ClassDeclaration */ + || kind === 245 /* InterfaceDeclaration */ + || kind === 246 /* TypeAliasDeclaration */ + || kind === 247 /* EnumDeclaration */ + || kind === 248 /* ModuleDeclaration */ + || kind === 253 /* ImportDeclaration */ + || kind === 252 /* ImportEqualsDeclaration */ + || kind === 259 /* ExportDeclaration */ + || kind === 258 /* ExportAssignment */ + || kind === 251 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 230 /* BreakStatement */ - || kind === 229 /* ContinueStatement */ - || kind === 237 /* DebuggerStatement */ - || kind === 224 /* DoStatement */ - || kind === 222 /* ExpressionStatement */ - || kind === 221 /* EmptyStatement */ - || kind === 227 /* ForInStatement */ - || kind === 228 /* ForOfStatement */ - || kind === 226 /* ForStatement */ - || kind === 223 /* IfStatement */ - || kind === 234 /* LabeledStatement */ - || kind === 231 /* ReturnStatement */ - || kind === 233 /* SwitchStatement */ - || kind === 235 /* ThrowStatement */ - || kind === 236 /* TryStatement */ - || kind === 220 /* VariableStatement */ - || kind === 225 /* WhileStatement */ - || kind === 232 /* WithStatement */ - || kind === 315 /* NotEmittedStatement */ - || kind === 319 /* EndOfDeclarationMarker */ - || kind === 318 /* MergeDeclarationMarker */; + return kind === 233 /* BreakStatement */ + || kind === 232 /* ContinueStatement */ + || kind === 240 /* DebuggerStatement */ + || kind === 227 /* DoStatement */ + || kind === 225 /* ExpressionStatement */ + || kind === 223 /* EmptyStatement */ + || kind === 230 /* ForInStatement */ + || kind === 231 /* ForOfStatement */ + || kind === 229 /* ForStatement */ + || kind === 226 /* IfStatement */ + || kind === 237 /* LabeledStatement */ + || kind === 234 /* ReturnStatement */ + || kind === 236 /* SwitchStatement */ + || kind === 238 /* ThrowStatement */ + || kind === 239 /* TryStatement */ + || kind === 224 /* VariableStatement */ + || kind === 228 /* WhileStatement */ + || kind === 235 /* WithStatement */ + || kind === 318 /* NotEmittedStatement */ + || kind === 322 /* EndOfDeclarationMarker */ + || kind === 321 /* MergeDeclarationMarker */; } /* @internal */ function isDeclaration(node) { - if (node.kind === 151 /* TypeParameter */) { - return (node.parent && node.parent.kind !== 311 /* JSDocTemplateTag */) || ts.isInJSFile(node); + if (node.kind === 154 /* TypeParameter */) { + return (node.parent && node.parent.kind !== 314 /* JSDocTemplateTag */) || ts.isInJSFile(node); } return isDeclarationKind(node.kind); } @@ -15280,10 +16345,10 @@ var ts; } ts.isStatement = isStatement; function isBlockStatement(node) { - if (node.kind !== 219 /* Block */) + if (node.kind !== 222 /* Block */) return false; if (node.parent !== undefined) { - if (node.parent.kind === 236 /* TryStatement */ || node.parent.kind === 275 /* CatchClause */) { + if (node.parent.kind === 239 /* TryStatement */ || node.parent.kind === 278 /* CatchClause */) { return false; } } @@ -15293,83 +16358,88 @@ var ts; /* @internal */ function isModuleReference(node) { var kind = node.kind; - return kind === 260 /* ExternalModuleReference */ - || kind === 149 /* QualifiedName */ - || kind === 73 /* Identifier */; + return kind === 263 /* ExternalModuleReference */ + || kind === 152 /* QualifiedName */ + || kind === 75 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX /* @internal */ function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 101 /* ThisKeyword */ - || kind === 73 /* Identifier */ - || kind === 190 /* PropertyAccessExpression */; + return kind === 103 /* ThisKeyword */ + || kind === 75 /* Identifier */ + || kind === 193 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; /* @internal */ function isJsxChild(node) { var kind = node.kind; - return kind === 261 /* JsxElement */ - || kind === 271 /* JsxExpression */ - || kind === 262 /* JsxSelfClosingElement */ + return kind === 264 /* JsxElement */ + || kind === 274 /* JsxExpression */ + || kind === 265 /* JsxSelfClosingElement */ || kind === 11 /* JsxText */ - || kind === 265 /* JsxFragment */; + || kind === 268 /* JsxFragment */; } ts.isJsxChild = isJsxChild; /* @internal */ function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 268 /* JsxAttribute */ - || kind === 270 /* JsxSpreadAttribute */; + return kind === 271 /* JsxAttribute */ + || kind === 273 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; /* @internal */ function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 10 /* StringLiteral */ - || kind === 271 /* JsxExpression */; + || kind === 274 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; function isJsxOpeningLikeElement(node) { var kind = node.kind; - return kind === 263 /* JsxOpeningElement */ - || kind === 262 /* JsxSelfClosingElement */; + return kind === 266 /* JsxOpeningElement */ + || kind === 265 /* JsxSelfClosingElement */; } ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 272 /* CaseClause */ - || kind === 273 /* DefaultClause */; + return kind === 275 /* CaseClause */ + || kind === 276 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; // JSDoc /** True if node is of some JSDoc syntax kind. */ /* @internal */ function isJSDocNode(node) { - return node.kind >= 289 /* FirstJSDocNode */ && node.kind <= 313 /* LastJSDocNode */; + return node.kind >= 292 /* FirstJSDocNode */ && node.kind <= 316 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; /** True if node is of a kind that may contain comment text. */ function isJSDocCommentContainingNode(node) { - return node.kind === 298 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); + return node.kind === 301 /* JSDocComment */ || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node); } ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode; // TODO: determine what this does before making it public. /* @internal */ function isJSDocTag(node) { - return node.kind >= 301 /* FirstJSDocTagNode */ && node.kind <= 313 /* LastJSDocTagNode */; + return node.kind >= 304 /* FirstJSDocTagNode */ && node.kind <= 316 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function isSetAccessor(node) { - return node.kind === 160 /* SetAccessor */; + return node.kind === 163 /* SetAccessor */; } ts.isSetAccessor = isSetAccessor; function isGetAccessor(node) { - return node.kind === 159 /* GetAccessor */; + return node.kind === 162 /* GetAccessor */; + } + ts.isGetAccessor = isGetAccessor; + /* @internal */ + function isOptionalChainRoot(node) { + return ts.isOptionalChain(node) && !!node.questionDotToken; } - ts.isGetAccessor = isGetAccessor; + ts.isOptionalChainRoot = isOptionalChainRoot; /** True if has jsdoc nodes attached to it. */ /* @internal */ // TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times @@ -15397,12 +16467,12 @@ var ts; } ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer; function isObjectLiteralElement(node) { - return node.kind === 268 /* JsxAttribute */ || node.kind === 270 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); + return node.kind === 271 /* JsxAttribute */ || node.kind === 273 /* JsxSpreadAttribute */ || isObjectLiteralElementLike(node); } ts.isObjectLiteralElement = isObjectLiteralElement; /* @internal */ function isTypeReferenceType(node) { - return node.kind === 165 /* TypeReference */ || node.kind === 212 /* ExpressionWithTypeArguments */; + return node.kind === 168 /* TypeReference */ || node.kind === 215 /* ExpressionWithTypeArguments */; } ts.isTypeReferenceType = isTypeReferenceType; var MAX_SMI_X86 = 1073741823; @@ -15438,7 +16508,7 @@ var ts; /* @internal */ (function (ts) { function isNamedImportsOrExports(node) { - return node.kind === 253 /* NamedImports */ || node.kind === 257 /* NamedExports */; + return node.kind === 256 /* NamedImports */ || node.kind === 260 /* NamedExports */; } ts.isNamedImportsOrExports = isNamedImportsOrExports; function Symbol(flags, name) { @@ -15456,7 +16526,12 @@ var ts; this.checker = checker; } } - function Signature() { } // tslint:disable-line no-empty + function Signature(checker, flags) { + this.flags = flags; + if (ts.Debug.isDebugging) { + this.checker = checker; + } + } function Node(kind, pos, end) { this.pos = pos; this.end = end; @@ -15470,759 +16545,303 @@ var ts; } function SourceMapSource(fileName, text, skipTrivia) { this.fileName = fileName; - this.text = text; - this.skipTrivia = skipTrivia || (function (pos) { return pos; }); - } - ts.objectAllocator = { - getNodeConstructor: function () { return Node; }, - getTokenConstructor: function () { return Node; }, - getIdentifierConstructor: function () { return Node; }, - getSourceFileConstructor: function () { return Node; }, - getSymbolConstructor: function () { return Symbol; }, - getTypeConstructor: function () { return Type; }, - getSignatureConstructor: function () { return Signature; }, - getSourceMapSourceConstructor: function () { return SourceMapSource; }, - }; - function formatStringFromArgs(text, args, baseIndex) { - if (baseIndex === void 0) { baseIndex = 0; } - return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); - } - ts.formatStringFromArgs = formatStringFromArgs; - function getLocaleSpecificMessage(message) { - return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; - } - ts.getLocaleSpecificMessage = getLocaleSpecificMessage; - function createFileDiagnostic(file, start, length, message) { - ts.Debug.assertGreaterThanOrEqual(start, 0); - ts.Debug.assertGreaterThanOrEqual(length, 0); - if (file) { - ts.Debug.assertLessThanOrEqual(start, file.text.length); - ts.Debug.assertLessThanOrEqual(start + length, file.text.length); - } - var text = getLocaleSpecificMessage(message); - if (arguments.length > 4) { - text = formatStringFromArgs(text, arguments, 4); - } - return { - file: file, - start: start, - length: length, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createFileDiagnostic = createFileDiagnostic; - function formatMessage(_dummy, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return text; - } - ts.formatMessage = formatMessage; - function createCompilerDiagnostic(message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 1) { - text = formatStringFromArgs(text, arguments, 1); - } - return { - file: undefined, - start: undefined, - length: undefined, - messageText: text, - category: message.category, - code: message.code, - reportsUnnecessary: message.reportsUnnecessary, - }; - } - ts.createCompilerDiagnostic = createCompilerDiagnostic; - function createCompilerDiagnosticFromMessageChain(chain) { - return { - file: undefined, - start: undefined, - length: undefined, - code: chain.code, - category: chain.category, - messageText: chain.next ? chain : chain.messageText, - }; - } - ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; - function chainDiagnosticMessages(details, message) { - var text = getLocaleSpecificMessage(message); - if (arguments.length > 2) { - text = formatStringFromArgs(text, arguments, 2); - } - return { - messageText: text, - category: message.category, - code: message.code, - next: details === undefined || Array.isArray(details) ? details : [details] - }; - } - ts.chainDiagnosticMessages = chainDiagnosticMessages; - function concatenateDiagnosticMessageChains(headChain, tailChain) { - var lastChain = headChain; - while (lastChain.next) { - lastChain = lastChain.next[0]; - } - lastChain.next = [tailChain]; - } - ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; - function getDiagnosticFilePath(diagnostic) { - return diagnostic.file ? diagnostic.file.path : undefined; - } - function compareDiagnostics(d1, d2) { - return compareDiagnosticsSkipRelatedInformation(d1, d2) || - compareRelatedInformation(d1, d2) || - 0 /* EqualTo */; - } - ts.compareDiagnostics = compareDiagnostics; - function compareDiagnosticsSkipRelatedInformation(d1, d2) { - return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || - ts.compareValues(d1.start, d2.start) || - ts.compareValues(d1.length, d2.length) || - ts.compareValues(d1.code, d2.code) || - compareMessageText(d1.messageText, d2.messageText) || - 0 /* EqualTo */; - } - ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; - function compareRelatedInformation(d1, d2) { - if (!d1.relatedInformation && !d2.relatedInformation) { - return 0 /* EqualTo */; - } - if (d1.relatedInformation && d2.relatedInformation) { - return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { - var d2i = d2.relatedInformation[index]; - return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared - }) || 0 /* EqualTo */; - } - return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; - } - function compareMessageText(t1, t2) { - if (typeof t1 === "string" && typeof t2 === "string") { - return ts.compareStringsCaseSensitive(t1, t2); - } - else if (typeof t1 === "string") { - return -1 /* LessThan */; - } - else if (typeof t2 === "string") { - return 1 /* GreaterThan */; - } - var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); - if (res) { - return res; - } - if (!t1.next && !t2.next) { - return 0 /* EqualTo */; - } - if (!t1.next) { - return -1 /* LessThan */; - } - if (!t2.next) { - return 1 /* GreaterThan */; - } - var len = Math.min(t1.next.length, t2.next.length); - for (var i = 0; i < len; i++) { - res = compareMessageText(t1.next[i], t2.next[i]); - if (res) { - return res; - } - } - if (t1.next.length < t2.next.length) { - return -1 /* LessThan */; - } - else if (t1.next.length > t2.next.length) { - return 1 /* GreaterThan */; - } - return 0 /* EqualTo */; - } - function getEmitScriptTarget(compilerOptions) { - return compilerOptions.target || 0 /* ES3 */; - } - ts.getEmitScriptTarget = getEmitScriptTarget; - function getEmitModuleKind(compilerOptions) { - return typeof compilerOptions.module === "number" ? - compilerOptions.module : - getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; - } - ts.getEmitModuleKind = getEmitModuleKind; - function getEmitModuleResolutionKind(compilerOptions) { - var moduleResolution = compilerOptions.moduleResolution; - if (moduleResolution === undefined) { - moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; - } - return moduleResolution; - } - ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; - function hasJsonModuleEmitEnabled(options) { - switch (getEmitModuleKind(options)) { - case ts.ModuleKind.CommonJS: - case ts.ModuleKind.AMD: - case ts.ModuleKind.ES2015: - case ts.ModuleKind.ESNext: - return true; - default: - return false; - } - } - ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; - function unreachableCodeIsError(options) { - return options.allowUnreachableCode === false; - } - ts.unreachableCodeIsError = unreachableCodeIsError; - function unusedLabelIsError(options) { - return options.allowUnusedLabels === false; - } - ts.unusedLabelIsError = unusedLabelIsError; - function getAreDeclarationMapsEnabled(options) { - return !!(getEmitDeclarations(options) && options.declarationMap); - } - ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; - function getAllowSyntheticDefaultImports(compilerOptions) { - var moduleKind = getEmitModuleKind(compilerOptions); - return compilerOptions.allowSyntheticDefaultImports !== undefined - ? compilerOptions.allowSyntheticDefaultImports - : compilerOptions.esModuleInterop || - moduleKind === ts.ModuleKind.System; - } - ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; - function getEmitDeclarations(compilerOptions) { - return !!(compilerOptions.declaration || compilerOptions.composite); - } - ts.getEmitDeclarations = getEmitDeclarations; - function isIncrementalCompilation(options) { - return !!(options.incremental || options.composite); - } - ts.isIncrementalCompilation = isIncrementalCompilation; - function getStrictOptionValue(compilerOptions, flag) { - return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; - } - ts.getStrictOptionValue = getStrictOptionValue; - function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; - function compilerOptionsAffectEmit(newOptions, oldOptions) { - return oldOptions !== newOptions && - ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); - } - ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; - function getCompilerOptionValue(options, option) { - return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; - } - ts.getCompilerOptionValue = getCompilerOptionValue; - function hasZeroOrOneAsteriskCharacter(str) { - var seenAsterisk = false; - for (var i = 0; i < str.length; i++) { - if (str.charCodeAt(i) === 42 /* asterisk */) { - if (!seenAsterisk) { - seenAsterisk = true; - } - else { - // have already seen asterisk - return false; - } - } - } - return true; - } - ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; - /** - * Internally, we represent paths as strings with '/' as the directory separator. - * When we make system calls (eg: LanguageServiceHost.getDirectory()), - * we expect the host to correctly handle paths in our specified format. - */ - ts.directorySeparator = "/"; - var altDirectorySeparator = "\\"; - var urlSchemeSeparator = "://"; - var backslashRegExp = /\\/g; - /** - * Normalize path separators. - */ - function normalizeSlashes(path) { - return path.replace(backslashRegExp, ts.directorySeparator); - } - ts.normalizeSlashes = normalizeSlashes; - function isVolumeCharacter(charCode) { - return (charCode >= 97 /* a */ && charCode <= 122 /* z */) || - (charCode >= 65 /* A */ && charCode <= 90 /* Z */); - } - function getFileUrlVolumeSeparatorEnd(url, start) { - var ch0 = url.charCodeAt(start); - if (ch0 === 58 /* colon */) - return start + 1; - if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) { - var ch2 = url.charCodeAt(start + 2); - if (ch2 === 97 /* a */ || ch2 === 65 /* A */) - return start + 3; - } - return -1; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * If the root is part of a URL, the twos-complement of the root length is returned. - */ - function getEncodedRootLength(path) { - if (!path) - return 0; - var ch0 = path.charCodeAt(0); - // POSIX or UNC - if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) { - if (path.charCodeAt(1) !== ch0) - return 1; // POSIX: "/" (or non-normalized "\") - var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : altDirectorySeparator, 2); - if (p1 < 0) - return path.length; // UNC: "//server" or "\\server" - return p1 + 1; // UNC: "//server/" or "\\server\" - } - // DOS - if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) { - var ch2 = path.charCodeAt(2); - if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */) - return 3; // DOS: "c:/" or "c:\" - if (path.length === 2) - return 2; // DOS: "c:" (but not "c:d") - } - // URL - var schemeEnd = path.indexOf(urlSchemeSeparator); - if (schemeEnd !== -1) { - var authorityStart = schemeEnd + urlSchemeSeparator.length; - var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart); - if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path" - // For local "file" URLs, include the leading DOS volume (if present). - // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a - // special case interpreted as "the machine from which the URL is being interpreted". - var scheme = path.slice(0, schemeEnd); - var authority = path.slice(authorityStart, authorityEnd); - if (scheme === "file" && (authority === "" || authority === "localhost") && - isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) { - var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2); - if (volumeSeparatorEnd !== -1) { - if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) { - // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/" - return ~(volumeSeparatorEnd + 1); - } - if (volumeSeparatorEnd === path.length) { - // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a" - // but not "file:///c:d" or "file:///c%3ad" - return ~volumeSeparatorEnd; - } - } - } - return ~(authorityEnd + 1); // URL: "file://server/", "http://server/" - } - return ~path.length; // URL: "file://server", "http://server" - } - // relative - return 0; - } - /** - * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files"). - * - * For example: - * ```ts - * getRootLength("a") === 0 // "" - * getRootLength("/") === 1 // "/" - * getRootLength("c:") === 2 // "c:" - * getRootLength("c:d") === 0 // "" - * getRootLength("c:/") === 3 // "c:/" - * getRootLength("c:\\") === 3 // "c:\\" - * getRootLength("//server") === 7 // "//server" - * getRootLength("//server/share") === 8 // "//server/" - * getRootLength("\\\\server") === 7 // "\\\\server" - * getRootLength("\\\\server\\share") === 8 // "\\\\server\\" - * getRootLength("file:///path") === 8 // "file:///" - * getRootLength("file:///c:") === 10 // "file:///c:" - * getRootLength("file:///c:d") === 8 // "file:///" - * getRootLength("file:///c:/path") === 11 // "file:///c:/" - * getRootLength("file://server") === 13 // "file://server" - * getRootLength("file://server/path") === 14 // "file://server/" - * getRootLength("http://server") === 13 // "http://server" - * getRootLength("http://server/path") === 14 // "http://server/" - * ``` - */ - function getRootLength(path) { - var rootLength = getEncodedRootLength(path); - return rootLength < 0 ? ~rootLength : rootLength; - } - ts.getRootLength = getRootLength; - // TODO(rbuckton): replace references with `resolvePath` - function normalizePath(path) { - return ts.resolvePath(path); - } - ts.normalizePath = normalizePath; - function normalizePathAndParts(path) { - path = normalizeSlashes(path); - var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1); - if (parts.length) { - var joinedParts = root + parts.join(ts.directorySeparator); - return { path: ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts }; - } - else { - return { path: root, parts: parts }; - } - } - ts.normalizePathAndParts = normalizePathAndParts; - function getDirectoryPath(path) { - path = normalizeSlashes(path); - // If the path provided is itself the root, then return it. - var rootLength = getRootLength(path); - if (rootLength === path.length) - return path; - // return the leading portion of the path up to the last (non-terminal) directory separator - // but not including any trailing directory separator. - path = ts.removeTrailingDirectorySeparator(path); - return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator))); - } - ts.getDirectoryPath = getDirectoryPath; - function startsWithDirectory(fileName, directoryName, getCanonicalFileName) { - var canonicalFileName = getCanonicalFileName(fileName); - var canonicalDirectoryName = getCanonicalFileName(directoryName); - return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\"); - } - ts.startsWithDirectory = startsWithDirectory; - function isUrl(path) { - return getEncodedRootLength(path) < 0; - } - ts.isUrl = isUrl; - function pathIsRelative(path) { - return /^\.\.?($|[\\/])/.test(path); - } - ts.pathIsRelative = pathIsRelative; - /** - * Determines whether a path is an absolute path (e.g. starts with `/`, or a dos path - * like `c:`, `c:\` or `c:/`). - */ - function isRootedDiskPath(path) { - return getEncodedRootLength(path) > 0; - } - ts.isRootedDiskPath = isRootedDiskPath; - /** - * Determines whether a path consists only of a path root. - */ - function isDiskPathRoot(path) { - var rootLength = getEncodedRootLength(path); - return rootLength > 0 && rootLength === path.length; - } - ts.isDiskPathRoot = isDiskPathRoot; - function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { - return !isRootedDiskPath(absoluteOrRelativePath) - ? absoluteOrRelativePath - : ts.getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - } - ts.convertToRelativePath = convertToRelativePath; - function pathComponents(path, rootLength) { - var root = path.substring(0, rootLength); - var rest = path.substring(rootLength).split(ts.directorySeparator); - if (rest.length && !ts.lastOrUndefined(rest)) - rest.pop(); - return __spreadArrays([root], rest); - } - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is not normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getPathComponents(path, currentDirectory) { - if (currentDirectory === void 0) { currentDirectory = ""; } - path = ts.combinePaths(currentDirectory, path); - var rootLength = getRootLength(path); - return pathComponents(path, rootLength); - } - ts.getPathComponents = getPathComponents; - /** - * Reduce an array of path components to a more simplified path by navigating any - * `"."` or `".."` entries in the path. - */ - function reducePathComponents(components) { - if (!ts.some(components)) - return []; - var reduced = [components[0]]; - for (var i = 1; i < components.length; i++) { - var component = components[i]; - if (!component) - continue; - if (component === ".") - continue; - if (component === "..") { - if (reduced.length > 1) { - if (reduced[reduced.length - 1] !== "..") { - reduced.pop(); - continue; - } - } - else if (reduced[0]) - continue; - } - reduced.push(component); - } - return reduced; - } - ts.reducePathComponents = reducePathComponents; - /** - * Parse a path into an array containing a root component (at index 0) and zero or more path - * components (at indices > 0). The result is normalized. - * If the path is relative, the root component is `""`. - * If the path is absolute, the root component includes the first path separator (`/`). - */ - function getNormalizedPathComponents(path, currentDirectory) { - return reducePathComponents(getPathComponents(path, currentDirectory)); - } - ts.getNormalizedPathComponents = getNormalizedPathComponents; - function getNormalizedAbsolutePath(fileName, currentDirectory) { - return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory)); - } - ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath; - /** - * Formats a parsed path consisting of a root component (at index 0) and zero or more path - * segments (at indices > 0). - */ - function getPathFromPathComponents(pathComponents) { - if (pathComponents.length === 0) - return ""; - var root = pathComponents[0] && ts.ensureTrailingDirectorySeparator(pathComponents[0]); - return root + pathComponents.slice(1).join(ts.directorySeparator); + this.text = text; + this.skipTrivia = skipTrivia || (function (pos) { return pos; }); } - ts.getPathFromPathComponents = getPathFromPathComponents; - function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) { - return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory)); + // eslint-disable-next-line prefer-const + ts.objectAllocator = { + getNodeConstructor: function () { return Node; }, + getTokenConstructor: function () { return Node; }, + getIdentifierConstructor: function () { return Node; }, + getSourceFileConstructor: function () { return Node; }, + getSymbolConstructor: function () { return Symbol; }, + getTypeConstructor: function () { return Type; }, + getSignatureConstructor: function () { return Signature; }, + getSourceMapSourceConstructor: function () { return SourceMapSource; }, + }; + function formatStringFromArgs(text, args, baseIndex) { + if (baseIndex === void 0) { baseIndex = 0; } + return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.assertDefined(args[+index + baseIndex]); }); } - ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot; - function getPathWithoutRoot(pathComponents) { - if (pathComponents.length === 0) - return ""; - return pathComponents.slice(1).join(ts.directorySeparator); + ts.formatStringFromArgs = formatStringFromArgs; + function getLocaleSpecificMessage(message) { + return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message; } -})(ts || (ts = {})); -/* @internal */ -(function (ts) { - function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) { - var fromComponents = ts.reducePathComponents(ts.getPathComponents(from)); - var toComponents = ts.reducePathComponents(ts.getPathComponents(to)); - var start; - for (start = 0; start < fromComponents.length && start < toComponents.length; start++) { - var fromComponent = getCanonicalFileName(fromComponents[start]); - var toComponent = getCanonicalFileName(toComponents[start]); - var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer; - if (!comparer(fromComponent, toComponent)) - break; + ts.getLocaleSpecificMessage = getLocaleSpecificMessage; + function createFileDiagnostic(file, start, length, message) { + ts.Debug.assertGreaterThanOrEqual(start, 0); + ts.Debug.assertGreaterThanOrEqual(length, 0); + if (file) { + ts.Debug.assertLessThanOrEqual(start, file.text.length); + ts.Debug.assertLessThanOrEqual(start + length, file.text.length); } - if (start === 0) { - return toComponents; + var text = getLocaleSpecificMessage(message); + if (arguments.length > 4) { + text = formatStringFromArgs(text, arguments, 4); } - var components = toComponents.slice(start); - var relative = []; - for (; start < fromComponents.length; start++) { - relative.push(".."); + return { + file: file, + start: start, + length: length, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; + } + ts.createFileDiagnostic = createFileDiagnostic; + function formatMessage(_dummy, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return __spreadArrays([""], relative, components); + return text; } - ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo; - function getRelativePathFromFile(from, to, getCanonicalFileName) { - return ensurePathIsNonModuleName(getRelativePathFromDirectory(ts.getDirectoryPath(from), to, getCanonicalFileName)); + ts.formatMessage = formatMessage; + function createCompilerDiagnostic(message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 1) { + text = formatStringFromArgs(text, arguments, 1); + } + return { + file: undefined, + start: undefined, + length: undefined, + messageText: text, + category: message.category, + code: message.code, + reportsUnnecessary: message.reportsUnnecessary, + }; } - ts.getRelativePathFromFile = getRelativePathFromFile; - function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) { - ts.Debug.assert((ts.getRootLength(fromDirectory) > 0) === (ts.getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); - var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity; - var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false; - var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName); - return ts.getPathFromPathComponents(pathComponents); + ts.createCompilerDiagnostic = createCompilerDiagnostic; + function createCompilerDiagnosticFromMessageChain(chain) { + return { + file: undefined, + start: undefined, + length: undefined, + code: chain.code, + category: chain.category, + messageText: chain.next ? chain : chain.messageText, + }; } - ts.getRelativePathFromDirectory = getRelativePathFromDirectory; - function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) { - var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName); - var firstComponent = pathComponents[0]; - if (isAbsolutePathAnUrl && ts.isRootedDiskPath(firstComponent)) { - var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///"; - pathComponents[0] = prefix + firstComponent; + ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain; + function chainDiagnosticMessages(details, message) { + var text = getLocaleSpecificMessage(message); + if (arguments.length > 2) { + text = formatStringFromArgs(text, arguments, 2); } - return ts.getPathFromPathComponents(pathComponents); + return { + messageText: text, + category: message.category, + code: message.code, + next: details === undefined || Array.isArray(details) ? details : [details] + }; } - ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl; - /** - * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed - * with `./` or `../`) so as not to be confused with an unprefixed module name. - */ - function ensurePathIsNonModuleName(path) { - return ts.getRootLength(path) === 0 && !ts.pathIsRelative(path) ? "./" + path : path; + ts.chainDiagnosticMessages = chainDiagnosticMessages; + function concatenateDiagnosticMessageChains(headChain, tailChain) { + var lastChain = headChain; + while (lastChain.next) { + lastChain = lastChain.next[0]; + } + lastChain.next = [tailChain]; } - ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName; - function getBaseFileName(path, extensions, ignoreCase) { - path = ts.normalizeSlashes(path); - // if the path provided is itself the root, then it has not file name. - var rootLength = ts.getRootLength(path); - if (rootLength === path.length) - return ""; - // return the trailing portion of the path starting after the last (non-terminal) directory - // separator but not including any trailing directory separator. - path = removeTrailingDirectorySeparator(path); - var name = path.slice(Math.max(ts.getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1)); - var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined; - return extension ? name.slice(0, name.length - extension.length) : name; + ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains; + function getDiagnosticFilePath(diagnostic) { + return diagnostic.file ? diagnostic.file.path : undefined; } - ts.getBaseFileName = getBaseFileName; - /** - * Combines paths. If a path is absolute, it replaces any previous path. - */ - function combinePaths(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareDiagnostics(d1, d2) { + return compareDiagnosticsSkipRelatedInformation(d1, d2) || + compareRelatedInformation(d1, d2) || + 0 /* EqualTo */; + } + ts.compareDiagnostics = compareDiagnostics; + function compareDiagnosticsSkipRelatedInformation(d1, d2) { + return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) || + ts.compareValues(d1.start, d2.start) || + ts.compareValues(d1.length, d2.length) || + ts.compareValues(d1.code, d2.code) || + compareMessageText(d1.messageText, d2.messageText) || + 0 /* EqualTo */; + } + ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation; + function compareRelatedInformation(d1, d2) { + if (!d1.relatedInformation && !d2.relatedInformation) { + return 0 /* EqualTo */; } - if (path) - path = ts.normalizeSlashes(path); - for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) { - var relativePath = paths_1[_a]; - if (!relativePath) - continue; - relativePath = ts.normalizeSlashes(relativePath); - if (!path || ts.getRootLength(relativePath) !== 0) { - path = relativePath; - } - else { - path = ensureTrailingDirectorySeparator(path) + relativePath; - } + if (d1.relatedInformation && d2.relatedInformation) { + return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) { + var d2i = d2.relatedInformation[index]; + return compareDiagnostics(d1i, d2i); // EqualTo is 0, so falsy, and will cause the next item to be compared + }) || 0 /* EqualTo */; } - return path; + return d1.relatedInformation ? -1 /* LessThan */ : 1 /* GreaterThan */; } - ts.combinePaths = combinePaths; - /** - * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any - * `.` and `..` path components are resolved. - */ - function resolvePath(path) { - var paths = []; - for (var _i = 1; _i < arguments.length; _i++) { - paths[_i - 1] = arguments[_i]; + function compareMessageText(t1, t2) { + if (typeof t1 === "string" && typeof t2 === "string") { + return ts.compareStringsCaseSensitive(t1, t2); } - var combined = ts.some(paths) ? combinePaths.apply(void 0, __spreadArrays([path], paths)) : ts.normalizeSlashes(path); - var normalized = ts.getPathFromPathComponents(ts.reducePathComponents(ts.getPathComponents(combined))); - return normalized && hasTrailingDirectorySeparator(combined) ? ensureTrailingDirectorySeparator(normalized) : normalized; - } - ts.resolvePath = resolvePath; - /** - * Determines whether a path has a trailing separator (`/` or `\\`). - */ - function hasTrailingDirectorySeparator(path) { - if (path.length === 0) - return false; - var ch = path.charCodeAt(path.length - 1); - return ch === 47 /* slash */ || ch === 92 /* backslash */; - } - ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator; - function removeTrailingDirectorySeparator(path) { - if (hasTrailingDirectorySeparator(path)) { - return path.substr(0, path.length - 1); + else if (typeof t1 === "string") { + return -1 /* LessThan */; } - return path; - } - ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator; - function ensureTrailingDirectorySeparator(path) { - if (!hasTrailingDirectorySeparator(path)) { - return path + ts.directorySeparator; + else if (typeof t2 === "string") { + return 1 /* GreaterThan */; } - return path; - } - ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator; - // check path for these segments: '', '.'. '..' - var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/; - function comparePathsWorker(a, b, componentComparer) { - if (a === b) + var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText); + if (res) { + return res; + } + if (!t1.next && !t2.next) { return 0 /* EqualTo */; - if (a === undefined) + } + if (!t1.next) { return -1 /* LessThan */; - if (b === undefined) - return 1 /* GreaterThan */; - // NOTE: Performance optimization - shortcut if the root segments differ as there would be no - // need to perform path reduction. - var aRoot = a.substring(0, ts.getRootLength(a)); - var bRoot = b.substring(0, ts.getRootLength(b)); - var result = ts.compareStringsCaseInsensitive(aRoot, bRoot); - if (result !== 0 /* EqualTo */) { - return result; } - // NOTE: Performance optimization - shortcut if there are no relative path segments in - // the non-root portion of the path - var aRest = a.substring(aRoot.length); - var bRest = b.substring(bRoot.length); - if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) { - return componentComparer(aRest, bRest); + if (!t2.next) { + return 1 /* GreaterThan */; } - // The path contains a relative path segment. Normalize the paths and perform a slower component - // by component comparison. - var aComponents = ts.reducePathComponents(ts.getPathComponents(a)); - var bComponents = ts.reducePathComponents(ts.getPathComponents(b)); - var sharedLength = Math.min(aComponents.length, bComponents.length); - for (var i = 1; i < sharedLength; i++) { - var result_1 = componentComparer(aComponents[i], bComponents[i]); - if (result_1 !== 0 /* EqualTo */) { - return result_1; + var len = Math.min(t1.next.length, t2.next.length); + for (var i = 0; i < len; i++) { + res = compareMessageText(t1.next[i], t2.next[i]); + if (res) { + return res; } } - return ts.compareValues(aComponents.length, bComponents.length); + if (t1.next.length < t2.next.length) { + return -1 /* LessThan */; + } + else if (t1.next.length > t2.next.length) { + return 1 /* GreaterThan */; + } + return 0 /* EqualTo */; } - /** - * Performs a case-sensitive comparison of two paths. - */ - function comparePathsCaseSensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseSensitive); + function getEmitScriptTarget(compilerOptions) { + return compilerOptions.target || 0 /* ES3 */; } - ts.comparePathsCaseSensitive = comparePathsCaseSensitive; - /** - * Performs a case-insensitive comparison of two paths. - */ - function comparePathsCaseInsensitive(a, b) { - return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive); + ts.getEmitScriptTarget = getEmitScriptTarget; + function getEmitModuleKind(compilerOptions) { + return typeof compilerOptions.module === "number" ? + compilerOptions.module : + getEmitScriptTarget(compilerOptions) >= 2 /* ES2015 */ ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS; } - ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive; - function comparePaths(a, b, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - a = combinePaths(currentDirectory, a); - b = combinePaths(currentDirectory, b); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; + ts.getEmitModuleKind = getEmitModuleKind; + function getEmitModuleResolutionKind(compilerOptions) { + var moduleResolution = compilerOptions.moduleResolution; + if (moduleResolution === undefined) { + moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic; } - return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase)); + return moduleResolution; } - ts.comparePaths = comparePaths; - function containsPath(parent, child, currentDirectory, ignoreCase) { - if (typeof currentDirectory === "string") { - parent = combinePaths(currentDirectory, parent); - child = combinePaths(currentDirectory, child); - } - else if (typeof currentDirectory === "boolean") { - ignoreCase = currentDirectory; - } - if (parent === undefined || child === undefined) - return false; - if (parent === child) - return true; - var parentComponents = ts.reducePathComponents(ts.getPathComponents(parent)); - var childComponents = ts.reducePathComponents(ts.getPathComponents(child)); - if (childComponents.length < parentComponents.length) { - return false; - } - var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive; - for (var i = 0; i < parentComponents.length; i++) { - var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer; - if (!equalityComparer(parentComponents[i], childComponents[i])) { + ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; + function hasJsonModuleEmitEnabled(options) { + switch (getEmitModuleKind(options)) { + case ts.ModuleKind.CommonJS: + case ts.ModuleKind.AMD: + case ts.ModuleKind.ES2015: + case ts.ModuleKind.ESNext: + return true; + default: return false; + } + } + ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled; + function unreachableCodeIsError(options) { + return options.allowUnreachableCode === false; + } + ts.unreachableCodeIsError = unreachableCodeIsError; + function unusedLabelIsError(options) { + return options.allowUnusedLabels === false; + } + ts.unusedLabelIsError = unusedLabelIsError; + function getAreDeclarationMapsEnabled(options) { + return !!(getEmitDeclarations(options) && options.declarationMap); + } + ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled; + function getAllowSyntheticDefaultImports(compilerOptions) { + var moduleKind = getEmitModuleKind(compilerOptions); + return compilerOptions.allowSyntheticDefaultImports !== undefined + ? compilerOptions.allowSyntheticDefaultImports + : compilerOptions.esModuleInterop || + moduleKind === ts.ModuleKind.System; + } + ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports; + function getEmitDeclarations(compilerOptions) { + return !!(compilerOptions.declaration || compilerOptions.composite); + } + ts.getEmitDeclarations = getEmitDeclarations; + function isIncrementalCompilation(options) { + return !!(options.incremental || options.composite); + } + ts.isIncrementalCompilation = isIncrementalCompilation; + function getStrictOptionValue(compilerOptions, flag) { + return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag]; + } + ts.getStrictOptionValue = getStrictOptionValue; + function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics; + function compilerOptionsAffectEmit(newOptions, oldOptions) { + return oldOptions !== newOptions && + ts.affectsEmitOptionDeclarations.some(function (option) { return !ts.isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); }); + } + ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit; + function getCompilerOptionValue(options, option) { + return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name]; + } + ts.getCompilerOptionValue = getCompilerOptionValue; + function hasZeroOrOneAsteriskCharacter(str) { + var seenAsterisk = false; + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) === 42 /* asterisk */) { + if (!seenAsterisk) { + seenAsterisk = true; + } + else { + // have already seen asterisk + return false; + } } } return true; } - ts.containsPath = containsPath; - function isDirectorySeparator(charCode) { - return charCode === 47 /* slash */ || charCode === 92 /* backslash */; + ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; + function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { + var result = ts.createMap(); + var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { + return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { + return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; + }))); + })); + for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { + var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; + var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; + result.set(commonOriginal, commonResolved); + } + return result; + } + ts.discoverProbableSymlinks = discoverProbableSymlinks; + function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { + var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); + var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); + while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && + !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && + getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) { + aParts.pop(); + bParts.pop(); + } + return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; + } + // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. + // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. + function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { + return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { function stripLeadingDirectorySeparator(s) { - return isDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; + return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined; } function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) { var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName); @@ -16241,10 +16860,6 @@ var ts; return "\\" + match; } var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; - function hasExtension(fileName) { - return ts.stringContains(getBaseFileName(fileName), "."); - } - ts.hasExtension = hasExtension; ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; var filesMatcher = { @@ -16320,7 +16935,7 @@ var ts; } // getNormalizedPathComponents includes the separator for the root component. // We need to remove to create our regex correctly. - components[0] = removeTrailingDirectorySeparator(components[0]); + components[0] = ts.removeTrailingDirectorySeparator(components[0]); if (isImplicitGlob(lastComponent)) { components.push("**", "*"); } @@ -16382,7 +16997,7 @@ var ts; function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) { path = ts.normalizePath(path); currentDirectory = ts.normalizePath(currentDirectory); - var absolutePath = combinePaths(currentDirectory, path); + var absolutePath = ts.combinePaths(currentDirectory, path); return { includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }), includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"), @@ -16411,7 +17026,7 @@ var ts; var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) { var basePath = _a[_i]; - visitDirectory(basePath, combinePaths(currentDirectory, basePath), depth); + visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth); } return ts.flatten(results); function visitDirectory(path, absolutePath, depth) { @@ -16421,8 +17036,8 @@ var ts; visited.set(canonicalPath, true); var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories; var _loop_1 = function (current) { - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if (extensions && !ts.fileExtensionIsOneOf(name, extensions)) return "continue"; if (excludeRegex && excludeRegex.test(absoluteName)) @@ -16449,8 +17064,8 @@ var ts; } for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) { var current = _d[_c]; - var name = combinePaths(path, current); - var absoluteName = combinePaths(absolutePath, current); + var name = ts.combinePaths(path, current); + var absoluteName = ts.combinePaths(absolutePath, current); if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) && (!excludeRegex || !excludeRegex.test(absoluteName))) { visitDirectory(name, absoluteName, depth); @@ -16472,14 +17087,14 @@ var ts; var include = includes_1[_i]; // We also need to check the relative paths by converting them to absolute and normalizing // in case they escape the base path (e.g "..\somedirectory") - var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(combinePaths(path, include)); + var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include)); // Append the literal and canonical candidate base paths. includeBasePaths.push(getIncludeBasePath(absolute)); } // Sort the offsets array using either the literal or canonical path representations. includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames)); var _loop_2 = function (includeBasePath) { - if (ts.every(basePaths, function (basePath) { return !containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { + if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) { basePaths.push(includeBasePath); } }; @@ -16496,9 +17111,9 @@ var ts; var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes); if (wildcardOffset < 0) { // No "*" or "?" in the path - return !hasExtension(absolute) + return !ts.hasExtension(absolute) ? absolute - : removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); + : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute)); } return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset)); } @@ -16663,14 +17278,9 @@ var ts; } ts.removeExtension = removeExtension; function changeExtension(path, newExtension) { - return changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); + return ts.changeAnyExtension(path, newExtension, extensionsToRemove, /*ignoreCase*/ false); } ts.changeExtension = changeExtension; - function changeAnyExtension(path, ext, extensions, ignoreCase) { - var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path); - return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path; - } - ts.changeAnyExtension = changeAnyExtension; function tryParsePattern(pattern) { // This should be verified outside of here and a proper error thrown. ts.Debug.assert(ts.hasZeroOrOneAsteriskCharacter(pattern)); @@ -16713,36 +17323,6 @@ var ts; return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); }); } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; - function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) { - if (typeof extensions === "string") - extensions = [extensions]; - for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) { - var extension = extensions_2[_i]; - if (!ts.startsWith(extension, ".")) - extension = "." + extension; - if (path.length >= extension.length && path.charAt(path.length - extension.length) === ".") { - var pathExtension = path.slice(path.length - extension.length); - if (stringEqualityComparer(pathExtension, extension)) { - return pathExtension; - } - } - } - return ""; - } - function getAnyExtensionFromPath(path, extensions, ignoreCase) { - // Retrieves any string from the final "." onwards from a base file name. - // Unlike extensionFromPath, which throws an exception on unrecognized extensions. - if (extensions) { - return getAnyExtensionFromPathWorker(path, extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive); - } - var baseFileName = getBaseFileName(path); - var extensionIndex = baseFileName.lastIndexOf("."); - if (extensionIndex >= 0) { - return baseFileName.substring(extensionIndex); - } - return ""; - } - ts.getAnyExtensionFromPath = getAnyExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } @@ -16872,14 +17452,17 @@ var ts; return { pos: typeParameters.pos - 1, end: typeParameters.end + 1 }; } ts.rangeOfTypeParameters = rangeOfTypeParameters; - function skipTypeChecking(sourceFile, options) { + function skipTypeChecking(sourceFile, options, host) { // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a // '/// ' directive. - return options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib; + return (options.skipLibCheck && sourceFile.isDeclarationFile || + options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) || + host.isSourceOfProjectReferenceRedirect(sourceFile.fileName); } ts.skipTypeChecking = skipTypeChecking; function isJsonEqual(a, b) { + // eslint-disable-next-line no-null/no-null return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual); } ts.isJsonEqual = isJsonEqual; @@ -16983,17 +17566,15 @@ var ts; SignatureFlags[SignatureFlags["IgnoreMissingOpenBrace"] = 16] = "IgnoreMissingOpenBrace"; SignatureFlags[SignatureFlags["JSDoc"] = 32] = "JSDoc"; })(SignatureFlags || (SignatureFlags = {})); - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name function createNode(kind, pos, end) { - if (kind === 285 /* SourceFile */) { + if (kind === 288 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 73 /* Identifier */) { + else if (kind === 75 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } else if (!ts.isNodeKind(kind)) { @@ -17042,19 +17623,19 @@ var ts; * that they appear in the source code. The language service depends on this property to locate nodes by position. */ function forEachChild(node, cbNode, cbNodes) { - if (!node || node.kind <= 148 /* LastToken */) { + if (!node || node.kind <= 151 /* LastToken */) { return; } switch (node.kind) { - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17062,9 +17643,9 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.equalsToken) || visitNode(cbNode, node.objectAssignmentInitializer); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || @@ -17072,7 +17653,7 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -17080,51 +17661,51 @@ var ts; visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.initializer); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.exclamationToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -17136,345 +17717,350 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 164 /* TypePredicate */: - return visitNode(cbNode, node.parameterName) || + case 167 /* TypePredicate */: + return visitNode(cbNode, node.assertsModifier) || + visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return visitNodes(cbNode, cbNodes, node.members); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 171 /* TupleType */: + case 174 /* TupleType */: return visitNodes(cbNode, cbNodes, node.elementTypes); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return visitNodes(cbNode, cbNodes, node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return visitNode(cbNode, node.checkType) || visitNode(cbNode, node.extendsType) || visitNode(cbNode, node.trueType) || visitNode(cbNode, node.falseType); - case 177 /* InferType */: + case 180 /* InferType */: return visitNode(cbNode, node.typeParameter); - case 184 /* ImportType */: + case 187 /* ImportType */: return visitNode(cbNode, node.argument) || visitNode(cbNode, node.qualifier) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 178 /* ParenthesizedType */: - case 180 /* TypeOperator */: + case 181 /* ParenthesizedType */: + case 183 /* TypeOperator */: return visitNode(cbNode, node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 182 /* MappedType */: + case 185 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return visitNode(cbNode, node.literal); - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return visitNodes(cbNode, cbNodes, node.elements); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitNodes(cbNode, cbNodes, node.properties); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.name); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNode(cbNode, node.argumentExpression); - case 192 /* CallExpression */: - case 193 /* NewExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNodes(cbNode, cbNodes, node.arguments); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || + visitNode(cbNode, node.questionDotToken) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.template); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitNode(cbNode, node.name); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return visitNodes(cbNode, cbNodes, node.statements); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return visitNodes(cbNode, cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitNodes(cbNode, cbNodes, node.declarations); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitNode(cbNode, node.awaitModifier) || visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return visitNode(cbNode, node.label); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitNodes(cbNode, cbNodes, node.clauses); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.statements); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitNodes(cbNode, cbNodes, node.statements); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 153 /* Decorator */: + case 156 /* Decorator */: return visitNode(cbNode, node.expression); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNodes(cbNode, cbNodes, node.heritageClauses) || visitNodes(cbNode, cbNodes, node.members); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNode, cbNodes, node.members); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: return visitNodes(cbNode, cbNodes, node.elements); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitNodes(cbNode, cbNodes, node.decorators) || visitNodes(cbNode, cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans); - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return visitNodes(cbNode, cbNodes, node.types); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNode, cbNodes, node.typeArguments); - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return visitNodes(cbNode, cbNodes, node.decorators); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return visitNodes(cbNode, cbNodes, node.elements); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitNode(cbNode, node.openingFragment) || visitNodes(cbNode, cbNodes, node.children) || visitNode(cbNode, node.closingFragment); - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNodes(cbNode, cbNodes, node.typeArguments) || visitNode(cbNode, node.attributes); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return visitNodes(cbNode, cbNodes, node.properties); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 172 /* OptionalType */: - case 173 /* RestType */: - case 289 /* JSDocTypeExpression */: - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 294 /* JSDocOptionalType */: - case 296 /* JSDocVariadicType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 292 /* JSDocTypeExpression */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 297 /* JSDocOptionalType */: + case 299 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return visitNodes(cbNode, cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return visitNodes(cbNode, cbNodes, node.tags); - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return visitNode(cbNode, node.tagName) || (node.isNameFirst ? visitNode(cbNode, node.name) || visitNode(cbNode, node.typeExpression) : visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name)); - case 303 /* JSDocAuthorTag */: + case 306 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.class); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.constraint) || visitNodes(cbNode, cbNodes, node.typeParameters); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return visitNode(cbNode, node.tagName) || (node.typeExpression && - node.typeExpression.kind === 289 /* JSDocTypeExpression */ + node.typeExpression.kind === 292 /* JSDocTypeExpression */ ? visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) : visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression)); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.typeExpression); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.typeExpression); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return ts.forEach(node.typeParameters, cbNode) || ts.forEach(node.parameters, cbNode) || visitNode(cbNode, node.type); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return ts.forEach(node.jsDocPropertyTags, cbNode); - case 301 /* JSDocTag */: - case 304 /* JSDocClassTag */: + case 304 /* JSDocTag */: + case 307 /* JSDocClassTag */: return visitNode(cbNode, node.tagName); - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); } } @@ -17528,7 +18114,7 @@ var ts; var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks); // Because new source file node is created, it may not have the flag PossiblyContainDynamicImport. This is the case if there is no new edit to add dynamic import. // We will manually port the flag to the new source file. - newSourceFile.flags |= (sourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */); + newSourceFile.flags |= (sourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */); return newSourceFile; } ts.updateSourceFile = updateSourceFile; @@ -17557,14 +18143,12 @@ var ts; // Share a single scanner across all calls to parse a source file. This helps speed things // up by avoiding the cost of creating/compiling scanners over and over again. var scanner = ts.createScanner(99 /* Latest */, /*skipTrivia*/ true); - var disallowInAndDecoratorContext = 2048 /* DisallowInContext */ | 8192 /* DecoratorContext */; + var disallowInAndDecoratorContext = 4096 /* DisallowInContext */ | 16384 /* DecoratorContext */; // capture constructors in 'initializeState' to avoid null checks - // tslint:disable variable-name var NodeConstructor; var TokenConstructor; var IdentifierConstructor; var SourceFileConstructor; - // tslint:enable variable-name var sourceFile; var parseDiagnostics; var syntaxCursor; @@ -17695,18 +18279,18 @@ var ts; sourceFile.endOfFileToken = parseTokenNode(); } else { - var statement = createNode(222 /* ExpressionStatement */); + var statement = createNode(225 /* ExpressionStatement */); switch (token()) { case 22 /* OpenBracketToken */: statement.expression = parseArrayLiteralExpression(); break; - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: statement.expression = parseTokenNode(); break; - case 39 /* MinusToken */: - if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 57 /* ColonToken */; })) { + case 40 /* MinusToken */: + if (lookAhead(function () { return nextToken() === 8 /* NumericLiteral */ && nextToken() !== 58 /* ColonToken */; })) { statement.expression = parsePrefixUnaryExpression(); } else { @@ -17715,7 +18299,7 @@ var ts; break; case 8 /* NumericLiteral */: case 10 /* StringLiteral */: - if (lookAhead(function () { return nextToken() !== 57 /* ColonToken */; })) { + if (lookAhead(function () { return nextToken() !== 58 /* ColonToken */; })) { statement.expression = parseLiteralNode(); break; } @@ -17731,6 +18315,9 @@ var ts; if (setParentNodes) { fixupParentReferences(sourceFile); } + sourceFile.nodeCount = nodeCount; + sourceFile.identifierCount = identifierCount; + sourceFile.identifiers = identifiers; sourceFile.parseDiagnostics = parseDiagnostics; var result = sourceFile; clearState(); @@ -17756,10 +18343,10 @@ var ts; switch (scriptKind) { case 1 /* JS */: case 2 /* JSX */: - contextFlags = 65536 /* JavaScriptFile */; + contextFlags = 131072 /* JavaScriptFile */; break; case 6 /* JSON */: - contextFlags = 65536 /* JavaScriptFile */ | 16777216 /* JsonFile */; + contextFlags = 131072 /* JavaScriptFile */ | 33554432 /* JsonFile */; break; default: contextFlags = 0 /* None */; @@ -17787,7 +18374,7 @@ var ts; function parseSourceFileWorker(fileName, languageVersion, setParentNodes, scriptKind) { var isDeclarationFile = isDeclarationFileName(fileName); if (isDeclarationFile) { - contextFlags |= 4194304 /* Ambient */; + contextFlags |= 8388608 /* Ambient */; } sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile); sourceFile.flags = contextFlags; @@ -17852,7 +18439,7 @@ var ts; function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile) { // code from createNode is inlined here so createNode won't have to deal with special case of creating source files // this is quite rare comparing to other nodes and createNode should be as fast as possible - var sourceFile = new SourceFileConstructor(285 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(288 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -17873,16 +18460,16 @@ var ts; } } function setDisallowInContext(val) { - setContextFlag(val, 2048 /* DisallowInContext */); + setContextFlag(val, 4096 /* DisallowInContext */); } function setYieldContext(val) { - setContextFlag(val, 4096 /* YieldContext */); + setContextFlag(val, 8192 /* YieldContext */); } function setDecoratorContext(val) { - setContextFlag(val, 8192 /* DecoratorContext */); + setContextFlag(val, 16384 /* DecoratorContext */); } function setAwaitContext(val) { - setContextFlag(val, 16384 /* AwaitContext */); + setContextFlag(val, 32768 /* AwaitContext */); } function doOutsideOfContext(context, func) { // contextFlagsToClear will contain only the context flags that are @@ -17923,40 +18510,40 @@ var ts; return func(); } function allowInAnd(func) { - return doOutsideOfContext(2048 /* DisallowInContext */, func); + return doOutsideOfContext(4096 /* DisallowInContext */, func); } function disallowInAnd(func) { - return doInsideOfContext(2048 /* DisallowInContext */, func); + return doInsideOfContext(4096 /* DisallowInContext */, func); } function doInYieldContext(func) { - return doInsideOfContext(4096 /* YieldContext */, func); + return doInsideOfContext(8192 /* YieldContext */, func); } function doInDecoratorContext(func) { - return doInsideOfContext(8192 /* DecoratorContext */, func); + return doInsideOfContext(16384 /* DecoratorContext */, func); } function doInAwaitContext(func) { - return doInsideOfContext(16384 /* AwaitContext */, func); + return doInsideOfContext(32768 /* AwaitContext */, func); } function doOutsideOfAwaitContext(func) { - return doOutsideOfContext(16384 /* AwaitContext */, func); + return doOutsideOfContext(32768 /* AwaitContext */, func); } function doInYieldAndAwaitContext(func) { - return doInsideOfContext(4096 /* YieldContext */ | 16384 /* AwaitContext */, func); + return doInsideOfContext(8192 /* YieldContext */ | 32768 /* AwaitContext */, func); } function inContext(flags) { return (contextFlags & flags) !== 0; } function inYieldContext() { - return inContext(4096 /* YieldContext */); + return inContext(8192 /* YieldContext */); } function inDisallowInContext() { - return inContext(2048 /* DisallowInContext */); + return inContext(4096 /* DisallowInContext */); } function inDecoratorContext() { - return inContext(8192 /* DecoratorContext */); + return inContext(16384 /* DecoratorContext */); } function inAwaitContext() { - return inContext(16384 /* AwaitContext */); + return inContext(32768 /* AwaitContext */); } function parseErrorAtCurrentToken(message, arg0) { parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0); @@ -18071,20 +18658,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 73 /* Identifier */) { + if (token() === 75 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 118 /* YieldKeyword */ && inYieldContext()) { + if (token() === 120 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 123 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 126 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 109 /* LastReservedWord */; + return token() > 111 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -18172,7 +18759,7 @@ var ts; nodeCount++; var p = pos >= 0 ? pos : scanner.getStartPos(); return ts.isNodeKind(kind) || kind === 0 /* Unknown */ ? new NodeConstructor(kind, p, p) : - kind === 73 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : + kind === 75 /* Identifier */ ? new IdentifierConstructor(kind, p, p) : new TokenConstructor(kind, p, p); } function createNodeWithJSDoc(kind, pos) { @@ -18202,7 +18789,7 @@ var ts; // flag so that we don't mark any subsequent nodes. if (parseErrorBeforeNextFinishedNode) { parseErrorBeforeNextFinishedNode = false; - node.flags |= 32768 /* ThisNodeHasError */; + node.flags |= 65536 /* ThisNodeHasError */; } return node; } @@ -18214,7 +18801,7 @@ var ts; parseErrorAtCurrentToken(diagnosticMessage, arg0); } var result = createNode(kind); - if (kind === 73 /* Identifier */) { + if (kind === 75 /* Identifier */) { result.escapedText = ""; } else if (ts.isLiteralKind(kind) || ts.isTemplateLiteralKind(kind)) { @@ -18235,9 +18822,9 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(73 /* Identifier */); + var node = createNode(75 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 73 /* Identifier */) { + if (token() !== 75 /* Identifier */) { node.originalKeywordKind = token(); } node.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -18246,7 +18833,12 @@ var ts; } // Only for end of file because the error gets reported incorrectly on embedded script tags. var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; - return createMissingNode(73 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var isReservedWord = scanner.isReservedWord(); + var msgArg = scanner.getTokenText(); + var defaultMessage = isReservedWord ? + ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here : + ts.Diagnostics.Identifier_expected; + return createMissingNode(75 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -18277,7 +18869,7 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(150 /* ComputedPropertyName */); + var node = createNode(153 /* ComputedPropertyName */); parseExpected(22 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker @@ -18298,20 +18890,20 @@ var ts; } function nextTokenCanFollowModifier() { switch (token()) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 85 /* EnumKeyword */; - case 86 /* ExportKeyword */: + return nextToken() === 87 /* EnumKeyword */; + case 88 /* ExportKeyword */: nextToken(); - if (token() === 81 /* DefaultKeyword */) { + if (token() === 83 /* DefaultKeyword */) { return lookAhead(nextTokenCanFollowDefaultKeyword); } - return token() !== 40 /* AsteriskToken */ && token() !== 120 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); - case 81 /* DefaultKeyword */: + return token() !== 41 /* AsteriskToken */ && token() !== 122 /* AsKeyword */ && token() !== 18 /* OpenBraceToken */ && canFollowModifier(); + case 83 /* DefaultKeyword */: return nextTokenCanFollowDefaultKeyword(); - case 117 /* StaticKeyword */: - case 127 /* GetKeyword */: - case 138 /* SetKeyword */: + case 119 /* StaticKeyword */: + case 130 /* GetKeyword */: + case 141 /* SetKeyword */: nextToken(); return canFollowModifier(); default: @@ -18324,16 +18916,16 @@ var ts; function canFollowModifier() { return token() === 22 /* OpenBracketToken */ || token() === 18 /* OpenBraceToken */ - || token() === 40 /* AsteriskToken */ + || token() === 41 /* AsteriskToken */ || token() === 25 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenCanFollowDefaultKeyword() { nextToken(); - return token() === 77 /* ClassKeyword */ || token() === 91 /* FunctionKeyword */ || - token() === 111 /* InterfaceKeyword */ || - (token() === 119 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || - (token() === 122 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 79 /* ClassKeyword */ || token() === 93 /* FunctionKeyword */ || + token() === 113 /* InterfaceKeyword */ || + (token() === 121 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 125 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -18353,7 +18945,7 @@ var ts; // outer module. We just want to consume and move on. return !(token() === 26 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -18369,7 +18961,7 @@ var ts; case 12 /* ObjectLiteralMembers */: switch (token()) { case 22 /* OpenBracketToken */: - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: case 25 /* DotDotDotToken */: case 24 /* DotToken */: // Not an object literal member, but don't want to close the object (see `tests/cases/fourslash/completionsDotInObjectLiteral.ts`) return true; @@ -18439,7 +19031,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 87 /* ExtendsKeyword */ || next === 110 /* ImplementsKeyword */; + return next === 27 /* CommaToken */ || next === 18 /* OpenBraceToken */ || next === 89 /* ExtendsKeyword */ || next === 112 /* ImplementsKeyword */; } return true; } @@ -18456,8 +19048,8 @@ var ts; return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 110 /* ImplementsKeyword */ || - token() === 87 /* ExtendsKeyword */) { + if (token() === 112 /* ImplementsKeyword */ || + token() === 89 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -18487,14 +19079,14 @@ var ts; case 23 /* ImportOrExportSpecifiers */: return token() === 19 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 19 /* CloseBraceToken */ || token() === 75 /* CaseKeyword */ || token() === 81 /* DefaultKeyword */; + return token() === 19 /* CloseBraceToken */ || token() === 77 /* CaseKeyword */ || token() === 83 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 19 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 30 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 31 /* GreaterThanToken */ || token() === 20 /* OpenParenToken */ || token() === 18 /* OpenBraceToken */ || token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery return token() === 21 /* CloseParenToken */ || token() === 26 /* SemicolonToken */; @@ -18513,9 +19105,9 @@ var ts; case 22 /* HeritageClauses */: return token() === 18 /* OpenBraceToken */ || token() === 19 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 30 /* GreaterThanToken */ || token() === 42 /* SlashToken */; + return token() === 31 /* GreaterThanToken */ || token() === 43 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsSlash); default: return false; } @@ -18535,7 +19127,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -18610,7 +19202,7 @@ var ts; // differently depending on what mode it is in. // // This also applies to all our other context flags as well. - var nodeContextFlags = node.flags & 12679168 /* ContextFlags */; + var nodeContextFlags = node.flags & 25358336 /* ContextFlags */; if (nodeContextFlags !== contextFlags) { return undefined; } @@ -18711,20 +19303,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 158 /* Constructor */: - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 218 /* SemicolonClassElement */: + case 161 /* Constructor */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 221 /* SemicolonClassElement */: return true; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 73 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 125 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 75 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 128 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -18733,8 +19325,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: return true; } } @@ -18743,58 +19335,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 220 /* VariableStatement */: - case 219 /* Block */: - case 223 /* IfStatement */: - case 222 /* ExpressionStatement */: - case 235 /* ThrowStatement */: - case 231 /* ReturnStatement */: - case 233 /* SwitchStatement */: - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 226 /* ForStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 221 /* EmptyStatement */: - case 236 /* TryStatement */: - case 234 /* LabeledStatement */: - case 224 /* DoStatement */: - case 237 /* DebuggerStatement */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 224 /* VariableStatement */: + case 222 /* Block */: + case 226 /* IfStatement */: + case 225 /* ExpressionStatement */: + case 238 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 236 /* SwitchStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 229 /* ForStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 223 /* EmptyStatement */: + case 239 /* TryStatement */: + case 237 /* LabeledStatement */: + case 227 /* DoStatement */: + case 240 /* DebuggerStatement */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 279 /* EnumMember */; + return node.kind === 282 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 154 /* PropertySignature */: - case 161 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 157 /* PropertySignature */: + case 164 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 238 /* VariableDeclaration */) { + if (node.kind !== 241 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -18815,7 +19407,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 152 /* Parameter */) { + if (node.kind !== 155 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -18882,7 +19474,7 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(27 /* CommaToken */); + parseExpected(27 /* CommaToken */, getExpectedCommaDiagnostic(kind)); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use @@ -18920,6 +19512,9 @@ var ts; } return result; } + function getExpectedCommaDiagnostic(kind) { + return kind === 6 /* EnumMembers */ ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined; + } function createMissingList() { var list = createNodeArray([], getNodePos()); list.isMissingList = true; @@ -18940,7 +19535,7 @@ var ts; var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage); var dotPos = scanner.getStartPos(); while (parseOptional(24 /* DotToken */)) { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { // the entity is part of a JSDoc-style generic, so record the trailing dot for later error reporting entity.jsdocDotPos = dotPos; break; @@ -18951,7 +19546,7 @@ var ts; return entity; } function createQualifiedName(entity, name) { - var node = createNode(149 /* QualifiedName */, entity.pos); + var node = createNode(152 /* QualifiedName */, entity.pos); node.left = entity; node.right = name; return finishNode(node); @@ -18982,13 +19577,13 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(207 /* TemplateExpression */); + var template = createNode(210 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 15 /* TemplateHead */, "Template head has wrong token kind"); var list = []; @@ -19000,7 +19595,7 @@ var ts; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(217 /* TemplateSpan */); + var span = createNode(220 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; if (token() === 19 /* CloseBraceToken */) { @@ -19060,24 +19655,24 @@ var ts; } // TYPES function parseTypeReference() { - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } // If true, we should abort parsing an error function. function typeHasArrowFunctionBlockingParseError(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return ts.nodeIsMissing(node.typeName); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: { + case 169 /* FunctionType */: + case 170 /* ConstructorType */: { var _a = node, parameters = _a.parameters, type = _a.type; return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type); } - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return typeHasArrowFunctionBlockingParseError(node.type); default: return false; @@ -19085,20 +19680,20 @@ var ts; } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(164 /* TypePredicate */, lhs.pos); + var node = createNode(167 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(179 /* ThisType */); + var node = createNode(182 /* ThisType */); nextToken(); return finishNode(node); } function parseJSDocAllType(postFixEquals) { - var result = createNode(290 /* JSDocAllType */); + var result = createNode(293 /* JSDocAllType */); if (postFixEquals) { - return createPostfixType(294 /* JSDocOptionalType */, result); + return createPostfixType(297 /* JSDocOptionalType */, result); } else { nextToken(); @@ -19106,7 +19701,7 @@ var ts; return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(293 /* JSDocNonNullableType */); + var result = createNode(296 /* JSDocNonNullableType */); nextToken(); result.type = parseNonArrayType(); return finishNode(result); @@ -19127,43 +19722,43 @@ var ts; if (token() === 27 /* CommaToken */ || token() === 19 /* CloseBraceToken */ || token() === 21 /* CloseParenToken */ || - token() === 30 /* GreaterThanToken */ || - token() === 60 /* EqualsToken */ || - token() === 50 /* BarToken */) { - var result = createNode(291 /* JSDocUnknownType */, pos); + token() === 31 /* GreaterThanToken */ || + token() === 62 /* EqualsToken */ || + token() === 51 /* BarToken */) { + var result = createNode(294 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(292 /* JSDocNullableType */, pos); + var result = createNode(295 /* JSDocNullableType */, pos); result.type = parseType(); return finishNode(result); } } function parseJSDocFunctionType() { if (lookAhead(nextTokenIsOpenParen)) { - var result = createNodeWithJSDoc(295 /* JSDocFunctionType */); + var result = createNodeWithJSDoc(298 /* JSDocFunctionType */); nextToken(); - fillSignature(57 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); + fillSignature(58 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); return finishNode(result); } - var node = createNode(165 /* TypeReference */); + var node = createNode(168 /* TypeReference */); node.typeName = parseIdentifierName(); return finishNode(node); } function parseJSDocParameter() { - var parameter = createNode(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */ || token() === 96 /* NewKeyword */) { + var parameter = createNode(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */ || token() === 98 /* NewKeyword */) { parameter.name = parseIdentifierName(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); } parameter.type = parseJSDocType(); return finishNode(parameter); } function parseJSDocType() { scanner.setInJSDocType(true); - var moduleSpecifier = parseOptionalToken(131 /* ModuleKeyword */); + var moduleSpecifier = parseOptionalToken(134 /* ModuleKeyword */); if (moduleSpecifier) { - var moduleTag = createNode(297 /* JSDocNamepathType */, moduleSpecifier.pos); + var moduleTag = createNode(300 /* JSDocNamepathType */, moduleSpecifier.pos); terminate: while (true) { switch (token()) { case 19 /* CloseBraceToken */: @@ -19182,25 +19777,25 @@ var ts; var type = parseTypeOrTypePredicate(); scanner.setInJSDocType(false); if (dotdotdot) { - var variadic = createNode(296 /* JSDocVariadicType */, dotdotdot.pos); + var variadic = createNode(299 /* JSDocVariadicType */, dotdotdot.pos); variadic.type = type; type = finishNode(variadic); } - if (token() === 60 /* EqualsToken */) { - return createPostfixType(294 /* JSDocOptionalType */, type); + if (token() === 62 /* EqualsToken */) { + return createPostfixType(297 /* JSDocOptionalType */, type); } return type; } function parseTypeQuery() { - var node = createNode(168 /* TypeQuery */); - parseExpected(105 /* TypeOfKeyword */); + var node = createNode(171 /* TypeQuery */); + parseExpected(107 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(87 /* ExtendsKeyword */)) { + if (parseOptional(89 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -19219,18 +19814,18 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(60 /* EqualsToken */)) { + if (parseOptional(62 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 28 /* LessThanToken */) { - return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (token() === 29 /* LessThanToken */) { + return parseBracketedList(19 /* TypeParameters */, parseTypeParameter, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(57 /* ColonToken */)) { + if (parseOptional(58 /* ColonToken */)) { return parseType(); } return undefined; @@ -19239,12 +19834,12 @@ var ts; return token() === 25 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 58 /* AtToken */ || + token() === 59 /* AtToken */ || isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } function parseParameter() { - var node = createNodeWithJSDoc(152 /* Parameter */); - if (token() === 101 /* ThisKeyword */) { + var node = createNodeWithJSDoc(155 /* Parameter */); + if (token() === 103 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); @@ -19266,7 +19861,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(56 /* QuestionToken */); + node.questionToken = parseOptionalToken(57 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseInitializer(); return finishNode(node); @@ -19288,16 +19883,16 @@ var ts; return parametersParsedSuccessfully; } function shouldParseReturnType(returnToken, isType) { - if (returnToken === 37 /* EqualsGreaterThanToken */) { + if (returnToken === 38 /* EqualsGreaterThanToken */) { parseExpected(returnToken); return true; } - else if (parseOptional(57 /* ColonToken */)) { + else if (parseOptional(58 /* ColonToken */)) { return true; } - else if (isType && token() === 37 /* EqualsGreaterThanToken */) { + else if (isType && token() === 38 /* EqualsGreaterThanToken */) { // This is easy to get backward, especially in type contexts, so parse the type anyway - parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); nextToken(); return true; } @@ -19344,10 +19939,10 @@ var ts; } function parseSignatureMember(kind) { var node = createNodeWithJSDoc(kind); - if (kind === 162 /* ConstructSignature */) { - parseExpected(96 /* NewKeyword */); + if (kind === 165 /* ConstructSignature */) { + parseExpected(98 /* NewKeyword */); } - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); parseTypeMemberSemicolon(); return finishNode(node); } @@ -19391,21 +19986,21 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 56 /* QuestionToken */) { + if (token() !== 57 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; + return token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 23 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(node) { - node.kind = 163 /* IndexSignature */; + node.kind = 166 /* IndexSignature */; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); @@ -19413,17 +20008,17 @@ var ts; } function parsePropertyOrMethodSignature(node) { node.name = parsePropertyName(); - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - node.kind = 156 /* MethodSignature */; + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + node.kind = 159 /* MethodSignature */; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(57 /* ColonToken */, 4 /* Type */, node); + fillSignature(58 /* ColonToken */, 4 /* Type */, node); } else { - node.kind = 154 /* PropertySignature */; + node.kind = 157 /* PropertySignature */; node.type = parseTypeAnnotation(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -19435,7 +20030,7 @@ var ts; } function isTypeMemberStart() { // Return true if we have the start of a signature member - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return true; } var idToken = false; @@ -19457,20 +20052,20 @@ var ts; // the start of a member declaration if (idToken) { return token() === 20 /* OpenParenToken */ || - token() === 28 /* LessThanToken */ || - token() === 56 /* QuestionToken */ || - token() === 57 /* ColonToken */ || + token() === 29 /* LessThanToken */ || + token() === 57 /* QuestionToken */ || + token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { - return parseSignatureMember(161 /* CallSignature */); + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { + return parseSignatureMember(164 /* CallSignature */); } - if (token() === 96 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { - return parseSignatureMember(162 /* ConstructSignature */); + if (token() === 98 /* NewKeyword */ && lookAhead(nextTokenIsOpenParenOrLessThan)) { + return parseSignatureMember(165 /* ConstructSignature */); } var node = createNodeWithJSDoc(0 /* Unknown */); node.modifiers = parseModifiers(); @@ -19481,7 +20076,7 @@ var ts; } function nextTokenIsOpenParenOrLessThan() { nextToken(); - return token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */; + return token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */; } function nextTokenIsDot() { return nextToken() === 24 /* DotToken */; @@ -19489,14 +20084,14 @@ var ts; function nextTokenIsOpenParenOrLessThanOrDot() { switch (nextToken()) { case 20 /* OpenParenToken */: - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: case 24 /* DotToken */: return true; } return false; } function parseTypeLiteral() { - var node = createNode(169 /* TypeLiteral */); + var node = createNode(172 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } @@ -19513,37 +20108,37 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { - return nextToken() === 134 /* ReadonlyKeyword */; + if (token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { + return nextToken() === 137 /* ReadonlyKeyword */; } - if (token() === 134 /* ReadonlyKeyword */) { + if (token() === 137 /* ReadonlyKeyword */) { nextToken(); } - return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 94 /* InKeyword */; + return token() === 22 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 96 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(151 /* TypeParameter */); + var node = createNode(154 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(94 /* InKeyword */); + parseExpected(96 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(182 /* MappedType */); + var node = createNode(185 /* MappedType */); parseExpected(18 /* OpenBraceToken */); - if (token() === 134 /* ReadonlyKeyword */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 137 /* ReadonlyKeyword */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.readonlyToken = parseTokenNode(); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { - parseExpectedToken(134 /* ReadonlyKeyword */); + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { + parseExpectedToken(137 /* ReadonlyKeyword */); } } parseExpected(22 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); parseExpected(23 /* CloseBracketToken */); - if (token() === 56 /* QuestionToken */ || token() === 38 /* PlusToken */ || token() === 39 /* MinusToken */) { + if (token() === 57 /* QuestionToken */ || token() === 39 /* PlusToken */ || token() === 40 /* MinusToken */) { node.questionToken = parseTokenNode(); - if (node.questionToken.kind !== 56 /* QuestionToken */) { - parseExpectedToken(56 /* QuestionToken */); + if (node.questionToken.kind !== 57 /* QuestionToken */) { + parseExpectedToken(57 /* QuestionToken */); } } node.type = parseTypeAnnotation(); @@ -19554,23 +20149,23 @@ var ts; function parseTupleElementType() { var pos = getNodePos(); if (parseOptional(25 /* DotDotDotToken */)) { - var node = createNode(173 /* RestType */, pos); + var node = createNode(176 /* RestType */, pos); node.type = parseType(); return finishNode(node); } var type = parseType(); - if (!(contextFlags & 2097152 /* JSDoc */) && type.kind === 292 /* JSDocNullableType */ && type.pos === type.type.pos) { - type.kind = 172 /* OptionalType */; + if (!(contextFlags & 4194304 /* JSDoc */) && type.kind === 295 /* JSDocNullableType */ && type.pos === type.type.pos) { + type.kind = 175 /* OptionalType */; } return type; } function parseTupleType() { - var node = createNode(171 /* TupleType */); + var node = createNode(174 /* TupleType */); node.elementTypes = parseBracketedList(21 /* TupleElementTypes */, parseTupleElementType, 22 /* OpenBracketToken */, 23 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(178 /* ParenthesizedType */); + var node = createNode(181 /* ParenthesizedType */); parseExpected(20 /* OpenParenToken */); node.type = parseType(); parseExpected(21 /* CloseParenToken */); @@ -19578,9 +20173,9 @@ var ts; } function parseFunctionOrConstructorType() { var pos = getNodePos(); - var kind = parseOptional(96 /* NewKeyword */) ? 167 /* ConstructorType */ : 166 /* FunctionType */; + var kind = parseOptional(98 /* NewKeyword */) ? 170 /* ConstructorType */ : 169 /* FunctionType */; var node = createNodeWithJSDoc(kind, pos); - fillSignature(37 /* EqualsGreaterThanToken */, 4 /* Type */, node); + fillSignature(38 /* EqualsGreaterThanToken */, 4 /* Type */, node); return finishNode(node); } function parseKeywordAndNoDot() { @@ -19588,14 +20183,14 @@ var ts; return token() === 24 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode(negative) { - var node = createNode(183 /* LiteralType */); + var node = createNode(186 /* LiteralType */); var unaryMinusExpression; if (negative) { - unaryMinusExpression = createNode(203 /* PrefixUnaryExpression */); - unaryMinusExpression.operator = 39 /* MinusToken */; + unaryMinusExpression = createNode(206 /* PrefixUnaryExpression */); + unaryMinusExpression.operator = 40 /* MinusToken */; nextToken(); } - var expression = token() === 103 /* TrueKeyword */ || token() === 88 /* FalseKeyword */ + var expression = token() === 105 /* TrueKeyword */ || token() === 90 /* FalseKeyword */ ? parseTokenNode() : parseLiteralLikeNode(token()); if (negative) { @@ -19608,23 +20203,23 @@ var ts; } function isStartOfTypeOfImportType() { nextToken(); - return token() === 93 /* ImportKeyword */; + return token() === 95 /* ImportKeyword */; } function parseImportType() { - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; - var node = createNode(184 /* ImportType */); - if (parseOptional(105 /* TypeOfKeyword */)) { + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; + var node = createNode(187 /* ImportType */); + if (parseOptional(107 /* TypeOfKeyword */)) { node.isTypeOf = true; } - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); parseExpected(20 /* OpenParenToken */); node.argument = parseType(); parseExpected(21 /* CloseParenToken */); if (parseOptional(24 /* DotToken */)) { node.qualifier = parseEntityName(/*allowReservedWords*/ true, ts.Diagnostics.Type_expected); } - if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 28 /* LessThanToken */) { - node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */); + if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29 /* LessThanToken */) { + node.typeArguments = parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */); } return finishNode(node); } @@ -19634,50 +20229,54 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 140 /* SymbolKeyword */: - case 124 /* BooleanKeyword */: - case 142 /* UndefinedKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 143 /* SymbolKeyword */: + case 127 /* BooleanKeyword */: + case 145 /* UndefinedKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. return tryParse(parseKeywordAndNoDot) || parseTypeReference(); - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: return parseJSDocAllType(/*postfixEquals*/ false); - case 63 /* AsteriskEqualsToken */: + case 65 /* AsteriskEqualsToken */: return parseJSDocAllType(/*postfixEquals*/ true); - case 56 /* QuestionToken */: + case 60 /* QuestionQuestionToken */: + // If there is '??', consider that is prefix '?' in JSDoc type. + scanner.reScanQuestionToken(); + // falls through + case 57 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: return parseJSDocNonNullableType(); case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseLiteralTypeNode(); - case 39 /* MinusToken */: + case 40 /* MinusToken */: return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(/*negative*/ true) : parseTypeReference(); - case 107 /* VoidKeyword */: - case 97 /* NullKeyword */: + case 109 /* VoidKeyword */: + case 99 /* NullKeyword */: return parseTokenNode(); - case 101 /* ThisKeyword */: { + case 103 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery(); case 18 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); @@ -19685,51 +20284,54 @@ var ts; return parseTupleType(); case 20 /* OpenParenToken */: return parseParenthesizedType(); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportType(); + case 123 /* AssertsKeyword */: + return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference(); default: return parseTypeReference(); } } function isStartOfType(inStartOfParameter) { switch (token()) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 134 /* ReadonlyKeyword */: - case 140 /* SymbolKeyword */: - case 143 /* UniqueKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 101 /* ThisKeyword */: - case 105 /* TypeOfKeyword */: - case 133 /* NeverKeyword */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 137 /* ReadonlyKeyword */: + case 143 /* SymbolKeyword */: + case 146 /* UniqueKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 103 /* ThisKeyword */: + case 107 /* TypeOfKeyword */: + case 136 /* NeverKeyword */: case 18 /* OpenBraceToken */: case 22 /* OpenBracketToken */: - case 28 /* LessThanToken */: - case 50 /* BarToken */: - case 49 /* AmpersandToken */: - case 96 /* NewKeyword */: + case 29 /* LessThanToken */: + case 51 /* BarToken */: + case 50 /* AmpersandToken */: + case 98 /* NewKeyword */: case 10 /* StringLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 137 /* ObjectKeyword */: - case 40 /* AsteriskToken */: - case 56 /* QuestionToken */: - case 52 /* ExclamationToken */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 140 /* ObjectKeyword */: + case 41 /* AsteriskToken */: + case 57 /* QuestionToken */: + case 53 /* ExclamationToken */: case 25 /* DotDotDotToken */: - case 128 /* InferKeyword */: - case 93 /* ImportKeyword */: + case 131 /* InferKeyword */: + case 95 /* ImportKeyword */: + case 123 /* AssertsKeyword */: return true; - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return !inStartOfParameter; - case 39 /* MinusToken */: + case 40 /* MinusToken */: return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral); case 20 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, @@ -19747,27 +20349,27 @@ var ts; var type = parseNonArrayType(); while (!scanner.hasPrecedingLineBreak()) { switch (token()) { - case 52 /* ExclamationToken */: - type = createPostfixType(293 /* JSDocNonNullableType */, type); + case 53 /* ExclamationToken */: + type = createPostfixType(296 /* JSDocNonNullableType */, type); break; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: // If not in JSDoc and next token is start of a type we have a conditional type - if (!(contextFlags & 2097152 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { + if (!(contextFlags & 4194304 /* JSDoc */) && lookAhead(nextTokenIsStartOfType)) { return type; } - type = createPostfixType(292 /* JSDocNullableType */, type); + type = createPostfixType(295 /* JSDocNullableType */, type); break; case 22 /* OpenBracketToken */: parseExpected(22 /* OpenBracketToken */); if (isStartOfType()) { - var node = createNode(181 /* IndexedAccessType */, type.pos); + var node = createNode(184 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); parseExpected(23 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(170 /* ArrayType */, type.pos); + var node = createNode(173 /* ArrayType */, type.pos); node.elementType = type; parseExpected(23 /* CloseBracketToken */); type = finishNode(node); @@ -19786,16 +20388,16 @@ var ts; return finishNode(postfix); } function parseTypeOperator(operator) { - var node = createNode(180 /* TypeOperator */); + var node = createNode(183 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); return finishNode(node); } function parseInferType() { - var node = createNode(177 /* InferType */); - parseExpected(128 /* InferKeyword */); - var typeParameter = createNode(151 /* TypeParameter */); + var node = createNode(180 /* InferType */); + parseExpected(131 /* InferKeyword */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseIdentifier(); node.typeParameter = finishNode(typeParameter); return finishNode(node); @@ -19803,11 +20405,11 @@ var ts; function parseTypeOperatorOrHigher() { var operator = token(); switch (operator) { - case 130 /* KeyOfKeyword */: - case 143 /* UniqueKeyword */: - case 134 /* ReadonlyKeyword */: + case 133 /* KeyOfKeyword */: + case 146 /* UniqueKeyword */: + case 137 /* ReadonlyKeyword */: return parseTypeOperator(operator); - case 128 /* InferKeyword */: + case 131 /* InferKeyword */: return parseInferType(); } return parsePostfixTypeOrHigher(); @@ -19828,13 +20430,13 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(175 /* IntersectionType */, parseTypeOperatorOrHigher, 49 /* AmpersandToken */); + return parseUnionOrIntersectionType(178 /* IntersectionType */, parseTypeOperatorOrHigher, 50 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(174 /* UnionType */, parseIntersectionTypeOrHigher, 50 /* BarToken */); + return parseUnionOrIntersectionType(177 /* UnionType */, parseIntersectionTypeOrHigher, 51 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { return true; } return token() === 20 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); @@ -19844,7 +20446,7 @@ var ts; // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 101 /* ThisKeyword */) { + if (isIdentifier() || token() === 103 /* ThisKeyword */) { nextToken(); return true; } @@ -19866,8 +20468,8 @@ var ts; if (skipParameterStart()) { // We successfully skipped modifiers (if any) and an identifier or binding pattern, // now see if we have something that indicates a parameter declaration - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || - token() === 56 /* QuestionToken */ || token() === 60 /* EqualsToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || + token() === 57 /* QuestionToken */ || token() === 62 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? @@ -19876,7 +20478,7 @@ var ts; } if (token() === 21 /* CloseParenToken */) { nextToken(); - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -19888,7 +20490,8 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(164 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(167 /* TypePredicate */, typePredicateVariable.pos); + node.assertsModifier = undefined; node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -19899,45 +20502,52 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 129 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 132 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } } + function parseAssertsTypePredicate() { + var node = createNode(167 /* TypePredicate */); + node.assertsModifier = parseExpectedToken(123 /* AssertsKeyword */); + node.parameterName = token() === 103 /* ThisKeyword */ ? parseThisTypeNode() : parseIdentifier(); + node.type = parseOptional(132 /* IsKeyword */) ? parseType() : undefined; + return finishNode(node); + } function parseType() { // The rules about 'yield' only apply to actual code/expression contexts. They don't // apply to 'type' contexts. So we disable these parameters here before moving on. - return doOutsideOfContext(20480 /* TypeExcludesFlags */, parseTypeWorker); + return doOutsideOfContext(40960 /* TypeExcludesFlags */, parseTypeWorker); } function parseTypeWorker(noConditionalTypes) { - if (isStartOfFunctionType() || token() === 96 /* NewKeyword */) { + if (isStartOfFunctionType() || token() === 98 /* NewKeyword */) { return parseFunctionOrConstructorType(); } var type = parseUnionTypeOrHigher(); - if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(87 /* ExtendsKeyword */)) { - var node = createNode(176 /* ConditionalType */, type.pos); + if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(89 /* ExtendsKeyword */)) { + var node = createNode(179 /* ConditionalType */, type.pos); node.checkType = type; // The type following 'extends' is not permitted to be another conditional type node.extendsType = parseTypeWorker(/*noConditionalTypes*/ true); - parseExpected(56 /* QuestionToken */); + parseExpected(57 /* QuestionToken */); node.trueType = parseTypeWorker(); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.falseType = parseTypeWorker(); return finishNode(node); } return type; } function parseTypeAnnotation() { - return parseOptional(57 /* ColonToken */) ? parseType() : undefined; + return parseOptional(58 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: @@ -19946,14 +20556,14 @@ var ts; case 20 /* OpenParenToken */: case 22 /* OpenBracketToken */: case 18 /* OpenBraceToken */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 96 /* NewKeyword */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 73 /* Identifier */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 98 /* NewKeyword */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 75 /* Identifier */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return lookAhead(nextTokenIsOpenParenOrLessThanOrDot); default: return isIdentifier(); @@ -19964,18 +20574,18 @@ var ts; return true; } switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: - case 28 /* LessThanToken */: - case 123 /* AwaitKeyword */: - case 118 /* YieldKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: + case 29 /* LessThanToken */: + case 126 /* AwaitKeyword */: + case 120 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -19994,9 +20604,9 @@ var ts; function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. return token() !== 18 /* OpenBraceToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && - token() !== 58 /* AtToken */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && + token() !== 59 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -20019,7 +20629,7 @@ var ts; return expr; } function parseInitializer() { - return parseOptional(60 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; + return parseOptional(62 /* EqualsToken */) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher() { // AssignmentExpression[in,yield]: @@ -20064,7 +20674,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -20080,7 +20690,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 118 /* YieldKeyword */) { + if (token() === 120 /* YieldKeyword */) { // If we have a 'yield' keyword, and this is a context where yield expressions are // allowed, then definitely parse out a yield expression. if (inYieldContext()) { @@ -20109,15 +20719,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(208 /* YieldExpression */); + var node = createNode(211 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 40 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + (token() === 41 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -20128,20 +20738,20 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 37 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 38 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(198 /* ArrowFunction */, asyncModifier.pos); + node = createNode(201 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(198 /* ArrowFunction */, identifier.pos); + node = createNode(201 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(152 /* Parameter */, identifier.pos); + var parameter = createNode(155 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); - node.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -20166,8 +20776,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(37 /* EqualsGreaterThanToken */); - arrowFunction.body = (lastToken === 37 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(38 /* EqualsGreaterThanToken */); + arrowFunction.body = (lastToken === 38 /* EqualsGreaterThanToken */ || lastToken === 18 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return finishNode(arrowFunction); @@ -20177,10 +20787,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */ || token() === 122 /* AsyncKeyword */) { + if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 125 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 37 /* EqualsGreaterThanToken */) { + if (token() === 38 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -20190,12 +20800,12 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 20 /* OpenParenToken */ && token() !== 28 /* LessThanToken */) { + if (token() !== 20 /* OpenParenToken */ && token() !== 29 /* LessThanToken */) { return 0 /* False */; } } @@ -20209,8 +20819,8 @@ var ts; // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 37 /* EqualsGreaterThanToken */: - case 57 /* ColonToken */: + case 38 /* EqualsGreaterThanToken */: + case 58 /* ColonToken */: case 18 /* OpenBraceToken */: return 1 /* True */; default: @@ -20234,30 +20844,30 @@ var ts; // Check for "(xxx yyy", where xxx is a modifier and yyy is an identifier. This // isn't actually allowed, but we want to treat it as a lambda so we can provide // a good error message. - if (ts.isModifierKind(second) && second !== 122 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { + if (ts.isModifierKind(second) && second !== 125 /* AsyncKeyword */ && lookAhead(nextTokenIsIdentifier)) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, // then this definitely doesn't look like a lambda. "this" is not // valid, but we want to parse it and then give a semantic error. - if (!isIdentifier() && second !== 101 /* ThisKeyword */) { + if (!isIdentifier() && second !== 103 /* ThisKeyword */) { return 0 /* False */; } switch (nextToken()) { - case 57 /* ColonToken */: + case 58 /* ColonToken */: // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. return 1 /* True */; - case 56 /* QuestionToken */: + case 57 /* QuestionToken */: nextToken(); // If we have "(a?:" or "(a?," or "(a?=" or "(a?)" then it is definitely a lambda. - if (token() === 57 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 60 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { + if (token() === 58 /* ColonToken */ || token() === 27 /* CommaToken */ || token() === 62 /* EqualsToken */ || token() === 21 /* CloseParenToken */) { return 1 /* True */; } // Otherwise it is definitely not a lambda. return 0 /* False */; case 27 /* CommaToken */: - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 21 /* CloseParenToken */: // If we have "(a," or "(a=" or "(a)" this *could* be an arrow function return 2 /* Unknown */; @@ -20266,7 +20876,7 @@ var ts; return 0 /* False */; } else { - ts.Debug.assert(first === 28 /* LessThanToken */); + ts.Debug.assert(first === 29 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -20276,11 +20886,11 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 87 /* ExtendsKeyword */) { + if (third === 89 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 60 /* EqualsToken */: - case 30 /* GreaterThanToken */: + case 62 /* EqualsToken */: + case 31 /* GreaterThanToken */: return false; default: return true; @@ -20313,7 +20923,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); @@ -20326,23 +20936,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a beginning of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 37 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 38 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 73 /* Identifier */ && token() === 37 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 75 /* Identifier */ && token() === 38 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNodeWithJSDoc(198 /* ArrowFunction */); + var node = createNodeWithJSDoc(201 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; // Arrow functions are never generators. @@ -20352,7 +20962,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - if (!fillSignature(57 /* ColonToken */, isAsync, node) && !allowAmbiguity) { + if (!fillSignature(58 /* ColonToken */, isAsync, node) && !allowAmbiguity) { return undefined; } // Parsing a signature isn't enough. @@ -20365,7 +20975,7 @@ var ts; // // So we need just a bit of lookahead to ensure that it can only be a signature. var hasJSDocFunctionType = node.type && ts.isJSDocFunctionType(node.type); - if (!allowAmbiguity && token() !== 37 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { + if (!allowAmbiguity && token() !== 38 /* EqualsGreaterThanToken */ && (hasJSDocFunctionType || token() !== 18 /* OpenBraceToken */)) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -20376,8 +20986,8 @@ var ts; return parseFunctionBlock(isAsync ? 2 /* Await */ : 0 /* None */); } if (token() !== 26 /* SemicolonToken */ && - token() !== 91 /* FunctionKeyword */ && - token() !== 77 /* ClassKeyword */ && + token() !== 93 /* FunctionKeyword */ && + token() !== 79 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -20402,20 +21012,20 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(56 /* QuestionToken */); + var questionToken = parseOptionalToken(57 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(206 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(209 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(57 /* ColonToken */); + node.colonToken = parseExpectedToken(58 /* ColonToken */); node.whenFalse = ts.nodeIsPresent(node.colonToken) ? parseAssignmentExpressionOrHigher() - : createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(57 /* ColonToken */)); + : createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */)); return finishNode(node); } function parseBinaryExpressionOrHigher(precedence) { @@ -20423,7 +21033,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 94 /* InKeyword */ || t === 148 /* OfKeyword */; + return t === 96 /* InKeyword */ || t === 151 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -20452,16 +21062,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 41 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 42 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 94 /* InKeyword */ && inDisallowInContext()) { + if (token() === 96 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -20482,51 +21092,51 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 94 /* InKeyword */) { + if (inDisallowInContext() && token() === 96 /* InKeyword */) { return false; } return ts.getBinaryOperatorPrecedence(token()) > 0; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(205 /* BinaryExpression */, left.pos); + var node = createNode(208 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(213 /* AsExpression */, left.pos); + var node = createNode(216 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(203 /* PrefixUnaryExpression */); + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(199 /* DeleteExpression */); + var node = createNode(202 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(200 /* TypeOfExpression */); + var node = createNode(203 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(201 /* VoidExpression */); + var node = createNode(204 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 123 /* AwaitKeyword */) { + if (token() === 126 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -20536,7 +21146,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(202 /* AwaitExpression */); + var node = createNode(205 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -20560,7 +21170,7 @@ var ts; */ if (isUpdateExpression()) { var updateExpression = parseUpdateExpression(); - return token() === 41 /* AsteriskAsteriskToken */ ? + return token() === 42 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression) : updateExpression; } @@ -20577,10 +21187,10 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 41 /* AsteriskAsteriskToken */) { + if (token() === 42 /* AsteriskAsteriskToken */) { var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); var end = simpleUnaryExpression.end; - if (simpleUnaryExpression.kind === 195 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 198 /* TypeAssertionExpression */) { parseErrorAt(pos, end, ts.Diagnostics.A_type_assertion_expression_is_not_allowed_in_the_left_hand_side_of_an_exponentiation_expression_Consider_enclosing_the_expression_in_parentheses); } else { @@ -20605,23 +21215,23 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 82 /* DeleteKeyword */: + case 84 /* DeleteKeyword */: return parseDeleteExpression(); - case 105 /* TypeOfKeyword */: + case 107 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return parseVoidExpression(); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 123 /* AwaitKeyword */: + case 126 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -20644,16 +21254,16 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly switch (token()) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: - case 52 /* ExclamationToken */: - case 82 /* DeleteKeyword */: - case 105 /* TypeOfKeyword */: - case 107 /* VoidKeyword */: - case 123 /* AwaitKeyword */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: + case 53 /* ExclamationToken */: + case 84 /* DeleteKeyword */: + case 107 /* TypeOfKeyword */: + case 109 /* VoidKeyword */: + case 126 /* AwaitKeyword */: return false; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; @@ -20676,21 +21286,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseUpdateExpression() { - if (token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) { - var node = createNode(203 /* PrefixUnaryExpression */); + if (token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) { + var node = createNode(206 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 28 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 29 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 44 /* PlusPlusToken */ || token() === 45 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(204 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 45 /* PlusPlusToken */ || token() === 46 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(207 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -20731,14 +21341,14 @@ var ts; // 3)we have a MemberExpression which either completes the LeftHandSideExpression, // or starts the beginning of the first four CallExpression productions. var expression; - if (token() === 93 /* ImportKeyword */) { + if (token() === 95 /* ImportKeyword */) { if (lookAhead(nextTokenIsOpenParenOrLessThan)) { // We don't want to eagerly consume all import keyword as import call expression so we look ahead to find "(" // For example: // var foo3 = require("subfolder // import * as foo1 from "module-from-node // We want this import to be a statement rather than import call expression - sourceFile.flags |= 524288 /* PossiblyContainsDynamicImport */; + sourceFile.flags |= 1048576 /* PossiblyContainsDynamicImport */; expression = parseTokenNode(); } else if (lookAhead(nextTokenIsDot)) { @@ -20746,21 +21356,22 @@ var ts; var fullStart = scanner.getStartPos(); nextToken(); // advance past the 'import' nextToken(); // advance past the dot - var node = createNode(215 /* MetaProperty */, fullStart); - node.keywordToken = 93 /* ImportKeyword */; + var node = createNode(218 /* MetaProperty */, fullStart); + node.keywordToken = 95 /* ImportKeyword */; node.name = parseIdentifierName(); expression = finishNode(node); - sourceFile.flags |= 1048576 /* PossiblyContainsImportMeta */; + sourceFile.flags |= 2097152 /* PossiblyContainsImportMeta */; } else { expression = parseMemberExpressionOrHigher(); } } else { - expression = token() === 99 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); + expression = token() === 101 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); } // Now, we *may* be complete. However, we might have consumed the start of a - // CallExpression. As such, we need to consume the rest of it here to be complete. + // CallExpression or OptionalExpression. As such, we need to consume the rest + // of it here to be complete. return parseCallExpressionRest(expression); } function parseMemberExpressionOrHigher() { @@ -20812,11 +21423,11 @@ var ts; // Because CallExpression and MemberExpression are left recursive, we need to bottom out // of the recursion immediately. So we parse out a primary expression to start with. var expression = parsePrimaryExpression(); - return parseMemberExpressionRest(expression); + return parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 28 /* LessThanToken */) { + if (token() === 29 /* LessThanToken */) { var startPos = getNodePos(); var typeArguments = tryParse(parseTypeArgumentsInExpression); if (typeArguments !== undefined) { @@ -20828,7 +21439,7 @@ var ts; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(190 /* PropertyAccessExpression */, expression.pos); + var node = createNode(193 /* PropertyAccessExpression */, expression.pos); node.expression = expression; parseExpectedToken(24 /* DotToken */, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); @@ -20837,8 +21448,8 @@ var ts; function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext); var result; - if (opening.kind === 263 /* JsxOpeningElement */) { - var node = createNode(261 /* JsxElement */, opening.pos); + if (opening.kind === 266 /* JsxOpeningElement */) { + var node = createNode(264 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -20847,15 +21458,15 @@ var ts; } result = finishNode(node); } - else if (opening.kind === 266 /* JsxOpeningFragment */) { - var node = createNode(265 /* JsxFragment */, opening.pos); + else if (opening.kind === 269 /* JsxOpeningFragment */) { + var node = createNode(268 /* JsxFragment */, opening.pos); node.openingFragment = opening; node.children = parseJsxChildren(node.openingFragment); node.closingFragment = parseJsxClosingFragment(inExpressionContext); result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 262 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 265 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -20866,11 +21477,11 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 28 /* LessThanToken */) { + if (inExpressionContext && token() === 29 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(205 /* BinaryExpression */, result.pos); + var badNode = createNode(208 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; @@ -20900,7 +21511,7 @@ var ts; parseErrorAtRange(openingTag.tagName, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName)); } return undefined; - case 29 /* LessThanSlashToken */: + case 30 /* LessThanSlashToken */: case 7 /* ConflictMarkerTrivia */: return undefined; case 11 /* JsxText */: @@ -20908,7 +21519,7 @@ var ts; return parseJsxText(); case 18 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: return parseJsxElementOrSelfClosingElementOrFragment(/*inExpressionContext*/ false); default: return ts.Debug.assertNever(token); @@ -20929,16 +21540,16 @@ var ts; return createNodeArray(list, listPos); } function parseJsxAttributes() { - var jsxAttributes = createNode(269 /* JsxAttributes */); + var jsxAttributes = createNode(272 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(28 /* LessThanToken */); - if (token() === 30 /* GreaterThanToken */) { + parseExpected(29 /* LessThanToken */); + if (token() === 31 /* GreaterThanToken */) { // See below for explanation of scanJsxText - var node_1 = createNode(266 /* JsxOpeningFragment */, fullStart); + var node_1 = createNode(269 /* JsxOpeningFragment */, fullStart); scanJsxText(); return finishNode(node_1); } @@ -20946,23 +21557,23 @@ var ts; var typeArguments = tryParseTypeArguments(); var attributes = parseJsxAttributes(); var node; - if (token() === 30 /* GreaterThanToken */) { + if (token() === 31 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(263 /* JsxOpeningElement */, fullStart); + node = createNode(266 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(42 /* SlashToken */); + parseExpected(43 /* SlashToken */); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(262 /* JsxSelfClosingElement */, fullStart); + node = createNode(265 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.typeArguments = typeArguments; @@ -20976,10 +21587,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 101 /* ThisKeyword */ ? + var expression = token() === 103 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -20987,7 +21598,7 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(271 /* JsxExpression */); + var node = createNode(274 /* JsxExpression */); if (!parseExpected(18 /* OpenBraceToken */)) { return undefined; } @@ -21013,9 +21624,9 @@ var ts; return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(268 /* JsxAttribute */); + var node = createNode(271 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 60 /* EqualsToken */) { + if (token() === 62 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 10 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -21028,7 +21639,7 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(270 /* JsxSpreadAttribute */); + var node = createNode(273 /* JsxSpreadAttribute */); parseExpected(18 /* OpenBraceToken */); parseExpected(25 /* DotDotDotToken */); node.expression = parseExpression(); @@ -21036,78 +21647,110 @@ var ts; return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(264 /* JsxClosingElement */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(267 /* JsxClosingElement */); + parseExpected(30 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxClosingFragment(inExpressionContext) { - var node = createNode(267 /* JsxClosingFragment */); - parseExpected(29 /* LessThanSlashToken */); + var node = createNode(270 /* JsxClosingFragment */); + parseExpected(30 /* LessThanSlashToken */); if (ts.tokenIsIdentifierOrKeyword(token())) { parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment); } if (inExpressionContext) { - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); } else { - parseExpected(30 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(31 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(195 /* TypeAssertionExpression */); - parseExpected(28 /* LessThanToken */); + var node = createNode(198 /* TypeAssertionExpression */); + parseExpected(29 /* LessThanToken */); node.type = parseType(); - parseExpected(30 /* GreaterThanToken */); + parseExpected(31 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseMemberExpressionRest(expression) { + function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() { + nextToken(); + return ts.tokenIsIdentifierOrKeyword(token()) + || token() === 22 /* OpenBracketToken */ + || isTemplateStartOfTaggedTemplate(); + } + function isStartOfOptionalPropertyOrElementAccessChain() { + return token() === 28 /* QuestionDotToken */ + && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate); + } + function parsePropertyAccessExpressionRest(expression, questionDotToken) { + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + propertyAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(propertyAccess); + } + function parseElementAccessExpressionRest(expression, questionDotToken) { + var indexedAccess = createNode(194 /* ElementAccessExpression */, expression.pos); + indexedAccess.expression = expression; + indexedAccess.questionDotToken = questionDotToken; + if (token() === 23 /* CloseBracketToken */) { + indexedAccess.argumentExpression = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); + } + else { + var argument = allowInAnd(parseExpression); + if (ts.isStringOrNumericLiteralLike(argument)) { + argument.text = internIdentifier(argument.text); + } + indexedAccess.argumentExpression = argument; + } + parseExpected(23 /* CloseBracketToken */); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + indexedAccess.flags |= 32 /* OptionalChain */; + } + return finishNode(indexedAccess); + } + function parseMemberExpressionRest(expression, allowOptionalChain) { while (true) { - var dotToken = parseOptionalToken(24 /* DotToken */); - if (dotToken) { - var propertyAccess = createNode(190 /* PropertyAccessExpression */, expression.pos); - propertyAccess.expression = expression; - propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); - expression = finishNode(propertyAccess); + var questionDotToken = void 0; + var isPropertyAccess = false; + if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) { + questionDotToken = parseExpectedToken(28 /* QuestionDotToken */); + isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token()); + } + else { + isPropertyAccess = parseOptional(24 /* DotToken */); + } + if (isPropertyAccess) { + expression = parsePropertyAccessExpressionRest(expression, questionDotToken); continue; } - if (token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(214 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(217 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(22 /* OpenBracketToken */)) { - var indexedAccess = createNode(191 /* ElementAccessExpression */, expression.pos); - indexedAccess.expression = expression; - if (token() === 23 /* CloseBracketToken */) { - indexedAccess.argumentExpression = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.An_element_access_expression_should_take_an_argument); - } - else { - var argument = allowInAnd(parseExpression); - if (ts.isStringOrNumericLiteralLike(argument)) { - argument.text = internIdentifier(argument.text); - } - indexedAccess.argumentExpression = argument; - } - parseExpected(23 /* CloseBracketToken */); - expression = finishNode(indexedAccess); + if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) { + expression = parseElementAccessExpressionRest(expression, questionDotToken); continue; } if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, /*typeArguments*/ undefined); + expression = parseTaggedTemplateRest(expression, questionDotToken, /*typeArguments*/ undefined); continue; } return expression; @@ -21116,48 +21759,70 @@ var ts; function isTemplateStartOfTaggedTemplate() { return token() === 14 /* NoSubstitutionTemplateLiteral */ || token() === 15 /* TemplateHead */; } - function parseTaggedTemplateRest(tag, typeArguments) { - var tagExpression = createNode(194 /* TaggedTemplateExpression */, tag.pos); + function parseTaggedTemplateRest(tag, questionDotToken, typeArguments) { + var tagExpression = createNode(197 /* TaggedTemplateExpression */, tag.pos); tagExpression.tag = tag; + tagExpression.questionDotToken = questionDotToken; tagExpression.typeArguments = typeArguments; tagExpression.template = token() === 14 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + if (questionDotToken || tag.flags & 32 /* OptionalChain */) { + tagExpression.flags |= 32 /* OptionalChain */; + } return finishNode(tagExpression); } function parseCallExpressionRest(expression) { while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ true); + var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */); // handle 'foo<()' - if (token() === 28 /* LessThanToken */ || token() === 46 /* LessThanLessThanToken */) { + if (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the // stack. var typeArguments = tryParse(parseTypeArgumentsInExpression); - if (!typeArguments) { - return expression; - } - if (isTemplateStartOfTaggedTemplate()) { - expression = parseTaggedTemplateRest(expression, typeArguments); + if (typeArguments) { + if (isTemplateStartOfTaggedTemplate()) { + expression = parseTaggedTemplateRest(expression, questionDotToken, typeArguments); + continue; + } + var callExpr = createNode(195 /* CallExpression */, expression.pos); + callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; + callExpr.typeArguments = typeArguments; + callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } + expression = finishNode(callExpr); continue; } - var callExpr = createNode(192 /* CallExpression */, expression.pos); - callExpr.expression = expression; - callExpr.typeArguments = typeArguments; - callExpr.arguments = parseArgumentList(); - expression = finishNode(callExpr); - continue; } else if (token() === 20 /* OpenParenToken */) { - var callExpr = createNode(192 /* CallExpression */, expression.pos); + var callExpr = createNode(195 /* CallExpression */, expression.pos); callExpr.expression = expression; + callExpr.questionDotToken = questionDotToken; callExpr.arguments = parseArgumentList(); + if (questionDotToken || expression.flags & 32 /* OptionalChain */) { + callExpr.flags |= 32 /* OptionalChain */; + } expression = finishNode(callExpr); continue; } - return expression; + if (questionDotToken) { + // We failed to parse anything, so report a missing identifier here. + var propertyAccess = createNode(193 /* PropertyAccessExpression */, expression.pos); + propertyAccess.expression = expression; + propertyAccess.questionDotToken = questionDotToken; + propertyAccess.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected); + propertyAccess.flags |= 32 /* OptionalChain */; + expression = finishNode(propertyAccess); + } + break; } + return expression; } function parseArgumentList() { parseExpected(20 /* OpenParenToken */); @@ -21166,12 +21831,12 @@ var ts; return result; } function parseTypeArgumentsInExpression() { - if (reScanLessThanToken() !== 28 /* LessThanToken */) { + if (reScanLessThanToken() !== 29 /* LessThanToken */) { return undefined; } nextToken(); var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType); - if (!parseExpected(30 /* GreaterThanToken */)) { + if (!parseExpected(31 /* GreaterThanToken */)) { // If it doesn't have the closing `>` then it's definitely not an type argument list. return undefined; } @@ -21188,21 +21853,23 @@ var ts; case 15 /* TemplateHead */: // foo `...${100}...` // these are the only tokens can legally follow a type argument // list. So we definitely want to treat them as type arg lists. + // falls through case 24 /* DotToken */: // foo. case 21 /* CloseParenToken */: // foo) case 23 /* CloseBracketToken */: // foo] - case 57 /* ColonToken */: // foo: + case 58 /* ColonToken */: // foo: case 26 /* SemicolonToken */: // foo; - case 56 /* QuestionToken */: // foo? - case 33 /* EqualsEqualsToken */: // foo == - case 35 /* EqualsEqualsEqualsToken */: // foo === - case 34 /* ExclamationEqualsToken */: // foo != - case 36 /* ExclamationEqualsEqualsToken */: // foo !== - case 54 /* AmpersandAmpersandToken */: // foo && - case 55 /* BarBarToken */: // foo || - case 51 /* CaretToken */: // foo ^ - case 49 /* AmpersandToken */: // foo & - case 50 /* BarToken */: // foo | + case 57 /* QuestionToken */: // foo? + case 34 /* EqualsEqualsToken */: // foo == + case 36 /* EqualsEqualsEqualsToken */: // foo === + case 35 /* ExclamationEqualsToken */: // foo != + case 37 /* ExclamationEqualsEqualsToken */: // foo !== + case 55 /* AmpersandAmpersandToken */: // foo && + case 56 /* BarBarToken */: // foo || + case 60 /* QuestionQuestionToken */: // foo ?? + case 52 /* CaretToken */: // foo ^ + case 50 /* AmpersandToken */: // foo & + case 51 /* BarToken */: // foo | case 19 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // foo // these cases can't legally follow a type arg list. However, they're not legal @@ -21214,6 +21881,7 @@ var ts; // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. + // falls through default: // Anything else treat as an expression. return false; @@ -21226,11 +21894,11 @@ var ts; case 10 /* StringLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 97 /* NullKeyword */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 99 /* NullKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return parseTokenNode(); case 20 /* OpenParenToken */: return parseParenthesizedExpression(); @@ -21238,7 +21906,7 @@ var ts; return parseArrayLiteralExpression(); case 18 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -21246,14 +21914,14 @@ var ts; break; } return parseFunctionExpression(); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassExpression(); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionExpression(); - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: return parseNewExpressionOrNewDotTarget(); - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: if (reScanSlashToken() === 13 /* RegularExpressionLiteral */) { return parseLiteralNode(); } @@ -21264,28 +21932,28 @@ var ts; return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNodeWithJSDoc(196 /* ParenthesizedExpression */); + var node = createNodeWithJSDoc(199 /* ParenthesizedExpression */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(209 /* SpreadElement */); + var node = createNode(212 /* SpreadElement */); parseExpected(25 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { return token() === 25 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 27 /* CommaToken */ ? createNode(211 /* OmittedExpression */) : + token() === 27 /* CommaToken */ ? createNode(214 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(188 /* ArrayLiteralExpression */); + var node = createNode(191 /* ArrayLiteralExpression */); parseExpected(22 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21297,25 +21965,25 @@ var ts; function parseObjectLiteralElement() { var node = createNodeWithJSDoc(0 /* Unknown */); if (parseOptionalToken(25 /* DotDotDotToken */)) { - node.kind = 278 /* SpreadAssignment */; + node.kind = 281 /* SpreadAssignment */; node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); node.name = parsePropertyName(); // Disallowing of optional property assignments and definite assignment assertion happens in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - node.exclamationToken = parseOptionalToken(52 /* ExclamationToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + node.exclamationToken = parseOptionalToken(53 /* ExclamationToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken); } // check if it is short-hand property assignment or normal property assignment @@ -21323,24 +21991,24 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 57 /* ColonToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58 /* ColonToken */); if (isShorthandPropertyAssignment) { - node.kind = 277 /* ShorthandPropertyAssignment */; - var equalsToken = parseOptionalToken(60 /* EqualsToken */); + node.kind = 280 /* ShorthandPropertyAssignment */; + var equalsToken = parseOptionalToken(62 /* EqualsToken */); if (equalsToken) { node.equalsToken = equalsToken; node.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); } } else { - node.kind = 276 /* PropertyAssignment */; - parseExpected(57 /* ColonToken */); + node.kind = 279 /* PropertyAssignment */; + parseExpected(58 /* ColonToken */); node.initializer = allowInAnd(parseAssignmentExpressionOrHigher); } return finishNode(node); } function parseObjectLiteralExpression() { - var node = createNode(189 /* ObjectLiteralExpression */); + var node = createNode(192 /* ObjectLiteralExpression */); parseExpected(18 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21359,10 +22027,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNodeWithJSDoc(197 /* FunctionExpression */); + var node = createNodeWithJSDoc(200 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; node.name = @@ -21370,7 +22038,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -21382,26 +22050,26 @@ var ts; } function parseNewExpressionOrNewDotTarget() { var fullStart = scanner.getStartPos(); - parseExpected(96 /* NewKeyword */); + parseExpected(98 /* NewKeyword */); if (parseOptional(24 /* DotToken */)) { - var node_2 = createNode(215 /* MetaProperty */, fullStart); - node_2.keywordToken = 96 /* NewKeyword */; + var node_2 = createNode(218 /* MetaProperty */, fullStart); + node_2.keywordToken = 98 /* NewKeyword */; node_2.name = parseIdentifierName(); return finishNode(node_2); } var expression = parsePrimaryExpression(); var typeArguments; while (true) { - expression = parseMemberExpressionRest(expression); + expression = parseMemberExpressionRest(expression, /*allowOptionalChain*/ false); typeArguments = tryParse(parseTypeArgumentsInExpression); if (isTemplateStartOfTaggedTemplate()) { ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'"); - expression = parseTaggedTemplateRest(expression, typeArguments); + expression = parseTaggedTemplateRest(expression, /*optionalChain*/ undefined, typeArguments); typeArguments = undefined; } break; } - var node = createNode(193 /* NewExpression */, fullStart); + var node = createNode(196 /* NewExpression */, fullStart); node.expression = expression; node.typeArguments = typeArguments; if (node.typeArguments || token() === 20 /* OpenParenToken */) { @@ -21411,7 +22079,7 @@ var ts; } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(219 /* Block */); + var node = createNode(222 /* Block */); if (parseExpected(18 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; @@ -21444,25 +22112,25 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(221 /* EmptyStatement */); + var node = createNode(223 /* EmptyStatement */); parseExpected(26 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(223 /* IfStatement */); - parseExpected(92 /* IfKeyword */); + var node = createNode(226 /* IfStatement */); + parseExpected(94 /* IfKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(84 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(86 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(224 /* DoStatement */); - parseExpected(83 /* DoKeyword */); + var node = createNode(227 /* DoStatement */); + parseExpected(85 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(108 /* WhileKeyword */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21474,8 +22142,8 @@ var ts; return finishNode(node); } function parseWhileStatement() { - var node = createNode(225 /* WhileStatement */); - parseExpected(108 /* WhileKeyword */); + var node = createNode(228 /* WhileStatement */); + parseExpected(110 /* WhileKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); @@ -21484,12 +22152,12 @@ var ts; } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(90 /* ForKeyword */); - var awaitToken = parseOptionalToken(123 /* AwaitKeyword */); + parseExpected(92 /* ForKeyword */); + var awaitToken = parseOptionalToken(126 /* AwaitKeyword */); parseExpected(20 /* OpenParenToken */); var initializer; if (token() !== 26 /* SemicolonToken */) { - if (token() === 106 /* VarKeyword */ || token() === 112 /* LetKeyword */ || token() === 78 /* ConstKeyword */) { + if (token() === 108 /* VarKeyword */ || token() === 114 /* LetKeyword */ || token() === 80 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -21497,23 +22165,23 @@ var ts; } } var forOrForInOrForOfStatement; - if (awaitToken ? parseExpected(148 /* OfKeyword */) : parseOptional(148 /* OfKeyword */)) { - var forOfStatement = createNode(228 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(151 /* OfKeyword */) : parseOptional(151 /* OfKeyword */)) { + var forOfStatement = createNode(231 /* ForOfStatement */, pos); forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } - else if (parseOptional(94 /* InKeyword */)) { - var forInStatement = createNode(227 /* ForInStatement */, pos); + else if (parseOptional(96 /* InKeyword */)) { + var forInStatement = createNode(230 /* ForInStatement */, pos); forInStatement.initializer = initializer; forInStatement.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); forOrForInOrForOfStatement = forInStatement; } else { - var forStatement = createNode(226 /* ForStatement */, pos); + var forStatement = createNode(229 /* ForStatement */, pos); forStatement.initializer = initializer; parseExpected(26 /* SemicolonToken */); if (token() !== 26 /* SemicolonToken */ && token() !== 21 /* CloseParenToken */) { @@ -21531,7 +22199,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 230 /* BreakStatement */ ? 74 /* BreakKeyword */ : 79 /* ContinueKeyword */); + parseExpected(kind === 233 /* BreakStatement */ ? 76 /* BreakKeyword */ : 81 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -21539,8 +22207,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(231 /* ReturnStatement */); - parseExpected(98 /* ReturnKeyword */); + var node = createNode(234 /* ReturnStatement */); + parseExpected(100 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -21548,39 +22216,39 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(232 /* WithStatement */); - parseExpected(109 /* WithKeyword */); + var node = createNode(235 /* WithStatement */); + parseExpected(111 /* WithKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - node.statement = doInsideOfContext(8388608 /* InWithStatement */, parseStatement); + node.statement = doInsideOfContext(16777216 /* InWithStatement */, parseStatement); return finishNode(node); } function parseCaseClause() { - var node = createNode(272 /* CaseClause */); - parseExpected(75 /* CaseKeyword */); + var node = createNode(275 /* CaseClause */); + parseExpected(77 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(273 /* DefaultClause */); - parseExpected(81 /* DefaultKeyword */); - parseExpected(57 /* ColonToken */); + var node = createNode(276 /* DefaultClause */); + parseExpected(83 /* DefaultKeyword */); + parseExpected(58 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 75 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 77 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(233 /* SwitchStatement */); - parseExpected(100 /* SwitchKeyword */); + var node = createNode(236 /* SwitchStatement */); + parseExpected(102 /* SwitchKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); parseExpected(21 /* CloseParenToken */); - var caseBlock = createNode(247 /* CaseBlock */); + var caseBlock = createNode(250 /* CaseBlock */); parseExpected(18 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); parseExpected(19 /* CloseBraceToken */); @@ -21595,29 +22263,29 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(235 /* ThrowStatement */); - parseExpected(102 /* ThrowKeyword */); + var node = createNode(238 /* ThrowStatement */); + parseExpected(104 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(236 /* TryStatement */); - parseExpected(104 /* TryKeyword */); + var node = createNode(239 /* TryStatement */); + parseExpected(106 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 76 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 78 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 89 /* FinallyKeyword */) { - parseExpected(89 /* FinallyKeyword */); + if (!node.catchClause || token() === 91 /* FinallyKeyword */) { + parseExpected(91 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(275 /* CatchClause */); - parseExpected(76 /* CatchKeyword */); + var result = createNode(278 /* CatchClause */); + parseExpected(78 /* CatchKeyword */); if (parseOptional(20 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); parseExpected(21 /* CloseParenToken */); @@ -21630,8 +22298,8 @@ var ts; return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(237 /* DebuggerStatement */); - parseExpected(80 /* DebuggerKeyword */); + var node = createNode(240 /* DebuggerStatement */); + parseExpected(82 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -21641,13 +22309,13 @@ var ts; // a colon. var node = createNodeWithJSDoc(0 /* Unknown */); var expression = allowInAnd(parseExpression); - if (expression.kind === 73 /* Identifier */ && parseOptional(57 /* ColonToken */)) { - node.kind = 234 /* LabeledStatement */; + if (expression.kind === 75 /* Identifier */ && parseOptional(58 /* ColonToken */)) { + node.kind = 237 /* LabeledStatement */; node.label = expression; node.statement = parseStatement(); } else { - node.kind = 222 /* ExpressionStatement */; + node.kind = 225 /* ExpressionStatement */; node.expression = expression; parseSemicolon(); } @@ -21659,11 +22327,11 @@ var ts; } function nextTokenIsClassKeywordOnSameLine() { nextToken(); - return token() === 77 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 79 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 91 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 93 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() { nextToken(); @@ -21672,12 +22340,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -21700,41 +22368,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 119 /* AbstractKeyword */: - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 134 /* ReadonlyKeyword */: + case 121 /* AbstractKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 137 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 146 /* GlobalKeyword */: + case 149 /* GlobalKeyword */: nextToken(); - return token() === 18 /* OpenBraceToken */ || token() === 73 /* Identifier */ || token() === 86 /* ExportKeyword */; - case 93 /* ImportKeyword */: + return token() === 18 /* OpenBraceToken */ || token() === 75 /* Identifier */ || token() === 88 /* ExportKeyword */; + case 95 /* ImportKeyword */: nextToken(); - return token() === 10 /* StringLiteral */ || token() === 40 /* AsteriskToken */ || + return token() === 10 /* StringLiteral */ || token() === 41 /* AsteriskToken */ || token() === 18 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); - if (token() === 60 /* EqualsToken */ || token() === 40 /* AsteriskToken */ || - token() === 18 /* OpenBraceToken */ || token() === 81 /* DefaultKeyword */ || - token() === 120 /* AsKeyword */) { + if (token() === 62 /* EqualsToken */ || token() === 41 /* AsteriskToken */ || + token() === 18 /* OpenBraceToken */ || token() === 83 /* DefaultKeyword */ || + token() === 122 /* AsKeyword */) { return true; } continue; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: nextToken(); continue; default: @@ -21747,50 +22415,51 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: case 26 /* SemicolonToken */: case 18 /* OpenBraceToken */: - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 91 /* FunctionKeyword */: - case 77 /* ClassKeyword */: - case 85 /* EnumKeyword */: - case 92 /* IfKeyword */: - case 83 /* DoKeyword */: - case 108 /* WhileKeyword */: - case 90 /* ForKeyword */: - case 79 /* ContinueKeyword */: - case 74 /* BreakKeyword */: - case 98 /* ReturnKeyword */: - case 109 /* WithKeyword */: - case 100 /* SwitchKeyword */: - case 102 /* ThrowKeyword */: - case 104 /* TryKeyword */: - case 80 /* DebuggerKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 93 /* FunctionKeyword */: + case 79 /* ClassKeyword */: + case 87 /* EnumKeyword */: + case 94 /* IfKeyword */: + case 85 /* DoKeyword */: + case 110 /* WhileKeyword */: + case 92 /* ForKeyword */: + case 81 /* ContinueKeyword */: + case 76 /* BreakKeyword */: + case 100 /* ReturnKeyword */: + case 111 /* WithKeyword */: + case 102 /* SwitchKeyword */: + case 104 /* ThrowKeyword */: + case 106 /* TryKeyword */: + case 82 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return true; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot); - case 78 /* ConstKeyword */: - case 86 /* ExportKeyword */: + case 80 /* ConstKeyword */: + case 88 /* ExportKeyword */: return isStartOfDeclaration(); - case 122 /* AsyncKeyword */: - case 126 /* DeclareKeyword */: - case 111 /* InterfaceKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 141 /* TypeKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 129 /* DeclareKeyword */: + case 113 /* InterfaceKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 144 /* TypeKeyword */: + case 149 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: // When these don't start a declaration, they may be the start of a class member if an identifier // immediately follows. Otherwise they're an identifier in an expression statement. return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); @@ -21813,63 +22482,64 @@ var ts; return parseEmptyStatement(); case 18 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 106 /* VarKeyword */: - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); - case 112 /* LetKeyword */: + case 108 /* VarKeyword */: + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); + case 114 /* LetKeyword */: if (isLetDeclaration()) { - return parseVariableStatement(createNodeWithJSDoc(238 /* VariableDeclaration */)); + return parseVariableStatement(createNodeWithJSDoc(241 /* VariableDeclaration */)); } break; - case 91 /* FunctionKeyword */: - return parseFunctionDeclaration(createNodeWithJSDoc(240 /* FunctionDeclaration */)); - case 77 /* ClassKeyword */: - return parseClassDeclaration(createNodeWithJSDoc(241 /* ClassDeclaration */)); - case 92 /* IfKeyword */: + case 93 /* FunctionKeyword */: + return parseFunctionDeclaration(createNodeWithJSDoc(243 /* FunctionDeclaration */)); + case 79 /* ClassKeyword */: + return parseClassDeclaration(createNodeWithJSDoc(244 /* ClassDeclaration */)); + case 94 /* IfKeyword */: return parseIfStatement(); - case 83 /* DoKeyword */: + case 85 /* DoKeyword */: return parseDoStatement(); - case 108 /* WhileKeyword */: + case 110 /* WhileKeyword */: return parseWhileStatement(); - case 90 /* ForKeyword */: + case 92 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 79 /* ContinueKeyword */: - return parseBreakOrContinueStatement(229 /* ContinueStatement */); - case 74 /* BreakKeyword */: - return parseBreakOrContinueStatement(230 /* BreakStatement */); - case 98 /* ReturnKeyword */: + case 81 /* ContinueKeyword */: + return parseBreakOrContinueStatement(232 /* ContinueStatement */); + case 76 /* BreakKeyword */: + return parseBreakOrContinueStatement(233 /* BreakStatement */); + case 100 /* ReturnKeyword */: return parseReturnStatement(); - case 109 /* WithKeyword */: + case 111 /* WithKeyword */: return parseWithStatement(); - case 100 /* SwitchKeyword */: + case 102 /* SwitchKeyword */: return parseSwitchStatement(); - case 102 /* ThrowKeyword */: + case 104 /* ThrowKeyword */: return parseThrowStatement(); - case 104 /* TryKeyword */: + case 106 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 76 /* CatchKeyword */: - case 89 /* FinallyKeyword */: + // falls through + case 78 /* CatchKeyword */: + case 91 /* FinallyKeyword */: return parseTryStatement(); - case 80 /* DebuggerKeyword */: + case 82 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 58 /* AtToken */: + case 59 /* AtToken */: return parseDeclaration(); - case 122 /* AsyncKeyword */: - case 111 /* InterfaceKeyword */: - case 141 /* TypeKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 85 /* EnumKeyword */: - case 86 /* ExportKeyword */: - case 93 /* ImportKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 116 /* PublicKeyword */: - case 119 /* AbstractKeyword */: - case 117 /* StaticKeyword */: - case 134 /* ReadonlyKeyword */: - case 146 /* GlobalKeyword */: + case 125 /* AsyncKeyword */: + case 113 /* InterfaceKeyword */: + case 144 /* TypeKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 87 /* EnumKeyword */: + case 88 /* ExportKeyword */: + case 95 /* ImportKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 118 /* PublicKeyword */: + case 121 /* AbstractKeyword */: + case 119 /* StaticKeyword */: + case 137 /* ReadonlyKeyword */: + case 149 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -21878,52 +22548,71 @@ var ts; return parseExpressionOrLabeledStatement(); } function isDeclareModifier(modifier) { - return modifier.kind === 126 /* DeclareKeyword */; + return modifier.kind === 129 /* DeclareKeyword */; } function parseDeclaration() { + var modifiers = lookAhead(function () { return (parseDecorators(), parseModifiers()); }); + // `parseListElement` attempted to get the reused node at this position, + // but the ambient context flag was not yet set, so the node appeared + // not reusable in that context. + var isAmbient = ts.some(modifiers, isDeclareModifier); + if (isAmbient) { + var node_3 = tryReuseAmbientDeclaration(); + if (node_3) { + return node_3; + } + } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - if (ts.some(node.modifiers, isDeclareModifier)) { + if (isAmbient) { for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var m = _a[_i]; - m.flags |= 4194304 /* Ambient */; + m.flags |= 8388608 /* Ambient */; } - return doInsideOfContext(4194304 /* Ambient */, function () { return parseDeclarationWorker(node); }); + return doInsideOfContext(8388608 /* Ambient */, function () { return parseDeclarationWorker(node); }); } else { return parseDeclarationWorker(node); } } + function tryReuseAmbientDeclaration() { + return doInsideOfContext(8388608 /* Ambient */, function () { + var node = currentNode(parsingContext); + if (node) { + return consumeNode(node); + } + }); + } function parseDeclarationWorker(node) { switch (token()) { - case 106 /* VarKeyword */: - case 112 /* LetKeyword */: - case 78 /* ConstKeyword */: + case 108 /* VarKeyword */: + case 114 /* LetKeyword */: + case 80 /* ConstKeyword */: return parseVariableStatement(node); - case 91 /* FunctionKeyword */: + case 93 /* FunctionKeyword */: return parseFunctionDeclaration(node); - case 77 /* ClassKeyword */: + case 79 /* ClassKeyword */: return parseClassDeclaration(node); - case 111 /* InterfaceKeyword */: + case 113 /* InterfaceKeyword */: return parseInterfaceDeclaration(node); - case 141 /* TypeKeyword */: + case 144 /* TypeKeyword */: return parseTypeAliasDeclaration(node); - case 85 /* EnumKeyword */: + case 87 /* EnumKeyword */: return parseEnumDeclaration(node); - case 146 /* GlobalKeyword */: - case 131 /* ModuleKeyword */: - case 132 /* NamespaceKeyword */: + case 149 /* GlobalKeyword */: + case 134 /* ModuleKeyword */: + case 135 /* NamespaceKeyword */: return parseModuleDeclaration(node); - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(node); - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: nextToken(); switch (token()) { - case 81 /* DefaultKeyword */: - case 60 /* EqualsToken */: + case 83 /* DefaultKeyword */: + case 62 /* EqualsToken */: return parseExportAssignment(node); - case 120 /* AsKeyword */: + case 122 /* AsKeyword */: return parseNamespaceExportDeclaration(node); default: return parseExportDeclaration(node); @@ -21932,7 +22621,7 @@ var ts; if (node.decorators || node.modifiers) { // We reached this point because we encountered decorators and/or modifiers and assumed a declaration // would follow. For recovery and error reporting purposes, return an incomplete declaration. - var missing = createMissingNode(259 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var missing = createMissingNode(262 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); missing.pos = node.pos; missing.decorators = node.decorators; missing.modifiers = node.modifiers; @@ -21955,24 +22644,24 @@ var ts; // DECLARATIONS function parseArrayBindingElement() { if (token() === 27 /* CommaToken */) { - return createNode(211 /* OmittedExpression */); + return createNode(214 /* OmittedExpression */); } - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseInitializer(); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(187 /* BindingElement */); + var node = createNode(190 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(25 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 57 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 58 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(57 /* ColonToken */); + parseExpected(58 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -21980,14 +22669,14 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(185 /* ObjectBindingPattern */); + var node = createNode(188 /* ObjectBindingPattern */); parseExpected(18 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); parseExpected(19 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(186 /* ArrayBindingPattern */); + var node = createNode(189 /* ArrayBindingPattern */); parseExpected(22 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); parseExpected(23 /* CloseBracketToken */); @@ -22009,10 +22698,10 @@ var ts; return parseVariableDeclaration(/*allowExclamation*/ true); } function parseVariableDeclaration(allowExclamation) { - var node = createNode(238 /* VariableDeclaration */); + var node = createNode(241 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); - if (allowExclamation && node.name.kind === 73 /* Identifier */ && - token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (allowExclamation && node.name.kind === 75 /* Identifier */ && + token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22022,14 +22711,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(239 /* VariableDeclarationList */); + var node = createNode(242 /* VariableDeclarationList */); switch (token()) { - case 106 /* VarKeyword */: + case 108 /* VarKeyword */: break; - case 112 /* LetKeyword */: + case 114 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -22045,7 +22734,7 @@ var ts; // So we need to look ahead to determine if 'of' should be treated as a keyword in // this context. // The checker will then give an error that there is an empty declaration list. - if (token() === 148 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 151 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -22060,25 +22749,25 @@ var ts; return nextTokenIsIdentifier() && nextToken() === 21 /* CloseParenToken */; } function parseVariableStatement(node) { - node.kind = 220 /* VariableStatement */; + node.kind = 224 /* VariableStatement */; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); parseSemicolon(); return finishNode(node); } function parseFunctionDeclaration(node) { - node.kind = 240 /* FunctionDeclaration */; - parseExpected(91 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + node.kind = 243 /* FunctionDeclaration */; + parseExpected(93 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = node.asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected); return finishNode(node); } function parseConstructorName() { - if (token() === 125 /* ConstructorKeyword */) { - return parseExpected(125 /* ConstructorKeyword */); + if (token() === 128 /* ConstructorKeyword */) { + return parseExpected(128 /* ConstructorKeyword */); } if (token() === 10 /* StringLiteral */ && lookAhead(nextToken) === 20 /* OpenParenToken */) { return tryParse(function () { @@ -22090,25 +22779,25 @@ var ts; function tryParseConstructorDeclaration(node) { return tryParse(function () { if (parseConstructorName()) { - node.kind = 158 /* Constructor */; - fillSignature(57 /* ColonToken */, 0 /* None */, node); + node.kind = 161 /* Constructor */; + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */, ts.Diagnostics.or_expected); return finishNode(node); } }); } function parseMethodDeclaration(node, asteriskToken, diagnosticMessage) { - node.kind = 157 /* MethodDeclaration */; + node.kind = 160 /* MethodDeclaration */; node.asteriskToken = asteriskToken; var isGenerator = asteriskToken ? 1 /* Yield */ : 0 /* None */; var isAsync = ts.hasModifier(node, 256 /* Async */) ? 2 /* Await */ : 0 /* None */; - fillSignature(57 /* ColonToken */, isGenerator | isAsync, node); + fillSignature(58 /* ColonToken */, isGenerator | isAsync, node); node.body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); return finishNode(node); } function parsePropertyDeclaration(node) { - node.kind = 155 /* PropertyDeclaration */; - if (!node.questionToken && token() === 52 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + node.kind = 158 /* PropertyDeclaration */; + if (!node.questionToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { node.exclamationToken = parseTokenNode(); } node.type = parseTypeAnnotation(); @@ -22123,17 +22812,17 @@ var ts; // The checker may still error in the static case to explicitly disallow the yield expression. node.initializer = ts.hasModifier(node, 32 /* Static */) ? allowInAnd(parseInitializer) - : doOutsideOfContext(4096 /* YieldContext */ | 2048 /* DisallowInContext */, parseInitializer); + : doOutsideOfContext(8192 /* YieldContext */ | 4096 /* DisallowInContext */, parseInitializer); parseSemicolon(); return finishNode(node); } function parsePropertyOrMethodDeclaration(node) { - var asteriskToken = parseOptionalToken(40 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(41 /* AsteriskToken */); node.name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - node.questionToken = parseOptionalToken(56 /* QuestionToken */); - if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 28 /* LessThanToken */) { + node.questionToken = parseOptionalToken(57 /* QuestionToken */); + if (asteriskToken || token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */) { return parseMethodDeclaration(node, asteriskToken, ts.Diagnostics.or_expected); } return parsePropertyDeclaration(node); @@ -22141,13 +22830,13 @@ var ts; function parseAccessorDeclaration(node, kind) { node.kind = kind; node.name = parsePropertyName(); - fillSignature(57 /* ColonToken */, 0 /* None */, node); + fillSignature(58 /* ColonToken */, 0 /* None */, node); node.body = parseFunctionBlockOrSemicolon(0 /* None */); return finishNode(node); } function isClassMemberStart() { var idToken; - if (token() === 58 /* AtToken */) { + if (token() === 59 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -22164,7 +22853,7 @@ var ts; } nextToken(); } - if (token() === 40 /* AsteriskToken */) { + if (token() === 41 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -22180,18 +22869,18 @@ var ts; // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 138 /* SetKeyword */ || idToken === 127 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 141 /* SetKeyword */ || idToken === 130 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { case 20 /* OpenParenToken */: // Method declaration - case 28 /* LessThanToken */: // Generic Method declaration - case 52 /* ExclamationToken */: // Non-null assertion on property name - case 57 /* ColonToken */: // Type Annotation for declaration - case 60 /* EqualsToken */: // Initializer for declaration - case 56 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. + case 29 /* LessThanToken */: // Generic Method declaration + case 53 /* ExclamationToken */: // Non-null assertion on property name + case 58 /* ColonToken */: // Type Annotation for declaration + case 62 /* EqualsToken */: // Initializer for declaration + case 57 /* QuestionToken */: // Not valid, but permitted so that it gets caught later on. return true; default: // Covers @@ -22209,10 +22898,10 @@ var ts; var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(58 /* AtToken */)) { + if (!parseOptional(59 /* AtToken */)) { break; } - var decorator = createNode(153 /* Decorator */, decoratorStart); + var decorator = createNode(156 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); (list || (list = [])).push(decorator); @@ -22232,7 +22921,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 78 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 80 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -22251,7 +22940,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 122 /* AsyncKeyword */) { + if (token() === 125 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -22262,20 +22951,20 @@ var ts; } function parseClassElement() { if (token() === 26 /* SemicolonToken */) { - var result = createNode(218 /* SemicolonClassElement */); + var result = createNode(221 /* SemicolonClassElement */); nextToken(); return finishNode(result); } var node = createNodeWithJSDoc(0 /* Unknown */); node.decorators = parseDecorators(); node.modifiers = parseModifiers(/*permitInvalidConstAsModifier*/ true); - if (parseContextualModifier(127 /* GetKeyword */)) { - return parseAccessorDeclaration(node, 159 /* GetAccessor */); + if (parseContextualModifier(130 /* GetKeyword */)) { + return parseAccessorDeclaration(node, 162 /* GetAccessor */); } - if (parseContextualModifier(138 /* SetKeyword */)) { - return parseAccessorDeclaration(node, 160 /* SetAccessor */); + if (parseContextualModifier(141 /* SetKeyword */)) { + return parseAccessorDeclaration(node, 163 /* SetAccessor */); } - if (token() === 125 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { + if (token() === 128 /* ConstructorKeyword */ || token() === 10 /* StringLiteral */) { var constructorDeclaration = tryParseConstructorDeclaration(node); if (constructorDeclaration) { return constructorDeclaration; @@ -22289,27 +22978,37 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 10 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 40 /* AsteriskToken */ || + token() === 41 /* AsteriskToken */ || token() === 22 /* OpenBracketToken */) { - return parsePropertyOrMethodDeclaration(node); + var isAmbient = node.modifiers && ts.some(node.modifiers, isDeclareModifier); + if (isAmbient) { + for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { + var m = _a[_i]; + m.flags |= 8388608 /* Ambient */; + } + return doInsideOfContext(8388608 /* Ambient */, function () { return parsePropertyOrMethodDeclaration(node); }); + } + else { + return parsePropertyOrMethodDeclaration(node); + } } if (node.decorators || node.modifiers) { // treat this as a property declaration with a missing name. - node.name = createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + node.name = createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(node); } // 'isClassMemberStart' should have hinted not to attempt parsing. return ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 210 /* ClassExpression */); + return parseClassDeclarationOrExpression(createNodeWithJSDoc(0 /* Unknown */), 213 /* ClassExpression */); } function parseClassDeclaration(node) { - return parseClassDeclarationOrExpression(node, 241 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(node, 244 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(node, kind) { node.kind = kind; - parseExpected(77 /* ClassKeyword */); + parseExpected(79 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22335,7 +23034,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 110 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 112 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -22347,33 +23046,32 @@ var ts; } function parseHeritageClause() { var tok = token(); - ts.Debug.assert(tok === 87 /* ExtendsKeyword */ || tok === 110 /* ImplementsKeyword */); // isListElement() should ensure this. - var node = createNode(274 /* HeritageClause */); + ts.Debug.assert(tok === 89 /* ExtendsKeyword */ || tok === 112 /* ImplementsKeyword */); // isListElement() should ensure this. + var node = createNode(277 /* HeritageClause */); node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); } function parseExpressionWithTypeArguments() { - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); node.typeArguments = tryParseTypeArguments(); return finishNode(node); } function tryParseTypeArguments() { - return token() === 28 /* LessThanToken */ - ? parseBracketedList(20 /* TypeArguments */, parseType, 28 /* LessThanToken */, 30 /* GreaterThanToken */) - : undefined; + return token() === 29 /* LessThanToken */ ? + parseBracketedList(20 /* TypeArguments */, parseType, 29 /* LessThanToken */, 31 /* GreaterThanToken */) : undefined; } function isHeritageClause() { - return token() === 87 /* ExtendsKeyword */ || token() === 110 /* ImplementsKeyword */; + return token() === 89 /* ExtendsKeyword */ || token() === 112 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(node) { - node.kind = 242 /* InterfaceDeclaration */; - parseExpected(111 /* InterfaceKeyword */); + node.kind = 245 /* InterfaceDeclaration */; + parseExpected(113 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -22381,11 +23079,11 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(node) { - node.kind = 243 /* TypeAliasDeclaration */; - parseExpected(141 /* TypeKeyword */); + node.kind = 246 /* TypeAliasDeclaration */; + parseExpected(144 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return finishNode(node); @@ -22395,14 +23093,14 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNodeWithJSDoc(279 /* EnumMember */); + var node = createNodeWithJSDoc(282 /* EnumMember */); node.name = parsePropertyName(); node.initializer = allowInAnd(parseInitializer); return finishNode(node); } function parseEnumDeclaration(node) { - node.kind = 244 /* EnumDeclaration */; - parseExpected(85 /* EnumKeyword */); + node.kind = 247 /* EnumDeclaration */; + parseExpected(87 /* EnumKeyword */); node.name = parseIdentifier(); if (parseExpected(18 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); @@ -22414,7 +23112,7 @@ var ts; return finishNode(node); } function parseModuleBlock() { - var node = createNode(246 /* ModuleBlock */); + var node = createNode(249 /* ModuleBlock */); if (parseExpected(18 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); parseExpected(19 /* CloseBraceToken */); @@ -22425,7 +23123,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(node, flags) { - node.kind = 245 /* ModuleDeclaration */; + node.kind = 248 /* ModuleDeclaration */; // If we are parsing a dotted namespace name, we want to // propagate the 'Namespace' flag across the names if set. var namespaceFlag = flags & 16 /* Namespace */; @@ -22437,11 +23135,11 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(node) { - node.kind = 245 /* ModuleDeclaration */; - if (token() === 146 /* GlobalKeyword */) { + node.kind = 248 /* ModuleDeclaration */; + if (token() === 149 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); - node.flags |= 512 /* GlobalAugmentation */; + node.flags |= 1024 /* GlobalAugmentation */; } else { node.name = parseLiteralNode(); @@ -22457,15 +23155,15 @@ var ts; } function parseModuleDeclaration(node) { var flags = 0; - if (token() === 146 /* GlobalKeyword */) { + if (token() === 149 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(node); } - else if (parseOptional(132 /* NamespaceKeyword */)) { + else if (parseOptional(135 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(131 /* ModuleKeyword */); + parseExpected(134 /* ModuleKeyword */); if (token() === 10 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(node); } @@ -22473,52 +23171,52 @@ var ts; return parseModuleOrNamespaceDeclaration(node, flags); } function isExternalModuleReference() { - return token() === 135 /* RequireKeyword */ && + return token() === 138 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { return nextToken() === 20 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 42 /* SlashToken */; + return nextToken() === 43 /* SlashToken */; } function parseNamespaceExportDeclaration(node) { - node.kind = 248 /* NamespaceExportDeclaration */; - parseExpected(120 /* AsKeyword */); - parseExpected(132 /* NamespaceKeyword */); + node.kind = 251 /* NamespaceExportDeclaration */; + parseExpected(122 /* AsKeyword */); + parseExpected(135 /* NamespaceKeyword */); node.name = parseIdentifier(); parseSemicolon(); return finishNode(node); } function parseImportDeclarationOrImportEqualsDeclaration(node) { - parseExpected(93 /* ImportKeyword */); + parseExpected(95 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 27 /* CommaToken */ && token() !== 145 /* FromKeyword */) { + if (token() !== 27 /* CommaToken */ && token() !== 148 /* FromKeyword */) { return parseImportEqualsDeclaration(node, identifier); } } // Import statement - node.kind = 250 /* ImportDeclaration */; + node.kind = 253 /* ImportDeclaration */; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || // import id - token() === 40 /* AsteriskToken */ || // import * + token() === 41 /* AsteriskToken */ || // import * token() === 18 /* OpenBraceToken */) { // import { node.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(145 /* FromKeyword */); + parseExpected(148 /* FromKeyword */); } node.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(node); } function parseImportEqualsDeclaration(node, identifier) { - node.kind = 249 /* ImportEqualsDeclaration */; + node.kind = 252 /* ImportEqualsDeclaration */; node.name = identifier; - parseExpected(60 /* EqualsToken */); + parseExpected(62 /* EqualsToken */); node.moduleReference = parseModuleReference(); parseSemicolon(); return finishNode(node); @@ -22530,7 +23228,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(251 /* ImportClause */, fullStart); + var importClause = createNode(254 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -22540,7 +23238,7 @@ var ts; // parse namespace or named imports if (!importClause.name || parseOptional(27 /* CommaToken */)) { - importClause.namedBindings = token() === 40 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(253 /* NamedImports */); + importClause.namedBindings = token() === 41 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(256 /* NamedImports */); } return finishNode(importClause); } @@ -22550,8 +23248,8 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(260 /* ExternalModuleReference */); - parseExpected(135 /* RequireKeyword */); + var node = createNode(263 /* ExternalModuleReference */); + parseExpected(138 /* RequireKeyword */); parseExpected(20 /* OpenParenToken */); node.expression = parseModuleSpecifier(); parseExpected(21 /* CloseParenToken */); @@ -22573,9 +23271,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(252 /* NamespaceImport */); - parseExpected(40 /* AsteriskToken */); - parseExpected(120 /* AsKeyword */); + var namespaceImport = createNode(255 /* NamespaceImport */); + parseExpected(41 /* AsteriskToken */); + parseExpected(122 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -22588,14 +23286,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 253 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); + node.elements = parseBracketedList(23 /* ImportOrExportSpecifiers */, kind === 256 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 18 /* OpenBraceToken */, 19 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(258 /* ExportSpecifier */); + return parseImportOrExportSpecifier(261 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(254 /* ImportSpecifier */); + return parseImportOrExportSpecifier(257 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -22609,9 +23307,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 120 /* AsKeyword */) { + if (token() === 122 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(120 /* AsKeyword */); + parseExpected(122 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -22620,24 +23318,24 @@ var ts; else { node.name = identifierName; } - if (kind === 254 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 257 /* ImportSpecifier */ && checkIdentifierIsKeyword) { parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(node) { - node.kind = 256 /* ExportDeclaration */; - if (parseOptional(40 /* AsteriskToken */)) { - parseExpected(145 /* FromKeyword */); + node.kind = 259 /* ExportDeclaration */; + if (parseOptional(41 /* AsteriskToken */)) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(257 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(260 /* NamedExports */); // It is not uncommon to accidentally omit the 'from' keyword. Additionally, in editing scenarios, // the 'from' keyword can be parsed as a named export when the export clause is unterminated (i.e. `export { from "moduleName";`) // If we don't have a 'from' keyword, see if we have a string literal such that ASI won't take effect. - if (token() === 145 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(145 /* FromKeyword */); + if (token() === 148 /* FromKeyword */ || (token() === 10 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(148 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -22645,12 +23343,12 @@ var ts; return finishNode(node); } function parseExportAssignment(node) { - node.kind = 255 /* ExportAssignment */; - if (parseOptional(60 /* EqualsToken */)) { + node.kind = 258 /* ExportAssignment */; + if (parseOptional(62 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(81 /* DefaultKeyword */); + parseExpected(83 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -22665,15 +23363,13 @@ var ts; } function isAnExternalModuleIndicatorNode(node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 249 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 260 /* ExternalModuleReference */ - || node.kind === 250 /* ImportDeclaration */ - || node.kind === 255 /* ExportAssignment */ - || node.kind === 256 /* ExportDeclaration */ - ? node - : undefined; + || node.kind === 252 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 263 /* ExternalModuleReference */ + || node.kind === 253 /* ImportDeclaration */ + || node.kind === 258 /* ExportAssignment */ + || node.kind === 259 /* ExportDeclaration */ ? node : undefined; } function getImportMetaIfNecessary(sourceFile) { - return sourceFile.flags & 1048576 /* PossiblyContainsImportMeta */ ? + return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ? walkTreeForExternalModuleIndicators(sourceFile) : undefined; } @@ -22681,7 +23377,7 @@ var ts; return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators); } function isImportMeta(node) { - return ts.isMetaProperty(node) && node.keywordToken === 93 /* ImportKeyword */ && node.name.escapedText === "meta"; + return ts.isMetaProperty(node) && node.keywordToken === 95 /* ImportKeyword */ && node.name.escapedText === "meta"; } var ParsingContext; (function (ParsingContext) { @@ -22732,9 +23428,9 @@ var ts; JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; // Parses out a JSDoc type expression. function parseJSDocTypeExpression(mayOmitBraces) { - var result = createNode(289 /* JSDocTypeExpression */); + var result = createNode(292 /* JSDocTypeExpression */); var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18 /* OpenBraceToken */); - result.type = doInsideOfContext(2097152 /* JSDoc */, parseJSDocType); + result.type = doInsideOfContext(4194304 /* JSDoc */, parseJSDocType); if (!mayOmitBraces || hasBrace) { parseExpectedJSDoc(19 /* CloseBraceToken */); } @@ -22744,8 +23440,8 @@ var ts; JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseIsolatedJSDocComment(content, start, length) { initializeState(content, 99 /* Latest */, /*_syntaxCursor:*/ undefined, 1 /* JS */); - sourceFile = { languageVariant: 0 /* Standard */, text: content }; // tslint:disable-line no-object-literal-type-assertion - var jsDoc = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + sourceFile = { languageVariant: 0 /* Standard */, text: content }; + var jsDoc = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); var diagnostics = parseDiagnostics; clearState(); return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined; @@ -22756,11 +23452,11 @@ var ts; var saveToken = currentToken; var saveParseDiagnosticsLength = parseDiagnostics.length; var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; - var comment = doInsideOfContext(2097152 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); + var comment = doInsideOfContext(4194304 /* JSDoc */, function () { return parseJSDocCommentWorker(start, length); }); if (comment) { comment.parent = parent; } - if (contextFlags & 65536 /* JavaScriptFile */) { + if (contextFlags & 131072 /* JavaScriptFile */) { if (!sourceFile.jsDocDiagnostics) { sourceFile.jsDocDiagnostics = []; } @@ -22825,7 +23521,7 @@ var ts; } loop: while (true) { switch (token()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingWhitespace(comments); addTag(parseTag(indent)); @@ -22844,7 +23540,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -22895,7 +23591,7 @@ var ts; } } function createJSDocComment() { - var result = createNode(298 /* JSDocComment */, start); + var result = createNode(301 /* JSDocComment */, start); result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -22931,14 +23627,14 @@ var ts; var precedingLineBreak = scanner.hasPrecedingLineBreak(); var seenLineBreak = false; var indentText = ""; - while ((precedingLineBreak && token() === 40 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { + while ((precedingLineBreak && token() === 41 /* AsteriskToken */) || token() === 5 /* WhitespaceTrivia */ || token() === 4 /* NewLineTrivia */) { indentText += scanner.getTokenText(); if (token() === 4 /* NewLineTrivia */) { precedingLineBreak = true; seenLineBreak = true; indentText = ""; } - else if (token() === 40 /* AsteriskToken */) { + else if (token() === 41 /* AsteriskToken */) { precedingLineBreak = false; } nextTokenJSDoc(); @@ -22946,7 +23642,7 @@ var ts; return seenLineBreak ? indentText : ""; } function parseTag(margin) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getTokenPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(/*message*/ undefined); @@ -23030,7 +23726,7 @@ var ts; } indent = 0; break; - case 58 /* AtToken */: + case 59 /* AtToken */: if (state === 3 /* SavingBackticks */) { comments.push(scanner.getTokenText()); break; @@ -23055,7 +23751,7 @@ var ts; break; case 18 /* OpenBraceToken */: state = 2 /* SavingComments */; - if (lookAhead(function () { return nextTokenJSDoc() === 58 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { + if (lookAhead(function () { return nextTokenJSDoc() === 59 /* AtToken */ && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) { pushComment(scanner.getTokenText()); nextTokenJSDoc(); pushComment(scanner.getTokenText()); @@ -23063,7 +23759,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 59 /* BacktickToken */: + case 61 /* BacktickToken */: if (state === 3 /* SavingBackticks */) { state = 2 /* SavingComments */; } @@ -23072,7 +23768,7 @@ var ts; } pushComment(scanner.getTokenText()); break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; @@ -23095,7 +23791,7 @@ var ts; return comments.length === 0 ? undefined : comments.join(""); } function parseUnknownTag(start, tagName) { - var result = createNode(301 /* JSDocTag */, start); + var result = createNode(304 /* JSDocTag */, start); result.tagName = tagName; return finishNode(result); } @@ -23123,15 +23819,15 @@ var ts; skipWhitespace(); } // a markdown-quoted name: `arg` is not legal jsdoc, but occurs in the wild - var isBackquoted = parseOptionalJsdoc(59 /* BacktickToken */); + var isBackquoted = parseOptionalJsdoc(61 /* BacktickToken */); var name = parseJSDocEntityName(); if (isBackquoted) { - parseExpectedTokenJSDoc(59 /* BacktickToken */); + parseExpectedTokenJSDoc(61 /* BacktickToken */); } if (isBracketed) { skipWhitespace(); // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(60 /* EqualsToken */)) { + if (parseOptionalToken(62 /* EqualsToken */)) { parseExpression(); } parseExpected(23 /* CloseBracketToken */); @@ -23140,9 +23836,9 @@ var ts; } function isObjectOrObjectArrayTypeReference(node) { switch (node.kind) { - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isObjectOrObjectArrayTypeReference(node.elementType); default: return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object"; @@ -23158,8 +23854,8 @@ var ts; typeExpression = tryParseTypeExpression(); } var result = target === 1 /* Property */ ? - createNode(313 /* JSDocPropertyTag */, start) : - createNode(307 /* JSDocParameterTag */, start); + createNode(316 /* JSDocPropertyTag */, start) : + createNode(310 /* JSDocParameterTag */, start); var comment = parseTagComments(indent + scanner.getStartPos() - start); var nestedTypeLiteral = target !== 4 /* CallbackParameter */ && parseNestedTypeLiteral(typeExpression, name, target, indent); if (nestedTypeLiteral) { @@ -23176,20 +23872,20 @@ var ts; } function parseNestedTypeLiteral(typeExpression, name, target, indent) { if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) { - var typeLiteralExpression = createNode(289 /* JSDocTypeExpression */, scanner.getTokenPos()); + var typeLiteralExpression = createNode(292 /* JSDocTypeExpression */, scanner.getTokenPos()); var child = void 0; var jsdocTypeLiteral = void 0; var start_3 = scanner.getStartPos(); var children = void 0; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) { - if (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) { + if (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) { children = ts.append(children, child); } } if (children) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start_3); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start_3); jsdocTypeLiteral.jsDocPropertyTags = children; - if (typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typeLiteralExpression.type = finishNode(jsdocTypeLiteral); @@ -23201,7 +23897,7 @@ var ts; if (ts.some(tags, ts.isJSDocReturnTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(308 /* JSDocReturnTag */, start); + var result = createNode(311 /* JSDocReturnTag */, start); result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); @@ -23210,13 +23906,13 @@ var ts; if (ts.some(tags, ts.isJSDocTypeTag)) { parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var result = createNode(310 /* JSDocTypeTag */, start); + var result = createNode(313 /* JSDocTypeTag */, start); result.tagName = tagName; result.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); return finishNode(result); } function parseAuthorTag(start, tagName, indent) { - var result = createNode(303 /* JSDocAuthorTag */, start); + var result = createNode(306 /* JSDocAuthorTag */, start); result.tagName = tagName; var authorInfoWithEmail = tryParse(function () { return tryParseAuthorNameAndEmail(); }); if (!authorInfoWithEmail) { @@ -23238,20 +23934,20 @@ var ts; var token = scanner.getToken(); loop: while (true) { switch (token) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 5 /* WhitespaceTrivia */: case 24 /* DotToken */: - case 58 /* AtToken */: + case 59 /* AtToken */: comments.push(scanner.getTokenText()); break; - case 28 /* LessThanToken */: + case 29 /* LessThanToken */: if (seenLessThan || seenGreaterThan) { return; } seenLessThan = true; comments.push(scanner.getTokenText()); break; - case 30 /* GreaterThanToken */: + case 31 /* GreaterThanToken */: if (!seenLessThan || seenGreaterThan) { return; } @@ -23270,14 +23966,14 @@ var ts; } } function parseAugmentsTag(start, tagName) { - var result = createNode(302 /* JSDocAugmentsTag */, start); + var result = createNode(305 /* JSDocAugmentsTag */, start); result.tagName = tagName; result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } function parseExpressionWithTypeArgumentsForAugments() { var usedBrace = parseOptional(18 /* OpenBraceToken */); - var node = createNode(212 /* ExpressionWithTypeArguments */); + var node = createNode(215 /* ExpressionWithTypeArguments */); node.expression = parsePropertyAccessEntityNameExpression(); node.typeArguments = tryParseTypeArguments(); var res = finishNode(node); @@ -23289,7 +23985,7 @@ var ts; function parsePropertyAccessEntityNameExpression() { var node = parseJSDocIdentifierName(); while (parseOptional(24 /* DotToken */)) { - var prop = createNode(190 /* PropertyAccessExpression */, node.pos); + var prop = createNode(193 /* PropertyAccessExpression */, node.pos); prop.expression = node; prop.name = parseJSDocIdentifierName(); node = finishNode(prop); @@ -23297,19 +23993,19 @@ var ts; return node; } function parseClassTag(start, tagName) { - var tag = createNode(304 /* JSDocClassTag */, start); + var tag = createNode(307 /* JSDocClassTag */, start); tag.tagName = tagName; return finishNode(tag); } function parseThisTag(start, tagName) { - var tag = createNode(309 /* JSDocThisTag */, start); + var tag = createNode(312 /* JSDocThisTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); return finishNode(tag); } function parseEnumTag(start, tagName) { - var tag = createNode(306 /* JSDocEnumTag */, start); + var tag = createNode(309 /* JSDocEnumTag */, start); tag.tagName = tagName; tag.typeExpression = parseJSDocTypeExpression(/*mayOmitBraces*/ true); skipWhitespace(); @@ -23318,7 +24014,7 @@ var ts; function parseTypedefTag(start, tagName, indent) { var typeExpression = tryParseTypeExpression(); skipWhitespaceOrAsterisk(); - var typedefTag = createNode(312 /* JSDocTypedefTag */, start); + var typedefTag = createNode(315 /* JSDocTypedefTag */, start); typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(); typedefTag.name = getJSDocTypeAliasName(typedefTag.fullName); @@ -23332,9 +24028,9 @@ var ts; var childTypeTag = void 0; while (child = tryParse(function () { return parseChildPropertyTag(indent); })) { if (!jsdocTypeLiteral) { - jsdocTypeLiteral = createNode(299 /* JSDocTypeLiteral */, start); + jsdocTypeLiteral = createNode(302 /* JSDocTypeLiteral */, start); } - if (child.kind === 310 /* JSDocTypeTag */) { + if (child.kind === 313 /* JSDocTypeTag */) { if (childTypeTag) { break; } @@ -23347,7 +24043,7 @@ var ts; } } if (jsdocTypeLiteral) { - if (typeExpression && typeExpression.type.kind === 170 /* ArrayType */) { + if (typeExpression && typeExpression.type.kind === 173 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } typedefTag.typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? @@ -23366,7 +24062,7 @@ var ts; } var typeNameOrNamespaceName = parseJSDocIdentifierName(); if (parseOptional(24 /* DotToken */)) { - var jsDocNamespaceNode = createNode(245 /* ModuleDeclaration */, pos); + var jsDocNamespaceNode = createNode(248 /* ModuleDeclaration */, pos); if (nested) { jsDocNamespaceNode.flags |= 4 /* NestedNamespace */; } @@ -23380,22 +24076,22 @@ var ts; return typeNameOrNamespaceName; } function parseCallbackTag(start, tagName, indent) { - var callbackTag = createNode(305 /* JSDocCallbackTag */, start); + var callbackTag = createNode(308 /* JSDocCallbackTag */, start); callbackTag.tagName = tagName; callbackTag.fullName = parseJSDocTypeNameWithNamespace(); callbackTag.name = getJSDocTypeAliasName(callbackTag.fullName); skipWhitespace(); callbackTag.comment = parseTagComments(indent); var child; - var jsdocSignature = createNode(300 /* JSDocSignature */, start); + var jsdocSignature = createNode(303 /* JSDocSignature */, start); jsdocSignature.parameters = []; while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4 /* CallbackParameter */, indent); })) { jsdocSignature.parameters = ts.append(jsdocSignature.parameters, child); } var returnTag = tryParse(function () { - if (parseOptionalJsdoc(58 /* AtToken */)) { + if (parseOptionalJsdoc(59 /* AtToken */)) { var tag = parseTag(indent); - if (tag && tag.kind === 308 /* JSDocReturnTag */) { + if (tag && tag.kind === 311 /* JSDocReturnTag */) { return tag; } } @@ -23437,10 +24133,10 @@ var ts; var seenAsterisk = false; while (true) { switch (nextTokenJSDoc()) { - case 58 /* AtToken */: + case 59 /* AtToken */: if (canParseTag) { var child = tryParseChildTag(target, indent); - if (child && (child.kind === 307 /* JSDocParameterTag */ || child.kind === 313 /* JSDocPropertyTag */) && + if (child && (child.kind === 310 /* JSDocParameterTag */ || child.kind === 316 /* JSDocPropertyTag */) && target !== 4 /* CallbackParameter */ && name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) { return false; @@ -23453,13 +24149,13 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 40 /* AsteriskToken */: + case 41 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 73 /* Identifier */: + case 75 /* Identifier */: canParseTag = false; break; case 1 /* EndOfFileToken */: @@ -23468,7 +24164,7 @@ var ts; } } function tryParseChildTag(target, indent) { - ts.Debug.assert(token() === 58 /* AtToken */); + ts.Debug.assert(token() === 59 /* AtToken */); var start = scanner.getStartPos(); nextTokenJSDoc(); var tagName = parseJSDocIdentifierName(); @@ -23504,13 +24200,13 @@ var ts; var typeParametersPos = getNodePos(); do { skipWhitespace(); - var typeParameter = createNode(151 /* TypeParameter */); + var typeParameter = createNode(154 /* TypeParameter */); typeParameter.name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces); finishNode(typeParameter); skipWhitespace(); typeParameters.push(typeParameter); } while (parseOptionalJsdoc(27 /* CommaToken */)); - var result = createNode(311 /* JSDocTemplateTag */, start); + var result = createNode(314 /* JSDocTemplateTag */, start); result.tagName = tagName; result.constraint = constraint; result.typeParameters = createNodeArray(typeParameters, typeParametersPos); @@ -23543,13 +24239,13 @@ var ts; } function parseJSDocIdentifierName(message) { if (!ts.tokenIsIdentifierOrKeyword(token())) { - return createMissingNode(73 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); + return createMissingNode(75 /* Identifier */, /*reportAtCurrentPosition*/ !message, message || ts.Diagnostics.Identifier_expected); } identifierCount++; var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(73 /* Identifier */, pos); - if (token() !== 73 /* Identifier */) { + var result = createNode(75 /* Identifier */, pos); + if (token() !== 75 /* Identifier */) { result.originalKeywordKind = token(); } result.escapedText = ts.escapeLeadingUnderscores(internIdentifier(scanner.getTokenValue())); @@ -23678,7 +24374,7 @@ var ts; switch (node.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: - case 73 /* Identifier */: + case 75 /* Identifier */: return true; } return false; @@ -24244,10 +24940,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 73 /* Identifier */) { + if (lhs.kind === 75 /* Identifier */) { return lhs.escapedText === rhs.escapedText; } - if (lhs.kind === 101 /* ThisKeyword */) { + if (lhs.kind === 103 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -24397,6 +25093,14 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Show_verbose_diagnostic_information }, + { + name: "generateCpuProfile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Generates_a_CPU_profile + }, { name: "incremental", shortName: "i", @@ -24461,6 +25165,15 @@ var ts; isCommandLineOnly: true, description: ts.Diagnostics.Print_the_final_configuration_instead_of_building }, + { + name: "listFilesOnly", + type: "boolean", + category: ts.Diagnostics.Command_line_Options, + affectsSemanticDiagnostics: true, + affectsEmit: true, + isCommandLineOnly: true, + description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing + }, // Basic { name: "target", @@ -25017,6 +25730,12 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects }, + { + name: "disableSourceOfProjectReferenceRedirect", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects + }, { name: "noImplicitUseStrict", type: "boolean", @@ -25112,6 +25831,13 @@ var ts; category: ts.Diagnostics.Advanced_Options, description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types, }, + { + name: "useDefineForClassFields", + type: "boolean", + affectsSemanticDiagnostics: true, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set, + }, { name: "keyofStringsOnly", type: "boolean", @@ -25209,7 +25935,8 @@ var ts; module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, strict: true, - esModuleInterop: true + esModuleInterop: true, + forceConsistentCasingInFileNames: true }; var optionNameMapCache; /* @internal */ @@ -25439,6 +26166,7 @@ var ts; return { buildOptions: buildOptions, projects: projects, errors: errors }; } ts.parseBuildCommand = parseBuildCommand; + /* @internal */ function getDiagnosticText(_message) { var _args = []; for (var _i = 1; _i < arguments.length; _i++) { @@ -25447,104 +26175,7 @@ var ts; var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments); return diagnostic.messageText; } - /* @internal */ - function printVersion() { - ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); - } - ts.printVersion = printVersion; - /* @internal */ - function printHelp(optionsList, syntaxPrefix) { - if (syntaxPrefix === void 0) { syntaxPrefix = ""; } - var output = []; - // We want to align our "syntax" and "examples" commands to a certain margin. - var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; - var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; - var marginLength = Math.max(syntaxLength, examplesLength); - // Build up the syntactic skeleton. - var syntax = makePadding(marginLength - syntaxLength); - syntax += "tsc " + syntaxPrefix + "[" + getDiagnosticText(ts.Diagnostics.options) + "] [" + getDiagnosticText(ts.Diagnostics.file) + "...]"; - output.push(getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax)); - output.push(ts.sys.newLine + ts.sys.newLine); - // Build up the list of examples. - var padding = makePadding(marginLength); - output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine); - output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine); - output.push(padding + "tsc @args.txt" + ts.sys.newLine); - output.push(padding + "tsc --build tsconfig.json" + ts.sys.newLine); - output.push(ts.sys.newLine); - output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); - // We want our descriptions to align at the same column in our output, - // so we keep track of the longest option usage string. - marginLength = 0; - var usageColumn = []; // Things like "-d, --declaration" go in here. - var descriptionColumn = []; - var optionsDescriptionMap = ts.createMap(); // Map between option.description and list of option.type if it is a kind - for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) { - var option = optionsList_1[_i]; - // If an option lacks a description, - // it is not officially supported. - if (!option.description) { - continue; - } - var usageText_1 = " "; - if (option.shortName) { - usageText_1 += "-" + option.shortName; - usageText_1 += getParamType(option); - usageText_1 += ", "; - } - usageText_1 += "--" + option.name; - usageText_1 += getParamType(option); - usageColumn.push(usageText_1); - var description = void 0; - if (option.name === "lib") { - description = getDiagnosticText(option.description); - var element = option.element; - var typeMap = element.type; - optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; })); - } - else { - description = getDiagnosticText(option.description); - } - descriptionColumn.push(description); - // Set the new margin for the description column if necessary. - marginLength = Math.max(usageText_1.length, marginLength); - } - // Special case that can't fit in the loop. - var usageText = " @<" + getDiagnosticText(ts.Diagnostics.file) + ">"; - usageColumn.push(usageText); - descriptionColumn.push(getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file)); - marginLength = Math.max(usageText.length, marginLength); - // Print out each row, aligning all the descriptions on the same column. - for (var i = 0; i < usageColumn.length; i++) { - var usage = usageColumn[i]; - var description = descriptionColumn[i]; - var kindsList = optionsDescriptionMap.get(description); - output.push(usage + makePadding(marginLength - usage.length + 2) + description + ts.sys.newLine); - if (kindsList) { - output.push(makePadding(marginLength + 4)); - for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) { - var kind = kindsList_1[_a]; - output.push(kind + " "); - } - output.push(ts.sys.newLine); - } - } - for (var _b = 0, output_1 = output; _b < output_1.length; _b++) { - var line = output_1[_b]; - ts.sys.write(line); - } - return; - function getParamType(option) { - if (option.paramType !== undefined) { - return " " + getDiagnosticText(option.paramType); - } - return ""; - } - function makePadding(paddingLength) { - return Array(paddingLength + 1).join(" "); - } - } - ts.printHelp = printHelp; + ts.getDiagnosticText = getDiagnosticText; /** * Reads the config file, reports errors if any and exits if the config file cannot be found */ @@ -25709,7 +26340,7 @@ var ts; var result = returnValue ? {} : undefined; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 276 /* PropertyAssignment */) { + if (element.kind !== 279 /* PropertyAssignment */) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected)); continue; } @@ -25765,15 +26396,15 @@ var ts; } function convertPropertyValueToJson(valueExpression, option) { switch (valueExpression.kind) { - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return true; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: reportInvalidOptionValue(option && option.type !== "boolean"); return false; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for - return null; // tslint:disable-line:no-null-keyword + return null; // eslint-disable-line no-null/no-null case 10 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected)); @@ -25791,13 +26422,13 @@ var ts; case 8 /* NumericLiteral */: reportInvalidOptionValue(option && option.type !== "number"); return Number(valueExpression.text); - case 203 /* PrefixUnaryExpression */: - if (valueExpression.operator !== 39 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { + case 206 /* PrefixUnaryExpression */: + if (valueExpression.operator !== 40 /* MinusToken */ || valueExpression.operand.kind !== 8 /* NumericLiteral */) { break; // not valid JSON syntax } reportInvalidOptionValue(option && option.type !== "number"); return -Number(valueExpression.operand.text); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: reportInvalidOptionValue(option && option.type !== "object"); var objectLiteralExpression = valueExpression; // Currently having element option declaration in the tsconfig with type "object" @@ -25814,7 +26445,7 @@ var ts; return convertObjectLiteralExpressionToJson(objectLiteralExpression, /* knownOptions*/ undefined, /*extraKeyDiagnosticMessage */ undefined, /*parentOption*/ undefined); } - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: reportInvalidOptionValue(option && option.type !== "list"); return convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element); } @@ -25863,7 +26494,7 @@ var ts; /** @internal */ function convertToTSConfig(configParseResult, configFileName, host) { var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); - var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); + var files = ts.map(ts.filter(configParseResult.fileNames, (!configParseResult.configFileSpecs || !configParseResult.configFileSpecs.validatedIncludeSpecs) ? function (_) { return true; } : matchesSpecs(configFileName, configParseResult.configFileSpecs.validatedIncludeSpecs, configParseResult.configFileSpecs.validatedExcludeSpecs, host)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); }); var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames }); var config = __assign(__assign({ compilerOptions: __assign(__assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) { var _a; @@ -25884,12 +26515,12 @@ var ts; return undefined; return specs; } - function matchesSpecs(path, includeSpecs, excludeSpecs) { + function matchesSpecs(path, includeSpecs, excludeSpecs, host) { if (!includeSpecs) return function (_) { return true; }; - var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, ts.sys.useCaseSensitiveFileNames, ts.sys.getCurrentDirectory()); - var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, ts.sys.useCaseSensitiveFileNames); - var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, ts.sys.useCaseSensitiveFileNames); + var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames); + var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames); if (includeRe) { if (excludeRe) { return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); }; @@ -26066,6 +26697,35 @@ var ts; } } ts.generateTSConfig = generateTSConfig; + /* @internal */ + function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) { + var result = {}; + var optionsNameMap = getOptionNameMap().optionNameMap; + for (var name in options) { + if (ts.hasProperty(options, name)) { + result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); + } + } + if (result.configFilePath) { + result.configFilePath = toAbsolutePath(result.configFilePath); + } + return result; + } + ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths; + function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) { + if (option) { + if (option.type === "list") { + var values = value; + if (option.element.isFilePath && values.length) { + return values.map(toAbsolutePath); + } + } + else if (option.isFilePath) { + return toAbsolutePath(value); + } + } + return value; + } /** * Parse the contents of a config file (tsconfig.json). * @param json The contents of the config file to parse @@ -26096,8 +26756,7 @@ var ts; } ts.setConfigFileInOptions = setConfigFileInOptions; function isNullOrUndefined(x) { - // tslint:disable-next-line:no-null-keyword - return x === undefined || x === null; + return x === undefined || x === null; // eslint-disable-line no-null/no-null } function directoryOfCombinedPath(fileName, basePath) { // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical @@ -26517,7 +27176,7 @@ var ts; } function normalizeNonListOptionValue(option, basePath, value) { if (option.isFilePath) { - value = ts.normalizePath(ts.combinePaths(basePath, value)); + value = ts.getNormalizedAbsolutePath(value, basePath); if (value === "") { value = "."; } @@ -26952,8 +27611,9 @@ var ts; return; } var value = jsonContent[fieldName]; - if (typeof value !== typeOfTag || value === null) { + if (typeof value !== typeOfTag || value === null) { // eslint-disable-line no-null/no-null if (state.traceEnabled) { + // eslint-disable-next-line no-null/no-null trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, fieldName, typeOfTag, value === null ? "null" : typeof value); } return; @@ -27212,7 +27872,7 @@ var ts; var packageJsonPath = ts.combinePaths(root, normalized, "package.json"); // `types-publisher` sometimes creates packages with `"typings": null` for packages that don't provide their own types. // See `createNotNeededPackageJSON` in the types-publisher` repo. - // tslint:disable-next-line:no-null-keyword + // eslint-disable-next-line no-null/no-null var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null; if (!isNotNeededPackage) { var baseFileName = ts.getBaseFileName(normalized); @@ -27676,7 +28336,7 @@ var ts; if (traceEnabled) { trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); // tslint:disable-line + ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real); return real; } function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) { @@ -28156,35 +28816,67 @@ var ts; ModuleInstanceState[ModuleInstanceState["Instantiated"] = 1] = "Instantiated"; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); - function getModuleInstanceState(node) { - return node.body ? getModuleInstanceStateWorker(node.body) : 1 /* Instantiated */; + function getModuleInstanceState(node, visited) { + if (node.body && !node.body.parent) { + // getModuleInstanceStateForAliasTarget needs to walk up the parent chain, so parent pointers must be set on this tree already + setParentPointers(node, node.body); + } + return node.body ? getModuleInstanceStateCached(node.body, visited) : 1 /* Instantiated */; } ts.getModuleInstanceState = getModuleInstanceState; - function getModuleInstanceStateWorker(node) { + function getModuleInstanceStateCached(node, visited) { + if (visited === void 0) { visited = ts.createMap(); } + var nodeId = "" + ts.getNodeId(node); + if (visited.has(nodeId)) { + return visited.get(nodeId) || 0 /* NonInstantiated */; + } + visited.set(nodeId, undefined); + var result = getModuleInstanceStateWorker(node, visited); + visited.set(nodeId, result); + return result; + } + function getModuleInstanceStateWorker(node, visited) { // A module is uninstantiated if it contains only switch (node.kind) { // 1. interface declarations, type alias declarations - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return 0 /* NonInstantiated */; // 2. const enum declarations - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (ts.isEnumConst(node)) { return 2 /* ConstEnumOnly */; } break; // 3. non-exported import declarations - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: if (!(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } break; - // 4. other uninstantiated module declarations. - case 246 /* ModuleBlock */: { + // 4. Export alias declarations pointing at only uninstantiated modules or things uninstantiated modules contain + case 259 /* ExportDeclaration */: + if (!node.moduleSpecifier && !!node.exportClause) { + var state = 0 /* NonInstantiated */; + for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) { + var specifier = _a[_i]; + var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited); + if (specifierState > state) { + state = specifierState; + } + if (state === 1 /* Instantiated */) { + return state; + } + } + return state; + } + break; + // 5. other uninstantiated module declarations. + case 249 /* ModuleBlock */: { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { - var childState = getModuleInstanceStateWorker(n); + var childState = getModuleInstanceStateCached(n, visited); switch (childState) { case 0 /* NonInstantiated */: // child is non-instantiated - continue searching @@ -28203,9 +28895,9 @@ var ts; }); return state_1; } - case 245 /* ModuleDeclaration */: - return getModuleInstanceState(node); - case 73 /* Identifier */: + case 248 /* ModuleDeclaration */: + return getModuleInstanceState(node, visited); + case 75 /* Identifier */: // Only jsdoc typedef definition can exist in jsdoc namespace, and it should // be considered the same as type alias if (node.isInJSDocNamespace) { @@ -28214,6 +28906,36 @@ var ts; } return 1 /* Instantiated */; } + function getModuleInstanceStateForAliasTarget(specifier, visited) { + var name = specifier.propertyName || specifier.name; + var p = specifier.parent; + while (p) { + if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) { + var statements = p.statements; + var found = void 0; + for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { + var statement = statements_1[_i]; + if (ts.nodeHasName(statement, name)) { + if (!statement.parent) { + setParentPointers(p, statement); + } + var state = getModuleInstanceStateCached(statement, visited); + if (found === undefined || state > found) { + found = state; + } + if (found === 1 /* Instantiated */) { + return found; + } + } + } + if (found !== undefined) { + return found; + } + } + p = p.parent; + } + return 1 /* Instantiated */; // Couldn't locate, assume could refer to a value + } var ContainerFlags; (function (ContainerFlags) { // The current node is not a container, and no container manipulation should happen before @@ -28238,7 +28960,11 @@ var ts; ContainerFlags[ContainerFlags["IsInterface"] = 64] = "IsInterface"; ContainerFlags[ContainerFlags["IsObjectLiteralOrClassExpressionMethod"] = 128] = "IsObjectLiteralOrClassExpressionMethod"; })(ContainerFlags || (ContainerFlags = {})); - var flowNodeCreated = ts.identity; + function initFlowNode(node) { + ts.Debug.attachFlowNodeDebugInfo(node); + return node; + } + var flowNodeCreated = initFlowNode; var binder = createBinder(); function bindSourceFile(file, options) { ts.performance.mark("beforeBind"); @@ -28278,7 +29004,7 @@ var ts; // or if compiler options contain alwaysStrict. var inStrictMode; var symbolCount = 0; - var Symbol; // tslint:disable-line variable-name + var Symbol; var classifiableNames; var unreachableFlow = { flags: 1 /* Unreachable */ }; var reportedUnreachableFlow = { flags: 1 /* Unreachable */ }; @@ -28302,6 +29028,9 @@ var ts; symbolCount = 0; skipTransformFlagAggregation = file.isDeclarationFile; Symbol = ts.objectAllocator.getSymbolConstructor(); + // Attach debugging information if necessary + ts.Debug.attachFlowNodeDebugInfo(unreachableFlow); + ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow); if (!file.locals) { bind(file); file.symbolCount = symbolCount; @@ -28346,7 +29075,7 @@ var ts; function addDeclarationToSymbol(symbol, node, symbolFlags) { symbol.flags |= symbolFlags; node.symbol = symbol; - symbol.declarations = ts.append(symbol.declarations, node); + symbol.declarations = ts.appendIfUnique(symbol.declarations, node); if (symbolFlags & (32 /* Class */ | 384 /* Enum */ | 1536 /* Module */ | 3 /* Variable */) && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -28373,7 +29102,7 @@ var ts; // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node) { - if (node.kind === 255 /* ExportAssignment */) { + if (node.kind === 258 /* ExportAssignment */) { return node.isExportEquals ? "export=" /* ExportEquals */ : "default" /* Default */; } var name = ts.getNameOfDeclaration(node); @@ -28382,7 +29111,7 @@ var ts; var moduleName = ts.getTextOfIdentifierOrLiteral(name); return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\""); } - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { var nameExpression = name.expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (ts.isStringOrNumericLiteralLike(nameExpression)) { @@ -28394,39 +29123,42 @@ var ts; ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression)); return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name)); } + if (ts.isWellKnownSymbolSyntactically(name)) { + return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name)); + } return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined; } switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return "__constructor" /* Constructor */; - case 166 /* FunctionType */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: return "__call" /* Call */; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: return "__new" /* New */; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return "__index" /* Index */; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return "__export" /* ExportStar */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // json file should behave as // module.exports = ... return "export=" /* ExportEquals */; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.getAssignmentDeclarationKind(node) === 2 /* ModuleExports */) { // module.exports = ... return "export=" /* ExportEquals */; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return (ts.isJSDocConstructSignature(node) ? "__new" /* New */ : "__call" /* Call */); - case 152 /* Parameter */: + case 155 /* Parameter */: // Parameters with names are handled at the top of this function. Parameters // without names can only come from JSDocFunctionTypes. - ts.Debug.assert(node.parent.kind === 295 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); + ts.Debug.assert(node.parent.kind === 298 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + (ts.SyntaxKind ? ts.SyntaxKind[node.parent.kind] : node.parent.kind) + ", expected JSDocFunctionType"; }); var functionType = node.parent; var index = functionType.parameters.indexOf(node); return "arg" + index; @@ -28526,7 +29258,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (node.kind === 255 /* ExportAssignment */ && !node.isExportEquals)) { + (node.kind === 258 /* ExportAssignment */ && !node.isExportEquals)) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; messageNeedsName_1 = false; multipleDefaultExports_1 = true; @@ -28561,7 +29293,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 2097152 /* Alias */) { - if (node.kind === 258 /* ExportSpecifier */ || (node.kind === 249 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 261 /* ExportSpecifier */ || (node.kind === 252 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -28585,7 +29317,7 @@ var ts; // and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed. if (ts.isJSDocTypeAlias(node)) ts.Debug.assert(ts.isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file. - if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { + if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64 /* ExportContext */)) || ts.isJSDocTypeAlias(node)) { if (!container.locals || (ts.hasModifier(node, 512 /* Default */) && !getDeclarationName(node))) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default! } @@ -28628,7 +29360,7 @@ var ts; // for it. We must clear this so we don't accidentally move any stale data forward from // a previous compilation. if (containerFlags & 1 /* IsContainer */) { - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { thisParentContainer = container; } container = blockScopeContainer = node; @@ -28654,34 +29386,35 @@ var ts; // A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave // similarly to break statements that exit to a label just past the statement body. if (!isIIFE) { - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); if (containerFlags & (16 /* IsFunctionExpression */ | 128 /* IsObjectLiteralOrClassExpressionMethod */)) { - currentFlow.container = node; + currentFlow.node = node; } } // We create a return control flow graph for IIFEs and constructors. For constructors // we use the return control flow graph in strict property initialization checks. - currentReturnTarget = isIIFE || node.kind === 158 /* Constructor */ ? createBranchLabel() : undefined; + currentReturnTarget = isIIFE || node.kind === 161 /* Constructor */ ? createBranchLabel() : undefined; currentBreakTarget = undefined; currentContinueTarget = undefined; activeLabels = undefined; hasExplicitReturn = false; - flowNodeCreated = ts.identity; + flowNodeCreated = initFlowNode; bindChildren(node); // Reset all reachability check related flags on node (for incremental scenarios) - node.flags &= ~1408 /* ReachabilityAndEmitFlags */; + node.flags &= ~2816 /* ReachabilityAndEmitFlags */; if (!(currentFlow.flags & 1 /* Unreachable */) && containerFlags & 8 /* IsFunctionLike */ && ts.nodeIsPresent(node.body)) { - node.flags |= 128 /* HasImplicitReturn */; + node.flags |= 256 /* HasImplicitReturn */; if (hasExplicitReturn) - node.flags |= 256 /* HasExplicitReturn */; + node.flags |= 512 /* HasExplicitReturn */; + node.endFlowNode = currentFlow; } - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { node.flags |= emitFlags; } if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); currentFlow = finishFlowLabel(currentReturnTarget); - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { node.returnFlowNode = currentFlow; } } @@ -28698,7 +29431,7 @@ var ts; else if (containerFlags & 64 /* IsInterface */) { seenThisKeyword = false; bindChildren(node); - node.flags = seenThisKeyword ? node.flags | 64 /* ContainsThis */ : node.flags & ~64 /* ContainsThis */; + node.flags = seenThisKeyword ? node.flags | 128 /* ContainsThis */ : node.flags & ~128 /* ContainsThis */; } else { bindChildren(node); @@ -28725,8 +29458,8 @@ var ts; } } function bindEachFunctionsFirst(nodes) { - bindEach(nodes, function (n) { return n.kind === 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); - bindEach(nodes, function (n) { return n.kind !== 240 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind === 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); + bindEach(nodes, function (n) { return n.kind !== 243 /* FunctionDeclaration */ ? bind(n) : undefined; }); } function bindEach(nodes, bindFunction) { if (bindFunction === void 0) { bindFunction = bind; } @@ -28758,80 +29491,90 @@ var ts; bindJSDoc(node); return; } + if (node.kind >= 224 /* FirstStatement */ && node.kind <= 240 /* LastStatement */ && !options.allowUnreachableCode) { + node.flowNode = currentFlow; + } switch (node.kind) { - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: bindWhileStatement(node); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: bindDoStatement(node); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: bindForStatement(node); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: bindIfStatement(node); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: bindTryStatement(node); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: bindSwitchStatement(node); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: bindCaseBlock(node); break; - case 272 /* CaseClause */: + case 275 /* CaseClause */: bindCaseClause(node); break; - case 234 /* LabeledStatement */: + case 225 /* ExpressionStatement */: + bindExpressionStatement(node); + break; + case 237 /* LabeledStatement */: bindLabeledStatement(node); break; - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 192 /* CallExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + bindAccessExpressionFlow(node); + break; + case 195 /* CallExpression */: bindCallExpressionFlow(node); break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: bindJSDocTypeAlias(node); break; // In source files and blocks, bind functions first to match hoisting that occurs at runtime - case 285 /* SourceFile */: { + case 288 /* SourceFile */: { bindEachFunctionsFirst(node.statements); bind(node.endOfFileToken); break; } - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: bindEachFunctionsFirst(node.statements); break; default: @@ -28842,30 +29585,29 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return isNarrowableReference(expr); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return hasNarrowableArgument(expr); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 203 /* PrefixUnaryExpression */: - return expr.operator === 52 /* ExclamationToken */ && isNarrowingExpression(expr.operand); - case 200 /* TypeOfExpression */: + case 206 /* PrefixUnaryExpression */: + return expr.operator === 53 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 203 /* TypeOfExpression */: return isNarrowingExpression(expr.expression); } return false; } function isNarrowableReference(expr) { - return expr.kind === 73 /* Identifier */ || expr.kind === 101 /* ThisKeyword */ || expr.kind === 99 /* SuperKeyword */ || + return expr.kind === 75 /* Identifier */ || expr.kind === 103 /* ThisKeyword */ || expr.kind === 101 /* SuperKeyword */ || (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) || - ts.isElementAccessExpression(expr) && expr.argumentExpression && - (ts.isStringLiteral(expr.argumentExpression) || ts.isNumericLiteral(expr.argumentExpression)) && - isNarrowableReference(expr.expression); + ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) || + ts.isOptionalChain(expr); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -28876,7 +29618,7 @@ var ts; } } } - if (expr.expression.kind === 190 /* PropertyAccessExpression */ && + if (expr.expression.kind === 193 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } @@ -28890,17 +29632,17 @@ var ts; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableReference(expr.left); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return isNarrowableInOperands(expr.left, expr.right); case 27 /* CommaToken */: return isNarrowingExpression(expr.right); @@ -28909,11 +29651,11 @@ var ts; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return isNarrowableOperand(expr.left); case 27 /* CommaToken */: return isNarrowableOperand(expr.right); @@ -28922,20 +29664,14 @@ var ts; return isNarrowableReference(expr); } function createBranchLabel() { - return { - flags: 4 /* BranchLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 4 /* BranchLabel */, antecedents: undefined }); } function createLoopLabel() { - return { - flags: 8 /* LoopLabel */, - antecedents: undefined - }; + return initFlowNode({ flags: 8 /* LoopLabel */, antecedents: undefined }); } function setFlowNodeReferenced(flow) { // On first reference we set the Referenced flag, thereafter we set the Shared flag - flow.flags |= flow.flags & 512 /* Referenced */ ? 1024 /* Shared */ : 512 /* Referenced */; + flow.flags |= flow.flags & 1024 /* Referenced */ ? 2048 /* Shared */ : 1024 /* Referenced */; } function addAntecedent(label, antecedent) { if (!(antecedent.flags & 1 /* Unreachable */) && !ts.contains(label.antecedents, antecedent)) { @@ -28950,31 +29686,35 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 103 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 88 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if ((expression.kind === 105 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 90 /* FalseKeyword */ && flags & 32 /* TrueCondition */) && + !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: flags, expression: expression, antecedent: antecedent }); + return flowNodeCreated({ flags: flags, antecedent: antecedent, node: expression }); } function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) { if (!isNarrowingExpression(switchStatement.expression)) { return antecedent; } setFlowNodeReferenced(antecedent); - return flowNodeCreated({ flags: 128 /* SwitchClause */, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd, antecedent: antecedent }); + return flowNodeCreated({ flags: 128 /* SwitchClause */, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd }); } function createFlowAssignment(antecedent, node) { setFlowNodeReferenced(antecedent); return flowNodeCreated({ flags: 16 /* Assignment */, antecedent: antecedent, node: node }); } + function createFlowCall(antecedent, node) { + setFlowNodeReferenced(antecedent); + return flowNodeCreated({ flags: 512 /* Call */, antecedent: antecedent, node: node }); + } function createFlowArrayMutation(antecedent, node) { setFlowNodeReferenced(antecedent); - var res = flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); - return res; + return flowNodeCreated({ flags: 256 /* ArrayMutation */, antecedent: antecedent, node: node }); } function finishFlowLabel(flow) { var antecedents = flow.antecedents; @@ -28989,47 +29729,52 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 223 /* IfStatement */: - case 225 /* WhileStatement */: - case 224 /* DoStatement */: + case 226 /* IfStatement */: + case 228 /* WhileStatement */: + case 227 /* DoStatement */: return parent.expression === node; - case 226 /* ForStatement */: - case 206 /* ConditionalExpression */: + case 229 /* ForStatement */: + case 209 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 196 /* ParenthesizedExpression */) { + if (node.kind === 199 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 203 /* PrefixUnaryExpression */ && node.operator === 52 /* ExclamationToken */) { + else if (node.kind === 206 /* PrefixUnaryExpression */ && node.operator === 53 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 205 /* BinaryExpression */ && (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 55 /* BarBarToken */); + return node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 56 /* BarBarToken */ || + node.operatorToken.kind === 60 /* QuestionQuestionToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */ || - node.parent.kind === 203 /* PrefixUnaryExpression */ && - node.parent.operator === 52 /* ExclamationToken */) { + while (ts.isParenthesizedExpression(node.parent) || + ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53 /* ExclamationToken */) { node = node.parent; } - return !isStatementCondition(node) && !isLogicalExpression(node.parent); + return !isStatementCondition(node) && + !isLogicalExpression(node.parent) && + !(ts.isOptionalChain(node.parent) && node.parent.expression === node); } - function bindCondition(node, trueTarget, falseTarget) { - var saveTrueTarget = currentTrueTarget; - var saveFalseTarget = currentFalseTarget; + function doWithConditionalBranches(action, value, trueTarget, falseTarget) { + var savedTrueTarget = currentTrueTarget; + var savedFalseTarget = currentFalseTarget; currentTrueTarget = trueTarget; currentFalseTarget = falseTarget; - bind(node); - currentTrueTarget = saveTrueTarget; - currentFalseTarget = saveFalseTarget; - if (!node || !isLogicalExpression(node)) { + action(value); + currentTrueTarget = savedTrueTarget; + currentFalseTarget = savedFalseTarget; + } + function bindCondition(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) { addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); } @@ -29057,7 +29802,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 234 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 237 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -29089,15 +29834,15 @@ var ts; function bindForInOrForOfStatement(node) { var preLoopLabel = createLoopLabel(); var postLoopLabel = createBranchLabel(); + bind(node.expression); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; - if (node.kind === 228 /* ForOfStatement */) { + if (node.kind === 231 /* ForOfStatement */) { bind(node.awaitModifier); } - bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 239 /* VariableDeclarationList */) { + if (node.initializer.kind !== 242 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -29119,7 +29864,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 231 /* ReturnStatement */) { + if (node.kind === 234 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -29139,7 +29884,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 230 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 233 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -29167,7 +29912,7 @@ var ts; // as possible antecedents of the start of the `catch` or `finally` blocks. // Don't bother intercepting the call if there's no finally or catch block that needs the information if (node.catchClause || node.finallyBlock) { - flowNodeCreated = function (node) { return (tryPriors.push(node), node); }; + flowNodeCreated = function (node) { return (tryPriors.push(node), initFlowNode(node)); }; } bind(node.tryBlock); flowNodeCreated = oldFlowNodeCreated; @@ -29231,7 +29976,7 @@ var ts; // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. - var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }; + var preFinallyFlow = initFlowNode({ flags: 4096 /* PreFinally */, antecedent: preFinallyPrior, lock: {} }); addAntecedent(preFinallyLabel, preFinallyFlow); currentFlow = finishFlowLabel(preFinallyLabel); bind(node.finallyBlock); @@ -29249,7 +29994,7 @@ var ts; } } if (!(currentFlow.flags & 1 /* Unreachable */)) { - var afterFinallyFlow = flowNodeCreated({ flags: 4096 /* AfterFinally */, antecedent: currentFlow }); + var afterFinallyFlow = flowNodeCreated({ flags: 8192 /* AfterFinally */, antecedent: currentFlow }); preFinallyFlow.lock = afterFinallyFlow; currentFlow = afterFinallyFlow; } @@ -29267,9 +30012,10 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 273 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 276 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all - // case clauses have unreachable end points (e.g. they all return). + // case clauses have unreachable end points (e.g. they all return). Note, we no longer need + // this property in control flow analysis, it's there only for backwards compatibility. node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -29297,7 +30043,7 @@ var ts; bind(clause); fallthroughFlow = currentFlow; if (!(currentFlow.flags & 1 /* Unreachable */) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) { - errorOnFirstToken(clause, ts.Diagnostics.Fallthrough_case_in_switch); + clause.fallthroughFlowNode = currentFlow; } } clauses.transformFlags = subtreeTransformFlags | 536870912 /* HasComputedFlags */; @@ -29323,6 +30069,17 @@ var ts; function popActiveLabel() { activeLabels.pop(); } + function bindExpressionStatement(node) { + bind(node.expression); + // A top level call expression with a dotted function name and at least one argument + // is potentially an assertion and is therefore included in the control flow. + if (node.expression.kind === 195 /* CallExpression */) { + var call = node.expression; + if (ts.isDottedName(call.expression)) { + currentFlow = createFlowCall(currentFlow, call); + } + } + } function bindLabeledStatement(node) { var preStatementLabel = createLoopLabel(); var postStatementLabel = createBranchLabel(); @@ -29334,14 +30091,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label); } - if (!node.statement || node.statement.kind !== 224 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 227 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -29352,10 +30109,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 188 /* ArrayLiteralExpression */) { + else if (node.kind === 191 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 209 /* SpreadElement */) { + if (e.kind === 212 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -29363,16 +30120,16 @@ var ts; } } } - else if (node.kind === 189 /* ObjectLiteralExpression */) { + else if (node.kind === 192 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 276 /* PropertyAssignment */) { + if (p.kind === 279 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 277 /* ShorthandPropertyAssignment */) { + else if (p.kind === 280 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 278 /* SpreadAssignment */) { + else if (p.kind === 281 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -29380,7 +30137,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -29391,7 +30148,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 52 /* ExclamationToken */) { + if (node.operator === 53 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -29401,20 +30158,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -29428,7 +30185,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 60 /* EqualsToken */ && node.left.kind === 191 /* ElementAccessExpression */) { + if (operator === 62 /* EqualsToken */ && node.left.kind === 194 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29439,7 +30196,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + if (node.expression.kind === 193 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -29478,27 +30235,102 @@ var ts; } function bindJSDocTypeAlias(node) { node.tagName.parent = node; - if (node.kind !== 306 /* JSDocEnumTag */ && node.fullName) { + if (node.kind !== 309 /* JSDocEnumTag */ && node.fullName) { setParentPointers(node, node.fullName); } } - function bindCallExpressionFlow(node) { - // If the target of the call expression is a function expression or arrow function we have - // an immediately invoked function expression (IIFE). Initialize the flowNode property to - // the current control flow (which includes evaluation of the IIFE arguments). - var expr = node.expression; - while (expr.kind === 196 /* ParenthesizedExpression */) { - expr = expr.expression; + function bindJSDocClassTag(node) { + bindEachChild(node); + var host = ts.getHostSignatureFromJSDoc(node); + if (host && host.kind !== 160 /* MethodDeclaration */) { + addDeclarationToSymbol(host.symbol, host, 32 /* Class */); } - if (expr.kind === 197 /* FunctionExpression */ || expr.kind === 198 /* ArrowFunction */) { - bindEach(node.typeArguments); - bindEach(node.arguments); - bind(node.expression); + } + function isOutermostOptionalChain(node) { + return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression; + } + function bindOptionalExpression(node, trueTarget, falseTarget) { + doWithConditionalBranches(bind, node, trueTarget, falseTarget); + if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainRest(node) { + bind(node.questionDotToken); + switch (node.kind) { + case 193 /* PropertyAccessExpression */: + bind(node.name); + break; + case 194 /* ElementAccessExpression */: + bind(node.argumentExpression); + break; + case 195 /* CallExpression */: + bindEach(node.typeArguments); + bindEach(node.arguments); + break; + } + } + function bindOptionalChain(node, trueTarget, falseTarget) { + // For an optional chain, we emulate the behavior of a logical expression: + // + // a?.b -> a && a.b + // a?.b.c -> a && a.b.c + // a?.b?.c -> a && a.b && a.b.c + // a?.[x = 1] -> a && a[x = 1] + // + // To do this we descend through the chain until we reach the root of a chain (the expression with a `?.`) + // and build it's CFA graph as if it were the first condition (`a && ...`). Then we bind the rest + // of the node as part of the "true" branch, and continue to do so as we ascend back up to the outermost + // chain node. We then treat the entire node as the right side of the expression. + var preChainLabel = node.questionDotToken ? createBranchLabel() : undefined; + bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget); + if (preChainLabel) { + currentFlow = finishFlowLabel(preChainLabel); + } + doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget); + if (isOutermostOptionalChain(node)) { + addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node)); + addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node)); + } + } + function bindOptionalChainFlow(node) { + if (isTopLevelLogicalExpression(node)) { + var postExpressionLabel = createBranchLabel(); + bindOptionalChain(node, postExpressionLabel, postExpressionLabel); + currentFlow = finishFlowLabel(postExpressionLabel); + } + else { + bindOptionalChain(node, currentTrueTarget, currentFalseTarget); + } + } + function bindAccessExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); } else { bindEachChild(node); } - if (node.expression.kind === 190 /* PropertyAccessExpression */) { + } + function bindCallExpressionFlow(node) { + if (ts.isOptionalChain(node)) { + bindOptionalChainFlow(node); + } + else { + // If the target of the call expression is a function expression or arrow function we have + // an immediately invoked function expression (IIFE). Initialize the flowNode property to + // the current control flow (which includes evaluation of the IIFE arguments). + var expr = ts.skipParentheses(node.expression); + if (expr.kind === 200 /* FunctionExpression */ || expr.kind === 201 /* ArrowFunction */) { + bindEach(node.typeArguments); + bindEach(node.arguments); + bind(node.expression); + } + else { + bindEachChild(node); + } + } + if (node.expression.kind === 193 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -29507,54 +30339,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 189 /* ObjectLiteralExpression */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 269 /* JsxAttributes */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 192 /* ObjectLiteralExpression */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 272 /* JsxAttributes */: return 1 /* IsContainer */; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } // falls through - case 158 /* Constructor */: - case 240 /* FunctionDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 161 /* CallSignature */: - case 300 /* JSDocSignature */: - case 295 /* JSDocFunctionType */: - case 166 /* FunctionType */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 167 /* ConstructorType */: + case 161 /* Constructor */: + case 243 /* FunctionDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 164 /* CallSignature */: + case 303 /* JSDocSignature */: + case 298 /* JSDocFunctionType */: + case 169 /* FunctionType */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 170 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 275 /* CatchClause */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: - case 247 /* CaseBlock */: + case 278 /* CatchClause */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: + case 250 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 219 /* Block */: + case 222 /* Block */: // do not treat blocks directly inside a function as a block-scoped-container. // Locals that reside in this block should go to the function locals. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -29587,45 +30419,45 @@ var ts; // members are declared (for example, a member of a class will go into a specific // symbol table depending on if it is static or not). We defer to specialized // handlers to take care of declaring these child members. - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 285 /* SourceFile */: + case 288 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 189 /* ObjectLiteralExpression */: - case 242 /* InterfaceDeclaration */: - case 269 /* JsxAttributes */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 192 /* ObjectLiteralExpression */: + case 245 /* InterfaceDeclaration */: + case 272 /* JsxAttributes */: // Interface/Object-types always have their children added to the 'members' of // their container. They are only accessible through an instance of their // container, and are never in scope otherwise (even inside the body of the // object / type / interface declaring them). An exception is type parameters, // which are in scope without qualification (similar to 'locals'). return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 300 /* JSDocSignature */: - case 163 /* IndexSignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 295 /* JSDocFunctionType */: - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 243 /* TypeAliasDeclaration */: - case 182 /* MappedType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 303 /* JSDocSignature */: + case 166 /* IndexSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 298 /* JSDocFunctionType */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 246 /* TypeAliasDeclaration */: + case 185 /* MappedType */: // All the children of these container types are never visible through another // symbol (i.e. through another symbol's 'exports' or 'members'). Instead, // they're only accessed 'lexically' (i.e. from code that exists underneath @@ -29652,11 +30484,11 @@ var ts; function setExportContextFlag(node) { // A declaration source file or ambient module declaration that contains no export declarations (but possibly regular // declarations with export modifiers) is an export context in which declarations are implicitly exported. - if (node.flags & 4194304 /* Ambient */ && !hasExportDeclarations(node)) { - node.flags |= 32 /* ExportContext */; + if (node.flags & 8388608 /* Ambient */ && !hasExportDeclarations(node)) { + node.flags |= 64 /* ExportContext */; } else { - node.flags &= ~32 /* ExportContext */; + node.flags &= ~64 /* ExportContext */; } } function bindModuleDeclaration(node) { @@ -29726,7 +30558,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */ || prop.name.kind !== 73 /* Identifier */) { + if (prop.kind === 281 /* SpreadAssignment */ || prop.name.kind !== 75 /* Identifier */) { continue; } var identifier = prop.name; @@ -29738,7 +30570,7 @@ var ts; // c.IsAccessorDescriptor(previous) is true and IsDataDescriptor(propId.descriptor) is true. // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields - var currentKind = prop.kind === 276 /* PropertyAssignment */ || prop.kind === 277 /* ShorthandPropertyAssignment */ || prop.kind === 157 /* MethodDeclaration */ + var currentKind = prop.kind === 279 /* PropertyAssignment */ || prop.kind === 280 /* ShorthandPropertyAssignment */ || prop.kind === 160 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.escapedText); @@ -29770,10 +30602,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (ts.isExternalOrCommonJsModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -29801,7 +30633,7 @@ var ts; var host = ts.getJSDocHost(typeAlias); container = ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1 /* IsContainer */); }) || file; blockScopeContainer = ts.getEnclosingBlockScopeContainer(host) || file; - currentFlow = { flags: 2 /* Start */ }; + currentFlow = initFlowNode({ flags: 2 /* Start */ }); parent = typeAlias; bind(typeAlias.typeExpression); var declName = ts.getNameOfDeclaration(typeAlias); @@ -29809,12 +30641,17 @@ var ts; // typedef anchored to an A.B.C assignment - we need to bind into B's namespace under name C var isTopLevel = isTopLevelNamespaceAssignment(declName.parent); if (isTopLevel) { - bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; })); + bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), /*containerIsClass*/ false); var oldContainer = container; switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) { case 1 /* ExportsProperty */: case 2 /* ModuleExports */: - container = file; + if (!ts.isExternalOrCommonJsModule(file)) { + container = undefined; + } + else { + container = file; + } break; case 4 /* ThisProperty */: container = declName.parent.expression; @@ -29828,11 +30665,13 @@ var ts; case 0 /* None */: return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration"); } - declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + if (container) { + declareModuleMember(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); + } container = oldContainer; } } - else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 73 /* Identifier */) { + else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 75 /* Identifier */) { parent = typeAlias.parent; bindBlockScopedDeclaration(typeAlias, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); } @@ -29850,11 +30689,11 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 110 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 118 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 112 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 120 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && - !(node.flags & 4194304 /* Ambient */) && - !(node.flags & 2097152 /* JSDoc */)) { + !(node.flags & 8388608 /* Ambient */) && + !(node.flags & 4194304 /* JSDoc */)) { // Report error only if there are no parse errors in file if (!file.parseDiagnostics.length) { file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node))); @@ -29888,7 +30727,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 73 /* Identifier */) { + if (inStrictMode && node.expression.kind === 75 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span = ts.getErrorSpanForNode(file, node.expression); @@ -29899,7 +30738,7 @@ var ts; return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 73 /* Identifier */) { + if (name && name.kind === 75 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -29940,8 +30779,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 285 /* SourceFile */ && - blockScopeContainer.kind !== 245 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 288 /* SourceFile */ && + blockScopeContainer.kind !== 248 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -29967,7 +30806,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) { + if (node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -30036,7 +30875,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 148 /* LastToken */) { + if (node.kind > 151 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -30076,8 +30915,8 @@ var ts; } function updateStrictModeStatementList(statements) { if (!inStrictMode) { - for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) { - var statement = statements_1[_i]; + for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { + var statement = statements_2[_i]; if (!ts.isPrologueDirective(statement)) { return; } @@ -30098,7 +30937,7 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 73 /* Identifier */: + case 75 /* Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. @@ -30111,27 +30950,28 @@ var ts; break; } // falls through - case 101 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 277 /* ShorthandPropertyAssignment */)) { + case 103 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 280 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: - if (currentFlow && isNarrowableReference(node)) { - node.flowNode = currentFlow; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + var expr = node; + if (currentFlow && isNarrowableReference(expr)) { + expr.flowNode = currentFlow; } - if (ts.isSpecialPropertyDeclaration(node)) { - bindSpecialPropertyDeclaration(node); + if (ts.isSpecialPropertyDeclaration(expr)) { + bindSpecialPropertyDeclaration(expr); } - if (ts.isInJSFile(node) && + if (ts.isInJSFile(expr) && file.commonJsModuleIndicator && - ts.isModuleExportsPropertyAccessExpression(node) && + ts.isModuleExportsAccessExpression(expr) && !lookupSymbolForNameWorker(blockScopeContainer, "module")) { - declareSymbol(file.locals, /*parent*/ undefined, node.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); + declareSymbol(file.locals, /*parent*/ undefined, expr.expression, 1 /* FunctionScopedVariable */ | 134217728 /* ModuleExports */, 111550 /* FunctionScopedVariableExcludes */); } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var specialKind = ts.getAssignmentDeclarationKind(node); switch (specialKind) { case 1 /* ExportsProperty */: @@ -30159,76 +30999,78 @@ var ts; ts.Debug.fail("Unknown binary expression special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return checkStrictModeCatchClause(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkStrictModeWithStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkStrictModeLabeledStatement(node); - case 179 /* ThisType */: + case 182 /* ThisType */: seenThisKeyword = true; return; - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: break; // Binding the children will handle everything - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return bindTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return bindParameter(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return bindVariableDeclarationOrBindingElement(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: node.flowNode = currentFlow; return bindVariableDeclarationOrBindingElement(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return bindPropertyWorker(node); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 279 /* EnumMember */: + case 282 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: // If this is an ObjectLiteralExpression method, then it sits in the same space // as other properties in the object literal. So we use SymbolFlags.PropertyExcludes // so that it will conflict with any other object literal members with the same // name. return bindPropertyOrMethodOrAccessor(node, 8192 /* Method */ | (node.questionToken ? 16777216 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 103359 /* MethodExcludes */); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 46015 /* GetAccessorExcludes */); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 78783 /* SetAccessorExcludes */); - case 166 /* FunctionType */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: + case 170 /* ConstructorType */: return bindFunctionOrConstructorType(node); - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 182 /* MappedType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 185 /* MappedType */: return bindAnonymousTypeWorker(node); - case 189 /* ObjectLiteralExpression */: + case 307 /* JSDocClassTag */: + return bindJSDocClassTag(node); + case 192 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return bindFunctionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: var assignmentKind = ts.getAssignmentDeclarationKind(node); switch (assignmentKind) { case 7 /* ObjectDefinePropertyValue */: @@ -30247,65 +31089,65 @@ var ts; } break; // Members of classes, interfaces, and modules - case 210 /* ClassExpression */: - case 241 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 244 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 788872 /* InterfaceExcludes */); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 788968 /* TypeAliasExcludes */); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return bindJsxAttributes(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return bindImportClause(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return bindExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return bindExportAssignment(node); - case 285 /* SourceFile */: + case 288 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 219 /* Block */: + case 222 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } // falls through - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); - case 307 /* JSDocParameterTag */: - if (node.parent.kind === 300 /* JSDocSignature */) { + case 310 /* JSDocParameterTag */: + if (node.parent.kind === 303 /* JSDocSignature */) { return bindParameter(node); } - if (node.parent.kind !== 299 /* JSDocTypeLiteral */) { + if (node.parent.kind !== 302 /* JSDocTypeLiteral */) { break; } // falls through - case 313 /* JSDocPropertyTag */: + case 316 /* JSDocPropertyTag */: var propTag = node; - var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 294 /* JSDocOptionalType */ ? + var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 297 /* JSDocOptionalType */ ? 4 /* Property */ | 16777216 /* Optional */ : 4 /* Property */; return declareSymbolAndAddToSymbolTable(propTag, flags, 0 /* PropertyExcludes */); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return (delayedTypeAliases || (delayedTypeAliases = [])).push(node); } } @@ -30413,8 +31255,7 @@ var ts; if (!setCommonJsModuleIndicator(node)) { return; } - var lhs = node.left; - var symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, function (id, symbol) { + var symbol = forEachIdentifierInEntityName(node.left.expression, /*parent*/ undefined, function (id, symbol) { if (symbol) { addDeclarationToSymbol(symbol, id, 1536 /* Module */ | 67108864 /* Assignment */); } @@ -30424,7 +31265,7 @@ var ts; var flags = ts.isClassExpression(node.right) ? 4 /* Property */ | 1048576 /* ExportValue */ | 32 /* Class */ : 4 /* Property */ | 1048576 /* ExportValue */; - declareSymbol(symbol.exports, symbol, lhs, flags, 0 /* None */); + declareSymbol(symbol.exports, symbol, node.left, flags, 0 /* None */); } } function bindModuleExportsAssignment(node) { @@ -30443,41 +31284,53 @@ var ts; var flags = ts.exportAssignmentIsAlias(node) ? 2097152 /* Alias */ : 4 /* Property */ | 1048576 /* ExportValue */ | 512 /* ValueModule */; - declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864 /* Assignment */, 0 /* None */); + setValueDeclaration(symbol, node); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJSFile(node)); var thisContainer = ts.getThisContainer(node, /*includeArrowFunctions*/ false); switch (thisContainer.kind) { - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: var constructorSymbol = thisContainer.symbol; // For `f.prototype.m = function() { this.x = 0; }`, `this.x = 0` should modify `f`'s members, not the function expression. - if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 60 /* EqualsToken */) { + if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62 /* EqualsToken */) { var l = thisContainer.parent.left; - if (ts.isPropertyAccessEntityNameExpression(l) && ts.isPrototypeAccess(l.expression)) { + if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) { constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer); } } - if (constructorSymbol) { + if (constructorSymbol && constructorSymbol.valueDeclaration) { // Declare a 'member' if the container is an ES5 class or ES6 constructor constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable(); // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol); + } + else { + declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* PropertyExcludes */ & ~4 /* Property */); + } + addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32 /* Class */); } break; - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // this.foo assignment in a JavaScript class // Bind this property to the containing class var containingClass = thisContainer.parent; var symbolTable = ts.hasModifier(thisContainer, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members; - declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */, 0 /* None */, /*isReplaceableByMethod*/ true); + if (ts.hasDynamicName(node)) { + bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol); + } + else { + declareSymbol(symbolTable, containingClass.symbol, node, 4 /* Property */ | 67108864 /* Assignment */, 0 /* None */, /*isReplaceableByMethod*/ true); + } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: // this.property = assignment in a source file -- declare symbol in exports for a module, in locals for a script if (thisContainer.commonJsModuleIndicator) { declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 /* Property */ | 1048576 /* ExportValue */, 0 /* None */); @@ -30490,11 +31343,21 @@ var ts; ts.Debug.failBadSyntaxKind(thisContainer); } } + function bindDynamicallyNamedThisPropertyAssignment(node, symbol) { + bindAnonymousDeclaration(node, 4 /* Property */, "__computed" /* Computed */); + addLateBoundAssignmentDeclarationToSymbol(node, symbol); + } + function addLateBoundAssignmentDeclarationToSymbol(node, symbol) { + if (symbol) { + var members = symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = ts.createMap()); + members.set("" + ts.getNodeId(node), node); + } + } function bindSpecialPropertyDeclaration(node) { - if (node.expression.kind === 101 /* ThisKeyword */) { + if (node.expression.kind === 103 /* ThisKeyword */) { bindThisPropertyAssignment(node); } - else if (ts.isPropertyAccessEntityNameExpression(node) && node.parent.parent.kind === 285 /* SourceFile */) { + else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 288 /* SourceFile */) { if (ts.isPrototypeAccess(node.expression)) { bindPrototypePropertyAssignment(node, node.parent); } @@ -30507,11 +31370,14 @@ var ts; function bindPrototypeAssignment(node) { node.left.parent = node; node.right.parent = node; - var lhs = node.left; - bindPropertyAssignment(lhs.expression, lhs, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.left.expression, node.left, /*isPrototypeProperty*/ false, /*containerIsClass*/ true); } function bindObjectDefinePrototypeProperty(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression); + if (namespaceSymbol) { + // Ensure the namespace symbol becomes class-like + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ true); } /** @@ -30527,32 +31393,38 @@ var ts; lhs.parent = parent; constructorFunction.parent = classPrototype; classPrototype.parent = lhs; - bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true); + bindPropertyAssignment(constructorFunction, lhs, /*isPrototypeProperty*/ true, /*containerIsClass*/ true); } function bindObjectDefinePropertyAssignment(node) { var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]); - var isToplevel = node.parent.parent.kind === 285 /* SourceFile */; - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false); + var isToplevel = node.parent.parent.kind === 288 /* SourceFile */; + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, /*isPrototypeProperty*/ false); } function bindSpecialPropertyAssignment(node) { - var lhs = node.left; // Class declarations in Typescript do not allow property declarations - var parentSymbol = lookupSymbolForPropertyAccess(lhs.expression); + var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression); if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) { return; } // Fix up parent pointers since we're going to use these nodes before we bind into them node.left.parent = node; node.right.parent = node; - if (ts.isIdentifier(lhs.expression) && container === file && isExportsOrModuleExportsOrAlias(file, lhs.expression)) { + if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { // This can be an alias for the 'exports' or 'module.exports' names, e.g. // var util = module.exports; // util.property = function ... bindExportsPropertyAssignment(node); } else { - bindStaticPropertyAssignment(lhs); + if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } + else { + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); + } } } /** @@ -30561,9 +31433,9 @@ var ts; */ function bindStaticPropertyAssignment(node) { node.expression.parent = node; - bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false); + bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } - function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty) { + function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) { if (isToplevel && !isPrototypeProperty) { // make symbols or add declarations for intermediate containers var flags_1 = 1536 /* Module */ | 67108864 /* Assignment */; @@ -30580,6 +31452,9 @@ var ts; } }); } + if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) { + addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */); + } return namespaceSymbol; } function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) { @@ -30590,20 +31465,47 @@ var ts; var symbolTable = isPrototypeProperty ? (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) : (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable())); - var isMethod = ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration)); - var includes = isMethod ? 8192 /* Method */ : 4 /* Property */; - var excludes = isMethod ? 103359 /* MethodExcludes */ : 0 /* PropertyExcludes */; + var includes = 0 /* None */; + var excludes = 0 /* None */; + // Method-like + if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) { + includes = 8192 /* Method */; + excludes = 103359 /* MethodExcludes */; + } + // Maybe accessor-like + else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "set"; + })) { + // We mix in `SymbolFLags.Property` so in the checker `getTypeOfVariableParameterOrProperty` is used for this + // symbol, instead of `getTypeOfAccessor` (which will assert as there is no real accessor declaration) + includes |= 65536 /* SetAccessor */ | 4 /* Property */; + excludes |= 78783 /* SetAccessorExcludes */; + } + if (ts.some(declaration.arguments[2].properties, function (p) { + var id = ts.getNameOfDeclaration(p); + return !!id && ts.isIdentifier(id) && ts.idText(id) === "get"; + })) { + includes |= 32768 /* GetAccessor */ | 4 /* Property */; + excludes |= 46015 /* GetAccessorExcludes */; + } + } + if (includes === 0 /* None */) { + includes = 4 /* Property */; + excludes = 0 /* PropertyExcludes */; + } declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864 /* Assignment */, excludes & ~67108864 /* Assignment */); } function isTopLevelNamespaceAssignment(propertyAccess) { return ts.isBinaryExpression(propertyAccess.parent) - ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 285 /* SourceFile */ - : propertyAccess.parent.parent.kind === 285 /* SourceFile */; + ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 288 /* SourceFile */ + : propertyAccess.parent.parent.kind === 288 /* SourceFile */; } - function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty) { + function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) { var namespaceSymbol = lookupSymbolForPropertyAccess(name); var isToplevel = isTopLevelNamespaceAssignment(propertyAccess); - namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty); + namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass); bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty); } /** @@ -30632,7 +31534,7 @@ var ts; init = init && ts.getRightMostAssignedExpression(init); if (init) { var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node); - return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && init.operatorToken.kind === 55 /* BarBarToken */ ? init.right : init, isPrototypeAssignment); + return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 /* BarBarToken */ || init.operatorToken.kind === 60 /* QuestionQuestionToken */) ? init.right : init, isPrototypeAssignment); } return false; } @@ -30649,7 +31551,7 @@ var ts; } else { var symbol = lookupSymbolForPropertyAccess(node.expression); - return symbol && symbol.exports && symbol.exports.get(node.name.escapedText); + return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node)); } } function forEachIdentifierInEntityName(e, parent, action) { @@ -30661,7 +31563,7 @@ var ts; } else { var s = forEachIdentifierInEntityName(e.expression, parent, action); - return action(e.name, s && s.exports && s.exports.get(e.name.escapedText), s); + return action(ts.getNameOrArgument(e), s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s); } } function bindCallExpression(node) { @@ -30672,7 +31574,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 241 /* ClassDeclaration */) { + if (node.kind === 244 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899503 /* ClassExcludes */); } else { @@ -30735,10 +31637,10 @@ var ts; } } function bindParameter(node) { - if (node.kind === 307 /* JSDocParameterTag */ && container.kind !== 300 /* JSDocSignature */) { + if (node.kind === 310 /* JSDocParameterTag */ && container.kind !== 303 /* JSDocSignature */) { return; } - if (inStrictMode && !(node.flags & 4194304 /* Ambient */)) { + if (inStrictMode && !(node.flags & 8388608 /* Ambient */)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -30757,9 +31659,9 @@ var ts; } } function bindFunctionDeclaration(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } checkStrictModeFunctionName(node); @@ -30772,9 +31674,9 @@ var ts; } } function bindFunctionExpression(node) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */)) { + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */)) { if (ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + emitFlags |= 2048 /* HasAsyncFunctions */; } } if (currentFlow) { @@ -30785,8 +31687,8 @@ var ts; return bindAnonymousDeclaration(node, 16 /* Function */, bindingName); } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { - if (!file.isDeclarationFile && !(node.flags & 4194304 /* Ambient */) && ts.isAsyncFunction(node)) { - emitFlags |= 1024 /* HasAsyncFunctions */; + if (!file.isDeclarationFile && !(node.flags & 8388608 /* Ambient */) && ts.isAsyncFunction(node)) { + emitFlags |= 2048 /* HasAsyncFunctions */; } if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) { node.flowNode = currentFlow; @@ -30812,7 +31714,7 @@ var ts; declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 526824 /* TypeParameterExcludes */); } } - else if (node.parent.kind === 177 /* InferType */) { + else if (node.parent.kind === 180 /* InferType */) { var container_2 = getInferTypeContainer(node.parent); if (container_2) { if (!container_2.locals) { @@ -30840,11 +31742,11 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 221 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 223 /* EmptyStatement */) || // report error on class declarations - node.kind === 241 /* ClassDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 245 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); + (node.kind === 248 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)); if (reportError) { currentFlow = reportedUnreachableFlow; if (!options.allowUnreachableCode) { @@ -30858,7 +31760,7 @@ var ts; // Rationale: we don't want to report errors on non-initialized var's since they are hoisted // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var isError_1 = ts.unreachableCodeIsError(options) && - !(node.flags & 4194304 /* Ambient */) && + !(node.flags & 8388608 /* Ambient */) && (!ts.isVariableStatement(node) || !!(ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */) || node.declarationList.declarations.some(function (d) { return !!d.initializer; })); @@ -30888,12 +31790,12 @@ var ts; } function isPurelyTypeDeclaration(s) { switch (s.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return true; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return getModuleInstanceState(s) !== 1 /* Instantiated */; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.hasModifier(s, 2048 /* Const */); default: return false; @@ -30905,7 +31807,7 @@ var ts; while (q.length && i < 100) { i++; node = q.shift(); - if (ts.isExportsIdentifier(node) || ts.isModuleExportsPropertyAccessExpression(node)) { + if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) { return true; } else if (ts.isIdentifier(node)) { @@ -30942,58 +31844,58 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 152 /* Parameter */: + case 155 /* Parameter */: return computeParameter(node, subtreeFlags); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 158 /* Constructor */: + case 161 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return computeElementAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -31004,6 +31906,9 @@ var ts; var transformFlags = subtreeFlags; var callee = ts.skipOuterExpressions(node.expression); var expression = node.expression; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } if (node.typeArguments) { transformFlags |= 1 /* AssertTypeScript */; } @@ -31015,7 +31920,7 @@ var ts; transformFlags |= 2048 /* ContainsLexicalThis */; } } - if (expression.kind === 93 /* ImportKeyword */) { + if (expression.kind === 95 /* ImportKeyword */) { transformFlags |= 524288 /* ContainsDynamicImport */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31038,17 +31943,20 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 189 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 60 /* QuestionQuestionToken */) { + transformFlags |= 4 /* AssertESNext */; + } + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 192 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ES2018 if they contain rest transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 60 /* EqualsToken */ && leftKind === 188 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 62 /* EqualsToken */ && leftKind === 191 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 128 /* AssertES2015 */ | 512 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 41 /* AsteriskAsteriskToken */ - || operatorTokenKind === 64 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 42 /* AsteriskAsteriskToken */ + || operatorTokenKind === 66 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 64 /* AssertES2016 */; } @@ -31091,8 +31999,8 @@ var ts; // If the node is synthesized, it means the emitter put the parentheses there, // not the user. If we didn't want them, the emitter would not have put them // there. - if (expressionKind === 213 /* AsExpression */ - || expressionKind === 195 /* TypeAssertionExpression */) { + if (expressionKind === 216 /* AsExpression */ + || expressionKind === 198 /* TypeAssertionExpression */) { transformFlags |= 1 /* AssertTypeScript */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -31132,11 +32040,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 87 /* ExtendsKeyword */: + case 89 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; - case 110 /* ImplementsKeyword */: + case 112 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; @@ -31327,9 +32235,12 @@ var ts; } function computePropertyAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31339,9 +32250,12 @@ var ts; } function computeElementAccess(node, subtreeFlags) { var transformFlags = subtreeFlags; + if (node.flags & 32 /* OptionalChain */) { + transformFlags |= 4 /* ContainsESNext */; + } // If an ElementAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { // super inside of an async function requires hoisting the super access (ES2017). // same for super inside of an async generator, which is ES2018. transformFlags |= 32 /* ContainsES2017 */ | 16 /* ContainsES2018 */; @@ -31429,43 +32343,43 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536870912 /* NodeExcludes */; switch (kind) { - case 122 /* AsyncKeyword */: - case 202 /* AwaitExpression */: + case 125 /* AsyncKeyword */: + case 205 /* AwaitExpression */: // async/await is ES2017 syntax, but may be ES2018 syntax (for async generators) transformFlags |= 16 /* AssertES2018 */ | 32 /* AssertES2017 */; break; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; excludeFlags = 536870912 /* OuterExpressionExcludes */; break; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 126 /* DeclareKeyword */: - case 78 /* ConstKeyword */: - case 244 /* EnumDeclaration */: - case 279 /* EnumMember */: - case 214 /* NonNullExpression */: - case 134 /* ReadonlyKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 129 /* DeclareKeyword */: + case 80 /* ConstKeyword */: + case 247 /* EnumDeclaration */: + case 282 /* EnumMember */: + case 217 /* NonNullExpression */: + case 137 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */; break; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: case 11 /* JsxText */: - case 264 /* JsxClosingElement */: - case 265 /* JsxFragment */: - case 266 /* JsxOpeningFragment */: - case 267 /* JsxClosingFragment */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 271 /* JsxExpression */: + case 267 /* JsxClosingElement */: + case 268 /* JsxFragment */: + case 269 /* JsxOpeningFragment */: + case 270 /* JsxClosingFragment */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 274 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 2 /* AssertJsx */; break; @@ -31473,11 +32387,11 @@ var ts; case 15 /* TemplateHead */: case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: - case 207 /* TemplateExpression */: - case 194 /* TaggedTemplateExpression */: - case 277 /* ShorthandPropertyAssignment */: - case 117 /* StaticKeyword */: - case 215 /* MetaProperty */: + case 210 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 280 /* ShorthandPropertyAssignment */: + case 119 /* StaticKeyword */: + case 218 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 128 /* AssertES2015 */; break; @@ -31494,103 +32408,103 @@ var ts; case 9 /* BigIntLiteral */: transformFlags |= 4 /* AssertESNext */; break; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). if (node.awaitModifier) { transformFlags |= 16 /* AssertES2018 */; } transformFlags |= 128 /* AssertES2015 */; break; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async // generator). transformFlags |= 16 /* AssertES2018 */ | 128 /* AssertES2015 */ | 131072 /* ContainsYield */; break; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 137 /* ObjectKeyword */: - case 139 /* StringKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 164 /* TypePredicate */: - case 165 /* TypeReference */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 168 /* TypeQuery */: - case 169 /* TypeLiteral */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 177 /* InferType */: - case 178 /* ParenthesizedType */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: - case 248 /* NamespaceExportDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 140 /* ObjectKeyword */: + case 142 /* StringKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 167 /* TypePredicate */: + case 168 /* TypeReference */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 171 /* TypeQuery */: + case 172 /* TypeLiteral */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 180 /* InferType */: + case 181 /* ParenthesizedType */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: + case 251 /* NamespaceExportDeclaration */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 1 /* AssertTypeScript */; excludeFlags = -2 /* TypeExcludes */; break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. transformFlags |= 16384 /* ContainsComputedPropertyName */; break; - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: transformFlags |= 128 /* AssertES2015 */ | 4096 /* ContainsRestOrSpread */; break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; break; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 128 /* AssertES2015 */; excludeFlags = 536870912 /* OuterExpressionExcludes */; // must be set to persist `Super` break; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 2048 /* ContainsLexicalThis */; break; - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; if (subtreeFlags & 4096 /* ContainsRestOrSpread */) { transformFlags |= 16 /* AssertES2018 */ | 8192 /* ContainsObjectRestOrSpread */; } excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: transformFlags |= 128 /* AssertES2015 */ | 65536 /* ContainsBindingPattern */; excludeFlags = 536875008 /* BindingPatternExcludes */; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: transformFlags |= 128 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 4096 /* ContainsRestOrSpread */; } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 1 /* AssertTypeScript */ | 1024 /* ContainsTypeScriptClassSyntax */; break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: excludeFlags = 536896512 /* ObjectLiteralExcludes */; if (subtreeFlags & 16384 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -31603,26 +32517,26 @@ var ts; transformFlags |= 16 /* AssertES2018 */; } break; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: excludeFlags = 536875008 /* ArrayLiteralOrCallOrNewExcludes */; break; - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 32768 /* ContainsBlockScopedBinding */) { transformFlags |= 128 /* AssertES2015 */; } break; - case 285 /* SourceFile */: + case 288 /* SourceFile */: break; - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: // Return statements may require an `await` in ES2018. transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */ | 16 /* AssertES2018 */; break; - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: transformFlags |= 262144 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -31640,67 +32554,67 @@ var ts; * than calling this function. */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 164 /* FirstTypeNode */ && kind <= 184 /* LastTypeNode */) { + if (kind >= 167 /* FirstTypeNode */ && kind <= 187 /* LastTypeNode */) { return -2 /* TypeExcludes */; } switch (kind) { - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 188 /* ArrayLiteralExpression */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 191 /* ArrayLiteralExpression */: return 536875008 /* ArrayLiteralOrCallOrNewExcludes */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return 537168896 /* ModuleExcludes */; - case 152 /* Parameter */: + case 155 /* Parameter */: return 536870912 /* ParameterExcludes */; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return 537371648 /* ArrowFunctionExcludes */; - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: return 537373696 /* FunctionExcludes */; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return 536944640 /* VariableDeclarationListExcludes */; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 536888320 /* ClassExcludes */; - case 158 /* Constructor */: + case 161 /* Constructor */: return 537372672 /* ConstructorExcludes */; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return 537372672 /* MethodOrAccessorExcludes */; - case 121 /* AnyKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 133 /* NeverKeyword */: - case 139 /* StringKeyword */: - case 137 /* ObjectKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 107 /* VoidKeyword */: - case 151 /* TypeParameter */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 124 /* AnyKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 136 /* NeverKeyword */: + case 142 /* StringKeyword */: + case 140 /* ObjectKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 109 /* VoidKeyword */: + case 154 /* TypeParameter */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: return -2 /* TypeExcludes */; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return 536896512 /* ObjectLiteralExcludes */; - case 275 /* CatchClause */: + case 278 /* CatchClause */: return 536879104 /* CatchClauseExcludes */; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: return 536875008 /* BindingPatternExcludes */; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 316 /* PartiallyEmittedExpression */: - case 196 /* ParenthesizedExpression */: - case 99 /* SuperKeyword */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 319 /* PartiallyEmittedExpression */: + case 199 /* ParenthesizedExpression */: + case 101 /* SuperKeyword */: return 536870912 /* OuterExpressionExcludes */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return 536870912 /* PropertyAccessExcludes */; default: return 536870912 /* NodeExcludes */; @@ -31719,7 +32633,7 @@ var ts; /** @internal */ var ts; (function (ts) { - function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier) { + function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) { return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } @@ -31792,7 +32706,7 @@ var ts; } function visitTypeReference(type) { visitType(type.target); - ts.forEach(type.typeArguments, visitType); + ts.forEach(getTypeArguments(type), visitType); } function visitTypeParameter(type) { visitType(getConstraintOfTypeParameter(type)); @@ -31875,7 +32789,7 @@ var ts; // (their type resolved directly to the member deeply referenced) // So to get the intervening symbols, we need to check if there's a type // query node on any of the symbol's declarations and get symbols there - if (d.type && d.type.kind === 168 /* TypeQuery */) { + if (d.type && d.type.kind === 171 /* TypeQuery */) { var query = d.type; var entity = getResolvedSymbol(getFirstIdentifier(query.exprName)); visitSymbol(entity); @@ -32029,6 +32943,7 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["ImmediateBaseConstraint"] = 4] = "ImmediateBaseConstraint"; TypeSystemPropertyName[TypeSystemPropertyName["EnumTagType"] = 5] = "EnumTagType"; TypeSystemPropertyName[TypeSystemPropertyName["JSDocTypeReference"] = 6] = "JSDocTypeReference"; + TypeSystemPropertyName[TypeSystemPropertyName["ResolvedTypeArguments"] = 7] = "ResolvedTypeArguments"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); var CheckMode; (function (CheckMode) { @@ -32039,11 +32954,6 @@ var ts; CheckMode[CheckMode["SkipGenericFunctions"] = 8] = "SkipGenericFunctions"; CheckMode[CheckMode["IsForSignatureHelp"] = 16] = "IsForSignatureHelp"; })(CheckMode || (CheckMode = {})); - var ContextFlags; - (function (ContextFlags) { - ContextFlags[ContextFlags["None"] = 0] = "None"; - ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; - })(ContextFlags || (ContextFlags = {})); var AccessFlags; (function (AccessFlags) { AccessFlags[AccessFlags["None"] = 0] = "None"; @@ -32146,11 +33056,9 @@ var ts; var cancellationToken; var requestedExternalEmitHelpers; var externalHelpersModule; - // tslint:disable variable-name var Symbol = ts.objectAllocator.getSymbolConstructor(); var Type = ts.objectAllocator.getTypeConstructor(); var Signature = ts.objectAllocator.getSignatureConstructor(); - // tslint:enable variable-name var typeCount = 0; var symbolCount = 0; var enumCount = 0; @@ -32232,8 +33140,11 @@ var ts; getParameterType: getTypeAtPosition, getPromisedTypeOfPromise: getPromisedTypeOfPromise, getReturnTypeOfSignature: getReturnTypeOfSignature, + isNullableType: isNullableType, getNullableType: getNullableType, getNonNullableType: getNonNullableType, + getNonOptionalType: removeOptionalTypeMarker, + getTypeArguments: getTypeArguments, typeToTypeNode: nodeBuilder.typeToTypeNode, indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, @@ -32299,9 +33210,9 @@ var ts; }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: function (nodeIn) { + getContextualType: function (nodeIn, contextFlags) { var node = ts.getParseTreeNode(nodeIn, ts.isExpression); - return node ? getContextualType(node) : undefined; + return node ? getContextualType(node, contextFlags) : undefined; }, getContextualTypeForObjectLiteralElement: function (nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike); @@ -32350,7 +33261,7 @@ var ts; getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, - getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier), + getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments), getAmbientModules: getAmbientModules, getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt, isOptionalParameter: function (nodeIn) { @@ -32366,6 +33277,9 @@ var ts; }, getApparentType: getApparentType, getUnionType: getUnionType, + isTypeAssignableTo: function (source, target) { + return isTypeAssignableTo(source, target); + }, createAnonymousType: createAnonymousType, createSignature: createSignature, createSymbol: createSymbol, @@ -32384,6 +33298,7 @@ var ts; getNullType: function () { return nullType; }, getESSymbolType: function () { return esSymbolType; }, getNeverType: function () { return neverType; }, + getOptionalType: function () { return optionalType; }, isSymbolAccessible: isSymbolAccessible, getObjectFlags: ts.getObjectFlags, isArrayType: isArrayType, @@ -32412,7 +33327,7 @@ var ts; return node && getTypeArgumentConstraint(node); }, getSuggestionDiagnostics: function (file, ct) { - if (ts.skipTypeChecking(file, compilerOptions)) { + if (ts.skipTypeChecking(file, compilerOptions, host)) { return ts.emptyArray; } var diagnostics; @@ -32476,6 +33391,7 @@ var ts; var unknownType = createIntrinsicType(2 /* Unknown */, "unknown"); var undefinedType = createIntrinsicType(32768 /* Undefined */, "undefined"); var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768 /* Undefined */, "undefined", 262144 /* ContainsWideningType */); + var optionalType = createIntrinsicType(32768 /* Undefined */, "undefined"); var nullType = createIntrinsicType(65536 /* Null */, "null"); var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536 /* Null */, "null", 262144 /* ContainsWideningType */); var stringType = createIntrinsicType(4 /* String */, "string"); @@ -32505,6 +33421,7 @@ var ts; var silentNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonInferrableType = createIntrinsicType(131072 /* Never */, "never", 1048576 /* NonInferrableType */); var implicitNeverType = createIntrinsicType(131072 /* Never */, "never"); + var unreachableNeverType = createIntrinsicType(131072 /* Never */, "never"); var nonPrimitiveType = createIntrinsicType(67108864 /* NonPrimitive */, "object"); var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]); var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType; @@ -32528,11 +33445,11 @@ var ts; var markerSubType = createTypeParameter(); markerSubType.constraint = markerSuperType; var markerOtherType = createTypeParameter(); - var noTypePredicate = createIdentifierTypePredicate("<>", 0, anyType); - var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); - var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var noTypePredicate = createTypePredicate(1 /* Identifier */, "<>", 0, anyType); + var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); + var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); var iterationTypesCache = ts.createMap(); // cache for common IterationTypes instances var noIterationTypes = { @@ -32625,6 +33542,9 @@ var ts; var flowLoopCount = 0; var sharedFlowCount = 0; var flowAnalysisDisabled = false; + var flowInvocationCount = 0; + var lastFlowNode; + var lastFlowNodeReachable; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" }); @@ -32637,13 +33557,13 @@ var ts; var symbolLinks = []; var nodeLinks = []; var flowLoopCaches = []; - var flowAssignmentKeys = []; var flowAssignmentTypes = []; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; var sharedFlowNodes = []; var sharedFlowTypes = []; + var flowNodeReachable = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -32679,10 +33599,10 @@ var ts; } var jsxPragma = file.pragmas.get("jsx"); if (jsxPragma) { - var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; // TODO: GH#18217 + var chosenpragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma; file.localJsxFactory = ts.parseIsolatedEntityName(chosenpragma.arguments.factory, languageVersion); if (file.localJsxFactory) { - return file.localJsxNamespace = getFirstIdentifier(file.localJsxFactory).escapedText; + return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText; } } } @@ -32692,7 +33612,7 @@ var ts; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); if (_jsxFactoryEntity) { - _jsxNamespace = getFirstIdentifier(_jsxFactoryEntity).escapedText; + _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText; } } else if (compilerOptions.reactNamespace) { @@ -32736,7 +33656,7 @@ var ts; } } function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) { - addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); + addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message)); // eslint-disable-line no-in-operator } function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) { var diagnostic = error(location, message, arg0, arg1, arg2, arg3); @@ -32821,7 +33741,11 @@ var ts; if (unidirectional === void 0) { unidirectional = false; } if (!(target.flags & getExcludedSymbolFlags(source.flags)) || (source.flags | target.flags) & 67108864 /* Assignment */) { - ts.Debug.assert(source !== target); + if (source === target) { + // This can happen when an export assigned namespace exports something also erroneously exported at the top level + // See `declarationFileNoCrashOnExtraExportModifier` for an example + return target; + } if (!(target.flags & 33554432 /* Transient */)) { var resolvedTarget = resolveSymbol(target); if (resolvedTarget === unknownSymbol) { @@ -32950,7 +33874,7 @@ var ts; else { // find a module that about to be augmented // do not validate names of augmentations that are defined in ambient context - var moduleNotFoundError = !(moduleName.parent.parent.flags & 4194304 /* Ambient */) + var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608 /* Ambient */) ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found : undefined; var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, /*isForAugmentation*/ true); @@ -32960,7 +33884,7 @@ var ts; // obtain item referenced by 'export=' mainModule_1 = resolveExternalModuleSymbol(mainModule_1); if (mainModule_1.flags & 1920 /* Namespace */) { - // If we’re merging an augmentation to a pattern ambient module, we want to + // If we're merging an augmentation to a pattern ambient module, we want to // perform the merge unidirectionally from the augmentation ('a.foo') to // the pattern ('*.foo'), so that 'getMergedSymbol()' on a.foo gives you // all the exports both from the pattern and from the augmentation, but @@ -33009,7 +33933,7 @@ var ts; return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node) { - return node.kind === 285 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 288 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -33053,7 +33977,7 @@ var ts; if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out) || isInTypeQuery(usage) || - declaration.flags & 4194304 /* Ambient */) { + declaration.flags & 8388608 /* Ambient */) { // nodes are in different files and order cannot be determined return true; } @@ -33067,17 +33991,17 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 187 /* BindingElement */) { + if (declaration.kind === 190 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 187 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 190 /* BindingElement */); if (errorBindingElement) { return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 238 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 241 /* VariableDeclaration */), usage); } - else if (declaration.kind === 238 /* VariableDeclaration */) { + else if (declaration.kind === 241 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } @@ -33100,22 +34024,22 @@ var ts; // or if usage is in a type context: // 1. inside a type query (typeof in type position) // 2. inside a jsdoc comment - if (usage.parent.kind === 258 /* ExportSpecifier */ || (usage.parent.kind === 255 /* ExportAssignment */ && usage.parent.isExportEquals)) { + if (usage.parent.kind === 261 /* ExportSpecifier */ || (usage.parent.kind === 258 /* ExportAssignment */ && usage.parent.isExportEquals)) { // export specifiers do not use the variable, they only make it available for use return true; } // When resolving symbols for exports, the `usage` location passed in can be the export site directly - if (usage.kind === 255 /* ExportAssignment */ && usage.isExportEquals) { + if (usage.kind === 258 /* ExportAssignment */ && usage.isExportEquals) { return true; } var container = ts.getEnclosingBlockScopeContainer(declaration); - return !!(usage.flags & 2097152 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); + return !!(usage.flags & 4194304 /* JSDoc */) || isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 220 /* VariableStatement */: - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: + case 224 /* VariableStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -33136,16 +34060,16 @@ var ts; return true; } var initializerOfProperty = current.parent && - current.parent.kind === 155 /* PropertyDeclaration */ && + current.parent.kind === 158 /* PropertyDeclaration */ && current.parent.initializer === current; if (initializerOfProperty) { if (ts.hasModifier(current.parent, 32 /* Static */)) { - if (declaration.kind === 157 /* MethodDeclaration */) { + if (declaration.kind === 160 /* MethodDeclaration */) { return true; } } else { - var isDeclarationInstanceProperty = declaration.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); + var isDeclarationInstanceProperty = declaration.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(declaration, 32 /* Static */); if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { return true; } @@ -33166,14 +34090,14 @@ var ts; return "quit"; } switch (node.kind) { - case 198 /* ArrowFunction */: - case 155 /* PropertyDeclaration */: + case 201 /* ArrowFunction */: + case 158 /* PropertyDeclaration */: return true; - case 219 /* Block */: + case 222 /* Block */: switch (node.parent.kind) { - case 159 /* GetAccessor */: - case 157 /* MethodDeclaration */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 160 /* MethodDeclaration */: + case 163 /* SetAccessor */: return true; default: return false; @@ -33219,12 +34143,12 @@ var ts; // - parameters are only in the scope of function body // This restriction does not apply to JSDoc comment types because they are parented // at a higher level than type parameters would normally be - if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 298 /* JSDocComment */) { + if (meaning & result.flags & 788968 /* Type */ && lastLocation.kind !== 301 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ // type parameters are visible in parameter list, return type and type parameter list ? lastLocation === location.type || - lastLocation.kind === 152 /* Parameter */ || - lastLocation.kind === 151 /* TypeParameter */ + lastLocation.kind === 155 /* Parameter */ || + lastLocation.kind === 154 /* TypeParameter */ // local types not visible outside the function body : false; } @@ -33241,13 +34165,13 @@ var ts; // however it is detected separately when checking initializers of parameters // to make sure that they reference no variables declared after them. useResult = - lastLocation.kind === 152 /* Parameter */ || + lastLocation.kind === 155 /* Parameter */ || (lastLocation === location.type && !!ts.findAncestor(result.valueDeclaration, ts.isParameter)); } } } - else if (location.kind === 176 /* ConditionalType */) { + else if (location.kind === 179 /* ConditionalType */) { // A type parameter declared using 'infer T' in a conditional type is visible only in // the true branch of the conditional type. useResult = lastLocation === location.trueType; @@ -33262,14 +34186,14 @@ var ts; } withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation); switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; // falls through - case 245 /* ModuleDeclaration */: - var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location)) { + case 248 /* ModuleDeclaration */: + var moduleExports = getSymbolOfNode(location).exports || emptySymbols; + if (location.kind === 288 /* SourceFile */ || (ts.isModuleDeclaration(location) && location.flags & 8388608 /* Ambient */ && !ts.isGlobalScopeAugmentation(location))) { // It's an external module. First see if the module has an export default and if the local // name of that export default matches. if (result = moduleExports.get("default" /* Default */)) { @@ -33293,7 +34217,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 2097152 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 258 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 261 /* ExportSpecifier */)) { break; } } @@ -33307,12 +34231,12 @@ var ts; } } break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript 1.0 spec (April 2014): 8.4.1 // Initializer expressions for instance member variables are evaluated in the scope // of the class constructor body but are not permitted to reference parameters or @@ -33329,9 +34253,9 @@ var ts; } } break; - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would // trigger resolving late-bound names, which we may already be in the process of doing while we're here! @@ -33350,7 +34274,7 @@ var ts; } break loop; } - if (location.kind === 210 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 213 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.escapedText) { result = location.symbol; @@ -33358,9 +34282,9 @@ var ts; } } break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // The type parameters of a class are not in scope in the base class expression. - if (lastLocation === location.expression && location.parent.token === 87 /* ExtendsKeyword */) { + if (lastLocation === location.expression && location.parent.token === 89 /* ExtendsKeyword */) { var container = location.parent.parent; if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968 /* Type */))) { if (nameNotFoundMessage) { @@ -33378,9 +34302,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 242 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 245 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -33388,24 +34312,24 @@ var ts; } } break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error if (compilerOptions.target >= 2 /* ES2015 */) { break; } // falls through - case 157 /* MethodDeclaration */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 240 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 243 /* FunctionDeclaration */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -33418,7 +34342,7 @@ var ts; } } break; - case 153 /* Decorator */: + case 156 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -33427,7 +34351,7 @@ var ts; // method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter. // } // - if (location.parent && location.parent.kind === 152 /* Parameter */) { + if (location.parent && location.parent.kind === 155 /* Parameter */) { location = location.parent; } // @@ -33442,25 +34366,25 @@ var ts; // declare function y(x: T): any; // @param(1 as T) // <-- T should resolve to the type alias outside of class C // class C {} - if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 241 /* ClassDeclaration */)) { + if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 244 /* ClassDeclaration */)) { location = location.parent; } break; - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: // js type aliases do not resolve names from their host, so skip past it location = ts.getJSDocHost(location); break; - case 152 /* Parameter */: + case 155 /* Parameter */: if (lastLocation && lastLocation === location.initializer) { associatedDeclarationForContainingInitializer = location; } break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: if (lastLocation && lastLocation === location.initializer) { var root = ts.getRootDeclaration(location); - if (root.kind === 152 /* Parameter */) { + if (root.kind === 155 /* Parameter */) { associatedDeclarationForContainingInitializer = location; } } @@ -33480,7 +34404,7 @@ var ts; } if (!result) { if (lastLocation) { - ts.Debug.assert(lastLocation.kind === 285 /* SourceFile */); + ts.Debug.assert(lastLocation.kind === 288 /* SourceFile */); if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) { return lastLocation.symbol; } @@ -33553,7 +34477,7 @@ var ts; } } // If we're in an external module, we can't reference value symbols created from UMD export declarations - if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 2097152 /* JSDoc */)) { + if (result && isInExternalModule && (meaning & 111551 /* Value */) === 111551 /* Value */ && !(originalLocation.flags & 4194304 /* JSDoc */)) { var merged = getMergedSymbol(result); if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) { errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, ts.unescapeLeadingUnderscores(name)); @@ -33576,10 +34500,10 @@ var ts; return result; } function getIsDeferredContext(location, lastLocation) { - if (location.kind !== 198 /* ArrowFunction */ && location.kind !== 197 /* FunctionExpression */) { + if (location.kind !== 201 /* ArrowFunction */ && location.kind !== 200 /* FunctionExpression */) { // initializers in instance property declaration of class like entities are executed in constructor and thus deferred return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) || - (location.kind === 155 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred + (location.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(location, 32 /* Static */))) && (!lastLocation || lastLocation !== location.name)); // A name is evaluated within the enclosing scope - so it shouldn't count as deferred } if (lastLocation && lastLocation === location.name) { return false; @@ -33592,12 +34516,12 @@ var ts; } function isSelfReferenceLocation(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 245 /* ModuleDeclaration */: // For `namespace N { N; }` + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 248 /* ModuleDeclaration */: // For `namespace N { N; }` return true; default: return false; @@ -33609,7 +34533,7 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 151 /* TypeParameter */) { + if (decl.kind === 154 /* TypeParameter */) { var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent; if (parent === container) { return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias)); // TODO: GH#18217 @@ -33664,10 +34588,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: if (ts.isEntityNameExpression(node.expression)) { return node.expression; } @@ -33755,11 +34679,15 @@ var ts; } function checkResolvedBlockScopedVariable(result, errorLocation) { ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); + if (result.flags & (16 /* Function */ | 1 /* FunctionScopedVariable */ | 67108864 /* Assignment */) && result.flags & 32 /* Class */) { + // constructor functions aren't block scoped + return; + } // Block-scoped variables cannot be used before their definition - var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 244 /* EnumDeclaration */); }); + var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 247 /* EnumDeclaration */); }); if (declaration === undefined) - return ts.Debug.fail("Declaration to checkResolvedBlockScopedVariable is undefined"); - if (!(declaration.flags & 4194304 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration"); + if (!(declaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { var diagnosticMessage = void 0; var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration)); if (result.flags & 2 /* BlockScopedVariable */) { @@ -33791,13 +34719,13 @@ var ts; } function getAnyImportSyntax(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return node; - case 251 /* ImportClause */: + case 254 /* ImportClause */: return node.parent; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return node.parent.parent; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return node.parent.parent.parent; default: return undefined; @@ -33807,7 +34735,7 @@ var ts; return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); @@ -33872,7 +34800,12 @@ var ts; ts.addRelatedInfo(err, ts.createDiagnosticForNode(exportAssignment, ts.Diagnostics.This_module_is_declared_with_using_export_and_can_only_be_used_with_a_default_import_when_using_the_0_flag, compilerOptionName)); } else { - error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + if (moduleSymbol.exports && moduleSymbol.exports.has(node.symbol.escapedName)) { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, symbolToString(moduleSymbol), symbolToString(node.symbol)); + } + else { + error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); + } } } else if (hasSyntheticDefault) { @@ -33884,7 +34817,7 @@ var ts; } function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias, /*suppressUsageError*/ false); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -33938,9 +34871,10 @@ var ts; function getExternalModuleMember(node, specifier, dontResolveAlias) { if (dontResolveAlias === void 0) { dontResolveAlias = false; } var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); // TODO: GH#18217 - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); + var name = specifier.propertyName || specifier.name; + var suppressInteropError = name.escapedText === "default" /* Default */ && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias, suppressInteropError); if (targetSymbol) { - var name = specifier.propertyName || specifier.name; if (name.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; @@ -33975,7 +34909,12 @@ var ts; } } else { - error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + if (moduleSymbol.exports && moduleSymbol.exports.has("default" /* Default */)) { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName); + } + else { + error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName); + } } } return symbol; @@ -33995,34 +34934,56 @@ var ts; } function getTargetOfExportAssignment(node, dontResolveAlias) { var expression = (ts.isExportAssignment(node) ? node.expression : node.right); + return getTargetOfAliasLikeExpression(expression, dontResolveAlias); + } + function getTargetOfAliasLikeExpression(expression, dontResolveAlias) { if (ts.isClassExpression(expression)) { - return checkExpression(expression).symbol; + return checkExpressionCached(expression).symbol; + } + if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) { + return undefined; } var aliasLike = resolveEntityName(expression, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontResolveAlias); if (aliasLike) { return aliasLike; } - checkExpression(expression); + checkExpressionCached(expression); return getNodeLinks(expression).resolvedSymbol; } + function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) { + var expression = node.initializer; + return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve); + } + function getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve) { + if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 /* EqualsToken */)) { + return undefined; + } + return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve); + } function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return getTargetOfImportClause(node, dontRecursivelyResolve); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return getTargetOfNamespaceImport(node, dontRecursivelyResolve); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return getTargetOfExportSpecifier(node, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, dontRecursivelyResolve); - case 255 /* ExportAssignment */: - case 205 /* BinaryExpression */: + case 258 /* ExportAssignment */: + case 208 /* BinaryExpression */: return getTargetOfExportAssignment(node, dontRecursivelyResolve); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); + case 280 /* ShorthandPropertyAssignment */: + return resolveEntityName(node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ true, dontRecursivelyResolve); + case 279 /* PropertyAssignment */: + return getTargetOfPropertyAssignment(node, dontRecursivelyResolve); + case 193 /* PropertyAccessExpression */: + return getTargetOfPropertyAccessExpression(node, dontRecursivelyResolve); default: return ts.Debug.fail(); } @@ -34102,17 +35063,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 73 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 75 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 73 /* Identifier */ || entityName.parent.kind === 149 /* QualifiedName */) { + if (entityName.kind === 75 /* Identifier */ || entityName.parent.kind === 152 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 249 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 252 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -34128,17 +35089,17 @@ var ts; } var namespaceMeaning = 1920 /* Namespace */ | (ts.isInJSFile(name) ? meaning & 111551 /* Value */ : 0); var symbol; - if (name.kind === 73 /* Identifier */) { - var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(getFirstIdentifier(name)); + if (name.kind === 75 /* Identifier */) { + var message = meaning === namespaceMeaning ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name)); var symbolFromJSPrototype = ts.isInJSFile(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined; symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, /*isUse*/ true); if (!symbol) { return symbolFromJSPrototype; } } - else if (name.kind === 149 /* QualifiedName */ || name.kind === 190 /* PropertyAccessExpression */) { - var left = name.kind === 149 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 149 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 152 /* QualifiedName */ || name.kind === 193 /* PropertyAccessExpression */) { + var left = name.kind === 152 /* QualifiedName */ ? name.left : name.expression; + var right = name.kind === 152 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -34190,7 +35151,7 @@ var ts; } } function getAssignmentDeclarationLocation(node) { - var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 2097152 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); + var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304 /* JSDoc */) ? "quit" : ts.isJSDocTypeAlias(node); }); if (typeAlias) { return; } @@ -34229,6 +35190,20 @@ var ts; undefined; return initializer || decl; } + /** + * Get the real symbol of a declaration with an expando initializer. + * + * Normally, declarations have an associated symbol, but when a declaration has an expando + * initializer, the expando's symbol is the one that has all the members merged into it. + */ + function getExpandoSymbol(symbol) { + var decl = symbol.valueDeclaration; + if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 /* TypeAlias */) { + return undefined; + } + var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl); + return init && getSymbolOfNode(init) || undefined; + } function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) { return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : ts.Diagnostics.Cannot_find_module_0); } @@ -34240,9 +35215,6 @@ var ts; } function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReference === undefined) { - return; - } if (ts.startsWith(moduleReference, "@types/")) { var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1; var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/"); @@ -34273,7 +35245,7 @@ var ts; if (patternAmbientModules) { var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference); if (pattern) { - // If the module reference matched a pattern ambient module ('*.foo') but there’s also a + // If the module reference matched a pattern ambient module ('*.foo') but there's also a // module augmentation by the specific name requested ('a.foo'), we store the merged symbol // by the augmentation name ('a.foo'), because asking for *.foo should not give you exports // from a.foo. @@ -34344,7 +35316,7 @@ var ts; function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { if (moduleSymbol) { var exportEquals = resolveSymbol(moduleSymbol.exports.get("export=" /* ExportEquals */), dontResolveAlias); - var exported = getCommonJsExportEquals(exportEquals, moduleSymbol); + var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol)); return getMergedSymbol(exported) || moduleSymbol; } return undefined; @@ -34353,9 +35325,13 @@ var ts; if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152 /* Alias */) { return exported; } - var merged = cloneSymbol(exported); + var links = getSymbolLinks(exported); + if (links.cjsExportMerged) { + return links.cjsExportMerged; + } + var merged = exported.flags & 33554432 /* Transient */ ? exported : cloneSymbol(exported); + merged.flags = merged.flags | 512 /* ValueModule */; if (merged.exports === undefined) { - merged.flags = merged.flags | 512 /* ValueModule */; merged.exports = ts.createSymbolTable(); } moduleSymbol.exports.forEach(function (s, name) { @@ -34363,15 +35339,16 @@ var ts; return; merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s); }); - return merged; + getSymbolLinks(merged).cjsExportMerged = merged; + return links.cjsExportMerged = merged; } // An external module with an 'export =' declaration may be referenced as an ES6 module provided the 'export =' // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias) { + function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) { var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol) { - if (!(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 285 /* SourceFile */)) { + if (!suppressInteropError && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */)) && !ts.getDeclarationOfKind(symbol, 288 /* SourceFile */)) { var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop"; @@ -34445,7 +35422,7 @@ var ts; return type.flags & 131068 /* Primitive */ ? undefined : getPropertyOfType(type, memberName); } function getExportsOfSymbol(symbol) { - return symbol.flags & 32 /* Class */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports" /* resolvedExports */) : symbol.flags & 1536 /* Module */ ? getExportsOfModule(symbol) : symbol.exports || emptySymbols; } @@ -34582,7 +35559,8 @@ var ts; */ function getContainersOfSymbol(symbol, enclosingDeclaration) { var container = getParentOfSymbol(symbol); - if (container) { + // Type parameters end up in the `members` lists but are not externally visible + if (container && !(symbol.flags & 262144 /* TypeParameter */)) { var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer); var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration); if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920 /* Namespace */, /*externalOnly*/ false)) { @@ -34591,7 +35569,18 @@ var ts; var res = ts.append(additionalContainers, container); return ts.concatenate(res, reexportContainers); } - var candidates = ts.mapDefined(symbol.declarations, function (d) { return !ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent) ? getSymbolOfNode(d.parent) : undefined; }); + var candidates = ts.mapDefined(symbol.declarations, function (d) { + if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) { + return getSymbolOfNode(d.parent); + } + if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 /* EqualsToken */ && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) { + if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) { + return getSymbolOfNode(ts.getSourceFileOfNode(d)); + } + checkExpressionCached(d.parent.left.expression); + return getNodeLinks(d.parent.left.expression).resolvedSymbol; + } + }); if (!ts.length(candidates)) { return undefined; } @@ -34599,7 +35588,7 @@ var ts; function fileSymbolIfFileSymbolExportEqualsContainer(d) { var fileSymbol = getExternalModuleContainer(d); var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=" /* ExportEquals */); - return resolveSymbol(exported) === resolveSymbol(container) ? fileSymbol : undefined; + return exported && container && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined; } } function getAliasForSymbolInContainer(container, symbol) { @@ -34607,20 +35596,29 @@ var ts; // fast path, `symbol` is either already the alias or isn't aliased return symbol; } + // Check if container is a thing with an `export=` which points directly at `symbol`, and if so, return + // the container itself as the alias for the symbol + var exportEquals = container.exports && container.exports.get("export=" /* ExportEquals */); + if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) { + return container; + } var exports = getExportsOfSymbol(container); var quick = exports.get(symbol.escapedName); - if (quick && symbolRefersToTarget(quick)) { + if (quick && getSymbolIfSameReference(quick, symbol)) { return quick; } return ts.forEachEntry(exports, function (exported) { - if (symbolRefersToTarget(exported)) { + if (getSymbolIfSameReference(exported, symbol)) { return exported; } }); - function symbolRefersToTarget(s) { - if (s === symbol || resolveSymbol(s) === symbol || resolveSymbol(s) === resolveSymbol(symbol)) { - return s; - } + } + /** + * Checks if two symbols, through aliasing and/or merging, refer to the same thing + */ + function getSymbolIfSameReference(s1, s2) { + if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) { + return s1; } } function getExportSymbolOfValueSymbolIfExported(symbol) { @@ -34633,7 +35631,7 @@ var ts; var members = node.members; for (var _i = 0, members_2 = members; _i < members_2.length; _i++) { var member = members_2[_i]; - if (member.kind === 158 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 161 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -34711,25 +35709,55 @@ var ts; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; - for (var location = enclosingDeclaration; location; location = location.parent) { + var _loop_5 = function (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { if (result = callback(location.locals)) { - return result; + return { value: result }; } } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } // falls through - case 245 /* ModuleDeclaration */: - if (result = callback(getSymbolOfNode(location).exports)) { - return result; + case 248 /* ModuleDeclaration */: + var sym = getSymbolOfNode(location); + // `sym` may not have exports if this module declaration is backed by the symbol for a `const` that's being rewritten + // into a namespace - in such cases, it's best to just let the namespace appear empty (the const members couldn't have referred + // to one another anyway) + if (result = callback(sym.exports || emptySymbols)) { + return { value: result }; + } + break; + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + // Type parameters are bound into `members` lists so they can merge across declarations + // This is troublesome, since in all other respects, they behave like locals :cries: + // TODO: the below is shared with similar code in `resolveName` - in fact, rephrasing all this symbol + // lookup logic in terms of `resolveName` would be nice + // The below is used to lookup type parameters within a class or interface, as they are added to the class/interface locals + // These can never be latebound, so the symbol's raw members are sufficient. `getMembersOfNode` cannot be used, as it would + // trigger resolving late-bound names, which we may already be in the process of doing while we're here! + var table_1; + // TODO: Should this filtered table be cached in some way? + (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) { + if (memberSymbol.flags & (788968 /* Type */ & ~67108864 /* Assignment */)) { + (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol); + } + }); + if (table_1 && (result = callback(table_1))) { + return { value: result }; } break; } + }; + for (var location = enclosingDeclaration; location; location = location.parent) { + var state_2 = _loop_5(location); + if (typeof state_2 === "object") + return state_2.value; } return callback(globals); } @@ -34766,12 +35794,12 @@ var ts; !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap); } function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) { - return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) && // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) // and if symbolFromSymbolTable or alias resolution matches the symbol, // check the symbol can be qualified, it is only then this symbol is accessible !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) && - (ignoreQualification || canQualifySymbol(symbolFromSymbolTable, meaning)); + (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning)); } function trySymbolTable(symbols, ignoreQualification) { // If symbol is directly available by its name in the symbol table @@ -34788,7 +35816,7 @@ var ts; && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) // While exports are generally considered to be in scope, export-specifier declared symbols are _not_ // See similar comment in `resolveName` for details - && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */))) { + && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */))) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) { return [symbolFromSymbolTable]; @@ -34824,7 +35852,7 @@ var ts; return true; } // Qualify if the symbol from symbol table has same meaning as expected - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 258 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 261 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -34839,10 +35867,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: continue; default: return false; @@ -34959,14 +35987,14 @@ var ts; return node && getSymbolOfNode(node); } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasNonGlobalAugmentationExternalModuleSymbol(declaration) { - return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; - if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 73 /* Identifier */; }), getIsDeclarationVisible)) { + if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 75 /* Identifier */; }), getIsDeclarationVisible)) { return undefined; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: aliasesToMakeVisible }; @@ -35009,14 +36037,14 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 168 /* TypeQuery */ || + if (entityName.parent.kind === 171 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) || - entityName.parent.kind === 150 /* ComputedPropertyName */) { + entityName.parent.kind === 153 /* ComputedPropertyName */) { // Typeof value meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 149 /* QualifiedName */ || entityName.kind === 190 /* PropertyAccessExpression */ || - entityName.parent.kind === 249 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 152 /* QualifiedName */ || entityName.kind === 193 /* PropertyAccessExpression */ || + entityName.parent.kind === 252 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -35025,7 +36053,7 @@ var ts; // Type Reference or TypeAlias entity = Identifier meaning = 788968 /* Type */; } - var firstIdentifier = getFirstIdentifier(entityName); + var firstIdentifier = ts.getFirstIdentifier(entityName); var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { @@ -35065,15 +36093,15 @@ var ts; function signatureToStringWorker(writer) { var sigOutput; if (flags & 262144 /* WriteArrowStyleSignature */) { - sigOutput = kind === 1 /* Construct */ ? 167 /* ConstructorType */ : 166 /* FunctionType */; + sigOutput = kind === 1 /* Construct */ ? 170 /* ConstructorType */ : 169 /* FunctionType */; } else { - sigOutput = kind === 1 /* Construct */ ? 162 /* ConstructSignature */ : 161 /* CallSignature */; + sigOutput = kind === 1 /* Construct */ ? 165 /* ConstructSignature */ : 164 /* CallSignature */; } var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */); var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonOmittingWriter(writer)); // TODO: GH#18217 + printer.writeNode(4 /* Unspecified */, sig, /*sourceFile*/ sourceFile, ts.getTrailingSemicolonDeferringWriter(writer)); // TODO: GH#18217 return writer; } } @@ -35096,14 +36124,17 @@ var ts; return result; } function getTypeNamesForErrorDisplay(left, right) { - var leftStr = typeToString(left); - var rightStr = typeToString(right); + var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left); + var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right); if (leftStr === rightStr) { leftStr = typeToString(left, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); rightStr = typeToString(right, /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */); } return [leftStr, rightStr]; } + function symbolValueDeclarationIsContextSensitive(symbol) { + return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration); + } function toNodeBuilderFlags(flags) { if (flags === void 0) { flags = 0 /* None */; } return flags & 9469291 /* NodeBuilderFlagsMask */; @@ -35134,6 +36165,9 @@ var ts; typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) { return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); }); }, + symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) { + return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); }); + }, }; function withContext(enclosingDeclaration, flags, tracker, cb) { ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8 /* Synthesized */) === 0); @@ -35144,7 +36178,8 @@ var ts; tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 /* DoNotIncludeSymbolChain */ ? { getCommonSourceDirectory: host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; }, getSourceFiles: function () { return host.getSourceFiles(); }, - getCurrentDirectory: host.getCurrentDirectory && (function () { return host.getCurrentDirectory(); }) + getCurrentDirectory: ts.maybeBind(host, host.getCurrentDirectory), + getProbableSymlinks: ts.maybeBind(host, host.getProbableSymlinks), } : undefined }, encounteredError: false, visitedTypes: undefined, @@ -35172,26 +36207,26 @@ var ts; } if (type.flags & 1 /* Any */) { context.approximateLength += 3; - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } if (type.flags & 2 /* Unknown */) { - return ts.createKeywordTypeNode(144 /* UnknownKeyword */); + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); } if (type.flags & 4 /* String */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(139 /* StringKeyword */); + return ts.createKeywordTypeNode(142 /* StringKeyword */); } if (type.flags & 8 /* Number */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(136 /* NumberKeyword */); + return ts.createKeywordTypeNode(139 /* NumberKeyword */); } if (type.flags & 64 /* BigInt */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(147 /* BigIntKeyword */); + return ts.createKeywordTypeNode(150 /* BigIntKeyword */); } if (type.flags & 16 /* Boolean */) { context.approximateLength += 7; - return ts.createKeywordTypeNode(124 /* BooleanKeyword */); + return ts.createKeywordTypeNode(127 /* BooleanKeyword */); } if (type.flags & 1024 /* EnumLiteral */ && !(type.flags & 1048576 /* Union */)) { var parentSymbol = getParentOfSymbol(type.symbol); @@ -35211,7 +36246,7 @@ var ts; if (type.flags & 256 /* NumberLiteral */) { var value = type.value; context.approximateLength += ("" + value).length; - return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(39 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); + return ts.createLiteralTypeNode(value < 0 ? ts.createPrefix(40 /* MinusToken */, ts.createLiteral(-value)) : ts.createLiteral(value)); } if (type.flags & 2048 /* BigIntLiteral */) { context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1; @@ -35232,31 +36267,31 @@ var ts; } } context.approximateLength += 13; - return ts.createTypeOperatorNode(143 /* UniqueKeyword */, ts.createKeywordTypeNode(140 /* SymbolKeyword */)); + return ts.createTypeOperatorNode(146 /* UniqueKeyword */, ts.createKeywordTypeNode(143 /* SymbolKeyword */)); } if (type.flags & 16384 /* Void */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(107 /* VoidKeyword */); + return ts.createKeywordTypeNode(109 /* VoidKeyword */); } if (type.flags & 32768 /* Undefined */) { context.approximateLength += 9; - return ts.createKeywordTypeNode(142 /* UndefinedKeyword */); + return ts.createKeywordTypeNode(145 /* UndefinedKeyword */); } if (type.flags & 65536 /* Null */) { context.approximateLength += 4; - return ts.createKeywordTypeNode(97 /* NullKeyword */); + return ts.createKeywordTypeNode(99 /* NullKeyword */); } if (type.flags & 131072 /* Never */) { context.approximateLength += 5; - return ts.createKeywordTypeNode(133 /* NeverKeyword */); + return ts.createKeywordTypeNode(136 /* NeverKeyword */); } if (type.flags & 4096 /* ESSymbol */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(140 /* SymbolKeyword */); + return ts.createKeywordTypeNode(143 /* SymbolKeyword */); } if (type.flags & 67108864 /* NonPrimitive */) { context.approximateLength += 6; - return ts.createKeywordTypeNode(137 /* ObjectKeyword */); + return ts.createKeywordTypeNode(140 /* ObjectKeyword */); } if (isThisTypeParameter(type)) { if (context.flags & 4194304 /* InObjectTypeLiteral */) { @@ -35270,10 +36305,16 @@ var ts; context.approximateLength += 4; return ts.createThis(); } + if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { + var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); + if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) + return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); + return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); + } var objectFlags = ts.getObjectFlags(type); if (objectFlags & 4 /* Reference */) { ts.Debug.assert(!!(type.flags & 524288 /* Object */)); - return typeReferenceToTypeNode(type); + return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type); } if (type.flags & 262144 /* TypeParameter */ || objectFlags & 3 /* ClassOrInterface */) { if (type.flags & 262144 /* TypeParameter */ && ts.contains(context.inferTypeParameters, type)) { @@ -35281,6 +36322,7 @@ var ts; return ts.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, /*constraintNode*/ undefined)); } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && + type.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) { var name = typeParameterToName(type, context); context.approximateLength += ts.idText(name).length; @@ -35291,12 +36333,6 @@ var ts; ? symbolToTypeNode(type.symbol, context, 788968 /* Type */) : ts.createTypeReferenceNode(ts.createIdentifier("?"), /*typeArguments*/ undefined); } - if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 /* UseAliasDefinedOutsideCurrentScope */ || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) { - var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32 /* Class */)) - return ts.createTypeReferenceNode(ts.createIdentifier(""), typeArgumentNodes); - return symbolToTypeNode(type.aliasSymbol, context, 788968 /* Type */, typeArgumentNodes); - } if (type.flags & (1048576 /* Union */ | 2097152 /* Intersection */)) { var types = type.flags & 1048576 /* Union */ ? formatUnionTypes(type.types) : type.types; if (ts.length(types) === 1) { @@ -35304,7 +36340,7 @@ var ts; } var typeNodes = mapToTypeNodes(types, context, /*isBareList*/ true); if (typeNodes && typeNodes.length > 0) { - var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 174 /* UnionType */ : 175 /* IntersectionType */, typeNodes); + var unionOrIntersectionTypeNode = ts.createUnionOrIntersectionTypeNode(type.flags & 1048576 /* Union */ ? 177 /* UnionType */ : 178 /* IntersectionType */, typeNodes); return unionOrIntersectionTypeNode; } else { @@ -35368,17 +36404,14 @@ var ts; function createAnonymousTypeNode(type) { var typeId = "" + type.id; var symbol = type.symbol; - var id; if (symbol) { - var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; - id = (isConstructorObject ? "+" : "") + getSymbolId(symbol); if (isJSConstructor(symbol.valueDeclaration)) { // Instance and static types share the same symbol; only add 'typeof' for the static side. - var isInstanceType = type === getInferredClassType(symbol) ? 788968 /* Type */ : 111551 /* Value */; + var isInstanceType = type === getDeclaredTypeOfClassOrInterface(symbol) ? 788968 /* Type */ : 111551 /* Value */; return symbolToTypeNode(symbol, context, isInstanceType); } // Always use 'typeof T' for type of class, enum, and module objects - else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 210 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || + else if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 213 /* ClassExpression */ && context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */) || symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || shouldWriteTypeOfFunctionSymbol()) { return symbolToTypeNode(symbol, context, 111551 /* Value */); @@ -35395,24 +36428,7 @@ var ts; } } else { - // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead - // of types allows us to catch circular references to instantiations of the same anonymous type - if (!context.visitedTypes) { - context.visitedTypes = ts.createMap(); - } - if (!context.symbolDepth) { - context.symbolDepth = ts.createMap(); - } - var depth = context.symbolDepth.get(id) || 0; - if (depth > 10) { - return createElidedInformationPlaceholder(context); - } - context.symbolDepth.set(id, depth + 1); - context.visitedTypes.set(typeId, true); - var result = createTypeNodeFromObjectType(type); - context.visitedTypes.delete(typeId); - context.symbolDepth.set(id, depth); - return result; + return visitAndTransformType(type, createTypeNodeFromObjectType); } } else { @@ -35425,15 +36441,45 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || // is exported function symbol ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 285 /* SourceFile */ || declaration.parent.kind === 246 /* ModuleBlock */; + return declaration.parent.kind === 288 /* SourceFile */ || declaration.parent.kind === 249 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions return (!!(context.flags & 4096 /* UseTypeOfFunction */) || (context.visitedTypes && context.visitedTypes.has(typeId))) && // it is type of the symbol uses itself recursively - (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // TODO: GH#18217 // And the build is going to succeed without visibility error or there is no structural fallback allowed + (!(context.flags & 8 /* UseStructuralFallback */) || isValueSymbolAccessible(symbol, context.enclosingDeclaration)); // And the build is going to succeed without visibility error or there is no structural fallback allowed } } } + function visitAndTransformType(type, transform) { + var typeId = "" + type.id; + var isConstructorObject = ts.getObjectFlags(type) & 16 /* Anonymous */ && type.symbol && type.symbol.flags & 32 /* Class */; + var id = ts.getObjectFlags(type) & 4 /* Reference */ && type.node ? "N" + getNodeId(type.node) : + type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) : + undefined; + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.visitedTypes) { + context.visitedTypes = ts.createMap(); + } + if (id && !context.symbolDepth) { + context.symbolDepth = ts.createMap(); + } + var depth; + if (id) { + depth = context.symbolDepth.get(id) || 0; + if (depth > 10) { + return createElidedInformationPlaceholder(context); + } + context.symbolDepth.set(id, depth + 1); + } + context.visitedTypes.set(typeId, true); + var result = transform(type); + context.visitedTypes.delete(typeId); + if (id) { + context.symbolDepth.set(id, depth); + } + return result; + } function createTypeNodeFromObjectType(type) { if (isGenericMappedType(type)) { return createMappedTypeNodeFromType(type); @@ -35446,12 +36492,12 @@ var ts; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var signature = resolved.callSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 166 /* FunctionType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 169 /* FunctionType */, context); return signatureNode; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { var signature = resolved.constructSignatures[0]; - var signatureNode = signatureToSignatureDeclarationHelper(signature, 167 /* ConstructorType */, context); + var signatureNode = signatureToSignatureDeclarationHelper(signature, 170 /* ConstructorType */, context); return signatureNode; } } @@ -35464,7 +36510,7 @@ var ts; return ts.setEmitFlags(typeLiteralNode, (context.flags & 1024 /* MultilineObjectLiterals */) ? 0 : 1 /* SingleLine */); } function typeReferenceToTypeNode(type) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); if (type.target === globalArrayType || type.target === globalReadonlyArrayType) { if (context.flags & 2 /* WriteArrayAsGenericType */) { var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); @@ -35472,7 +36518,7 @@ var ts; } var elementType = typeToTypeNodeHelper(typeArguments[0], context); var arrayType = ts.createArrayTypeNode(elementType); - return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, arrayType); + return type.target === globalArrayType ? arrayType : ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, arrayType); } else if (type.target.objectFlags & 8 /* Tuple */) { if (typeArguments.length > 0) { @@ -35486,12 +36532,12 @@ var ts; ts.createOptionalTypeNode(tupleConstituentNodes[i]); } var tupleTypeNode = ts.createTupleTypeNode(tupleConstituentNodes); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } } if (context.encounteredError || (context.flags & 524288 /* AllowEmptyTuple */)) { var tupleTypeNode = ts.createTupleTypeNode([]); - return type.target.readonly ? ts.createTypeOperatorNode(134 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; + return type.target.readonly ? ts.createTypeOperatorNode(137 /* ReadonlyKeyword */, tupleTypeNode) : tupleTypeNode; } context.encounteredError = true; return undefined; // TODO: GH#18217 @@ -35586,11 +36632,11 @@ var ts; var typeElements = []; for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 161 /* CallSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 164 /* CallSignature */, context)); } for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; - typeElements.push(signatureToSignatureDeclarationHelper(signature, 162 /* ConstructSignature */, context)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, 165 /* ConstructSignature */, context)); } if (resolvedType.stringIndexInfo) { var indexSignature = void 0; @@ -35637,7 +36683,7 @@ var ts; if (!(context.flags & 1 /* NoTruncation */)) { return ts.createTypeReferenceNode(ts.createIdentifier("..."), /*typeArguments*/ undefined); } - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } function addPropertyToElementList(propertySymbol, context, typeElements) { var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192 /* ReverseMapped */); @@ -35648,25 +36694,29 @@ var ts; if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 /* Late */) { var decl = ts.first(propertySymbol.declarations); if (hasLateBindableName(decl)) { - trackComputedName(decl.name, saveEnclosingDeclaration, context); + if (ts.isBinaryExpression(decl)) { + var name = ts.getNameOfDeclaration(decl); + if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) { + trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context); + } + } + else { + trackComputedName(decl.name.expression, saveEnclosingDeclaration, context); + } } } var propertyName = symbolToName(propertySymbol, context, 111551 /* Value */, /*expectsIdentifier*/ true); context.approximateLength += (ts.symbolName(propertySymbol).length + 1); context.enclosingDeclaration = saveEnclosingDeclaration; - var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(56 /* QuestionToken */) : undefined; + var optionalToken = propertySymbol.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined; if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) { var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768 /* Undefined */); }), 0 /* Call */); for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) { var signature = signatures_1[_i]; - var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 156 /* MethodSignature */, context); + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 159 /* MethodSignature */, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; - if (propertySymbol.valueDeclaration) { - // Copy comments to node for declaration emit - ts.setCommentRange(methodDeclaration, propertySymbol.valueDeclaration); - } - typeElements.push(methodDeclaration); + typeElements.push(preserveCommentsOn(methodDeclaration)); } } else { @@ -35677,20 +36727,30 @@ var ts; propertyTypeNode = createElidedInformationPlaceholder(context); } else { - propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.flags = savedFlags; - var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined; + var modifiers = isReadonlySymbol(propertySymbol) ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined; if (modifiers) { context.approximateLength += 9; } var propertySignature = ts.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode, /*initializer*/ undefined); - if (propertySymbol.valueDeclaration) { + typeElements.push(preserveCommentsOn(propertySignature)); + } + function preserveCommentsOn(node) { + if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; })) { + var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 316 /* JSDocPropertyTag */; }); + var commentText = d.comment; + if (commentText) { + ts.setSyntheticLeadingComments(node, [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]); + } + } + else if (propertySymbol.valueDeclaration) { // Copy comments to node for declaration emit - ts.setCommentRange(propertySignature, propertySymbol.valueDeclaration); + ts.setCommentRange(node, propertySymbol.valueDeclaration); } - typeElements.push(propertySignature); + return node; } } function mapToTypeNodes(types, context, isBareList) { @@ -35731,7 +36791,7 @@ var ts; } function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context) { var name = ts.getNameFromIndexInfo(indexInfo) || "x"; - var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 139 /* StringKeyword */ : 136 /* NumberKeyword */); + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 142 /* StringKeyword */ : 139 /* NumberKeyword */); var indexingParameter = ts.createParameter( /*decorators*/ undefined, /*modifiers*/ undefined, @@ -35744,7 +36804,7 @@ var ts; } context.approximateLength += (name.length + 4); return ts.createIndexSignature( - /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(134 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(137 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); } function signatureToSignatureDeclarationHelper(signature, kind, context) { var typeParameters; @@ -35755,7 +36815,7 @@ var ts; else { typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); }); } - var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 158 /* Constructor */); }); + var parameters = getExpandedParameters(signature).map(function (parameter) { return symbolToParameterDeclaration(parameter, context, kind === 161 /* Constructor */); }); if (signature.thisParameter) { var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); parameters.unshift(thisParameter); @@ -35763,23 +36823,26 @@ var ts; var returnTypeNode; var typePredicate = getTypePredicateOfSignature(signature); if (typePredicate) { - var parameterName = typePredicate.kind === 1 /* Identifier */ ? + var assertsModifier = typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? + ts.createToken(123 /* AssertsKeyword */) : + undefined; + var parameterName = typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.setEmitFlags(ts.createIdentifier(typePredicate.parameterName), 16777216 /* NoAsciiEscaping */) : ts.createThisTypeNode(); - var typeNode = typeToTypeNodeHelper(typePredicate.type, context); - returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context); + returnTypeNode = ts.createTypePredicateNodeWithModifier(assertsModifier, parameterName, typeNode); } else { var returnType = getReturnTypeOfSignature(signature); returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } if (context.flags & 256 /* SuppressAnyReturnType */) { - if (returnTypeNode && returnTypeNode.kind === 121 /* AnyKeyword */) { + if (returnTypeNode && returnTypeNode.kind === 124 /* AnyKeyword */) { returnTypeNode = undefined; } } else if (!returnTypeNode) { - returnTypeNode = ts.createKeywordTypeNode(121 /* AnyKeyword */); + returnTypeNode = ts.createKeywordTypeNode(124 /* AnyKeyword */); } context.approximateLength += 3; // Usually a signature contributes a few more characters than this, but 3 is the minimum return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode, typeArguments); @@ -35799,9 +36862,9 @@ var ts; return typeParameterToDeclarationWithConstraint(type, context, constraintNode); } function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) { - var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 152 /* Parameter */); + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 155 /* Parameter */); if (!parameterDeclaration && !isTransientSymbol(parameterSymbol)) { - parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 307 /* JSDocParameterTag */); + parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 310 /* JSDocParameterTag */); } var parameterType = getTypeOfSymbol(parameterSymbol); if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) { @@ -35811,15 +36874,14 @@ var ts; var modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.getSynthesizedClone) : undefined; var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768 /* RestParameter */; var dotDotDotToken = isRest ? ts.createToken(25 /* DotDotDotToken */) : undefined; - var name = parameterDeclaration - ? parameterDeclaration.name ? - parameterDeclaration.name.kind === 73 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : - parameterDeclaration.name.kind === 149 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : - cloneBindingName(parameterDeclaration.name) : - ts.symbolName(parameterSymbol) - : ts.symbolName(parameterSymbol); + var name = parameterDeclaration ? parameterDeclaration.name ? + parameterDeclaration.name.kind === 75 /* Identifier */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name), 16777216 /* NoAsciiEscaping */) : + parameterDeclaration.name.kind === 152 /* QualifiedName */ ? ts.setEmitFlags(ts.getSynthesizedClone(parameterDeclaration.name.right), 16777216 /* NoAsciiEscaping */) : + cloneBindingName(parameterDeclaration.name) : + ts.symbolName(parameterSymbol) : + ts.symbolName(parameterSymbol); var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384 /* OptionalParameter */; - var questionToken = isOptional ? ts.createToken(56 /* QuestionToken */) : undefined; + var questionToken = isOptional ? ts.createToken(57 /* QuestionToken */) : undefined; var parameterNode = ts.createParameter( /*decorators*/ undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, /*initializer*/ undefined); @@ -35829,22 +36891,22 @@ var ts; return elideInitializerAndSetEmitFlags(node); function elideInitializerAndSetEmitFlags(node) { if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) { - trackComputedName(node, context.enclosingDeclaration, context); + trackComputedName(node.expression, context.enclosingDeclaration, context); } var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); var clone = ts.nodeIsSynthesized(visited) ? visited : ts.getSynthesizedClone(visited); - if (clone.kind === 187 /* BindingElement */) { + if (clone.kind === 190 /* BindingElement */) { clone.initializer = undefined; } return ts.setEmitFlags(clone, 1 /* SingleLine */ | 16777216 /* NoAsciiEscaping */); } } } - function trackComputedName(node, enclosingDeclaration, context) { + function trackComputedName(accessExpression, enclosingDeclaration, context) { if (!context.tracker.trackSymbol) return; // get symbol of the first identifier of the entityName - var firstIdentifier = getFirstIdentifier(node.expression); + var firstIdentifier = ts.getFirstIdentifier(accessExpression); var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 /* Value */ | 1048576 /* ExportValue */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (name) { context.tracker.trackSymbol(name, enclosingDeclaration, 111551 /* Value */); @@ -35852,6 +36914,9 @@ var ts; } function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) { context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning); // TODO: GH#18217 + return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol); + } + function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. var chain; var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; @@ -35884,6 +36949,13 @@ var ts; var parent = sortedParents_1[_i]; var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); if (parentChain) { + if (parent.exports && parent.exports.get("export=" /* ExportEquals */) && + getSymbolIfSameReference(parent.exports.get("export=" /* ExportEquals */), symbol)) { + // parentChain root _is_ symbol - symbol is a module export=, so it kinda looks like it's own parent + // No need to lookup an alias for the symbol in itself + accessibleSymbolChain = parentChain; + break; + } accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]); break; } @@ -35964,7 +37036,7 @@ var ts; return top; } function getSpecifierForModuleSymbol(symbol, context) { - var file = ts.getDeclarationOfKind(symbol, 285 /* SourceFile */); + var file = ts.getDeclarationOfKind(symbol, 288 /* SourceFile */); if (file && file.moduleName !== undefined) { // Use the amd name if it is available return file.moduleName; @@ -36056,16 +37128,32 @@ var ts; function createAccessFromSymbolChain(chain, index, stopper) { var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; + var parent = chain[index - 1]; + var symbolName; if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; - } - var symbolName = getNameOfSymbolAsWritten(symbol, context); - context.approximateLength += symbolName.length + 1; - if (index === 0) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + context.approximateLength += (symbolName ? symbolName.length : 0) + 1; context.flags ^= 16777216 /* InInitialEntityName */; } - var parent = chain[index - 1]; - if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) === symbol) { + else { + if (parent && getExportsOfSymbol(parent)) { + var exports_1 = getExportsOfSymbol(parent); + ts.forEachEntry(exports_1, function (ex, name) { + if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=" /* ExportEquals */) { + symbolName = ts.unescapeLeadingUnderscores(name); + return true; + } + }); + } + } + if (!symbolName) { + symbolName = getNameOfSymbolAsWritten(symbol, context); + } + context.approximateLength += symbolName.length + 1; + if (!(context.flags & 16 /* ForbidIndexedAccessSymbolReferences */) && parent && + getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) && + getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) { // Should use an indexed access var LHS = createAccessFromSymbolChain(chain, index - 1, stopper); if (ts.isIndexedAccessTypeNode(LHS)) { @@ -36098,6 +37186,9 @@ var ts; } } var result = symbolToName(type.symbol, context, 788968 /* Type */, /*expectsIdentifier*/ true); + if (!(result.kind & 75 /* Identifier */)) { + return ts.createIdentifier("(Missing type parameter)"); + } if (context.flags & 4 /* GenerateNamesForShadowedTypeParams */) { var rawtext = result.escapedText; var i = 0; @@ -36143,9 +37234,6 @@ var ts; function createExpressionFromSymbolChain(chain, index) { var typeParameterNodes = lookupTypeParameterNodes(chain, index, context); var symbol = chain[index]; - if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { - return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); - } if (index === 0) { context.flags |= 16777216 /* InInitialEntityName */; } @@ -36154,6 +37242,9 @@ var ts; context.flags ^= 16777216 /* InInitialEntityName */; } var firstChar = symbolName.charCodeAt(0); + if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) { + return ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)); + } var canUsePropertyAccess = ts.isIdentifierStart(firstChar, languageVersion); if (index === 0 || canUsePropertyAccess) { var identifier = ts.setEmitFlags(ts.createIdentifier(symbolName, typeParameterNodes), 16777216 /* NoAsciiEscaping */); @@ -36181,12 +37272,1104 @@ var ts; } } } + function getPropertyNameNodeForSymbol(symbol, context) { + var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context); + if (fromNameType) { + return fromNameType; + } + var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName); + return createPropertyNameNodeForIdentifierOrLiteral(rawName); + } + // See getNameForSymbolFromNameType for a stringy equivalent + function getPropertyNameNodeForSymbolFromNameType(symbol, context) { + var nameType = symbol.nameType; + if (nameType) { + if (nameType.flags & 384 /* StringOrNumberLiteral */) { + var name = "" + nameType.value; + if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + return ts.createLiteral(name); + } + if (isNumericLiteralName(name) && ts.startsWith(name, "-")) { + return ts.createComputedPropertyName(ts.createLiteral(+name)); + } + return createPropertyNameNodeForIdentifierOrLiteral(name); + } + if (nameType.flags & 8192 /* UniqueESSymbol */) { + return ts.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551 /* Value */)); + } + } + } + function createPropertyNameNodeForIdentifierOrLiteral(name) { + return ts.isIdentifierText(name, compilerOptions.target) ? ts.createIdentifier(name) : ts.createLiteral(isNumericLiteralName(name) ? +name : name); + } + function cloneNodeBuilderContext(context) { + var initial = __assign({}, context); + // Make type parameters created within this context not consume the name outside this context + // The symbol serializer ends up creating many sibling scopes that all need "separate" contexts when + // it comes to naming things - within a normal `typeToTypeNode` call, the node builder only ever descends + // through the type tree, so the only cases where we could have used distinct sibling scopes was when there + // were multiple generic overloads with similar generated type parameter names + // The effect: + // When we write out + // export const x: (x: T) => T + // export const y: (x: T) => T + // we write it out like that, rather than as + // export const x: (x: T) => T + // export const y: (x: T_1) => T_1 + if (initial.typeParameterNames) { + initial.typeParameterNames = ts.cloneMap(initial.typeParameterNames); + } + if (initial.typeParameterNamesByText) { + initial.typeParameterNamesByText = ts.cloneMap(initial.typeParameterNamesByText); + } + if (initial.typeParameterSymbolList) { + initial.typeParameterSymbolList = ts.cloneMap(initial.typeParameterSymbolList); + } + return initial; + } + function symbolTableToDeclarationStatements(symbolTable, context, bundled) { + var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.createProperty, 160 /* MethodDeclaration */, /*useAcessors*/ true); + var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type, initializer) { return ts.createPropertySignature(mods, name, question, type, initializer); }, 159 /* MethodSignature */, /*useAcessors*/ false); + // TODO: Use `setOriginalNode` on original declaration names where possible so these declarations see some kind of + // declaration mapping + // We save the enclosing declaration off here so it's not adjusted by well-meaning declaration + // emit codepaths which want to apply more specific contexts (so we can still refer to the root real declaration + // we're trying to emit from later on) + var enclosingDeclaration = context.enclosingDeclaration; + var results = []; + var visitedSymbols = ts.createMap(); + var deferredPrivates; + var oldcontext = context; + context = __assign(__assign({}, oldcontext), { usedSymbolNames: ts.createMap(), remappedSymbolNames: ts.createMap(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) { + var accessibleResult = isSymbolAccessible(sym, decl, meaning, /*computeALiases*/ false); + if (accessibleResult.accessibility === 0 /* Accessible */) { + // Lookup the root symbol of the chain of refs we'll use to access it and serialize it + var chain = lookupSymbolChainWorker(sym, context, meaning); + if (!(sym.flags & 4 /* Property */)) { + includePrivateSymbol(chain[0]); + } + } + else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) { + oldcontext.tracker.trackSymbol(sym, decl, meaning); + } + } }) }); + if (oldcontext.usedSymbolNames) { + oldcontext.usedSymbolNames.forEach(function (_, name) { + context.usedSymbolNames.set(name, true); + }); + } + ts.forEachEntry(symbolTable, function (symbol, name) { + var baseName = ts.unescapeLeadingUnderscores(name); + void getInternalSymbolName(symbol, baseName); // Called to cache values into `usedSymbolNames` and `remappedSymbolNames` + }); + var addingDeclare = !bundled; + var exportEquals = symbolTable.get("export=" /* ExportEquals */); + if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152 /* Alias */) { + symbolTable = ts.createSymbolTable(); + // Remove extraneous elements from root symbol table (they'll be mixed back in when the target of the `export=` is looked up) + symbolTable.set("export=" /* ExportEquals */, exportEquals); + } + visitSymbolTable(symbolTable); + return mergeRedundantStatements(results); + function isIdentifierAndNotUndefined(node) { + return !!node && node.kind === 75 /* Identifier */; + } + function getNamesOfDeclaration(statement) { + if (ts.isVariableStatement(statement)) { + return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined); + } + return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined); + } + function flattenExportAssignedNamespace(statements) { + var exportAssignment = ts.find(statements, ts.isExportAssignment); + var ns = ts.find(statements, ts.isModuleDeclaration); + if (ns && exportAssignment && exportAssignment.isExportEquals && + ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) && + ns.body && ts.isModuleBlock(ns.body)) { + // Pass 0: Correct situations where a module has both an `export = ns` and multiple top-level exports by stripping the export modifiers from + // the top-level exports and exporting them in the targeted ns, as can occur when a js file has both typedefs and `module.export` assignments + var excessExports = ts.filter(statements, function (s) { return !!(ts.getModifierFlags(s) & 1 /* Export */); }); + if (ts.length(excessExports)) { + ns.body.statements = ts.createNodeArray(__spreadArrays(ns.body.statements, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.flatMap(excessExports, function (e) { return getNamesOfDeclaration(e); }), function (id) { return ts.createExportSpecifier(/*alias*/ undefined, id); })), + /*moduleSpecifier*/ undefined)])); + } + // Pass 1: Flatten `export namespace _exports {} export = _exports;` so long as the `export=` only points at a single namespace declaration + if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, ns.name); })) { + results = []; + ts.forEach(ns.body.statements, function (s) { + addResult(s, 0 /* None */); // Recalculates the ambient (and export, if applicable from above) flag + }); + statements = __spreadArrays(ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; }), results); + } + } + return statements; + } + function mergeExportDeclarations(statements) { + // Pass 2: Combine all `export {}` declarations + var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(exports) > 1) { + var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; }); + statements = __spreadArrays(nonExports, [ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(exports, function (e) { return e.exportClause.elements; })), + /*moduleSpecifier*/ undefined)]); + } + // Pass 2b: Also combine all `export {} from "..."` declarations as needed + var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause; }); + if (ts.length(reexports) > 1) { + var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; }); + if (groups.length !== reexports.length) { + var _loop_6 = function (group_1) { + if (group_1.length > 1) { + // remove group members from statements and then merge group members and add back to statements + statements = __spreadArrays(ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; }), [ + ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.flatMap(group_1, function (e) { return e.exportClause.elements; })), group_1[0].moduleSpecifier) + ]); + } + }; + for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) { + var group_1 = groups_1[_i]; + _loop_6(group_1); + } + } + } + return statements; + } + function inlineExportModifiers(statements) { + // Pass 3: Move all `export {}`'s to `export` modifiers where possible + var exportDecl = ts.find(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause; }); + if (exportDecl) { + var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) { + if (!e.propertyName) { + // export {name} - look thru `statements` for `name`, and if all results can take an `export` modifier, do so and filter it + var associated = ts.filter(statements, function (s) { return ts.nodeHasName(s, e.name); }); + if (ts.length(associated) && ts.every(associated, canHaveExportModifier)) { + ts.forEach(associated, addExportModifier); + return undefined; + } + } + return e; + }); + if (!ts.length(replacements)) { + // all clauses removed, filter the export declaration + statements = ts.filter(statements, function (s) { return s !== exportDecl; }); + } + else { + // some items filtered, others not - update the export declaration + // (mutating because why not, we're building a whole new tree here anyway) + exportDecl.exportClause.elements = ts.createNodeArray(replacements); + } + } + return statements; + } + function mergeRedundantStatements(statements) { + statements = flattenExportAssignedNamespace(statements); + statements = mergeExportDeclarations(statements); + statements = inlineExportModifiers(statements); + // Not a cleanup, but as a final step: If there is a mix of `export` and non-`export` declarations, but no `export =` or `export {}` add a `export {};` so + // declaration privacy is respected. + if (enclosingDeclaration && + ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) && + (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) { + statements.push(ts.createEmptyExports()); + } + return statements; + } + function canHaveExportModifier(node) { + return ts.isEnumDeclaration(node) || + ts.isVariableStatement(node) || + ts.isFunctionDeclaration(node) || + ts.isClassDeclaration(node) || + (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) || + ts.isInterfaceDeclaration(node) || + isTypeDeclaration(node); + } + function addExportModifier(statement) { + var flags = (ts.getModifierFlags(statement) | 1 /* Export */) & ~2 /* Ambient */; + statement.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(flags)); + statement.modifierFlagsCache = 0; + } + function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) { + var oldDeferredPrivates = deferredPrivates; + if (!suppressNewPrivateContext) { + deferredPrivates = ts.createMap(); + } + symbolTable.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ false, !!propertyAsAlias); + }); + if (!suppressNewPrivateContext) { + // deferredPrivates will be filled up by visiting the symbol table + // And will continue to iterate as elements are added while visited `deferredPrivates` + // (As that's how a map iterator is defined to work) + deferredPrivates.forEach(function (symbol) { + serializeSymbol(symbol, /*isPrivate*/ true, !!propertyAsAlias); + }); + } + deferredPrivates = oldDeferredPrivates; + } + function serializeSymbol(symbol, isPrivate, propertyAsAlias) { + // cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but + // still skip reserializing it if we encounter the merged product later on + var visitedSym = getMergedSymbol(symbol); + if (visitedSymbols.has("" + getSymbolId(visitedSym))) { + return; // Already printed + } + visitedSymbols.set("" + getSymbolId(visitedSym), true); + // Only actually serialize symbols within the correct enclosing declaration, otherwise do nothing with the out-of-context symbol + var skipMembershipCheck = !isPrivate; // We only call this on exported symbols when we know they're in the correct scope + if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) { + var oldContext = context; + context = cloneNodeBuilderContext(context); + var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias); + context = oldContext; + return result; + } + } + // Synthesize declarations for a symbol - might be an Interface, a Class, a Namespace, a Type, a Variable (const, let, or var), an Alias + // or a merge of some number of those. + // An interesting challenge is ensuring that when classes merge with namespaces and interfaces, is keeping + // each symbol in only one of the representations + // Also, synthesizing a default export of some kind + // If it's an alias: emit `export default ref` + // If it's a property: emit `export default _default` with a `_default` prop + // If it's a class/interface/function: emit a class/interface/function with a `default` modifier + // These forms can merge, eg (`export default 12; export default interface A {}`) + function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) { + var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isDefault = symbol.escapedName === "default" /* Default */; + if (ts.isStringANonContextualKeyword(symbolName) && !isDefault) { + // Oh no. We cannot use this symbol's name as it's name... It's likely some jsdoc had an invalid name like `export` or `default` :( + context.encounteredError = true; + // TODO: Issue error via symbol tracker? + return; // If we need to emit a private with a keyword name, we're done for, since something else will try to refer to it by that name + } + var needsPostExportDefault = isDefault && !!(symbol.flags & -113 /* ExportDoesNotSupportDefaultModifier */ + || (symbol.flags & 16 /* Function */ && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152 /* Alias */); // An alias symbol should preclude needing to make an alias ourselves + if (needsPostExportDefault) { + isPrivate = true; + } + var modifierFlags = (!isPrivate ? 1 /* Export */ : 0) | (isDefault && !needsPostExportDefault ? 512 /* Default */ : 0); + var isConstMergedWithNS = symbol.flags & 1536 /* Module */ && + symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) && + symbol.escapedName !== "export=" /* ExportEquals */; + var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol); + if (symbol.flags & 16 /* Function */ || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 524288 /* TypeAlias */) { + serializeTypeAlias(symbol, symbolName, modifierFlags); + } + // Need to skip over export= symbols below - json source files get a single `Property` flagged + // symbol of name `export=` which needs to be handled like an alias. It's not great, but it is what it is. + if (symbol.flags & (2 /* BlockScopedVariable */ | 1 /* FunctionScopedVariable */ | 4 /* Property */) + && symbol.escapedName !== "export=" /* ExportEquals */ + && !(symbol.flags & 4194304 /* Prototype */) + && !(symbol.flags & 32 /* Class */) + && !isConstMergedWithNSPrintableAsSignatureMerge) { + serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags); + } + if (symbol.flags & 384 /* Enum */) { + serializeEnum(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 32 /* Class */) { + if (symbol.flags & 4 /* Property */) { + // Looks like a `module.exports.Sub = class {}` - if we serialize `symbol` as a class, the result will have no members, + // since the classiness is actually from the target of the effective alias the symbol is. yes. A BlockScopedVariable|Class|Property + // _really_ acts like an Alias, and none of a BlockScopedVariable, Class, or Property. This is the travesty of JS binding today. + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + else { + serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + } + if ((symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) { + serializeModule(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 64 /* Interface */) { + serializeInterface(symbol, symbolName, modifierFlags); + } + if (symbol.flags & 2097152 /* Alias */) { + serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags); + } + if (symbol.flags & 4 /* Property */ && symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + if (symbol.flags & 8388608 /* ExportStar */) { + // synthesize export * from "moduleReference" + // Straightforward - only one thing to do - make an export declaration + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var node = _a[_i]; + var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier); + if (!resolvedModule) + continue; + addResult(ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*exportClause*/ undefined, ts.createLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0 /* None */); + } + } + if (needsPostExportDefault) { + addResult(ts.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, ts.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0 /* None */); + } + } + function includePrivateSymbol(symbol) { + if (ts.some(symbol.declarations, ts.isParameterDeclaration)) + return; + ts.Debug.assertDefined(deferredPrivates); + getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol); // Call to cache unique name for symbol + deferredPrivates.set("" + getSymbolId(symbol), symbol); + } + function isExportingScope(enclosingDeclaration) { + return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) || + (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration))); + } + // Prepends a `declare` and/or `export` modifier if the context requires it, and then adds `node` to `result` and returns `node` + // Note: This _mutates_ `node` without using `updateNode` - the assumption being that all nodes should be manufactured fresh by the node builder + function addResult(node, additionalModifierFlags) { + var newModifierFlags = 0 /* None */; + if (additionalModifierFlags & 1 /* Export */ && + enclosingDeclaration && + isExportingScope(enclosingDeclaration) && + canHaveExportModifier(node)) { + // Classes, namespaces, variables, functions, interfaces, and types should all be `export`ed in a module context if not private + newModifierFlags |= 1 /* Export */; + } + if (addingDeclare && !(newModifierFlags & 1 /* Export */) && + (!enclosingDeclaration || !(enclosingDeclaration.flags & 8388608 /* Ambient */)) && + (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) { + // Classes, namespaces, variables, enums, and functions all need `declare` modifiers to be valid in a declaration file top-level scope + newModifierFlags |= 2 /* Ambient */; + } + if ((additionalModifierFlags & 512 /* Default */) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) { + newModifierFlags |= 512 /* Default */; + } + if (newModifierFlags) { + node.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(newModifierFlags | ts.getModifierFlags(node))); + node.modifierFlagsCache = 0; // Reset computed flags cache + } + results.push(node); + } + function serializeTypeAlias(symbol, symbolName, modifierFlags) { + var aliasType = getDeclaredTypeOfTypeAlias(symbol); + var typeParams = getSymbolLinks(symbol).typeParameters; + var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); }); + var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias); + var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined; + var oldFlags = context.flags; + context.flags |= 8388608 /* InTypeAlias */; + addResult(ts.setSyntheticLeadingComments(ts.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeToTypeNodeHelper(aliasType, context)), !commentText ? [] : [{ kind: 3 /* MultiLineCommentTrivia */, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags); + context.flags = oldFlags; + } + function serializeInterface(symbol, symbolName, modifierFlags) { + var interfaceType = getDeclaredTypeOfClassOrInterface(symbol); + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var baseTypes = getBaseTypes(interfaceType); + var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined; + var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); }); + var callSignatures = serializeSignatures(0 /* Call */, interfaceType, baseType, 164 /* CallSignature */); + var constructSignatures = serializeSignatures(1 /* Construct */, interfaceType, baseType, 165 /* ConstructSignature */); + var indexSignatures = serializeIndexSignatures(interfaceType, baseType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b); }))]; + addResult(ts.createInterfaceDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, constructSignatures, callSignatures, members)), modifierFlags); + } + function getNamespaceMembersForSerialization(symbol) { + return !symbol.exports ? [] : ts.filter(ts.arrayFrom((symbol.exports).values()), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + } + function isTypeOnlyNamespace(symbol) { + return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551 /* Value */); }); + } + function serializeModule(symbol, symbolName, modifierFlags) { + var members = getNamespaceMembersForSerialization(symbol); + // Split NS members up by declaration - members whose parent symbol is the ns symbol vs those whose is not (but were added in later via merging) + var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; }); + var realMembers = locationMap.get("real") || ts.emptyArray; + var mergedMembers = locationMap.get("merged") || ts.emptyArray; + // TODO: `suppressNewPrivateContext` is questionable -we need to simply be emitting privates in whatever scope they were declared in, rather + // than whatever scope we traverse to them in. That's a bit of a complex rewrite, since we're not _actually_ tracking privates at all in advance, + // so we don't even have placeholders to fill in. + if (ts.length(realMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 /* Function */ | 67108864 /* Assignment */))); + } + if (ts.length(mergedMembers)) { + var localName = getInternalSymbolName(symbol, symbolName); + var nsBody = ts.createModuleBlock([ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports(ts.map(ts.filter(mergedMembers, function (n) { return n.escapedName !== "export=" /* ExportEquals */; }), function (s) { + var name = ts.unescapeLeadingUnderscores(s.escapedName); + var localName = getInternalSymbolName(s, name); + var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s); + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + includePrivateSymbol(target || s); + var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName; + return ts.createExportSpecifier(name === targetName ? undefined : targetName, name); + })))]); + addResult(ts.createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), nsBody, 16 /* Namespace */), 0 /* None */); + } + } + function serializeEnum(symbol, symbolName, modifierFlags) { + addResult(ts.createEnumDeclaration( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? 2048 /* Const */ : 0), getInternalSymbolName(symbol, symbolName), ts.map(ts.filter(getPropertiesOfType(getTypeOfSymbol(symbol)), function (p) { return !!(p.flags & 8 /* EnumMember */); }), function (p) { + // TODO: Handle computed names + // I hate that to get the initialized value we need to walk back to the declarations here; but there's no + // other way to get the possible const value of an enum member that I'm aware of, as the value is cached + // _on the declaration_, not on the declaration's symbol... + var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) && getConstantValue(p.declarations[0]); + return ts.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined : ts.createLiteral(initializedValue)); + })), modifierFlags); + } + function serializeVariableOrProperty(symbol, symbolName, isPrivate, needsPostExportDefault, propertyAsAlias, modifierFlags) { + if (propertyAsAlias) { + serializeMaybeAliasAssignment(symbol); + } + else { + var type = getTypeOfSymbol(symbol); + var localName = getInternalSymbolName(symbol, symbolName); + if (!(symbol.flags & 16 /* Function */) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) { + // If the type looks like a function declaration + ns could represent it, and it's type is sourced locally, rewrite it into a function declaration + ns + serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags); + } + else { + // A Class + Property merge is made for a `module.exports.Member = class {}`, and it doesn't serialize well as either a class _or_ a property symbol - in fact, _it behaves like an alias!_ + // `var` is `FunctionScopedVariable`, `const` and `let` are `BlockScopedVariable`, and `module.exports.thing =` is `Property` + var flags = !(symbol.flags & 2 /* BlockScopedVariable */) ? undefined + : isConstVariable(symbol) ? 2 /* Const */ + : 1 /* Let */; + var name = (needsPostExportDefault || !(symbol.flags & 4 /* Property */)) ? localName : getUnusedName(localName, symbol); + var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); }); + if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) { + textRange = textRange.parent.parent; + } + var statement = ts.setTextRange(ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(name, serializeTypeForDeclaration(type, symbol)) + ], flags)), textRange); + addResult(statement, name !== localName ? modifierFlags & ~1 /* Export */ : modifierFlags); + if (name !== localName && !isPrivate) { + // We rename the variable declaration we generate for Property symbols since they may have a name which + // conflicts with a local declaration. For example, given input: + // ``` + // function g() {} + // module.exports.g = g + // ``` + // In such a situation, we have a local variable named `g`, and a seperate exported variable named `g`. + // Naively, we would emit + // ``` + // function g() {} + // export const g: typeof g; + // ``` + // That's obviously incorrect - the `g` in the type annotation needs to refer to the local `g`, but + // the export declaration shadows it. + // To work around that, we instead write + // ``` + // function g() {} + // const g_1: typeof g; + // export { g_1 as g }; + // ``` + // To create an export named `g` that does _not_ shadow the local `g` + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(name, localName)])), 0 /* None */); + } + } + } + } + function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) { + var signatures = getSignaturesOfType(type, 0 /* Call */); + for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { + var sig = signatures_2[_i]; + // Each overload becomes a separate function declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, 243 /* FunctionDeclaration */, context); + decl.name = ts.createIdentifier(localName); + addResult(ts.setTextRange(decl, sig.declaration), modifierFlags); + } + // Module symbol emit will take care of module-y members, provided it has exports + if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) { + var props = ts.filter(getPropertiesOfType(type), function (p) { return !((p.flags & 4194304 /* Prototype */) || (p.escapedName === "prototype")); }); + serializeAsNamespaceDeclaration(props, localName, modifierFlags, /*suppressNewPrivateContext*/ true); + } + } + function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) { + if (ts.length(props)) { + var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) { + return !ts.length(p.declarations) || ts.some(p.declarations, function (d) { + return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); + }) ? "local" : "remote"; + }); + var localProps = localVsRemoteMap.get("local") || ts.emptyArray; + // handle remote props first - we need to make an `import` declaration that points at the module containing each remote + // prop in the outermost scope (TODO: a namespace within a namespace would need to be appropriately handled by this) + // Example: + // import Foo_1 = require("./exporter"); + // export namespace ns { + // import Foo = Foo_1.Foo; + // export { Foo }; + // export const c: number; + // } + // This is needed because in JS, statements like `const x = require("./f")` support both type and value lookup, even if they're + // normally just value lookup (so it functions kinda like an alias even when it's not an alias) + // _Usually_, we'll simply print the top-level as an alias instead of a `var` in such situations, however is is theoretically + // possible to encounter a situation where a type has members from both the current file and other files - in those situations, + // emit akin to the above would be needed. + // Add a namespace + var fakespace = ts.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createIdentifier(localName), ts.createModuleBlock([]), 16 /* Namespace */); + fakespace.flags ^= 8 /* Synthesized */; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration; + fakespace.locals = ts.createSymbolTable(props); + fakespace.symbol = props[0].parent; + var oldResults = results; + results = []; + var oldAddingDeclare = addingDeclare; + addingDeclare = false; + var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace }); + var oldContext = context; + context = subcontext; + // TODO: implement handling for the localVsRemoteMap.get("remote") - should be difficult to trigger (see comment above), as only interesting cross-file js merges should make this possible + visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, /*propertyAsAlias*/ true); + context = oldContext; + addingDeclare = oldAddingDeclare; + var declarations = results; + results = oldResults; + fakespace.flags ^= 8 /* Synthesized */; // reset synthesized + fakespace.parent = undefined; + fakespace.locals = undefined; + fakespace.symbol = undefined; + fakespace.body = ts.createModuleBlock(declarations); + addResult(fakespace, modifierFlags); // namespaces can never be default exported + } + } + function serializeAsClass(symbol, localName, modifierFlags) { + var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); }); + var classType = getDeclaredTypeOfClassOrInterface(symbol); + var baseTypes = getBaseTypes(classType); + var staticType = getTypeOfSymbol(symbol); + var staticBaseType = getBaseConstructorTypeOfClass(staticType); + var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.createHeritageClause(89 /* ExtendsKeyword */, ts.map(baseTypes, function (b) { return serializeBaseType(b, staticBaseType, localName); }))]; + var members = ts.flatMap(getPropertiesOfType(classType), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ false, baseTypes[0]); }); + // Consider static members empty if symbol also has function or module meaning - function namespacey emit will handle statics + var staticMembers = symbol.flags & (16 /* Function */ | 512 /* ValueModule */) + ? [] + : ts.flatMap(ts.filter(getPropertiesOfType(staticType), function (p) { return !(p.flags & 4194304 /* Prototype */) && p.escapedName !== "prototype"; }), function (p) { return serializePropertySymbolForClass(p, /*isStatic*/ true, staticBaseType); }); + var constructors = serializeSignatures(1 /* Construct */, staticType, baseTypes[0], 161 /* Constructor */); + for (var _i = 0, constructors_1 = constructors; _i < constructors_1.length; _i++) { + var c = constructors_1[_i]; + // A constructor's return type and type parameters are supposed to be controlled by the enclosing class declaration + // `signatureToSignatureDeclarationHelper` appends them regardless, so for now we delete them here + c.type = undefined; + c.typeParameters = undefined; + } + var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); + addResult(ts.setTextRange(ts.createClassDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, localName, typeParamDecls, heritageClauses, __spreadArrays(indexSignatures, staticMembers, constructors, members)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags); + } + function serializeAsAlias(symbol, localName, modifierFlags) { + // synthesize an alias, eg `export { symbolName as Name }` + // need to mark the alias `symbol` points + // at as something we need to serialize as a private declaration as well + var node = getDeclarationOfAliasSymbol(symbol); + if (!node) + return ts.Debug.fail(); + var target = getMergedSymbol(getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true)); + if (!target) { + return; + } + var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName); + if (verbatimTargetName === "export=" /* ExportEquals */ && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match + verbatimTargetName = "default" /* Default */; + } + var targetName = getInternalSymbolName(target, verbatimTargetName); + includePrivateSymbol(target); // the target may be within the same scope - attempt to serialize it first + switch (node.kind) { + case 252 /* ImportEqualsDeclaration */: + // Could be a local `import localName = ns.member` or + // an external `import localName = require("whatever")` + var isLocalImport = !(target.flags & 512 /* ValueModule */); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(localName), isLocalImport + ? symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false) + : ts.createExternalModuleReference(ts.createLiteral(getSpecifierForModuleSymbol(symbol, context)))), isLocalImport ? modifierFlags : 0 /* None */); + break; + case 251 /* NamespaceExportDeclaration */: + // export as namespace foo + // TODO: Not part of a file's local or export symbol tables + // Is bound into file.symbol.globalExports instead, which we don't currently traverse + addResult(ts.createNamespaceExportDeclaration(ts.idText(node.name)), 0 /* None */); + break; + case 254 /* ImportClause */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(ts.createIdentifier(localName), /*namedBindings*/ undefined), + // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned + // And then made into a default by the `esModuleInterop` or `allowSyntheticDefaultImports` flag + // In such cases, the `target` refers to the module itself already + ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 255 /* NamespaceImport */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamespaceImport(ts.createIdentifier(localName))), ts.createLiteral(getSpecifierForModuleSymbol(target, context))), 0 /* None */); + break; + case 257 /* ImportSpecifier */: + addResult(ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createImportClause(/*importClause*/ undefined, ts.createNamedImports([ + ts.createImportSpecifier(localName !== verbatimTargetName ? ts.createIdentifier(verbatimTargetName) : undefined, ts.createIdentifier(localName)) + ])), ts.createLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0 /* None */); + break; + case 261 /* ExportSpecifier */: + // does not use localName because the symbol name in this case refers to the name in the exports table, + // which we must exactly preserve + var specifier = node.parent.parent.moduleSpecifier; + // targetName is only used when the target is local, as otherwise the target is an alias that points at + // another file + serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.createLiteral(specifier.text) : undefined); + break; + case 258 /* ExportAssignment */: + serializeMaybeAliasAssignment(symbol); + break; + case 208 /* BinaryExpression */: + case 193 /* PropertyAccessExpression */: + // Could be best encoded as though an export specifier or as though an export assignment + // If name is default or export=, do an export assignment + // Otherwise do an export specifier + if (symbol.escapedName === "default" /* Default */ || symbol.escapedName === "export=" /* ExportEquals */) { + serializeMaybeAliasAssignment(symbol); + } + else { + serializeExportSpecifier(localName, targetName); + } + break; + default: + return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!"); + } + } + function serializeExportSpecifier(localName, targetName, specifier) { + addResult(ts.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createNamedExports([ts.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0 /* None */); + } + function serializeMaybeAliasAssignment(symbol) { + if (symbol.flags & 4194304 /* Prototype */) { + return; + } + var name = ts.unescapeLeadingUnderscores(symbol.escapedName); + var isExportEquals = name === "export=" /* ExportEquals */; + var isDefault = name === "default" /* Default */; + var isExportAssignment = isExportEquals || isDefault; + // synthesize export = ref + // ref should refer to either be a locally scoped symbol which we need to emit, or + // a reference to another namespace/module which we may need to emit an `import` statement for + var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol); + // serialize what the alias points to, preserve the declaration's initializer + var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, /*dontRecursivelyResolve*/ true); + // If the target resolves and resolves to a thing defined in this file, emit as an alias, otherwise emit as a const + if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) { + // In case `target` refers to a namespace member, look at the declaration and serialize the leftmost symbol in it + // eg, `namespace A { export class B {} }; exports = A.B;` + // Technically, this is all that's required in the case where the assignment is an entity name expression + var expr = isExportAssignment ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl); + var first_1 = ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined; + var referenced = first_1 && resolveEntityName(first_1, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, enclosingDeclaration); + if (referenced || target) { + includePrivateSymbol(referenced || target); + } + // We disable the context's symbol traker for the duration of this name serialization + // as, by virtue of being here, the name is required to print something, and we don't want to + // issue a visibility error on it. Only anonymous classes that an alias points at _would_ issue + // a visibility error here (as they're not visible within any scope), but we want to hoist them + // into the containing scope anyway, so we want to skip the visibility checks. + var oldTrack = context.tracker.trackSymbol; + context.tracker.trackSymbol = ts.noop; + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, 67108863 /* All */))); + } + else { + if (first_1 === expr) { + // serialize as `export {target as name}` + serializeExportSpecifier(name, ts.idText(first_1)); + } + else if (ts.isClassExpression(expr)) { + serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target))); + } + else { + // serialize as `import _Ref = t.arg.et; export { _Ref as name }` + var varName = getUnusedName(name, symbol); + addResult(ts.createImportEqualsDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createIdentifier(varName), symbolToName(target, context, 67108863 /* All */, /*expectsIdentifier*/ false)), 0 /* None */); + serializeExportSpecifier(name, varName); + } + } + context.tracker.trackSymbol = oldTrack; + } + else { + // serialize as an anonymous property declaration + var varName = getUnusedName(name, symbol); + // We have to use `getWidenedType` here since the object within a json file is unwidened within the file + // (Unwidened types can only exist in expression contexts and should never be serialized) + var typeToSerialize = getWidenedType(getTypeOfSymbol(symbol)); + if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) { + // If there are no index signatures and `typeToSerialize` is an object type, emit as a namespace instead of a const + serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignment ? 0 /* None */ : 1 /* Export */); + } + else { + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(varName, serializeTypeForDeclaration(typeToSerialize, symbol)) + ], 2 /* Const */)); + addResult(statement, name === varName ? 1 /* Export */ : 0 /* None */); + } + if (isExportAssignment) { + results.push(ts.createExportAssignment( + /*decorators*/ undefined, + /*modifiers*/ undefined, isExportEquals, ts.createIdentifier(varName))); + } + else if (name !== varName) { + serializeExportSpecifier(name, varName); + } + } + } + function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) { + // Only object types which are not constructable, or indexable, whose members all come from the + // context source file, and whose property names are all valid identifiers and not late-bound, _and_ + // whose input is not type annotated (if the input symbol has an annotation we can reuse, we should prefer it) + var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration); + return ts.getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && + !getIndexInfoOfType(typeToSerialize, 0 /* String */) && + !getIndexInfoOfType(typeToSerialize, 1 /* Number */) && + !!(ts.length(getPropertiesOfType(typeToSerialize)) || ts.length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && + !ts.length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK + !getDeclarationWithTypeAnnotation(hostSymbol) && + !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) && + !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) && + ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion) && !ts.isStringAKeyword(ts.symbolName(p)); }); + } + function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) { + return function serializePropertySymbol(p, isStatic, baseType) { + if (isStatic && (p.flags & (788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */))) { + // Only value-only-meaning symbols can be correctly encoded as class statics, type/namespace/alias meaning symbols + // need to be merged namespace members + return []; + } + if (p.flags & 4194304 /* Prototype */ || (baseType && getPropertyOfType(baseType, p.escapedName) + && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p) + && (p.flags & 16777216 /* Optional */) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216 /* Optional */) + && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) { + return []; + } + var staticFlag = isStatic ? 32 /* Static */ : 0; + var name = getPropertyNameNodeForSymbol(p, context); + var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression)); + if (p.flags & 98304 /* Accessor */ && useAccessors) { + var result = []; + if (p.flags & 65536 /* SetAccessor */) { + result.push(ts.setTextRange(ts.createSetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "arg", + /*questionToken*/ undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p))], + /*body*/ undefined), ts.find(p.declarations, ts.isSetAccessor) || firstPropertyLikeDecl)); + } + if (p.flags & 32768 /* GetAccessor */) { + result.push(ts.setTextRange(ts.createGetAccessor( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags(staticFlag), name, [], serializeTypeForDeclaration(getTypeOfSymbol(p), p), + /*body*/ undefined), ts.find(p.declarations, ts.isGetAccessor) || firstPropertyLikeDecl)); + } + return result; + } + // This is an else/if as accessors and properties can't merge in TS, but might in JS + // If this happens, we assume the accessor takes priority, as it imposes more constraints + else if (p.flags & (4 /* Property */ | 3 /* Variable */)) { + return ts.setTextRange(createProperty( + /*decorators*/ undefined, ts.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 64 /* Readonly */ : 0) | staticFlag), name, p.flags & 16777216 /* Optional */ ? ts.createToken(57 /* QuestionToken */) : undefined, serializeTypeForDeclaration(getTypeOfSymbol(p), p), + // TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357 + // interface members can't have initializers, however class members _can_ + /*initializer*/ undefined), ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isVariableDeclaration)) || firstPropertyLikeDecl); + } + if (p.flags & (8192 /* Method */ | 16 /* Function */)) { + var type = getTypeOfSymbol(p); + var signatures = getSignaturesOfType(type, 0 /* Call */); + var results_1 = []; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var sig = signatures_3[_i]; + // Each overload becomes a separate method declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context); + decl.name = name; // TODO: Clone + if (staticFlag) { + decl.modifiers = ts.createNodeArray(ts.createModifiersFromModifierFlags(staticFlag)); + } + if (p.flags & 16777216 /* Optional */) { + decl.questionToken = ts.createToken(57 /* QuestionToken */); + } + results_1.push(ts.setTextRange(decl, sig.declaration)); + } + return results_1; + } + // The `Constructor`'s symbol isn't in the class's properties lists, obviously, since it's a signature on the static + return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags)); + }; + } + function serializePropertySymbolForInterface(p, baseType) { + return serializePropertySymbolForInterfaceWorker(p, /*isStatic*/ false, baseType); + } + function getDeclarationWithTypeAnnotation(symbol) { + return ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; }); }); + } + /** + * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag + * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` + */ + function serializeTypeForDeclaration(type, symbol) { + var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol); + if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { + // try to reuse the existing annotation + var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); + var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols); + return transformed === existing ? ts.getMutableClone(existing) : transformed; + } + var oldFlags = context.flags; + if (type.flags & 8192 /* UniqueESSymbol */ && + type.symbol === symbol) { + context.flags |= 1048576 /* AllowUniqueESSymbolType */; + } + var result = typeToTypeNodeHelper(type, context); + context.flags = oldFlags; + return result; + function visitExistingNodeTreeSymbols(node) { + if (ts.isJSDocAllType(node)) { + return ts.createKeywordTypeNode(124 /* AnyKeyword */); + } + if (ts.isJSDocUnknownType(node)) { + return ts.createKeywordTypeNode(147 /* UnknownKeyword */); + } + if (ts.isJSDocNullableType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(99 /* NullKeyword */)]); + } + if (ts.isJSDocOptionalType(node)) { + return ts.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.createKeywordTypeNode(145 /* UndefinedKeyword */)]); + } + if (ts.isJSDocNonNullableType(node)) { + return ts.visitNode(node.type, visitExistingNodeTreeSymbols); + } + if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) { + return ts.createTypeLiteralNode([ts.createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotdotdotToken*/ undefined, "x", + /*questionToken*/ undefined, ts.visitNode(node.typeArguments[0], visitExistingNodeTreeSymbols))], ts.visitNode(node.typeArguments[1], visitExistingNodeTreeSymbols))]); + } + if (ts.isJSDocFunctionType(node)) { + if (ts.isJSDocConstructSignature(node)) { + var newTypeNode_1; + return ts.createConstructorTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.mapDefined(node.parameters, function (p, i) { return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode_1 = p.type, undefined) : ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(newTypeNode_1 || node.type, visitExistingNodeTreeSymbols)); + } + else { + return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, p.dotDotDotToken, p.name || p.dotDotDotToken ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), + /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); + } + } + if (ts.isLiteralImportTypeNode(node)) { + return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); + } + if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) { + var leftmost = ts.getFirstIdentifier(node); + var sym = resolveEntityName(leftmost, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveALias*/ true); + if (sym) { + includePrivateSymbol(sym); + if (ts.isIdentifier(node) && sym.flags & 262144 /* TypeParameter */) { + var name = typeParameterToName(getDeclaredTypeOfSymbol(sym), context); + if (ts.idText(name) !== ts.idText(node)) { + return name; + } + return node; + } + } + } + return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext); + } + function rewriteModuleSpecifier(parent, lit) { + if (bundled) { + if (context.tracker && context.tracker.moduleResolverHost) { + var targetFile = getExternalModuleFileFromDeclaration(parent); + if (targetFile) { + var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames); + var resolverHost = { + getCanonicalFileName: getCanonicalFileName, + getCurrentDirectory: context.tracker.moduleResolverHost.getCurrentDirectory ? function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); } : function () { return ""; }, + getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); } + }; + var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile); + return ts.createLiteral(newName); + } + } + } + else { + if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) { + var moduleSym = resolveExternalModuleNameWorker(lit, lit, /*moduleNotFoundError*/ undefined); + if (moduleSym) { + context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym); + } + } + } + return lit; + } + } + function serializeSignatures(kind, input, baseType, outputKind) { + var signatures = getSignaturesOfType(input, kind); + if (kind === 1 /* Construct */) { + if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // No base type, every constructor is empty - elide the extraneous `constructor()` + } + if (baseType) { + // If there is a base type, if every signature in the class is identical to a signature in the baseType, elide all the declarations + var baseSigs = getSignaturesOfType(baseType, 1 /* Construct */); + if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) { + return []; // Base had no explicit signatures, if all our signatures are also implicit, return an empty list + } + if (baseSigs.length === signatures.length) { + var failed = false; + for (var i = 0; i < baseSigs.length; i++) { + if (!compareSignaturesIdentical(signatures[i], baseSigs[i], /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ true, compareTypesIdentical)) { + failed = true; + break; + } + } + if (!failed) { + return []; // Every signature was identical - elide constructor list as it is inherited + } + } + } + } + var results = []; + for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { + var sig = signatures_4[_i]; + // Each overload becomes a separate constructor declaration, in order + var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context); + results.push(ts.setTextRange(decl, sig.declaration)); + } + return results; + } + function serializeIndexSignatures(input, baseType) { + var results = []; + for (var _i = 0, _a = [0 /* String */, 1 /* Number */]; _i < _a.length; _i++) { + var type = _a[_i]; + var info = getIndexInfoOfType(input, type); + if (info) { + if (baseType) { + var baseInfo = getIndexInfoOfType(baseType, type); + if (baseInfo) { + if (isTypeIdenticalTo(info.type, baseInfo.type)) { + continue; // elide identical index signatures + } + } + } + results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context)); + } + } + return results; + } + function serializeBaseType(t, staticType, rootName) { + var ref = trySerializeAsTypeReference(t); + if (ref) { + return ref; + } + var tempName = getUnusedName(rootName + "_base"); + var statement = ts.createVariableStatement(/*modifiers*/ undefined, ts.createVariableDeclarationList([ + ts.createVariableDeclaration(tempName, typeToTypeNodeHelper(staticType, context)) + ], 2 /* Const */)); + addResult(statement, 0 /* None */); + return ts.createExpressionWithTypeArguments(/*typeArgs*/ undefined, ts.createIdentifier(tempName)); + } + function trySerializeAsTypeReference(t) { + var typeArgs; + var reference; + // We don't use `isValueSymbolAccessible` below. since that considers alternative containers (like modules) + // which we can't write out in a syntactically valid way as an expression + if (t.target && getAccessibleSymbolChain(t.target.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); }); + reference = symbolToExpression(t.target.symbol, context, 788968 /* Type */); + } + else if (t.symbol && getAccessibleSymbolChain(t.symbol, enclosingDeclaration, 111551 /* Value */, /*useOnlyExternalAliasing*/ false)) { + reference = symbolToExpression(t.symbol, context, 788968 /* Type */); + } + if (reference) { + return ts.createExpressionWithTypeArguments(typeArgs, reference); + } + } + function getUnusedName(input, symbol) { + if (symbol) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + } + if (symbol) { + input = getNameCandidateWorker(symbol, input); + } + var i = 0; + var original = input; + while (context.usedSymbolNames.has(input)) { + i++; + input = original + "_" + i; + } + context.usedSymbolNames.set(input, true); + if (symbol) { + context.remappedSymbolNames.set("" + getSymbolId(symbol), input); + } + return input; + } + function getNameCandidateWorker(symbol, localName) { + if (localName === "default" /* Default */ || localName === "__class" /* Class */ || localName === "__function" /* Function */) { + var flags = context.flags; + context.flags |= 16777216 /* InInitialEntityName */; + var nameCandidate = getNameOfSymbolAsWritten(symbol, context); + context.flags = flags; + localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate; + } + if (localName === "default" /* Default */) { + localName = "_default"; + } + else if (localName === "export=" /* ExportEquals */) { + localName = "_exports"; + } + localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_"); + return localName; + } + function getInternalSymbolName(symbol, localName) { + if (context.remappedSymbolNames.has("" + getSymbolId(symbol))) { + return context.remappedSymbolNames.get("" + getSymbolId(symbol)); + } + localName = getNameCandidateWorker(symbol, localName); + // The result of this is going to be used as the symbol's name - lock it in, so `getUnusedName` will also pick it up + context.remappedSymbolNames.set("" + getSymbolId(symbol), localName); + return localName; + } + } } function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) { if (flags === void 0) { flags = 16384 /* UseAliasDefinedOutsideCurrentScope */; } return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker); function typePredicateToStringWorker(writer) { - var predicate = ts.createTypePredicateNode(typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */)); + var predicate = ts.createTypePredicateNodeWithModifier(typePredicate.kind === 2 /* AssertsThis */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createToken(123 /* AssertsKeyword */) : undefined, typePredicate.kind === 1 /* Identifier */ || typePredicate.kind === 3 /* AssertsIdentifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(), typePredicate.type && nodeBuilder.typeToTypeNode(typePredicate.type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 /* IgnoreErrors */ | 512 /* WriteTypeParametersInQualifiedName */) // TODO: GH#18217 + ); var printer = ts.createPrinter({ removeComments: true }); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); printer.writeNode(4 /* Unspecified */, predicate, /*sourceFile*/ sourceFile, writer); @@ -36231,8 +38414,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 178 /* ParenthesizedType */; }); - if (node.kind === 243 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 181 /* ParenthesizedType */; }); + if (node.kind === 246 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -36240,11 +38423,11 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 246 /* ModuleBlock */ && + node.parent.kind === 249 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function isDefaultBindingContext(location) { - return location.kind === 285 /* SourceFile */ || ts.isAmbientModule(location); + return location.kind === 288 /* SourceFile */ || ts.isAmbientModule(location); } function getNameOfSymbolFromNameType(symbol, context) { var nameType = symbol.nameType; @@ -36282,9 +38465,9 @@ var ts; return "default"; } if (symbol.declarations && symbol.declarations.length) { - var declaration = symbol.declarations[0]; - var name_2 = ts.getNameOfDeclaration(declaration); - if (name_2) { + var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; }); // Try using a declaration with a name, first + var name_2 = declaration && ts.getNameOfDeclaration(declaration); + if (declaration && name_2) { if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) { return ts.symbolName(symbol); } @@ -36297,17 +38480,20 @@ var ts; } return ts.declarationNameToString(name_2); } - if (declaration.parent && declaration.parent.kind === 238 /* VariableDeclaration */) { + if (!declaration) { + declaration = symbol.declarations[0]; // Declaration may be nameless, but we'll try anyway + } + if (declaration.parent && declaration.parent.kind === 241 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } switch (declaration.kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (context && !context.encounteredError && !(context.flags & 131072 /* AllowAnonymousIdentifier */)) { context.encounteredError = true; } - return declaration.kind === 210 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; + return declaration.kind === 213 /* ClassExpression */ ? "(Anonymous class)" : "(Anonymous function)"; } } var name = getNameOfSymbolFromNameType(symbol, context); @@ -36324,28 +38510,28 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 305 /* JSDocCallbackTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: // Top-level jsdoc type aliases are considered exported // First parent is comment node, second is hosting declaration or token; we only care about those tokens or declarations whose parent is a source file return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } // falls through - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 240 /* FunctionDeclaration */: - case 244 /* EnumDeclaration */: - case 249 /* ImportEqualsDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + case 247 /* EnumDeclaration */: + case 252 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -36353,53 +38539,54 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 249 /* ImportEqualsDeclaration */ && parent.kind !== 285 /* SourceFile */ && parent.flags & 4194304 /* Ambient */)) { + !(node.kind !== 252 /* ImportEqualsDeclaration */ && parent.kind !== 288 /* SourceFile */ && parent.flags & 8388608 /* Ambient */)) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 8 /* Private */ | 16 /* Protected */)) { // Private/protected properties/methods are not visible return false; } // Public properties/methods are visible if its parents are visible, so: // falls through - case 158 /* Constructor */: - case 162 /* ConstructSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 152 /* Parameter */: - case 246 /* ModuleBlock */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 165 /* TypeReference */: - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 178 /* ParenthesizedType */: + case 161 /* Constructor */: + case 165 /* ConstructSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 155 /* Parameter */: + case 249 /* ModuleBlock */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 168 /* TypeReference */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 181 /* ParenthesizedType */: return isDeclarationVisible(node.parent); // Default binding, import specifier and namespace import is visible // only on demand so by default it is not visible - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: return false; // Type parameters are always visible - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: // Source file and namespace export are always visible - case 285 /* SourceFile */: - case 248 /* NamespaceExportDeclaration */: + // falls through + case 288 /* SourceFile */: + case 251 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return false; default: return false; @@ -36408,14 +38595,17 @@ var ts; } function collectLinkedAliases(node, setVisibility) { var exportSymbol; - if (node.parent && node.parent.kind === 255 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 258 /* ExportAssignment */) { exportSymbol = resolveName(node, node.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, node, /*isUse*/ false); } - else if (node.parent.kind === 258 /* ExportSpecifier */) { + else if (node.parent.kind === 261 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } var result; + var visited; if (exportSymbol) { + visited = ts.createMap(); + visited.set("" + getSymbolId(exportSymbol), true); buildVisibleNodeList(exportSymbol.declarations); } return result; @@ -36432,9 +38622,11 @@ var ts; if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; - var firstIdentifier = getFirstIdentifier(internalModuleReference); + var firstIdentifier = ts.getFirstIdentifier(internalModuleReference); var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); - if (importSymbol) { + var id = importSymbol && "" + getSymbolId(importSymbol); + if (importSymbol && !visited.has(id)) { + visited.set(id, true); buildVisibleNodeList(importSymbol.declarations); } } @@ -36494,6 +38686,8 @@ var ts; return !!target.immediateBaseConstraint; case 6 /* JSDocTypeReference */: return !!getSymbolLinks(target).resolvedJSDocType; + case 7 /* ResolvedTypeArguments */: + return !!target.resolvedTypeArguments; } return ts.Debug.assertNever(propertyName); } @@ -36509,12 +38703,12 @@ var ts; function getDeclarationContainer(node) { return ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 238 /* VariableDeclaration */: - case 239 /* VariableDeclarationList */: - case 254 /* ImportSpecifier */: - case 253 /* NamedImports */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + case 241 /* VariableDeclaration */: + case 242 /* VariableDeclarationList */: + case 257 /* ImportSpecifier */: + case 256 /* NamedImports */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: return false; default: return true; @@ -36547,7 +38741,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 150 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); + return name.kind === 153 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteralLike(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 98304 /* Nullable */); }); @@ -36599,7 +38793,7 @@ var ts; if (parentAccess && parentAccess.flowNode) { var propName = getDestructuringPropertyName(node); if (propName) { - var result = ts.createNode(191 /* ElementAccessExpression */, node.pos, node.end); + var result = ts.createNode(194 /* ElementAccessExpression */, node.pos, node.end); result.parent = node; result.expression = parentAccess; var literal = ts.createNode(10 /* StringLiteral */, node.pos, node.end); @@ -36614,23 +38808,23 @@ var ts; function getParentElementAccess(node) { var ancestor = node.parent.parent; switch (ancestor.kind) { - case 187 /* BindingElement */: - case 276 /* PropertyAssignment */: + case 190 /* BindingElement */: + case 279 /* PropertyAssignment */: return getSyntheticElementAccess(ancestor); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getSyntheticElementAccess(node.parent); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ancestor.initializer; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ancestor.right; } } function getDestructuringPropertyName(node) { var parent = node.parent; - if (node.kind === 187 /* BindingElement */ && parent.kind === 185 /* ObjectBindingPattern */) { + if (node.kind === 190 /* BindingElement */ && parent.kind === 188 /* ObjectBindingPattern */) { return getLiteralPropertyNameText(node.propertyName || node.name); } - if (node.kind === 276 /* PropertyAssignment */ || node.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.kind === 279 /* PropertyAssignment */ || node.kind === 280 /* ShorthandPropertyAssignment */) { return getLiteralPropertyNameText(node.name); } return "" + parent.elements.indexOf(node); @@ -36648,11 +38842,11 @@ var ts; return parentType; } // Relax null check on ambient destructuring parameters, since the parameters have no implementation and are just documentation - if (strictNullChecks && declaration.flags & 4194304 /* Ambient */ && ts.isParameterDeclaration(declaration)) { + if (strictNullChecks && declaration.flags & 8388608 /* Ambient */ && ts.isParameterDeclaration(declaration)) { parentType = getNonNullableType(parentType); } var type; - if (pattern.kind === 185 /* ObjectBindingPattern */) { + if (pattern.kind === 188 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (parentType.flags & 2 /* Unknown */ || !isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -36720,30 +38914,30 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 97 /* NullKeyword */ || expr.kind === 73 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 99 /* NullKeyword */ || expr.kind === 75 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 188 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 191 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { if (optional === void 0) { optional = true; } return strictNullChecks && optional ? getOptionalType(type) : type; } function isParameterOfContextuallyTypedFunction(node) { - return node.kind === 152 /* Parameter */ && - (node.parent.kind === 197 /* FunctionExpression */ || node.parent.kind === 198 /* ArrowFunction */) && + return node.kind === 155 /* Parameter */ && + (node.parent.kind === 200 /* FunctionExpression */ || node.parent.kind === 201 /* ArrowFunction */) && !!getContextualType(node.parent); } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 227 /* ForInStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 230 /* ForInStatement */) { var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression))); return indexType.flags & (262144 /* TypeParameter */ | 4194304 /* Index */) ? getExtractStringType(indexType) : stringType; } - if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 228 /* ForOfStatement */) { + if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 231 /* ForOfStatement */) { // checkRightHandSideOfForOf will return undefined if the for-of expression type was // missing properties/signatures required to get its iteratedType (like // [Symbol.iterator] or next). This may be because we accessed properties from anyType, @@ -36762,8 +38956,8 @@ var ts; return addOptionality(declaredType, isOptional); } if ((noImplicitAny || ts.isInJSFile(declaration)) && - declaration.kind === 238 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && - !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 4194304 /* Ambient */)) { + declaration.kind === 241 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !(declaration.flags & 8388608 /* Ambient */)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. @@ -36776,11 +38970,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 152 /* Parameter */) { + if (declaration.kind === 155 /* Parameter */) { var func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present - if (func.kind === 160 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { - var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 159 /* GetAccessor */); + if (func.kind === 163 /* SetAccessor */ && !hasNonBindableDynamicName(func)) { + var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 162 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -36847,12 +39041,14 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration : - ts.isPropertyAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : + ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration : undefined; if (!expression) { - return errorType; + continue; // Non-assignment declaration merged in (eg, an Identifier to mark the thing as a namespace) - skip over it and pull type info from elsewhere } - var kind = ts.isPropertyAccessExpression(expression) ? ts.getAssignmentDeclarationPropertyAccessKind(expression) : ts.getAssignmentDeclarationKind(expression); + var kind = ts.isAccessExpression(expression) + ? ts.getAssignmentDeclarationPropertyAccessKind(expression) + : ts.getAssignmentDeclarationKind(expression); if (kind === 4 /* ThisProperty */) { if (isDeclarationInConstructor(expression)) { definedInConstructor = true; @@ -36870,6 +39066,9 @@ var ts; } var type = jsdocType; if (!type) { + if (!ts.length(types)) { + return errorType; // No types from any declarations :( + } var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined; // use only the constructor types unless they were only assigned null | undefined (including widening variants) if (definedInMethod) { @@ -36895,9 +39094,9 @@ var ts; } var exports = ts.createSymbolTable(); while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) { - var s_1 = getSymbolOfNode(decl); - if (s_1 && ts.hasEntries(s_1.exports)) { - mergeSymbolTable(exports, s_1.exports); + var s_2 = getSymbolOfNode(decl); + if (s_2 && ts.hasEntries(s_2.exports)) { + mergeSymbolTable(exports, s_2.exports); } decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent; } @@ -36990,9 +39189,9 @@ var ts; var thisContainer = ts.getThisContainer(expression, /*includeArrowFunctions*/ false); // Properties defined in a constructor (or base constructor, or javascript constructor function) don't get undefined added. // Function expressions that are assigned to the prototype count as methods. - return thisContainer.kind === 158 /* Constructor */ || - thisContainer.kind === 240 /* FunctionDeclaration */ || - (thisContainer.kind === 197 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); + return thisContainer.kind === 161 /* Constructor */ || + thisContainer.kind === 243 /* FunctionDeclaration */ || + (thisContainer.kind === 200 /* FunctionExpression */ && !ts.isPrototypePropertyAssignment(thisContainer.parent)); } function getConstructorDefinedThisAssignmentTypes(types, declarations) { ts.Debug.assert(types.length === declarations.length); @@ -37067,7 +39266,7 @@ var ts; function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) { var elements = pattern.elements; var lastElement = ts.lastOrUndefined(elements); - var hasRestElement = !!(lastElement && lastElement.kind === 187 /* BindingElement */ && lastElement.dotDotDotToken); + var hasRestElement = !!(lastElement && lastElement.kind === 190 /* BindingElement */ && lastElement.dotDotDotToken); if (elements.length === 0 || elements.length === 1 && hasRestElement) { return languageVersion >= 2 /* ES2015 */ ? createIterableType(anyType) : anyArrayType; } @@ -37090,7 +39289,7 @@ var ts; function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { if (includePatternInType === void 0) { includePatternInType = false; } if (reportErrors === void 0) { reportErrors = false; } - return pattern.kind === 185 /* ObjectBindingPattern */ + return pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -37129,7 +39328,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 152 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 155 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function tryGetTypeFromEffectiveTypeNode(declaration) { @@ -37185,22 +39384,26 @@ var ts; // Handle variable, parameter or property if (!pushTypeResolution(symbol, 0 /* Type */)) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); } var type; - if (declaration.kind === 255 /* ExportAssignment */) { + if (declaration.kind === 258 /* ExportAssignment */) { type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration); } - else if (ts.isInJSFile(declaration) && - (ts.isCallExpression(declaration) || ts.isBinaryExpression(declaration) || ts.isPropertyAccessExpression(declaration) && ts.isBinaryExpression(declaration.parent))) { + else if (ts.isBinaryExpression(declaration) || + (ts.isInJSFile(declaration) && + (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) { type = getWidenedTypeForAssignmentDeclaration(symbol); } else if (ts.isJSDocPropertyLikeTag(declaration) || ts.isPropertyAccessExpression(declaration) + || ts.isElementAccessExpression(declaration) || ts.isIdentifier(declaration) + || ts.isStringLiteralLike(declaration) + || ts.isNumericLiteral(declaration) || ts.isClassDeclaration(declaration) || ts.isFunctionDeclaration(declaration) || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration)) @@ -37241,12 +39444,15 @@ var ts; else if (ts.isEnumMember(declaration)) { type = getTypeOfEnumMember(symbol); } + else if (ts.isAccessor(declaration)) { + type = resolveTypeOfAccessors(symbol); + } else { return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol)); } if (!popTypeResolution()) { // Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty` - if (symbol.flags & 512 /* ValueModule */) { + if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) { return getTypeOfFuncClassEnumModule(symbol); } return reportCircularityError(symbol); @@ -37255,7 +39461,7 @@ var ts; } function getAnnotatedAccessorTypeNode(accessor) { if (accessor) { - if (accessor.kind === 159 /* GetAccessor */) { + if (accessor.kind === 162 /* GetAccessor */) { var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor); return getterTypeAnnotation; } @@ -37282,33 +39488,43 @@ var ts; return links.type || (links.type = getTypeOfAccessorsWorker(symbol)); } function getTypeOfAccessorsWorker(symbol) { - var getter = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 160 /* SetAccessor */); + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return errorType; + } + var type = resolveTypeOfAccessors(symbol); + if (!popTypeResolution()) { + type = anyType; + if (noImplicitAny) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); + } + } + return type; + } + function resolveTypeOfAccessors(symbol) { + var getter = ts.getDeclarationOfKind(symbol, 162 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 163 /* SetAccessor */); if (getter && ts.isInJSFile(getter)) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return jsDocType; } } - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return errorType; - } - var type; // First try to see if the user specified a return type on the get-accessor. var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { - type = getterReturnType; + return getterReturnType; } else { // If the user didn't specify a return type, try to use the set-accessor's parameter type. var setterParameterType = getAnnotatedAccessorType(setter); if (setterParameterType) { - type = setterParameterType; + return setterParameterType; } else { // If there are no specified types, try to infer it from the body of the get accessor if it exists. if (getter && getter.body) { - type = getReturnTypeFromBody(getter); + return getReturnTypeFromBody(getter); } // Otherwise, fall back to 'any'. else { @@ -37318,25 +39534,21 @@ var ts; } } else { - ts.Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); - errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function"); + if (!isPrivateWithinAmbient(getter)) { + errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + } } - type = anyType; + return anyType; } } } - if (!popTypeResolution()) { - type = anyType; - if (noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 159 /* GetAccessor */); - error(getter_1, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); - } - } - return type; } function getBaseTypeVariableOfClass(symbol) { var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol)); - return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : undefined; + return baseConstructorType.flags & 8650752 /* TypeVariable */ ? baseConstructorType : + baseConstructorType.flags & 2097152 /* Intersection */ ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752 /* TypeVariable */); }) : + undefined; } function getTypeOfFuncClassEnumModule(symbol) { var links = getSymbolLinks(symbol); @@ -37344,19 +39556,10 @@ var ts; if (!links.type) { var jsDeclaration = ts.getDeclarationOfExpando(symbol.valueDeclaration); if (jsDeclaration) { - var jsSymbol = getSymbolOfNode(jsDeclaration); - if (jsSymbol && (ts.hasEntries(jsSymbol.exports) || ts.hasEntries(jsSymbol.members))) { - symbol = cloneSymbol(symbol); + var merged = mergeJSSymbols(symbol, getSymbolOfNode(jsDeclaration)); + if (merged) { // note:we overwrite links because we just cloned the symbol - links = symbol; - if (ts.hasEntries(jsSymbol.exports)) { - symbol.exports = symbol.exports || ts.createSymbolTable(); - mergeSymbolTable(symbol.exports, jsSymbol.exports); - } - if (ts.hasEntries(jsSymbol.members)) { - symbol.members = symbol.members || ts.createSymbolTable(); - mergeSymbolTable(symbol.members, jsSymbol.members); - } + symbol = links = merged; } } originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol); @@ -37368,8 +39571,9 @@ var ts; if (symbol.flags & 1536 /* Module */ && ts.isShorthandAmbientModuleSymbol(symbol)) { return anyType; } - else if (declaration.kind === 205 /* BinaryExpression */ || - declaration.kind === 190 /* PropertyAccessExpression */ && declaration.parent.kind === 205 /* BinaryExpression */) { + else if (declaration.kind === 208 /* BinaryExpression */ || + (declaration.kind === 193 /* PropertyAccessExpression */ || declaration.kind === 194 /* ElementAccessExpression */) && + declaration.parent.kind === 208 /* BinaryExpression */) { return getWidenedTypeForAssignmentDeclaration(symbol); } else if (symbol.flags & 512 /* ValueModule */ && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) { @@ -37436,7 +39640,7 @@ var ts; return errorType; } // Check if variable has initializer that circularly references the variable itself - if (noImplicitAny && (declaration.kind !== 152 /* Parameter */ || declaration.initializer)) { + if (noImplicitAny && (declaration.kind !== 155 /* Parameter */ || declaration.initializer)) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } // Circularities could also result from parameters in function expressions that end up @@ -37517,40 +39721,50 @@ var ts; function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; // TODO: GH#18217 Use SourceFile kind check instead + if (node && ts.isBinaryExpression(node)) { + // prototype assignments get the outer type parameters of their constructor function + var assignmentKind = ts.getAssignmentDeclarationKind(node); + if (assignmentKind === 6 /* Prototype */ || assignmentKind === 3 /* PrototypeProperty */) { + var symbol = getSymbolOfNode(node.left); + if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) { + node = symbol.parent.valueDeclaration; + } + } + } if (!node) { return undefined; } switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 242 /* InterfaceDeclaration */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 156 /* MethodSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 295 /* JSDocFunctionType */: - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 243 /* TypeAliasDeclaration */: - case 311 /* JSDocTemplateTag */: - case 312 /* JSDocTypedefTag */: - case 306 /* JSDocEnumTag */: - case 305 /* JSDocCallbackTag */: - case 182 /* MappedType */: - case 176 /* ConditionalType */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 245 /* InterfaceDeclaration */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 159 /* MethodSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 298 /* JSDocFunctionType */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 246 /* TypeAliasDeclaration */: + case 314 /* JSDocTemplateTag */: + case 315 /* JSDocTypedefTag */: + case 309 /* JSDocEnumTag */: + case 308 /* JSDocCallbackTag */: + case 185 /* MappedType */: + case 179 /* ConditionalType */: var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); - if (node.kind === 182 /* MappedType */) { + if (node.kind === 185 /* MappedType */) { return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); } - else if (node.kind === 176 /* ConditionalType */) { + else if (node.kind === 179 /* ConditionalType */) { return ts.concatenate(outerTypeParameters, getInferTypeParameters(node)); } var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node)); var thisType = includeThisTypes && - (node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */ || node.kind === 242 /* InterfaceDeclaration */) && + (node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */ || node.kind === 245 /* InterfaceDeclaration */ || isJSConstructor(node)) && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } @@ -37558,7 +39772,8 @@ var ts; } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); + ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations"); return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, @@ -37567,9 +39782,10 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 241 /* ClassDeclaration */ || - node.kind === 210 /* ClassExpression */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 244 /* ClassDeclaration */ || + node.kind === 213 /* ClassExpression */ || + isJSConstructor(node) || ts.isTypeAlias(node)) { var declaration = node; result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration)); @@ -37588,19 +39804,19 @@ var ts; var signatures = getSignaturesOfType(type, 1 /* Construct */); if (signatures.length === 1) { var s = signatures[0]; - return !s.typeParameters && s.parameters.length === 1 && s.hasRestParameter && getTypeOfParameter(s.parameters[0]) === anyArrayType; + return !s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s) && getElementTypeOfArrayType(getTypeOfParameter(s.parameters[0])) === anyType; } return false; } function isConstructorType(type) { - if (isValidBaseType(type) && getSignaturesOfType(type, 1 /* Construct */).length > 0) { + if (getSignaturesOfType(type, 1 /* Construct */).length > 0) { return true; } if (type.flags & 8650752 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return !!constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); + return !!constraint && isMixinConstructorType(constraint); } - return isJSConstructorType(type); + return false; } function getBaseTypeNodeOfClass(type) { return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration); @@ -37693,24 +39909,18 @@ var ts; return type.resolvedBaseTypes = ts.emptyArray; } var baseTypeNode = getBaseTypeNodeOfClass(type); - var typeArgs = typeArgumentsFromTypeReferenceNode(baseTypeNode); var baseType; - var originalBaseType = isJSConstructorType(baseConstructorType) ? baseConstructorType : - baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : - undefined; + var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined; if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 /* Class */ && areAllOuterTypeParametersApplied(originalBaseType)) { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgs); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } else if (baseConstructorType.flags & 1 /* Any */) { baseType = baseConstructorType; } - else if (isJSConstructorType(baseConstructorType)) { - baseType = !baseTypeNode.typeArguments && getJSClassType(baseConstructorType.symbol) || anyType; - } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere @@ -37748,14 +39958,21 @@ var ts; var outerTypeParameters = type.outerTypeParameters; if (outerTypeParameters) { var last_1 = outerTypeParameters.length - 1; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol; } return true; } - // A valid base type is `any`, any non-generic object type or intersection of non-generic - // object types. + // A valid base type is `any`, an object type or intersection of object types. function isValidBaseType(type) { + if (type.flags & 262144 /* TypeParameter */) { + var constraint = getBaseConstraintOfType(type); + if (constraint) { + return isValidBaseType(constraint); + } + } + // TODO: Given that we allow type parmeters here now, is this `!isGenericMappedType(type)` check really needed? + // There's no reason a `T` should be allowed while a `Readonly` should not. return !!(type.flags & (524288 /* Object */ | 67108864 /* NonPrimitive */ | 1 /* Any */)) && !isGenericMappedType(type) || !!(type.flags & 2097152 /* Intersection */) && ts.every(type.types, isValidBaseType); } @@ -37763,7 +39980,7 @@ var ts; type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 245 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -37799,8 +40016,8 @@ var ts; function isThislessInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 242 /* InterfaceDeclaration */) { - if (declaration.flags & 64 /* ContainsThis */) { + if (declaration.kind === 245 /* InterfaceDeclaration */) { + if (declaration.flags & 128 /* ContainsThis */) { return false; } var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration); @@ -37821,9 +40038,15 @@ var ts; } function getDeclaredTypeOfClassOrInterface(symbol) { var links = getSymbolLinks(symbol); + var originalLinks = links; if (!links.declaredType) { var kind = symbol.flags & 32 /* Class */ ? 1 /* Class */ : 2 /* Interface */; - var type = links.declaredType = createObjectType(kind, symbol); + var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration)); + if (merged) { + // note:we overwrite links because we just cloned the symbol + symbol = links = merged; + } + var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol); var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol); var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); // A class or interface is generic if it has type parameters or a "this" type. We always give classes a "this" type @@ -37839,7 +40062,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(symbol); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -37881,10 +40104,10 @@ var ts; return links.declaredType; } function isStringConcatExpression(expr) { - if (expr.kind === 10 /* StringLiteral */) { + if (ts.isStringLiteralLike(expr)) { return true; } - else if (expr.kind === 205 /* BinaryExpression */) { + else if (expr.kind === 208 /* BinaryExpression */) { return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right); } return false; @@ -37892,18 +40115,19 @@ var ts; function isLiteralEnumMember(member) { var expr = member.initializer; if (!expr) { - return !(member.flags & 4194304 /* Ambient */); + return !(member.flags & 8388608 /* Ambient */); } switch (expr.kind) { case 10 /* StringLiteral */: case 8 /* NumericLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return true; - case 203 /* PrefixUnaryExpression */: - return expr.operator === 39 /* MinusToken */ && + case 206 /* PrefixUnaryExpression */: + return expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return isStringConcatExpression(expr); default: return false; @@ -37917,10 +40141,10 @@ var ts; var hasNonLiteralMember = false; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; - if (member.initializer && member.initializer.kind === 10 /* StringLiteral */) { + if (member.initializer && ts.isStringLiteralLike(member.initializer)) { return links.enumKind = 1 /* Literal */; } if (!isLiteralEnumMember(member)) { @@ -37944,7 +40168,7 @@ var ts; var memberTypeList = []; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 244 /* EnumDeclaration */) { + if (declaration.kind === 247 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; var value = getEnumMemberValue(member); @@ -38016,23 +40240,23 @@ var ts; */ function isThislessType(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 147 /* BigIntKeyword */: - case 124 /* BooleanKeyword */: - case 140 /* SymbolKeyword */: - case 137 /* ObjectKeyword */: - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: - case 183 /* LiteralType */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 150 /* BigIntKeyword */: + case 127 /* BooleanKeyword */: + case 143 /* SymbolKeyword */: + case 140 /* ObjectKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: + case 186 /* LiteralType */: return true; - case 170 /* ArrayType */: + case 173 /* ArrayType */: return isThislessType(node.elementType); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return !node.typeArguments || node.typeArguments.every(isThislessType); } return false; @@ -38058,7 +40282,7 @@ var ts; function isThislessFunctionLikeDeclaration(node) { var returnType = ts.getEffectiveReturnTypeNode(node); var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - return (node.kind === 158 /* Constructor */ || (!!returnType && isThislessType(returnType))) && + return (node.kind === 161 /* Constructor */ || (!!returnType && isThislessType(returnType))) && node.parameters.every(isThislessVariableLikeDeclaration) && typeParameters.every(isThislessTypeParameter); } @@ -38074,14 +40298,14 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return isThislessVariableLikeDeclaration(declaration); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return isThislessFunctionLikeDeclaration(declaration); } } @@ -38136,9 +40360,12 @@ var ts; * - The type of its expression is a string or numeric literal type, or is a `unique symbol` type. */ function isLateBindableName(node) { - return ts.isComputedPropertyName(node) - && ts.isEntityNameExpression(node.expression) - && isTypeUsableAsPropertyName(checkComputedPropertyName(node)); + if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) { + return false; + } + var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression; + return ts.isEntityNameExpression(expr) + && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr)); } function isLateBoundName(name) { return name.charCodeAt(0) === 95 /* _ */ && @@ -38232,7 +40459,8 @@ var ts; // In the event we attempt to resolve the late-bound name of this member recursively, // fall back to the early-bound name of this member. links.resolvedSymbol = decl.symbol; - var type = checkComputedPropertyName(decl.name); + var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name; + var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName); if (isTypeUsableAsPropertyName(type)) { var memberName = getPropertyNameFromType(type); var symbolFlags = decl.symbol.flags; @@ -38248,9 +40476,9 @@ var ts; // If we have an existing early-bound member, combine its declarations so that we can // report an error at each declaration. var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations; - var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(decl.name); + var name_3 = !(type.flags & 8192 /* UniqueESSymbol */) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName); ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_3); }); - error(decl.name || decl, ts.Diagnostics.Duplicate_property_0, name_3); + error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_3); lateSymbol = createSymbol(0 /* None */, memberName, 4096 /* Late */); } lateSymbol.nameType = type; @@ -38291,6 +40519,21 @@ var ts; } } } + var assignments = symbol.assignmentDeclarationMembers; + if (assignments) { + var decls = ts.arrayFrom(assignments.values()); + for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) { + var member = decls_1[_c]; + var assignmentKind = ts.getAssignmentDeclarationKind(member); + var isInstanceMember = assignmentKind === 3 /* PrototypeProperty */ + || assignmentKind === 4 /* ThisProperty */ + || assignmentKind === 9 /* ObjectDefinePrototypeProperty */ + || assignmentKind === 6 /* Prototype */; // A straight `Prototype` assignment probably can never have a computed name + if (isStatic === !isInstanceMember && hasLateBindableName(member)) { + lateBindMember(symbol, earlySymbols, lateSymbols, member); + } + } + } links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols; } return links[resolutionKind]; @@ -38301,7 +40544,7 @@ var ts; * For a description of late-binding, see `lateBindMember`. */ function getMembersOfSymbol(symbol) { - return symbol.flags & 6240 /* LateBindingContainer */ + return symbol.flags & 6256 /* LateBindingContainer */ ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers" /* resolvedMembers */) : symbol.members || emptySymbols; } @@ -38331,7 +40574,7 @@ var ts; function getTypeWithThisArgument(type, thisArgument, needApparentType) { if (ts.getObjectFlags(type) & 4 /* Reference */) { var target = type.target; - var typeArguments = type.typeArguments; + var typeArguments = getTypeArguments(type); if (ts.length(target.typeParameters) === ts.length(typeArguments)) { var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType])); return needApparentType ? getApparentType(ref) : ref; @@ -38394,12 +40637,12 @@ var ts; function resolveTypeReferenceMembers(type) { var source = resolveDeclaredMembers(type.target); var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]); - var typeArguments = type.typeArguments && type.typeArguments.length === typeParameters.length ? - type.typeArguments : ts.concatenate(type.typeArguments, [type]); - resolveObjectTypeMembers(type, source, typeParameters, typeArguments); + var typeArguments = getTypeArguments(type); + var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]); + resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments); } - function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, hasRestParameter, hasLiteralTypes) { - var sig = new Signature(checker); + function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) { + var sig = new Signature(checker, flags); sig.declaration = declaration; sig.typeParameters = typeParameters; sig.parameters = parameters; @@ -38407,15 +40650,13 @@ var ts; sig.resolvedReturnType = resolvedReturnType; sig.resolvedTypePredicate = resolvedTypePredicate; sig.minArgumentCount = minArgumentCount; - sig.hasRestParameter = hasRestParameter; - sig.hasLiteralTypes = hasLiteralTypes; sig.target = undefined; sig.mapper = undefined; return sig; } function cloneSignature(sig) { var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.hasRestParameter, sig.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */); result.target = sig.target; result.mapper = sig.mapper; return result; @@ -38427,13 +40668,22 @@ var ts; result.mapper = undefined; return result; } + function getOptionalCallSignature(signature) { + return signatureIsOptionalCall(signature) ? signature : + (signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature))); + } + function createOptionalCallSignature(signature) { + var result = cloneSignature(signature); + result.flags |= 4 /* IsOptionalCall */; + return result; + } function getExpandedParameters(sig) { - if (sig.hasRestParameter) { + if (signatureHasRestParameter(sig)) { var restIndex_1 = sig.parameters.length - 1; var restParameter = sig.parameters[restIndex_1]; var restType = getTypeOfSymbol(restParameter); if (isTupleType(restType)) { - var elementTypes = restType.typeArguments || ts.emptyArray; + var elementTypes = getTypeArguments(restType); var minLength_1 = restType.target.minLength; var tupleRestIndex_1 = restType.target.hasRestElement ? elementTypes.length - 1 : -1; var restParams = ts.map(elementTypes, function (t, i) { @@ -38453,7 +40703,7 @@ var ts; var baseConstructorType = getBaseConstructorTypeOfClass(classType); var baseSignatures = getSignaturesOfType(baseConstructorType, 1 /* Construct */); if (baseSignatures.length === 0) { - return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; // TODO: GH#18217 + return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); var isJavaScript = ts.isInJSFile(baseTypeNode); @@ -38550,7 +40800,7 @@ var ts; // signatures from the type, whose ordering would be non-obvious) var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0]; var results = masterList.slice(); - var _loop_5 = function (signatures) { + var _loop_7 = function (signatures) { if (signatures !== masterList) { var signature_1 = signatures[0]; ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass"); @@ -38562,8 +40812,8 @@ var ts; }; for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) { var signatures = signatureLists_1[_b]; - var state_2 = _loop_5(signatures); - if (state_2 === "break") + var state_3 = _loop_7(signatures); + if (state_3 === "break") break; } result = results; @@ -38617,11 +40867,9 @@ var ts; var params = combineUnionParameters(left, right); var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter); var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount); - var hasRestParam = left.hasRestParameter || right.hasRestParameter; - var hasLiteralTypes = left.hasLiteralTypes || right.hasLiteralTypes; var result = createSignature(declaration, left.typeParameters || right.typeParameters, thisParam, params, /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, minArgCount, hasRestParam, hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, minArgCount, (left.flags | right.flags) & 3 /* PropagatingFlags */); result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]); return result; } @@ -38688,7 +40936,7 @@ var ts; var types = type.types; var mixinFlags = findMixins(types); var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; }); - var _loop_6 = function (i) { + var _loop_8 = function (i) { var t = type.types[i]; // When an intersection type contains mixin constructor types, the construct signatures from // those types are discarded and their return types are mixed into the return types of all @@ -38711,19 +40959,19 @@ var ts; numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1 /* Number */)); }; for (var i = 0; i < types.length; i++) { - _loop_6(i); + _loop_8(i); } setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo); } function appendSignatures(signatures, newSignatures) { - var _loop_7 = function (sig) { + var _loop_9 = function (sig) { if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, /*partialMatch*/ false, /*ignoreThisTypes*/ false, /*ignoreReturnTypes*/ false, compareTypesIdentical); })) { signatures = ts.append(signatures, sig); } }; for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) { var sig = newSignatures_1[_i]; - _loop_7(sig); + _loop_9(sig); } return signatures; } @@ -38731,7 +40979,7 @@ var ts; * Converts an AnonymousType to a ResolvedType. */ function resolveAnonymousTypeMembers(type) { - var symbol = type.symbol; + var symbol = getMergedSymbol(type.symbol); if (type.target) { setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined); var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, /*mappingThisOnly*/ false); @@ -38787,14 +41035,18 @@ var ts; // will never be observed because a qualified name can't reference signatures. if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { type.callSignatures = getSignaturesOfSymbol(symbol); - type.constructSignatures = ts.filter(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration); }); } // And likewise for construct signatures for classes if (symbol.flags & 32 /* Class */) { - var classType = getDeclaredTypeOfClassOrInterface(symbol); - var constructSignatures = getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)); + var classType_1 = getDeclaredTypeOfClassOrInterface(symbol); + var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor" /* Constructor */)) : ts.emptyArray; + if (symbol.flags & 16 /* Function */) { + constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ? + createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, /*resolvedTypePredicate*/ undefined, sig.minArgumentCount, sig.flags & 3 /* PropagatingFlags */) : + undefined; })); + } if (!constructSignatures.length) { - constructSignatures = getDefaultConstructSignatures(classType); + constructSignatures = getDefaultConstructSignatures(classType_1); } type.constructSignatures = constructSignatures; } @@ -38937,8 +41189,8 @@ var ts; } function isMappedTypeWithKeyofConstraintDeclaration(type) { var constraintDeclaration = getConstraintDeclarationForMappedType(type); // TODO: GH#18217 - return constraintDeclaration.kind === 180 /* TypeOperator */ && - constraintDeclaration.operator === 130 /* KeyOfKeyword */; + return constraintDeclaration.kind === 183 /* TypeOperator */ && + constraintDeclaration.operator === 133 /* KeyOfKeyword */; } function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { @@ -38962,8 +41214,8 @@ var ts; } function getMappedTypeModifiers(type) { var declaration = type.declaration; - return (declaration.readonlyToken ? declaration.readonlyToken.kind === 39 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | - (declaration.questionToken ? declaration.questionToken.kind === 39 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); + return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 /* MinusToken */ ? 2 /* ExcludeReadonly */ : 1 /* IncludeReadonly */ : 0) | + (declaration.questionToken ? declaration.questionToken.kind === 40 /* MinusToken */ ? 8 /* ExcludeOptional */ : 4 /* IncludeOptional */ : 0); } function getMappedTypeOptionality(type) { var modifiers = getMappedTypeModifiers(type); @@ -39179,11 +41431,11 @@ var ts; function getConstraintOfConditionalType(type) { return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined; } - function getUnionConstraintOfIntersection(type, targetIsUnion) { + function getEffectiveConstraintOfIntersection(types, targetIsUnion) { var constraints; var hasDisjointDomainType = false; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var t = _a[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var t = types_4[_i]; if (t.flags & 63176704 /* Instantiable */) { // We keep following constraints as long as we have an instantiable type that is known // not to be circular or infinite (hence we stop on index access types). @@ -39193,6 +41445,9 @@ var ts; } if (constraint) { constraints = ts.append(constraints, constraint); + if (targetIsUnion) { + constraints = ts.append(constraints, t); + } } } else if (t.flags & 67238908 /* DisjointDomains */) { @@ -39205,8 +41460,8 @@ var ts; if (hasDisjointDomainType) { // We add any types belong to one of the disjoint domains because they might cause the final // intersection operation to reduce the union constraints. - for (var _b = 0, _c = type.types; _b < _c.length; _b++) { - var t = _c[_b]; + for (var _a = 0, types_5 = types; _a < types_5.length; _a++) { + var t = types_5[_a]; if (t.flags & 67238908 /* DisjointDomains */) { constraints = ts.append(constraints, t); } @@ -39292,8 +41547,8 @@ var ts; if (t.flags & 3145728 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type_3 = types_4[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type_3 = types_6[_i]; var baseType = getBaseConstraint(type_3); if (baseType) { baseTypes.push(baseType); @@ -39641,10 +41896,10 @@ var ts; function isJSDocOptionalParameter(node) { return ts.isInJSFile(node) && ( // node.type should only be a JSDocOptionalType when node is a parameter of a JSDocFunctionType - node.type && node.type.kind === 294 /* JSDocOptionalType */ + node.type && node.type.kind === 297 /* JSDocOptionalType */ || ts.getJSDocParameterTags(node).some(function (_a) { var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; })); } function tryFindAmbientModule(moduleName, withAugmentations) { @@ -39678,13 +41933,10 @@ var ts; return false; } var isBracketed = node.isBracketed, typeExpression = node.typeExpression; - return isBracketed || !!typeExpression && typeExpression.type.kind === 294 /* JSDocOptionalType */; + return isBracketed || !!typeExpression && typeExpression.type.kind === 297 /* JSDocOptionalType */; } - function createIdentifierTypePredicate(parameterName, parameterIndex, type) { - return { kind: 1 /* Identifier */, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; - } - function createThisTypePredicate(type) { - return { kind: 0 /* This */, type: type }; + function createTypePredicate(kind, parameterName, parameterIndex, type) { + return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type }; } /** * Gets the minimum number of type arguments needed to satisfy all non-optional type @@ -39730,7 +41982,7 @@ var ts; var links = getNodeLinks(declaration); if (!links.resolvedSignature) { var parameters = []; - var hasLiteralTypes = false; + var flags = 0 /* None */; var minArgumentCount = 0; var thisParameter = void 0; var hasThisParameter = false; @@ -39760,8 +42012,8 @@ var ts; else { parameters.push(paramSymbol); } - if (type && type.kind === 183 /* LiteralType */) { - hasLiteralTypes = true; + if (type && type.kind === 186 /* LiteralType */) { + flags |= 2 /* HasLiteralTypes */; } // Record a new minimum argument count if this is not an optional parameter var isOptionalParameter_1 = isOptionalJSDocParameterTag(param) || @@ -39774,22 +42026,24 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 159 /* GetAccessor */ || declaration.kind === 160 /* SetAccessor */) && + if ((declaration.kind === 162 /* GetAccessor */ || declaration.kind === 163 /* SetAccessor */) && !hasNonBindableDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = declaration.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 158 /* Constructor */ ? + var classType = declaration.kind === 161 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration); - var hasRestLikeParameter = ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters); + if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) { + flags |= 1 /* HasRestParameter */; + } links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, - /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, hasRestLikeParameter, hasLiteralTypes); + /*resolvedReturnType*/ undefined, /*resolvedTypePredicate*/ undefined, minArgumentCount, flags); } return links.resolvedSignature; } @@ -39841,13 +42095,13 @@ var ts; if (!node) return false; switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node.escapedText === "arguments" && ts.isExpressionNode(node); - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - return node.name.kind === 150 /* ComputedPropertyName */ + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + return node.name.kind === 153 /* ComputedPropertyName */ && traverse(node.name); default: return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse); @@ -39890,9 +42144,6 @@ var ts; return getTypeOfSymbol(signature.thisParameter); } } - function signatureHasTypePredicate(signature) { - return getTypePredicateOfSignature(signature) !== undefined; - } function getTypePredicateOfSignature(signature) { if (!signature.resolvedTypePredicate) { if (signature.target) { @@ -39921,13 +42172,10 @@ var ts; } function createTypePredicateFromTypePredicateNode(node, signature) { var parameterName = node.parameterName; - var type = getTypeFromTypeNode(node.type); - if (parameterName.kind === 73 /* Identifier */) { - return createIdentifierTypePredicate(parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); - } - else { - return createThisTypePredicate(type); - } + var type = node.type && getTypeFromTypeNode(node.type); + return parameterName.kind === 182 /* ThisType */ ? + createTypePredicate(node.assertsModifier ? 2 /* AssertsThis */ : 0 /* This */, /*parameterName*/ undefined, /*parameterIndex*/ undefined, type) : + createTypePredicate(node.assertsModifier ? 3 /* AssertsIdentifier */ : 1 /* Identifier */, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type); } function getReturnTypeOfSignature(signature) { if (!signature.resolvedReturnType) { @@ -39937,8 +42185,10 @@ var ts; var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) : signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) : getReturnTypeFromAnnotation(signature.declaration) || - isJSConstructor(signature.declaration) && getJSClassType(getSymbolOfNode(signature.declaration)) || (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration)); + if (signatureIsOptionalCall(signature)) { + type = addOptionalTypeMarker(type); + } if (!popTypeResolution()) { if (signature.declaration) { var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration); @@ -39963,7 +42213,7 @@ var ts; return signature.resolvedReturnType; } function getReturnTypeFromAnnotation(declaration) { - if (declaration.kind === 158 /* Constructor */) { + if (declaration.kind === 161 /* Constructor */) { return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)); } if (ts.isJSDocConstructSignature(declaration)) { @@ -39973,12 +42223,12 @@ var ts; if (typeNode) { return getTypeFromTypeNode(typeNode); } - if (declaration.kind === 159 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { + if (declaration.kind === 162 /* GetAccessor */ && !hasNonBindableDynamicName(declaration)) { var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration); if (jsDocType) { return jsDocType; } - var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 160 /* SetAccessor */); + var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 163 /* SetAccessor */); var setterType = getAnnotatedAccessorType(setter); if (setterType) { return setterType; @@ -39993,7 +42243,7 @@ var ts; return tryGetRestTypeOfSignature(signature) || anyType; } function tryGetRestTypeOfSignature(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType; return restType && getIndexTypeOfType(restType, 1 /* Number */); @@ -40068,7 +42318,7 @@ var ts; // will result in a different declaration kind. if (!signature.isolatedSignatureType) { var kind = signature.declaration ? signature.declaration.kind : 0 /* Unknown */; - var isConstructor = kind === 158 /* Constructor */ || kind === 162 /* ConstructSignature */ || kind === 167 /* ConstructorType */; + var isConstructor = kind === 161 /* Constructor */ || kind === 165 /* ConstructSignature */ || kind === 170 /* ConstructorType */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = ts.emptyArray; @@ -40082,7 +42332,7 @@ var ts; return symbol.members.get("__index" /* Index */); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 136 /* NumberKeyword */ : 139 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 139 /* NumberKeyword */ : 142 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -40116,13 +42366,13 @@ var ts; if (typeParameter.symbol) { for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.parent.kind === 177 /* InferType */) { + if (declaration.parent.kind === 180 /* InferType */) { // When an 'infer T' declaration is immediately contained in a type reference node // (such as 'Foo'), T's constraint is inferred from the constraint of the // corresponding type parameter in 'Foo'. When multiple 'infer T' declarations are // present, we form an intersection of the inferred constraint types. var grandParent = declaration.parent.parent; - if (grandParent.kind === 165 /* TypeReference */) { + if (grandParent.kind === 168 /* TypeReference */) { var typeReference = grandParent; var typeParameters = getTypeParametersForTypeReference(typeReference); if (typeParameters) { @@ -40147,7 +42397,7 @@ var ts; } // When an 'infer T' declaration is immediately contained in a rest parameter // declaration, we infer an 'unknown[]' constraint. - else if (grandParent.kind === 152 /* Parameter */ && grandParent.dotDotDotToken) { + else if (grandParent.kind === 155 /* Parameter */ && grandParent.dotDotDotToken) { inferences = ts.append(inferences, createArrayType(unknownType)); } } @@ -40171,7 +42421,7 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - var tp = ts.getDeclarationOfKind(typeParameter.symbol, 151 /* TypeParameter */); + var tp = ts.getDeclarationOfKind(typeParameter.symbol, 154 /* TypeParameter */); var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent; return host && getSymbolOfNode(host); } @@ -40204,8 +42454,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var type = types_7[_i]; if (!(type.flags & excludeKinds)) { result |= ts.getObjectFlags(type); } @@ -40220,7 +42470,7 @@ var ts; target.instantiations.set(id, type); type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; - type.typeArguments = typeArguments; + type.resolvedTypeArguments = typeArguments; } return type; } @@ -40229,16 +42479,50 @@ var ts; type.symbol = source.symbol; type.objectFlags = source.objectFlags; type.target = source.target; - type.typeArguments = source.typeArguments; + type.resolvedTypeArguments = source.resolvedTypeArguments; return type; } + function createDeferredTypeReference(target, node, mapper) { + var aliasSymbol = getAliasSymbolForTypeNode(node); + var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol); + var type = createObjectType(4 /* Reference */, target.symbol); + type.target = target; + type.node = node; + type.mapper = mapper; + type.aliasSymbol = aliasSymbol; + type.aliasTypeArguments = mapper ? instantiateTypes(aliasTypeArguments, mapper) : aliasTypeArguments; + return type; + } + function getTypeArguments(type) { + var _a, _b; + if (!type.resolvedTypeArguments) { + if (!pushTypeResolution(type, 7 /* ResolvedTypeArguments */)) { + return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray; + } + var node = type.node; + var typeArguments = !node ? ts.emptyArray : + node.kind === 168 /* TypeReference */ ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) : + node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : + ts.map(node.elementTypes, getTypeFromTypeNode); + if (popTypeResolution()) { + type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments; + } + else { + type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray; + error(type.node || currentNode, type.target.symbol + ? ts.Diagnostics.Type_arguments_for_0_circularly_reference_themselves + : ts.Diagnostics.Tuple_type_arguments_circularly_reference_themselves, type.target.symbol && symbolToString(type.target.symbol)); + } + } + return type.resolvedTypeArguments; + } function getTypeReferenceArity(type) { return ts.length(type.target.typeParameters); } /** * Get type from type-reference that reference to class or interface */ - function getTypeFromClassOrInterfaceReference(node, symbol, typeArgs) { + function getTypeFromClassOrInterfaceReference(node, symbol) { var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); var typeParameters = type.localTypeParameters; if (typeParameters) { @@ -40248,13 +42532,13 @@ var ts; var isJsImplicitAny = !noImplicitAny && isJs; if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent); - var diag = minTypeArgumentCount === typeParameters.length - ? missingAugmentsTag - ? ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : missingAugmentsTag - ? ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; + var diag = minTypeArgumentCount === typeParameters.length ? + missingAugmentsTag ? + ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + missingAugmentsTag ? + ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments; var typeStr = typeToString(type, /*enclosingDeclaration*/ undefined, 2 /* WriteArrayAsGenericType */); error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length); if (!isJs) { @@ -40262,10 +42546,13 @@ var ts; return errorType; } } + if (node.kind === 168 /* TypeReference */ && isAliasedType(node)) { + return createDeferredTypeReference(type, node, /*mapper*/ undefined); + } // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJs)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs)); return createTypeReference(type, typeArguments); } return checkNoTypeArguments(node, symbol) ? type : errorType; @@ -40286,27 +42573,27 @@ var ts; * references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the * declared type. Instantiations are cached using the type identities of the type arguments as the key. */ - function getTypeFromTypeAliasReference(node, symbol, typeArguments) { + function getTypeFromTypeAliasReference(node, symbol) { var type = getDeclaredTypeOfSymbol(symbol); var typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { - error(node, minTypeArgumentCount === typeParameters.length - ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s - : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); + error(node, minTypeArgumentCount === typeParameters.length ? + ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : + ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length); return errorType; } - return getTypeAliasInstantiation(symbol, typeArguments); + return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node)); } return checkNoTypeArguments(node, symbol) ? type : errorType; } function getTypeReferenceName(node) { switch (node.kind) { - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -40324,13 +42611,15 @@ var ts; return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol; } function getTypeReferenceType(node, symbol) { - var typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. if (symbol === unknownSymbol) { return errorType; } - var type = getTypeReferenceTypeWorker(node, symbol, typeArguments); - if (type) { - return type; + symbol = getExpandoSymbol(symbol) || symbol; + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + return getTypeFromClassOrInterfaceReference(node, symbol); + } + if (symbol.flags & 524288 /* TypeAlias */) { + return getTypeFromTypeAliasReference(node, symbol); } // Get type from reference to named type that cannot be generic (enum or type parameter) var res = tryGetDeclaredTypeOfSymbol(symbol); @@ -40339,56 +42628,44 @@ var ts; res.flags & 262144 /* TypeParameter */ ? getConstrainedTypeVariable(res, node) : getRegularTypeOfLiteralType(res) : errorType; } - if (!(symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node))) { - return errorType; - } - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + if (symbol.flags & 111551 /* Value */ && isJSDocTypeReference(node)) { + var jsdocType = getTypeFromJSDocValueReference(node, symbol); + if (jsdocType) { + return jsdocType; + } + else { + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); + return getTypeOfSymbol(symbol); + } } - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */); - return getTypeOfSymbol(symbol); + return errorType; } /** - * A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - * the symbol is a constructor function, return the inferred class type; otherwise, - * the type of this reference is just the type of the value we resolved to. + * A JSdoc TypeReference may be to a value, but resolve it as a type anyway. + * Note: If the value is imported from commonjs, it should really be an alias, + * but this function's special-case code fakes alias resolution as well. */ - function getJSDocTypeReference(node, symbol, typeArguments) { - // In the case of an assignment of a function expression (binary expressions, variable declarations, etc.), we will get the - // correct instance type for the symbol on the LHS by finding the type for RHS. For example if we want to get the type of the symbol `foo`: - // var foo = function() {} - // We will find the static type of the assigned anonymous function. - var staticType = getTypeOfSymbol(symbol); - var instanceType = staticType.symbol && - staticType.symbol !== symbol && // Make sure this is an assignment like expression by checking that symbol -> type -> symbol doesn't roundtrips. - getTypeReferenceTypeWorker(node, staticType.symbol, typeArguments); // Get the instance type of the RHS symbol. - if (instanceType) { - return getSymbolLinks(symbol).resolvedJSDocType = instanceType; - } - } - function getTypeReferenceTypeWorker(node, symbol, typeArguments) { - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - if (symbol.valueDeclaration && symbol.valueDeclaration.parent && ts.isBinaryExpression(symbol.valueDeclaration.parent)) { - var jsdocType = getJSDocTypeReference(node, symbol, typeArguments); - if (jsdocType) { - return jsdocType; + function getTypeFromJSDocValueReference(node, symbol) { + var valueType = getTypeOfSymbol(symbol); + var typeType = valueType; + if (symbol.valueDeclaration) { + var decl = ts.getRootDeclaration(symbol.valueDeclaration); + var isRequireAlias = false; + if (ts.isVariableDeclaration(decl) && decl.initializer) { + var expr = decl.initializer; + // skip past entity names, eg `require("x").a.b.c` + while (ts.isPropertyAccessExpression(expr)) { + expr = expr.expression; } + isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol; } - return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); - } - if (symbol.flags & 524288 /* TypeAlias */) { - return getTypeFromTypeAliasReference(node, symbol, typeArguments); - } - if (symbol.flags & 16 /* Function */ && - isJSDocTypeReference(node) && - isJSConstructor(symbol.valueDeclaration)) { - var resolved = resolveStructuredTypeMembers(getTypeOfSymbol(symbol)); - if (resolved.callSignatures.length === 1) { - return getReturnTypeOfSignature(resolved.callSignatures[0]); + var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol; + if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) { + typeType = getTypeReferenceType(node, valueType.symbol); } } + return getSymbolLinks(symbol).resolvedJSDocType = typeType; } function getSubstitutionType(typeVariable, substitute) { if (substitute.flags & 3 /* AnyOrUnknown */ || substitute === typeVariable) { @@ -40406,7 +42683,7 @@ var ts; return result; } function isUnaryTupleTypeNode(node) { - return node.kind === 171 /* TupleType */ && node.elementTypes.length === 1; + return node.kind === 174 /* TupleType */ && node.elementTypes.length === 1; } function getImpliedConstraint(typeVariable, checkNode, extendsNode) { return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(typeVariable, checkNode.elementTypes[0], extendsNode.elementTypes[0]) : @@ -40415,9 +42692,9 @@ var ts; } function getConstrainedTypeVariable(typeVariable, node) { var constraints; - while (node && !ts.isStatement(node) && node.kind !== 298 /* JSDocComment */) { + while (node && !ts.isStatement(node) && node.kind !== 301 /* JSDocComment */) { var parent = node.parent; - if (parent.kind === 176 /* ConditionalType */ && node === parent.trueType) { + if (parent.kind === 179 /* ConditionalType */ && node === parent.trueType) { var constraint = getImpliedConstraint(typeVariable, parent.checkType, parent.extendsType); if (constraint) { constraints = ts.append(constraints, constraint); @@ -40428,7 +42705,7 @@ var ts; return constraints ? getSubstitutionType(typeVariable, getIntersectionType(ts.append(constraints, typeVariable))) : typeVariable; } function isJSDocTypeReference(node) { - return !!(node.flags & 2097152 /* JSDoc */) && (node.kind === 165 /* TypeReference */ || node.kind === 184 /* ImportType */); + return !!(node.flags & 4194304 /* JSDoc */) && (node.kind === 168 /* TypeReference */ || node.kind === 187 /* ImportType */); } function checkNoTypeArguments(node, symbol) { if (node.typeArguments) { @@ -40465,10 +42742,10 @@ var ts; return globalFunctionType; case "Array": case "array": - return !typeArgs || !typeArgs.length ? anyArrayType : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined; case "Promise": case "promise": - return !typeArgs || !typeArgs.length ? createPromiseType(anyType) : undefined; + return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined; case "Object": if (typeArgs && typeArgs.length === 2) { if (ts.isJSDocIndexSignature(node)) { @@ -40480,7 +42757,7 @@ var ts; return anyType; } checkNoTypeArguments(node); - return anyType; + return !noImplicitAny ? anyType : undefined; } } } @@ -40538,9 +42815,9 @@ var ts; for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) { var declaration = declarations_3[_i]; switch (declaration.kind) { - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 247 /* EnumDeclaration */: return declaration; } } @@ -40659,15 +42936,55 @@ var ts; function createArrayType(elementType, readonly) { return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]); } - function getTypeFromArrayTypeNode(node) { + function getArrayOrTupleTargetType(node) { + var readonly = isReadonlyTypeOperator(node.parent); + if (node.kind === 173 /* ArrayType */ || node.elementTypes.length === 1 && node.elementTypes[0].kind === 176 /* RestType */) { + return readonly ? globalReadonlyArrayType : globalArrayType; + } + var lastElement = ts.lastOrUndefined(node.elementTypes); + var restElement = lastElement && lastElement.kind === 176 /* RestType */ ? lastElement : undefined; + var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 175 /* OptionalType */ && n !== restElement; }) + 1; + return getTupleTypeOfArity(node.elementTypes.length, minLength, !!restElement, readonly, /*associatedNames*/ undefined); + } + // Return true when the given node is transitively contained in type constructs that eagerly + // resolve their constituent types. We include SyntaxKind.TypeReference because type arguments + // of type aliases are eagerly resolved. + function isAliasedType(node) { + var parent = node.parent; + switch (parent.kind) { + case 181 /* ParenthesizedType */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 184 /* IndexedAccessType */: + case 179 /* ConditionalType */: + case 183 /* TypeOperator */: + return isAliasedType(parent); + case 246 /* TypeAliasDeclaration */: + return true; + } + return false; + } + function getTypeFromArrayOrTupleTypeNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - links.resolvedType = createArrayType(getTypeFromTypeNode(node.elementType), isReadonlyTypeOperator(node.parent)); + var target = getArrayOrTupleTargetType(node); + if (target === emptyGenericType) { + links.resolvedType = emptyObjectType; + } + else if (isAliasedType(node)) { + links.resolvedType = node.kind === 174 /* TupleType */ && node.elementTypes.length === 0 ? target : + createDeferredTypeReference(target, node, /*mapper*/ undefined); + } + else { + var elementTypes = node.kind === 173 /* ArrayType */ ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elementTypes, getTypeFromTypeNode); + links.resolvedType = createTypeReference(target, elementTypes); + } } return links.resolvedType; } function isReadonlyTypeOperator(node) { - return ts.isTypeOperatorNode(node) && node.operator === 134 /* ReadonlyKeyword */; + return ts.isTypeOperatorNode(node) && node.operator === 137 /* ReadonlyKeyword */; } // We represent tuple types as type references to synthesized generic interface types created by // this function. The types are of the form: @@ -40704,7 +43021,7 @@ var ts; type.instantiations = ts.createMap(); type.instantiations.set(getTypeListId(type.typeParameters), type); type.target = type; - type.typeArguments = type.typeParameters; + type.resolvedTypeArguments = type.typeParameters; type.thisType = createTypeParameter(); type.thisType.isThisType = true; type.thisType.constraint = type; @@ -40738,27 +43055,13 @@ var ts; var tupleType = getTupleTypeOfArity(arity, minLength, arity > 0 && hasRestElement, readonly, associatedNames); return elementTypes.length ? createTypeReference(tupleType, elementTypes) : tupleType; } - function getTypeFromTupleTypeNode(node) { - var links = getNodeLinks(node); - if (!links.resolvedType) { - var lastElement = ts.lastOrUndefined(node.elementTypes); - var restElement_1 = lastElement && lastElement.kind === 173 /* RestType */ ? lastElement : undefined; - var minLength = ts.findLastIndex(node.elementTypes, function (n) { return n.kind !== 172 /* OptionalType */ && n !== restElement_1; }) + 1; - var elementTypes = ts.map(node.elementTypes, function (n) { - var type = getTypeFromTypeNode(n); - return n === restElement_1 && getIndexTypeOfType(type, 1 /* Number */) || type; - }); - links.resolvedType = createTupleType(elementTypes, minLength, !!restElement_1, isReadonlyTypeOperator(node.parent)); - } - return links.resolvedType; - } function sliceTupleType(type, index) { var tuple = type.target; if (tuple.hasRestElement) { // don't slice off rest element index = Math.min(index, getTypeReferenceArity(type) - 1); } - return createTupleType((type.typeArguments || ts.emptyArray).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); + return createTupleType(getTypeArguments(type).slice(index), Math.max(0, tuple.minLength - index), tuple.hasRestElement, tuple.readonly, tuple.associatedNames && tuple.associatedNames.slice(index)); } function getTypeFromOptionalTypeNode(node) { var type = getTypeFromTypeNode(node.type); @@ -40807,8 +43110,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, includes, types) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var type = types_6[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; includes = addTypeToUnion(typeSet, includes, type); } return includes; @@ -40837,8 +43140,8 @@ var ts; while (i > 0) { i--; var source = types[i]; - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var target = types_7[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var target = types_9[_i]; if (source !== target) { if (count === 100000) { // After 100000 subtype checks we estimate the remaining amount of work by assuming the @@ -40923,10 +43226,10 @@ var ts; function getUnionTypePredicate(signatures) { var first; var types = []; - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var sig = signatures_2[_i]; + for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { + var sig = signatures_5[_i]; var pred = getTypePredicateOfSignature(sig); - if (!pred) { + if (!pred || pred.kind === 2 /* AssertsThis */ || pred.kind === 3 /* AssertsIdentifier */) { continue; } if (first) { @@ -40945,14 +43248,10 @@ var ts; return undefined; } var unionType = getUnionType(types); - return ts.isIdentifierTypePredicate(first) - ? createIdentifierTypePredicate(first.parameterName, first.parameterIndex, unionType) - : createThisTypePredicate(unionType); + return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType); } function typePredicateKindsMatch(a, b) { - return ts.isIdentifierTypePredicate(a) - ? ts.isIdentifierTypePredicate(b) && a.parameterIndex === b.parameterIndex - : !ts.isIdentifierTypePredicate(b); + return a.kind === b.kind && a.parameterIndex === b.parameterIndex; } // This function assumes the constituent type list is sorted and deduplicated. function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments) { @@ -41019,8 +43318,8 @@ var ts; // Add the given types to the given type set. Order is preserved, freshness is removed from literal // types, duplicates are removed, and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, includes, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var type = types_10[_i]; includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type)); } return includes; @@ -41295,21 +43594,22 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedType) { switch (node.operator) { - case 130 /* KeyOfKeyword */: + case 133 /* KeyOfKeyword */: links.resolvedType = getIndexType(getTypeFromTypeNode(node.type)); break; - case 143 /* UniqueKeyword */: - links.resolvedType = node.type.kind === 140 /* SymbolKeyword */ + case 146 /* UniqueKeyword */: + links.resolvedType = node.type.kind === 143 /* SymbolKeyword */ ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent)) : errorType; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: links.resolvedType = getTypeFromTypeNode(node.type); break; + default: + throw ts.Debug.assertNever(node.operator); } } - // tslint:disable no-unnecessary-type-assertion - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function createIndexedAccessType(objectType, indexType) { var type = createType(8388608 /* IndexedAccess */); @@ -41345,7 +43645,7 @@ var ts; return false; } function getPropertyNameFromIndex(indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; return isTypeUsableAsPropertyName(indexType) ? getPropertyNameFromType(indexType) : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -41356,13 +43656,13 @@ var ts; undefined; } function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags) { - var accessExpression = accessNode && accessNode.kind === 191 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode : undefined; var propName = getPropertyNameFromIndex(indexType, accessNode); if (propName !== undefined) { var prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { - markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, accessExpression, /*isThisAccess*/ accessExpression.expression.kind === 103 /* ThisKeyword */); if (ts.isAssignmentTarget(accessExpression) && (isReferenceToReadonlyEntity(accessExpression, prop) || isReferenceThroughNamespaceImport(accessExpression))) { error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop)); return undefined; @@ -41493,13 +43793,10 @@ var ts; } } function getIndexNodeForAccessExpression(accessNode) { - return accessNode.kind === 191 /* ElementAccessExpression */ - ? accessNode.argumentExpression - : accessNode.kind === 181 /* IndexedAccessType */ - ? accessNode.indexType - : accessNode.kind === 150 /* ComputedPropertyName */ - ? accessNode.expression - : accessNode; + return accessNode.kind === 194 /* ElementAccessExpression */ ? accessNode.argumentExpression : + accessNode.kind === 184 /* IndexedAccessType */ ? accessNode.indexType : + accessNode.kind === 153 /* ComputedPropertyName */ ? accessNode.expression : + accessNode; } function isGenericObjectType(type) { return maybeTypeOfKind(type, 58982400 /* InstantiableNonPrimitive */ | 131072 /* GenericMappedType */); @@ -41624,7 +43921,7 @@ var ts; // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. - if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 181 /* IndexedAccessType */) && isGenericObjectType(objectType)) { + if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind !== 184 /* IndexedAccessType */) && isGenericObjectType(objectType)) { if (objectType.flags & 3 /* AnyOrUnknown */) { return objectType; } @@ -41836,7 +44133,7 @@ var ts; links.resolvedSymbol = unknownSymbol; return links.resolvedType = errorType; } - var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 2097152 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; + var targetMeaning = node.isTypeOf ? 111551 /* Value */ : node.flags & 4194304 /* JSDoc */ ? 111551 /* Value */ | 788968 /* Type */ : 788968 /* Type */; // TODO: Future work: support unions/generics/whatever via a deferred import-type var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal); if (!innerModuleSymbol) { @@ -41859,11 +44156,11 @@ var ts; getNodeLinks(current.parent).resolvedSymbol = next; currentNamespace = next; } - resolveImportSymbolType(node, links, currentNamespace, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning); } else { if (moduleSymbol.flags & targetMeaning) { - resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); + links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning); } else { var errorMessage = targetMeaning === 111551 /* Value */ @@ -41875,16 +44172,16 @@ var ts; } } } - return links.resolvedType; // TODO: GH#18217 + return links.resolvedType; } function resolveImportSymbolType(node, links, symbol, meaning) { var resolvedSymbol = resolveSymbol(symbol); links.resolvedSymbol = resolvedSymbol; if (meaning === 111551 /* Value */) { - return links.resolvedType = getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias + return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias } else { - return links.resolvedType = getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol + return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol } } function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) { @@ -41908,7 +44205,11 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return ts.isTypeAlias(node.parent) ? getSymbolOfNode(node.parent) : undefined; + var host = node.parent; + while (ts.isParenthesizedTypeNode(host) || ts.isTypeOperatorNode(host) && host.operator === 137 /* ReadonlyKeyword */) { + host = host.parent; + } + return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined; } function getTypeArgumentsForAliasSymbol(symbol) { return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined; @@ -42097,12 +44398,26 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 242 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 245 /* InterfaceDeclaration */)) { if (!ts.hasModifier(container, 32 /* Static */) && - (container.kind !== 158 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } + // inside x.prototype = { ... } + if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6 /* Prototype */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType; + } + // /** @return {this} */ + // x.prototype.m = function() { ... } + var host = node.flags & 4194304 /* JSDoc */ ? ts.getHostSignatureFromJSDoc(node) : undefined; + if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3 /* PrototypeProperty */) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType; + } + // inside constructor function C() { ... } + if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) { + return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType; + } error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface); return errorType; } @@ -42115,89 +44430,89 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 121 /* AnyKeyword */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: + case 124 /* AnyKeyword */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: return anyType; - case 144 /* UnknownKeyword */: + case 147 /* UnknownKeyword */: return unknownType; - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return stringType; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return numberType; - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return bigintType; - case 124 /* BooleanKeyword */: + case 127 /* BooleanKeyword */: return booleanType; - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return esSymbolType; - case 107 /* VoidKeyword */: + case 109 /* VoidKeyword */: return voidType; - case 142 /* UndefinedKeyword */: + case 145 /* UndefinedKeyword */: return undefinedType; - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullType; - case 133 /* NeverKeyword */: + case 136 /* NeverKeyword */: return neverType; - case 137 /* ObjectKeyword */: - return node.flags & 65536 /* JavaScriptFile */ ? anyType : nonPrimitiveType; - case 179 /* ThisType */: - case 101 /* ThisKeyword */: + case 140 /* ObjectKeyword */: + return node.flags & 131072 /* JavaScriptFile */ ? anyType : nonPrimitiveType; + case 182 /* ThisType */: + case 103 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return getTypeFromTypeReference(node); - case 164 /* TypePredicate */: - return booleanType; - case 212 /* ExpressionWithTypeArguments */: + case 167 /* TypePredicate */: + return node.assertsModifier ? voidType : booleanType; + case 215 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 170 /* ArrayType */: - return getTypeFromArrayTypeNode(node); - case 171 /* TupleType */: - return getTypeFromTupleTypeNode(node); - case 172 /* OptionalType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: + return getTypeFromArrayOrTupleTypeNode(node); + case 175 /* OptionalType */: return getTypeFromOptionalTypeNode(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return getTypeFromJSDocNullableTypeNode(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return addOptionality(getTypeFromTypeNode(node.type)); - case 178 /* ParenthesizedType */: - case 173 /* RestType */: - case 293 /* JSDocNonNullableType */: - case 289 /* JSDocTypeExpression */: + case 181 /* ParenthesizedType */: + case 296 /* JSDocNonNullableType */: + case 292 /* JSDocTypeExpression */: return getTypeFromTypeNode(node.type); - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + return getElementTypeOfArrayType(getTypeFromTypeNode(node.type)) || errorType; + case 299 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 169 /* TypeLiteral */: - case 299 /* JSDocTypeLiteral */: - case 295 /* JSDocFunctionType */: - case 300 /* JSDocSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 172 /* TypeLiteral */: + case 302 /* JSDocTypeLiteral */: + case 298 /* JSDocFunctionType */: + case 303 /* JSDocSignature */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return getTypeFromMappedTypeNode(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getTypeFromConditionalTypeNode(node); - case 177 /* InferType */: + case 180 /* InferType */: return getTypeFromInferTypeNode(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return getTypeFromImportTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 73 /* Identifier */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 152 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType; default: @@ -42286,20 +44601,7 @@ var ts; return result; } function instantiateTypePredicate(predicate, mapper) { - if (ts.isIdentifierTypePredicate(predicate)) { - return { - kind: 1 /* Identifier */, - parameterName: predicate.parameterName, - parameterIndex: predicate.parameterIndex, - type: instantiateType(predicate.type, mapper) - }; - } - else { - return { - kind: 0 /* This */, - type: instantiateType(predicate.type, mapper) - }; - } + return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper)); } function instantiateSignature(signature, mapper, eraseTypeParameters) { var freshTypeParameters; @@ -42319,7 +44621,7 @@ var ts; // See GH#17600. var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), /*resolvedReturnType*/ undefined, - /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.hasRestParameter, signature.hasLiteralTypes); + /*resolvedTypePredicate*/ undefined, signature.minArgumentCount, signature.flags & 3 /* PropagatingFlags */); result.target = signature; result.mapper = mapper; return result; @@ -42353,17 +44655,17 @@ var ts; } return result; } - function getAnonymousTypeInstantiation(type, mapper) { + function getObjectTypeInstantiation(type, mapper) { var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - var symbol = target.symbol; - var links = getSymbolLinks(symbol); + var node = type.objectFlags & 4 /* Reference */ ? type.node : type.symbol.declarations[0]; + var links = getNodeLinks(node); var typeParameters = links.outerTypeParameters; if (!typeParameters) { // The first time an anonymous type is instantiated we compute and store a list of the type // parameters that are in scope (and therefore potentially referenced). For type literals that // aren't the right hand side of a generic type alias declaration we optimize by reducing the // set of type parameters to those that are possibly referenced in the literal. - var declaration_1 = symbol.declarations[0]; + var declaration_1 = node; if (ts.isInJSFile(declaration_1)) { var paramTag = ts.findAncestor(declaration_1, ts.isJSDocParameterTag); if (paramTag) { @@ -42379,7 +44681,7 @@ var ts; outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters); } typeParameters = outerTypeParameters || ts.emptyArray; - typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + typeParameters = (target.objectFlags & 4 /* Reference */ || target.symbol.flags & 2048 /* TypeLiteral */) && !target.aliasTypeArguments ? ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration_1); }) : typeParameters; links.outerTypeParameters = typeParameters; @@ -42392,13 +44694,14 @@ var ts; // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the // mapper to the type parameters to produce the effective list of type arguments, and compute the // instantiation cache key from the type IDs of the type arguments. - var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - var typeArguments = ts.map(typeParameters, combinedMapper); + var typeArguments = ts.map(typeParameters, combineTypeMappers(type.mapper, mapper)); var id = getTypeListId(typeArguments); var result = links.instantiations.get(id); if (!result) { var newMapper = createTypeMapper(typeParameters, typeArguments); - result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + result = target.objectFlags & 4 /* Reference */ ? createDeferredTypeReference(type.target, type.node, newMapper) : + target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : + instantiateAnonymousType(target, newMapper); links.instantiations.set(id, result); } return result; @@ -42406,9 +44709,9 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 149 /* QualifiedName */ || - node.parent.kind === 165 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || - node.parent.kind === 184 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); + return !(node.kind === 152 /* QualifiedName */ || + node.parent.kind === 168 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + node.parent.kind === 187 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { // If the type parameter doesn't have exactly one declaration, if there are invening statement blocks @@ -42417,7 +44720,7 @@ var ts; if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) { var container = tp.symbol.declarations[0].parent; for (var n = node; n !== container; n = n.parent) { - if (!n || n.kind === 219 /* Block */ || n.kind === 176 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { + if (!n || n.kind === 222 /* Block */ || n.kind === 179 /* ConditionalType */ && ts.forEachChild(n.extendsType, containsReference)) { return true; } } @@ -42426,12 +44729,12 @@ var ts; return true; function containsReference(node) { switch (node.kind) { - case 179 /* ThisType */: + case 182 /* ThisType */: return !!tp.isThisType; - case 73 /* Identifier */: + case 75 /* Identifier */: return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) && getTypeFromTypeNode(node) === tp; - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return true; } return !!ts.forEachChild(node, containsReference); @@ -42485,7 +44788,7 @@ var ts; } function instantiateMappedTupleType(tupleType, mappedType, mapper) { var minLength = tupleType.target.minLength; - var elementTypes = ts.map(tupleType.typeArguments || ts.emptyArray, function (_, i) { + var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) { return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), i >= minLength, mapper); }); var modifiers = getMappedTypeModifiers(mappedType); @@ -42581,15 +44884,18 @@ var ts; // interface, in an object type literal, or in an object literal expression, we may need // to instantiate the type because it might reference a type parameter. return couldContainTypeVariables(type) ? - getAnonymousTypeInstantiation(type, mapper) : type; + getObjectTypeInstantiation(type, mapper) : type; } if (objectFlags & 32 /* Mapped */) { - return getAnonymousTypeInstantiation(type, mapper); + return getObjectTypeInstantiation(type, mapper); } if (objectFlags & 4 /* Reference */) { - var typeArguments = type.typeArguments; - var newTypeArguments = instantiateTypes(typeArguments, mapper); - return newTypeArguments !== typeArguments ? createTypeReference(type.target, newTypeArguments) : type; + if (type.node) { + return getObjectTypeInstantiation(type, mapper); + } + var resolvedTypeArguments = type.resolvedTypeArguments; + var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper); + return newTypeArguments !== resolvedTypeArguments ? createTypeReference(type.target, newTypeArguments) : type; } return type; } @@ -42653,35 +44959,35 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: // Function declarations can have context when annotated with a jsdoc @type return isContextSensitiveFunctionLikeDeclaration(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.some(node.properties, isContextSensitive); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.some(node.elements, isContextSensitive); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 205 /* BinaryExpression */: - return node.operatorToken.kind === 55 /* BarBarToken */ && + case 208 /* BinaryExpression */: + return (node.operatorToken.kind === 56 /* BarBarToken */ || node.operatorToken.kind === 60 /* QuestionQuestionToken */) && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive); - case 268 /* JsxAttribute */: { + case 271 /* JsxAttribute */: { // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. var initializer = node.initializer; return !!initializer && isContextSensitive(initializer); } - case 271 /* JsxExpression */: { + case 274 /* JsxExpression */: { // It is possible to that node.expression is undefined (e.g
) var expression = node.expression; return !!expression && isContextSensitive(expression); @@ -42701,7 +45007,7 @@ var ts; if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) { return true; } - if (node.kind !== 198 /* ArrowFunction */) { + if (node.kind !== 201 /* ArrowFunction */) { // If the first parameter is not an explicit 'this' parameter, then the function has // an implicit 'this' parameter which is subject to contextual typing. var parameter = ts.firstOrUndefined(node.parameters); @@ -42713,7 +45019,7 @@ var ts; } function hasContextSensitiveReturnExpression(node) { // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value. - return !!node.body && node.body.kind !== 219 /* Block */ && isContextSensitive(node.body); + return !!node.body && node.body.kind !== 222 /* Block */ && isContextSensitive(node.body); } function isContextSensitiveFunctionOrObjectLiteralMethod(func) { return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) && @@ -42816,23 +45122,23 @@ var ts; return true; } switch (node.kind) { - case 271 /* JsxExpression */: - case 196 /* ParenthesizedExpression */: + case 274 /* JsxExpression */: + case 199 /* ParenthesizedExpression */: return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: case 27 /* CommaToken */: return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer); } break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer); } return false; @@ -43004,7 +45310,7 @@ var ts; } function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) { switch (child.kind) { - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: // child is of the type of the expression return { errorNode: child, innerExpression: child.expression, nameType: nameType }; case 11 /* JsxText */: @@ -43013,9 +45319,9 @@ var ts; } // child is a string return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() }; - case 261 /* JsxElement */: - case 262 /* JsxSelfClosingElement */: - case 265 /* JsxFragment */: + case 264 /* JsxElement */: + case 265 /* JsxSelfClosingElement */: + case 268 /* JsxFragment */: // child is of type JSX.Element return { errorNode: child, innerExpression: child, nameType: nameType }; default: @@ -43157,11 +45463,11 @@ var ts; } _b = prop.kind; switch (_b) { - case 160 /* SetAccessor */: return [3 /*break*/, 2]; - case 159 /* GetAccessor */: return [3 /*break*/, 2]; - case 157 /* MethodDeclaration */: return [3 /*break*/, 2]; - case 277 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; - case 276 /* PropertyAssignment */: return [3 /*break*/, 4]; + case 163 /* SetAccessor */: return [3 /*break*/, 2]; + case 162 /* GetAccessor */: return [3 /*break*/, 2]; + case 160 /* MethodDeclaration */: return [3 /*break*/, 2]; + case 280 /* ShorthandPropertyAssignment */: return [3 /*break*/, 2]; + case 279 /* PropertyAssignment */: return [3 /*break*/, 4]; } return [3 /*break*/, 6]; case 2: return [4 /*yield*/, { errorNode: prop.name, innerExpression: undefined, nameType: type }]; @@ -43196,20 +45502,20 @@ var ts; } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { return compareSignaturesRelated(source, target, 0 /* None */, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + /*errorReporter*/ undefined, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * Returns true if `s` is `(...args: any[]) => any` or `(this: any, ...args: any[]) => any` */ function isAnySignature(s) { return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 && - s.hasRestParameter && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && + signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) && isTypeAny(getReturnTypeOfSignature(s)); } /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, callbackCheck, ignoreReturnTypes, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -43233,8 +45539,8 @@ var ts; return 0 /* False */; } var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; - var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 157 /* MethodDeclaration */ && - kind !== 156 /* MethodSignature */ && kind !== 158 /* Constructor */; + var strictVariance = !callbackCheck && strictFunctionTypes && kind !== 160 /* MethodDeclaration */ && + kind !== 159 /* MethodSignature */ && kind !== 161 /* Constructor */; var result = -1 /* True */; var sourceThisType = getThisTypeOfSignature(source); if (sourceThisType && sourceThisType !== voidType) { @@ -43267,11 +45573,11 @@ var ts; // with respect to T. var sourceSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(sourceType)); var targetSig = callbackCheck ? undefined : getSingleCallSignature(getNonNullableType(targetType)); - var callbacks = sourceSig && targetSig && !signatureHasTypePredicate(sourceSig) && !signatureHasTypePredicate(targetSig) && + var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) && (getFalsyFlags(sourceType) & 98304 /* Nullable */) === (getFalsyFlags(targetType) & 98304 /* Nullable */); var related = callbacks ? // TODO: GH#18217 It will work if they're both `undefined`, but not if only one is - compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : + compareSignaturesRelated(targetSig, sourceSig, strictVariance ? 2 /* Strict */ : 1 /* Bivariant */, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes) : !callbackCheck && !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { @@ -43282,15 +45588,17 @@ var ts; result &= related; } if (!ignoreReturnTypes) { - // If a signature reolution is already in-flight, skip issuing a circularity error + // If a signature resolution is already in-flight, skip issuing a circularity error // here and just use the `any` type directly - var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType : (target.declaration && isJSConstructor(target.declaration)) ? - getJSClassType(target.declaration.symbol) : getReturnTypeOfSignature(target); + var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType + : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol)) + : getReturnTypeOfSignature(target); if (targetReturnType === voidType) { return result; } - var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType : (source.declaration && isJSConstructor(source.declaration)) ? - getJSClassType(source.declaration.symbol) : getReturnTypeOfSignature(source); + var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType + : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol)) + : getReturnTypeOfSignature(source); // The following block preserves behavior forbidding boolean returning functions from being assignable to type guard returning functions var targetTypePredicate = getTypePredicateOfSignature(target); if (targetTypePredicate) { @@ -43311,6 +45619,9 @@ var ts; // wouldn't be co-variant for T without this rule. result &= callbackCheck === 1 /* Bivariant */ && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || compareTypes(sourceReturnType, targetReturnType, reportErrors); + if (!result && reportErrors && incompatibleErrorReporter) { + incompatibleErrorReporter(sourceReturnType, targetReturnType); + } } } return result; @@ -43323,7 +45634,7 @@ var ts; } return 0 /* False */; } - if (source.kind === 1 /* Identifier */) { + if (source.kind === 1 /* Identifier */ || source.kind === 3 /* AssertsIdentifier */) { if (source.parameterIndex !== target.parameterIndex) { if (reportErrors) { errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName); @@ -43332,7 +45643,9 @@ var ts; return 0 /* False */; } } - var related = compareTypes(source.type, target.type, reportErrors); + var related = source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type, reportErrors) : + 0 /* False */; if (related === 0 /* False */ && reportErrors) { errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target)); } @@ -43378,12 +45691,12 @@ var ts; return true; } var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol); - var relation = enumRelation.get(id); - if (relation !== undefined && !(relation === 2 /* Failed */ && errorReporter)) { - return relation === 1 /* Succeeded */; + var entry = enumRelation.get(id); + if (entry !== undefined && !(!(entry & 4 /* Reported */) && entry & 2 /* Failed */ && errorReporter)) { + return !!(entry & 1 /* Succeeded */); } if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256 /* RegularEnum */) || !(targetSymbol.flags & 256 /* RegularEnum */)) { - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); return false; } var targetEnumType = getTypeOfSymbol(targetSymbol); @@ -43394,7 +45707,7 @@ var ts; if (!targetProperty || !(targetProperty.flags & 8 /* EnumMember */)) { if (errorReporter) { errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), /*enclosingDeclaration*/ undefined, 64 /* UseFullyQualifiedType */)); - enumRelation.set(id, 3 /* FailedAndReported */); + enumRelation.set(id, 2 /* Failed */ | 4 /* Reported */); } else { enumRelation.set(id, 2 /* Failed */); @@ -43471,9 +45784,9 @@ var ts; return true; } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { - var related = relation.get(getRelationKey(source, target, relation)); + var related = relation.get(getRelationKey(source, target, /*isIntersectionConstituent*/ false, relation)); if (related !== undefined) { - return related === 1 /* Succeeded */; + return !!(related & 1 /* Succeeded */); } } if (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */) { @@ -43505,9 +45818,14 @@ var ts; var depth = 0; var expandingFlags = 0 /* None */; var overflow = false; - var overrideNextErrorInfo; + var overrideNextErrorInfo = 0; // How many `reportRelationError` calls should be skipped in the elaboration pyramid + var lastSkippedInfo; + var incompatibleStack = []; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); var result = isRelatedTo(source, target, /*reportErrors*/ !!errorNode, headMessage); + if (incompatibleStack.length) { + reportIncompatibleStack(); + } if (overflow) { var diag = error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); if (errorOutputContainer) { @@ -43550,8 +45868,131 @@ var ts; ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error."); } return result !== 0 /* False */; + function resetErrorInfo(saved) { + errorInfo = saved.errorInfo; + lastSkippedInfo = saved.lastSkippedInfo; + incompatibleStack = saved.incompatibleStack; + overrideNextErrorInfo = saved.overrideNextErrorInfo; + relatedInfo = saved.relatedInfo; + } + function captureErrorCalculationState() { + return { + errorInfo: errorInfo, + lastSkippedInfo: lastSkippedInfo, + incompatibleStack: incompatibleStack.slice(), + overrideNextErrorInfo: overrideNextErrorInfo, + relatedInfo: !relatedInfo ? undefined : relatedInfo.slice() + }; + } + function reportIncompatibleError(message, arg0, arg1, arg2, arg3) { + overrideNextErrorInfo++; // Suppress the next relation error + lastSkippedInfo = undefined; // Reset skipped info cache + incompatibleStack.push([message, arg0, arg1, arg2, arg3]); + } + function reportIncompatibleStack() { + var stack = incompatibleStack; + incompatibleStack = []; + var info = lastSkippedInfo; + lastSkippedInfo = undefined; + if (stack.length === 1) { + reportError.apply(void 0, stack[0]); + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + return; + } + // The first error will be the innermost, while the last will be the outermost - so by popping off the end, + // we can build from left to right + var path = ""; + var secondaryRootErrors = []; + while (stack.length) { + var _a = stack.pop(), msg = _a[0], args = _a.slice(1); + switch (msg.code) { + case ts.Diagnostics.Types_of_property_0_are_incompatible.code: { + // Parenthesize a `new` if there is one + if (path.indexOf("new ") === 0) { + path = "(" + path + ")"; + } + var str = "" + args[0]; + // If leading, just print back the arg (irrespective of if it's a valid identifier) + if (path.length === 0) { + path = "" + str; + } + // Otherwise write a dotted name if possible + else if (ts.isIdentifierText(str, compilerOptions.target)) { + path = path + "." + str; + } + // Failing that, check if the name is already a computed name + else if (str[0] === "[" && str[str.length - 1] === "]") { + path = "" + path + str; + } + // And finally write out a computed name as a last resort + else { + path = path + "[" + str + "]"; + } + break; + } + case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code: + case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: + case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: { + if (path.length === 0) { + // Don't flatten signature compatability errors at the start of a chain - instead prefer + // to unify (the with no arguments bit is excessive for printback) and print them back + var mappedMsg = msg; + if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible; + } + else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) { + mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible; + } + secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]); + } + else { + var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "new " + : ""; + var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code || + msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) + ? "" + : "..."; + path = "" + prefix + path + "(" + params + ")"; + } + break; + } + default: + return ts.Debug.fail("Unhandled Diagnostic: " + msg.code); + } + } + if (path) { + reportError(path[path.length - 1] === ")" + ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types + : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path); + } + else { + // Remove the innermost secondary error as it will duplicate the error already reported by `reportRelationError` on entry + secondaryRootErrors.shift(); + } + for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) { + var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1); + var originalValue = msg.elidedInCompatabilityPyramid; + msg.elidedInCompatabilityPyramid = false; // Teporarily override elision to ensure error is reported + reportError.apply(void 0, __spreadArrays([msg], args)); + msg.elidedInCompatabilityPyramid = originalValue; + } + if (info) { + // Actually do the last relation error + reportRelationError.apply(void 0, __spreadArrays([/*headMessage*/ undefined], info)); + } + } function reportError(message, arg0, arg1, arg2, arg3) { ts.Debug.assert(!!errorNode); + if (incompatibleStack.length) + reportIncompatibleStack(); + if (message.elidedInCompatabilityPyramid) + return; errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3); } function associateRelatedInfo(info) { @@ -43564,6 +46005,8 @@ var ts; } } function reportRelationError(message, source, target) { + if (incompatibleStack.length) + reportIncompatibleStack(); var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1]; if (target.flags & 262144 /* TypeParameter */ && target.immediateBaseConstraint !== undefined && isTypeAssignableTo(source, target.immediateBaseConstraint)) { reportError(ts.Diagnostics._0_is_assignable_to_the_constraint_of_type_1_but_1_could_be_instantiated_with_a_different_subtype_of_constraint_2, sourceType, targetType, typeToString(target.immediateBaseConstraint)); @@ -43582,8 +46025,8 @@ var ts; reportError(message, sourceType, targetType); } function tryElaborateErrorsForPrimitivesAndObjects(source, target) { - var sourceType = typeToString(source); - var targetType = typeToString(target); + var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source); + var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target); if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || @@ -43705,14 +46148,14 @@ var ts; return 0 /* False */; } var result = 0 /* False */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); var isIntersectionConstituent = !!isApparentIntersectionConstituent; // Note that these checks are specifically ordered to produce correct results. In particular, // we need to deconstruct unions before intersections (because unions are always at the top), // and we need to handle "each" relations before "some" relations for the same kind of type. if (source.flags & 1048576 /* Union */) { result = relation === comparableRelation ? - someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */), isIntersectionConstituent) : + someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)) : eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068 /* Primitive */)); } else { @@ -43750,15 +46193,15 @@ var ts; // // - For a primitive type or type parameter (such as 'number = A & B') there is no point in // breaking the intersection apart. - result = someTypeRelatedToType(source, target, /*reportErrors*/ false, /*isIntersectionConstituent*/ true); + result = someTypeRelatedToType(source, target, /*reportErrors*/ false); } if (!result && (source.flags & 66846720 /* StructuredOrInstantiable */ || target.flags & 66846720 /* StructuredOrInstantiable */)) { if (result = recursiveTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } - if (!result && source.flags & 2097152 /* Intersection */) { + if (!result && source.flags & (2097152 /* Intersection */ | 262144 /* TypeParameter */)) { // The combined constraint of an intersection type is the intersection of the constraints of // the constituents. When an intersection type contains instantiable types with union type // constraints, there are situations where we need to examine the combined constraint. One is @@ -43768,21 +46211,30 @@ var ts; // we need to check this constraint against a union on the target side. Also, given a type // variable V constrained to 'string | number', 'V & number' has a combined constraint of // 'string & number | number & number' which reduces to just 'number'. - var constraint = getUnionConstraintOfIntersection(source, !!(target.flags & 1048576 /* Union */)); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + // This also handles type parameters, as a type parameter with a union constraint compared against a union + // needs to have its constraint hoisted into an intersection with said type parameter, this way + // the type param can be compared with itself in the target (with the influence of its constraint to match other parts) + // For example, if `T extends 1 | 2` and `U extends 2 | 3` and we compare `T & U` to `T & U & (1 | 2 | 3)` + var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 /* Intersection */ ? source.types : [source], !!(target.flags & 1048576 /* Union */)); + if (constraint && (source.flags & 2097152 /* Intersection */ || target.flags & 1048576 /* Union */)) { + if (everyType(constraint, function (c) { return c !== source; })) { // Skip comparison if expansion contains the source itself + // TODO: Stack errors so we get a pyramid for the "normal" comparison above, _and_ a second for this + if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { + resetErrorInfo(saveErrorInfo); + } } } } if (!result && reportErrors) { - var maybeSuppress = overrideNextErrorInfo; - overrideNextErrorInfo = undefined; + var maybeSuppress = overrideNextErrorInfo > 0; + if (maybeSuppress) { + overrideNextErrorInfo--; + } if (source.flags & 524288 /* Object */ && target.flags & 524288 /* Object */) { var currentError = errorInfo; tryElaborateArrayLikeErrors(source, target, reportErrors); if (errorInfo !== currentError) { - maybeSuppress = errorInfo; + maybeSuppress = !!errorInfo; } } if (source.flags & 524288 /* Object */ && target.flags & 131068 /* Primitive */) { @@ -43802,6 +46254,7 @@ var ts; } } if (!headMessage && maybeSuppress) { + lastSkippedInfo = [source, target]; // Used by, eg, missing property checking to replace the top-level message with a more informative one return result; } @@ -43838,7 +46291,7 @@ var ts; // check excess properties against discriminant type only, not the entire union return hasExcessProperties(source, discriminant, /*discriminant*/ undefined, reportErrors); } - var _loop_8 = function (prop) { + var _loop_10 = function (prop) { if (shouldCheckAsExcessProperty(prop, source.symbol) && !isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) { if (reportErrors) { // Report error in terms of object types in the target as those are the only ones @@ -43853,6 +46306,11 @@ var ts; // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. // TODO: Spelling suggestions for excess jsx attributes (needs new diagnostic messages) + if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration)) { + // Note that extraneous children (as in `extra`) don't pass this check, + // since `children` is a SyntaxKind.PropertySignature instead of a SyntaxKind.JsxAttribute. + errorNode = prop.valueDeclaration.name; + } reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(errorTarget)); } else { @@ -43881,9 +46339,9 @@ var ts; }; for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) { var prop = _a[_i]; - var state_3 = _loop_8(prop); - if (typeof state_3 === "object") - return state_3.value; + var state_4 = _loop_10(prop); + if (typeof state_4 === "object") + return state_4.value; } } return false; @@ -44019,14 +46477,14 @@ var ts; } return result; } - function someTypeRelatedToType(source, target, reportErrors, isIntersectionConstituent) { + function someTypeRelatedToType(source, target, reportErrors) { var sourceTypes = source.types; if (source.flags & 1048576 /* Union */ && containsType(sourceTypes, target)) { return -1 /* True */; } var len = sourceTypes.length; for (var i = 0; i < len; i++) { - var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, /*headMessage*/ undefined, isIntersectionConstituent); + var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1); if (related) { return related; } @@ -44105,17 +46563,6 @@ var ts; } return result; } - function propagateSidebandVarianceFlags(typeArguments, variances) { - for (var i = 0; i < variances.length; i++) { - var v = variances[i]; - if (v & 8 /* Unmeasurable */) { - instantiateType(typeArguments[i], reportUnmeasurableMarkers); - } - if (v & 16 /* Unreliable */) { - instantiateType(typeArguments[i], reportUnreliableMarkers); - } - } - } // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are @@ -44125,25 +46572,25 @@ var ts; if (overflow) { return 0 /* False */; } - var id = getRelationKey(source, target, relation); - var related = relation.get(id); - if (related !== undefined) { - if (reportErrors && related === 2 /* Failed */) { + var id = getRelationKey(source, target, isIntersectionConstituent, relation); + var entry = relation.get(id); + if (entry !== undefined) { + if (reportErrors && entry & 2 /* Failed */ && !(entry & 4 /* Reported */)) { // We are elaborating errors and the cached result is an unreported failure. The result will be reported // as a failure, and should be updated as a reported failure by the bottom of this function. } else { if (outofbandVarianceMarkerHandler) { // We're in the middle of variance checking - integrate any unmeasurable/unreliable flags from this cached component - if (source.flags & (524288 /* Object */ | 16777216 /* Conditional */) && source.aliasSymbol && - source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) { - propagateSidebandVarianceFlags(source.aliasTypeArguments, getAliasVariances(source.aliasSymbol)); + var saved = entry & 24 /* ReportsMask */; + if (saved & 8 /* ReportsUnmeasurable */) { + instantiateType(source, reportUnmeasurableMarkers); } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && source.target === target.target && ts.length(source.typeArguments)) { - propagateSidebandVarianceFlags(source.typeArguments, getVariances(source.target)); + if (saved & 16 /* ReportsUnreliable */) { + instantiateType(source, reportUnreliableMarkers); } } - return related === 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; + return entry & 1 /* Succeeded */ ? -1 /* True */ : 0 /* False */; } } if (!maybeKeys) { @@ -44174,14 +46621,26 @@ var ts; expandingFlags |= 1 /* Source */; if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2 /* Target */; + var originalHandler; + var propagatingVarianceFlags = 0; + if (outofbandVarianceMarkerHandler) { + originalHandler = outofbandVarianceMarkerHandler; + outofbandVarianceMarkerHandler = function (onlyUnreliable) { + propagatingVarianceFlags |= onlyUnreliable ? 16 /* ReportsUnreliable */ : 8 /* ReportsUnmeasurable */; + return originalHandler(onlyUnreliable); + }; + } var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors, isIntersectionConstituent) : 1 /* Maybe */; + if (outofbandVarianceMarkerHandler) { + outofbandVarianceMarkerHandler = originalHandler; + } expandingFlags = saveExpandingFlags; depth--; if (result) { if (result === -1 /* True */ || depth === 0) { // If result is definitely true, record all maybe keys as having succeeded for (var i = maybeStart; i < maybeCount; i++) { - relation.set(maybeKeys[i], 1 /* Succeeded */); + relation.set(maybeKeys[i], 1 /* Succeeded */ | propagatingVarianceFlags); } maybeCount = maybeStart; } @@ -44189,7 +46648,7 @@ var ts; else { // A false result goes straight into global cache (when something is false under // assumptions it will also be false without assumptions) - relation.set(id, reportErrors ? 3 /* FailedAndReported */ : 2 /* Failed */); + relation.set(id, (reportErrors ? 4 /* Reported */ : 0) | 2 /* Failed */ | propagatingVarianceFlags); maybeCount = maybeStart; } return result; @@ -44229,7 +46688,7 @@ var ts; var result; var originalErrorInfo; var varianceCheckFailed = false; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); // We limit alias variance probing to only object and conditional types since their alias behavior // is more predictable than other, interned types, which may or may not have an alias depending on // the order in which things were checked. @@ -44319,7 +46778,7 @@ var ts; } } originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44330,7 +46789,7 @@ var ts; result &= isRelatedTo(source.indexType, target.indexType, reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44339,25 +46798,25 @@ var ts; if (!constraint || (source.flags & 262144 /* TypeParameter */ && constraint.flags & 1 /* Any */)) { // A type variable with no constraint is not related to the non-primitive object type. if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } // hi-speed no-this-instantiation check (less accurate, but avoids costly `this`-instantiation when the constraint will suffice), see #28231 for report on why this is needed else if (result = isRelatedTo(constraint, target, /*reportErrors*/ false, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } // slower, fuller, this-instantiated check (necessary when comparing raw `this` types from base classes), see `subclassWithPolymorphicThisIsAssignable.ts` test for example else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, /*headMessage*/ undefined, isIntersectionConstituent)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } } else if (source.flags & 4194304 /* Index */) { if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44366,13 +46825,23 @@ var ts; // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, // and Y1 is related to Y2. - if (isTypeIdenticalTo(source.extendsType, target.extendsType) && + var sourceParams = source.root.inferTypeParameters; + var sourceExtends = source.extendsType; + var mapper = void 0; + if (sourceParams) { + // If the source has infer type parameters, we instantiate them in the context of the target + var ctx = createInferenceContext(sourceParams, /*signature*/ undefined, 0 /* None */, isRelatedTo); + inferTypes(ctx.inferences, target.extendsType, sourceExtends, 64 /* NoConstraints */ | 128 /* AlwaysStrict */); + sourceExtends = instantiateType(sourceExtends, ctx.mapper); + mapper = ctx.mapper; + } + if (isTypeIdenticalTo(sourceExtends, target.extendsType) && (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) { - if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { + if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } if (result) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44381,14 +46850,14 @@ var ts; var distributiveConstraint = getConstraintOfDistributiveConditionalType(source); if (distributiveConstraint) { if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } var defaultConstraint = getDefaultConstraintOfConditionalType(source); if (defaultConstraint) { if (result = isRelatedTo(defaultConstraint, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44402,7 +46871,7 @@ var ts; if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { if (result = mappedTypeRelatedTo(source, target, reportErrors)) { - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return result; } } @@ -44421,7 +46890,7 @@ var ts; // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. var variances = getVariances(source.target); - var varianceResult = relateVariances(source.typeArguments, target.typeArguments, variances, isIntersectionConstituent); + var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, isIntersectionConstituent); if (varianceResult !== undefined) { return varianceResult; } @@ -44448,7 +46917,7 @@ var ts; // relates to X. Thus, we include intersection types on the source side here. if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 524288 /* Object */) { // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive; result = propertiesRelatedTo(source, target, reportStructuralErrors, /*excludedProperties*/ undefined, isIntersectionConstituent); if (result) { result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); @@ -44463,7 +46932,7 @@ var ts; } } if (varianceCheckFailed && result) { - errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo; // Use variance error (there is no structural one) and return false } else if (result) { return result; @@ -44494,7 +46963,7 @@ var ts; // We elide the variance-based error elaborations, since those might not be too helpful, since we'll potentially // be assuming identity of the type parameter. originalErrorInfo = undefined; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); return undefined; } var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); @@ -44522,7 +46991,7 @@ var ts; // comparison unexpectedly succeeds. This can happen when the structural comparison result // is a Ternary.Maybe for example caused by the recursion depth limiter. originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); } } } @@ -44598,11 +47067,11 @@ var ts; // constituents of 'target'. If any combination does not have a match then 'source' is not relatable. var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes); var matchingTypes = []; - var _loop_9 = function (combination) { + var _loop_11 = function (combination) { var hasMatch = false; outer: for (var _i = 0, _a = target.types; _i < _a.length; _i++) { var type = _a[_i]; - var _loop_10 = function (i) { + var _loop_12 = function (i) { var sourceProperty = sourcePropertiesFiltered[i]; var targetProperty = getPropertyOfObjectType(type, sourceProperty.escapedName); if (!targetProperty) @@ -44618,8 +47087,8 @@ var ts; } }; for (var i = 0; i < sourcePropertiesFiltered.length; i++) { - var state_5 = _loop_10(i); - switch (state_5) { + var state_6 = _loop_12(i); + switch (state_6) { case "continue-outer": continue outer; } } @@ -44632,9 +47101,9 @@ var ts; }; for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) { var combination = discriminantCombinations_1[_a]; - var state_4 = _loop_9(combination); - if (typeof state_4 === "object") - return state_4.value; + var state_5 = _loop_11(combination); + if (typeof state_5 === "object") + return state_5.value; } // Compare the remaining non-discriminant properties of each match. var result = -1 /* True */; @@ -44759,7 +47228,7 @@ var ts; var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, isIntersectionConstituent); if (!related) { if (reportErrors) { - reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); + reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } return 0 /* False */; } @@ -44799,8 +47268,8 @@ var ts; if (ts.length(unmatchedProperty.declarations)) { associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName)); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } else if (tryElaborateArrayLikeErrors(source, target, /*reportErrors*/ false)) { @@ -44810,8 +47279,8 @@ var ts; else { reportError(ts.Diagnostics.Type_0_is_missing_the_following_properties_from_type_1_Colon_2, typeToString(source), typeToString(target), ts.map(props, function (p) { return symbolToString(p); }).join(", ")); } - if (shouldSkipElaboration) { - overrideNextErrorInfo = errorInfo; + if (shouldSkipElaboration && errorInfo) { + overrideNextErrorInfo++; } } // ELSE: No array like or unmatched property error - just issue top level error (errorInfo = undefined) @@ -44823,7 +47292,7 @@ var ts; var sourceProp = _a[_i]; if (!getPropertyOfObjectType(target, sourceProp.escapedName)) { var sourceType = getTypeOfSymbol(sourceProp); - if (!(sourceType === undefinedType || sourceType === undefinedWideningType)) { + if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target)); } @@ -44848,8 +47317,9 @@ var ts; } var targetCount = getTypeReferenceArity(target) - 1; var sourceCount = getTypeReferenceArity(source) - (sourceRestType ? 1 : 0); + var sourceTypeArguments = getTypeArguments(source); for (var i = targetCount; i < sourceCount; i++) { - var related = isRelatedTo(source.typeArguments[i], targetRestType, reportErrors); + var related = isRelatedTo(sourceTypeArguments[i], targetRestType, reportErrors); if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_incompatible_with_rest_element_type, "" + i); @@ -44863,10 +47333,12 @@ var ts; // We only call this for union target types when we're attempting to do excess property checking - in those cases, we want to get _all possible props_ // from the target union, across all members var properties = target.flags & 1048576 /* Union */ ? getPossiblePropertiesOfUnionType(target) : getPropertiesOfType(target); + var numericNamesOnly = isTupleType(source) && isTupleType(target); for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) { var targetProp = _c[_b]; - if (!(targetProp.flags & 4194304 /* Prototype */)) { - var sourceProp = getPropertyOfType(source, targetProp.escapedName); + var name = targetProp.escapedName; + if (!(targetProp.flags & 4194304 /* Prototype */) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) { + var sourceProp = getPropertyOfType(source, name); if (sourceProp && sourceProp !== targetProp) { var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, isIntersectionConstituent); if (!related) { @@ -44931,14 +47403,15 @@ var ts; } } var result = -1 /* True */; - var saveErrorInfo = errorInfo; + var saveErrorInfo = captureErrorCalculationState(); + var incompatibleReporter = kind === 1 /* Construct */ ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn; if (ts.getObjectFlags(source) & 64 /* Instantiated */ && ts.getObjectFlags(target) & 64 /* Instantiated */ && source.symbol === target.symbol) { // We have instantiations of the same anonymous type (which typically will be the type of a // method). Simply do a pairwise comparison of the signatures in the two signature lists instead // of the much more expensive N * M comparison matrix we explore below. We erase type parameters // as they are known to always be the same. for (var i = 0; i < targetSignatures.length; i++) { - var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors); + var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], /*erase*/ true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i])); if (!related) { return 0 /* False */; } @@ -44952,7 +47425,7 @@ var ts; // this regardless of the number of signatures, but the potential costs are prohibitive due // to the quadratic nature of the logic below. var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks; - result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors); + result = signatureRelatedTo(sourceSignatures[0], targetSignatures[0], eraseGenerics, reportErrors, incompatibleReporter(sourceSignatures[0], targetSignatures[0])); } else { outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) { @@ -44961,10 +47434,10 @@ var ts; var shouldElaborateErrors = reportErrors; for (var _a = 0, sourceSignatures_1 = sourceSignatures; _a < sourceSignatures_1.length; _a++) { var s = sourceSignatures_1[_a]; - var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors); + var related = signatureRelatedTo(s, t, /*erase*/ true, shouldElaborateErrors, incompatibleReporter(s, t)); if (related) { result &= related; - errorInfo = saveErrorInfo; + resetErrorInfo(saveErrorInfo); continue outer; } shouldElaborateErrors = false; @@ -44977,11 +47450,23 @@ var ts; } return result; } + function reportIncompatibleCallSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } + function reportIncompatibleConstructSignatureReturn(siga, sigb) { + if (siga.parameters.length === 0 && sigb.parameters.length === 0) { + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); }; + } + return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); }; + } /** * See signatureAssignableTo, compareSignaturesIdentical */ - function signatureRelatedTo(source, target, erase, reportErrors) { - return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) { + return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, 0 /* None */, /*ignoreReturnTypes*/ false, reportErrors, reportError, incompatibleReporter, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -45047,7 +47532,7 @@ var ts; if (isGenericMappedType(source)) { // A generic mapped type { [P in K]: T } is related to an index signature { [x: string]: U } // if T is related to U. - return (kind === 0 /* String */ && isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors)); // TODO: GH#18217 + return kind === 0 /* String */ ? isRelatedTo(getTemplateTypeFromMappedType(source), targetInfo.type, reportErrors) : 0 /* False */; } if (isObjectTypeWithInferableIndex(source)) { var related = -1 /* True */; @@ -45179,7 +47664,7 @@ var ts; // The emptyArray singleton is used to signal a recursive invocation. cache.variances = ts.emptyArray; variances = []; - var _loop_11 = function (tp) { + var _loop_13 = function (tp) { var unmeasurable = false; var unreliable = false; var oldHandler = outofbandVarianceMarkerHandler; @@ -45211,7 +47696,7 @@ var ts; }; for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { var tp = typeParameters_1[_i]; - _loop_11(tp); + _loop_13(tp); } cache.variances = variances; } @@ -45237,8 +47722,11 @@ var ts; function isUnconstrainedTypeParameter(type) { return type.flags & 262144 /* TypeParameter */ && !getConstraintOfTypeParameter(type); } + function isNonDeferredTypeReference(type) { + return !!(ts.getObjectFlags(type) & 4 /* Reference */) && !type.node; + } function isTypeReferenceWithGenericArguments(type) { - return !!(ts.getObjectFlags(type) & 4 /* Reference */) && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); + return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" @@ -45247,7 +47735,7 @@ var ts; function getTypeReferenceId(type, typeParameters, depth) { if (depth === void 0) { depth = 0; } var result = "" + type.target.id; - for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { + for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) { var t = _a[_i]; if (isUnconstrainedTypeParameter(t)) { var index = typeParameters.indexOf(t); @@ -45270,17 +47758,18 @@ var ts; * To improve caching, the relation key for two generic types uses the target's id plus ids of the type parameters. * For other cases, the types ids are used. */ - function getRelationKey(source, target, relation) { + function getRelationKey(source, target, isIntersectionConstituent, relation) { if (relation === identityRelation && source.id > target.id) { var temp = source; source = target; target = temp; } + var intersection = isIntersectionConstituent ? "&" : ""; if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) { var typeParameters = []; - return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters); + return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + intersection; } - return source.id + "," + target.id; + return source.id + "," + target.id + intersection; } // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. @@ -45476,20 +47965,22 @@ var ts; if (!ignoreReturnTypes) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - result &= sourceTypePredicate !== undefined || targetTypePredicate !== undefined - ? compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) - // If they're both type predicates their return types will both be `boolean`, so no need to compare those. - : compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + result &= sourceTypePredicate || targetTypePredicate ? + compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) : + compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); } return result; } function compareTypePredicatesIdentical(source, target, compareTypes) { - return source === undefined || target === undefined || !typePredicateKindsMatch(source, target) ? 0 /* False */ : compareTypes(source.type, target.type); + return !(source && target && typePredicateKindsMatch(source, target)) ? 0 /* False */ : + source.type === target.type ? -1 /* True */ : + source.type && target.type ? compareTypes(source.type, target.type) : + 0 /* False */; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -45528,7 +48019,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */) && type.target === globalReadonlyArrayType; } function getElementTypeOfArrayType(type) { - return isArrayType(type) && type.typeArguments ? type.typeArguments[0] : undefined; + return isArrayType(type) ? getTypeArguments(type)[0] : undefined; } function isArrayLikeType(type) { // A type is array-like if it is a reference to the global Array or global ReadonlyArray type, @@ -45536,7 +48027,7 @@ var ts; return isArrayType(type) || !(type.flags & 98304 /* Nullable */) && isTypeAssignableTo(type, anyReadonlyArrayType); } function isEmptyArrayLiteralType(type) { - var elementType = isArrayType(type) ? type.typeArguments[0] : undefined; + var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined; return elementType === undefinedWideningType || elementType === implicitNeverType; } function isTupleLikeType(type) { @@ -45620,7 +48111,7 @@ var ts; return !!(ts.getObjectFlags(type) & 4 /* Reference */ && type.target.objectFlags & 8 /* Tuple */); } function getRestTypeOfTupleType(type) { - return type.target.hasRestElement ? type.typeArguments[type.target.typeParameters.length - 1] : undefined; + return type.target.hasRestElement ? getTypeArguments(type)[type.target.typeParameters.length - 1] : undefined; } function getRestArrayTypeOfTupleType(type) { var restType = getRestTypeOfTupleType(type); @@ -45635,8 +48126,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -45701,6 +48192,23 @@ var ts; function getNonNullableType(type) { return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type; } + function addOptionalTypeMarker(type) { + return strictNullChecks ? getUnionType([type, optionalType]) : type; + } + function isNotOptionalTypeMarker(type) { + return type !== optionalType; + } + function removeOptionalTypeMarker(type) { + return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type; + } + function propagateOptionalTypeMarker(type, wasOptional) { + return wasOptional ? addOptionalTypeMarker(type) : type; + } + function getOptionalExpressionType(exprType, expression) { + return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) : + ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) : + exprType; + } /** * Is source potentially coercible to target type under `==`. * Assumes that `source` is a constituent of a union, hence @@ -45730,8 +48238,8 @@ var ts; * with no call or construct signatures. */ function isObjectTypeWithInferableIndex(type) { - return type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && - !typeHasCallOrConstructSignatures(type); + return !!(type.symbol && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0 && + !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source)); } function createSymbolWithType(source, type) { var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */); @@ -45883,7 +48391,7 @@ var ts; result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); } else if (isArrayType(type) || isTupleType(type)) { - result = createTypeReference(type.target, ts.sameMap(type.typeArguments, getWidenedType)); + result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); } if (result && context === undefined) { type.widened = result; @@ -45920,7 +48428,7 @@ var ts; } } if (isArrayType(type) || isTupleType(type)) { - for (var _b = 0, _c = type.typeArguments; _b < _c.length; _b++) { + for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) { var t = _c[_b]; if (reportWideningErrorsInType(t)) { errorReported = true; @@ -45950,12 +48458,12 @@ var ts; } var diagnostic; switch (declaration.kind) { - case 205 /* BinaryExpression */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 208 /* BinaryExpression */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: diagnostic = noImplicitAny ? ts.Diagnostics.Member_0_implicitly_has_an_1_type : ts.Diagnostics.Member_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 152 /* Parameter */: + case 155 /* Parameter */: var param = declaration; if (ts.isIdentifier(param.name) && (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) && @@ -45970,23 +48478,23 @@ var ts; noImplicitAny ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type_but_a_better_type_may_be_inferred_from_usage : noImplicitAny ? ts.Diagnostics.Parameter_0_implicitly_has_an_1_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type_but_a_better_type_may_be_inferred_from_usage; break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; if (!noImplicitAny) { // Don't issue a suggestion for binding elements since the codefix doesn't yet support them. return; } break; - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; - case 240 /* FunctionDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 243 /* FunctionDeclaration */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: if (noImplicitAny && !declaration.name) { if (wideningKind === 1 /* GeneratorYield */) { error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString); @@ -46000,7 +48508,7 @@ var ts; wideningKind === 1 /* GeneratorYield */ ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type : ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type; break; - case 182 /* MappedType */: + case 185 /* MappedType */: if (noImplicitAny) { error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type); } @@ -46042,8 +48550,7 @@ var ts; function applyToReturnTypes(source, target, callback) { var sourceTypePredicate = getTypePredicateOfSignature(source); var targetTypePredicate = getTypePredicateOfSignature(target); - if (sourceTypePredicate && targetTypePredicate && sourceTypePredicate.kind === targetTypePredicate.kind && - (sourceTypePredicate.kind === 0 /* This */ || sourceTypePredicate.parameterIndex === targetTypePredicate.parameterIndex)) { + if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) { callback(sourceTypePredicate.type, targetTypePredicate.type); } else { @@ -46112,6 +48619,12 @@ var ts; isFixed: inference.isFixed }; } + function cloneInferredPartOfContext(context) { + var inferences = ts.filter(context.inferences, hasInferenceCandidates); + return inferences.length ? + createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) : + undefined; + } function getMapperFromContext(context) { return context && context.mapper; } @@ -46121,7 +48634,7 @@ var ts; function couldContainTypeVariables(type) { var objectFlags = ts.getObjectFlags(type); return !!(type.flags & 63176704 /* Instantiable */ || - objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || + objectFlags & 4 /* Reference */ && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & 32 /* Mapped */ || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && couldUnionOrIntersectionContainTypeVariables(type)); @@ -46190,10 +48703,10 @@ var ts; // For arrays and tuples we infer new arrays and tuples where the reverse mapping has been // applied to the element type(s). if (isArrayType(source)) { - return createArrayType(inferReverseMappedType(source.typeArguments[0], target, constraint), isReadonlyArrayType(source)); + return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source)); } if (isTupleType(source)) { - var elementTypes = ts.map(source.typeArguments || ts.emptyArray, function (t) { return inferReverseMappedType(t, target, constraint); }); + var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); }); var minLength = getMappedTypeModifiers(target) & 4 /* IncludeOptional */ ? getTypeReferenceArity(source) - (source.target.hasRestElement ? 1 : 0) : source.target.minLength; return createTupleType(elementTypes, minLength, source.target.hasRestElement, source.target.readonly, source.target.associatedNames); @@ -46329,10 +48842,7 @@ var ts; // inferring a type parameter constraint. Instead, make a lower priority inference from // the full source to whatever remains in the target. For example, when inferring from // string to 'string | T', make a lower priority inference of string for T. - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; - inferFromTypes(source, target); - priority = savePriority; + inferWithPriority(source, target, 1 /* NakedTypeVariable */); return; } source = getUnionType(sources); @@ -46419,9 +48929,10 @@ var ts; } } } - if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target)) && + !(source.node && target.node)) { // If source and target are references to the same generic type, infer from type arguments - inferFromTypeArguments(source.typeArguments || ts.emptyArray, target.typeArguments || ts.emptyArray, getVariances(source.target)); + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); } else if (source.flags & 4194304 /* Index */ && target.flags & 4194304 /* Index */) { contravariant = !contravariant; @@ -46431,10 +48942,7 @@ var ts; else if ((isLiteralType(source) || source.flags & 4 /* String */) && target.flags & 4194304 /* Index */) { var empty = createEmptyObjectTypeFromStringLiteral(source); contravariant = !contravariant; - var savePriority = priority; - priority |= 32 /* LiteralKeyof */; - inferFromTypes(empty, target.type); - priority = savePriority; + inferWithPriority(empty, target.type, 32 /* LiteralKeyof */); contravariant = !contravariant; } else if (source.flags & 8388608 /* IndexedAccess */ && target.flags & 8388608 /* IndexedAccess */) { @@ -46486,6 +48994,12 @@ var ts; } } } + function inferWithPriority(source, target, newPriority) { + var savePriority = priority; + priority |= newPriority; + inferFromTypes(source, target); + priority = savePriority; + } function invokeOnce(source, target, action) { var key = source.id + "," + target.id; var status = visited && visited.get(key); @@ -46551,6 +49065,18 @@ var ts; } return undefined; } + function getSingleTypeVariableFromIntersectionTypes(types) { + var typeVariable; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var type = types_13[_i]; + var t = type.flags & 2097152 /* Intersection */ && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); }); + if (!t || typeVariable && t !== typeVariable) { + return undefined; + } + typeVariable = t; + } + return typeVariable; + } function inferToMultipleTypes(source, targets, targetFlags) { var typeVariableCount = 0; if (targetFlags & 1048576 /* Union */) { @@ -46580,6 +49106,16 @@ var ts; } } } + if (typeVariableCount === 0) { + // If every target is an intersection of types containing a single naked type variable, + // make a lower priority inference to that type variable. This handles inferring from + // 'A | B' to 'T & (X | Y)' where we want to infer 'A | B' for T. + var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets); + if (intersectionTypeVariable) { + inferWithPriority(source, intersectionTypeVariable, 1 /* NakedTypeVariable */); + } + return; + } // If the target has a single naked type variable and no inference circularities were // encountered above (meaning we explored the types fully), create a union of the source // types from which no inferences have been made so far and infer from that union to the @@ -46611,15 +49147,12 @@ var ts; // we want to infer string for T, not Promise | string. For intersection types // we only infer to single naked type variables. if (targetFlags & 2097152 /* Intersection */ ? typeVariableCount === 1 : typeVariableCount > 0) { - var savePriority = priority; - priority |= 1 /* NakedTypeVariable */; for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) { var t = targets_4[_b]; if (getInferenceInfoForType(t)) { - inferFromTypes(source, t); + inferWithPriority(source, t, 1 /* NakedTypeVariable */); } } - priority = savePriority; } } function inferToMappedType(source, target, constraintType) { @@ -46640,14 +49173,12 @@ var ts; if (inference && !inference.isFixed) { var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); if (inferredType) { - var savePriority = priority; // We assign a lower priority to inferences made from types containing non-inferrable // types because we may only have a partial result (i.e. we may have failed to make // reverse inferences for some properties). - priority |= ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? - 4 /* PartialHomomorphicMappedType */ : 2 /* HomomorphicMappedType */; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; + inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 1048576 /* NonInferrableType */ ? + 4 /* PartialHomomorphicMappedType */ : + 2 /* HomomorphicMappedType */); } } return true; @@ -46655,10 +49186,7 @@ var ts; if (constraintType.flags & 262144 /* TypeParameter */) { // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type // parameter. First infer from 'keyof S' to K. - var savePriority = priority; - priority |= 8 /* MappedTypeConstraint */; - inferFromTypes(getIndexType(source), constraintType); - priority = savePriority; + inferWithPriority(getIndexType(source), constraintType, 8 /* MappedTypeConstraint */); // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, // where K extends keyof T, we make the same inferences as for a homomorphic mapped type // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a @@ -46700,6 +49228,11 @@ var ts; } } function inferFromObjectTypesWorker(source, target) { + if (ts.getObjectFlags(source) & 4 /* Reference */ && ts.getObjectFlags(target) & 4 /* Reference */ && (source.target === target.target || isArrayType(source) && isArrayType(target))) { + // If source and target are references to the same generic type, infer from type arguments + inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target)); + return; + } if (isGenericMappedType(source) && isGenericMappedType(target)) { // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer // from S to T and from X to Y. @@ -46729,10 +49262,10 @@ var ts; var targetRestType = getRestTypeOfTupleType(target); var fixedLength = targetLength < sourceLength || sourceRestType ? targetLength : sourceLength; for (var i = 0; i < fixedLength; i++) { - inferFromTypes(i < sourceLength ? source.typeArguments[i] : sourceRestType, target.typeArguments[i]); + inferFromTypes(i < sourceLength ? getTypeArguments(source)[i] : sourceRestType, getTypeArguments(target)[i]); } if (targetRestType) { - var types = fixedLength < sourceLength ? source.typeArguments.slice(fixedLength, sourceLength) : []; + var types = fixedLength < sourceLength ? getTypeArguments(source).slice(fixedLength, sourceLength) : []; if (sourceRestType) { types.push(sourceRestType); } @@ -46772,7 +49305,7 @@ var ts; var saveBivariant = bivariant; var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */; // Once we descend into a bivariant signature we remain bivariant for all nested inferences - bivariant = bivariant || kind === 157 /* MethodDeclaration */ || kind === 156 /* MethodSignature */ || kind === 158 /* Constructor */; + bivariant = bivariant || kind === 160 /* MethodDeclaration */ || kind === 159 /* MethodSignature */ || kind === 161 /* Constructor */; applyToParameterTypes(source, target, inferFromContravariantTypes); bivariant = saveBivariant; } @@ -46942,7 +49475,7 @@ var ts; case "AsyncIterator": return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_es2015_or_later; default: - if (node.parent.kind === 277 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 280 /* ShorthandPropertyAssignment */) { return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer; } else { @@ -46963,7 +49496,7 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - return !!ts.findAncestor(node, function (n) { return n.kind === 168 /* TypeQuery */ ? true : n.kind === 73 /* Identifier */ || n.kind === 149 /* QualifiedName */ ? false : "quit"; }); + return !!ts.findAncestor(node, function (n) { return n.kind === 171 /* TypeQuery */ ? true : n.kind === 75 /* Identifier */ || n.kind === 152 /* QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the @@ -46973,16 +49506,16 @@ var ts; // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node, declaredType, initialType, flowContainer) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return "0"; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var propName = getAccessedPropertyName(node); if (propName !== undefined) { var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer); @@ -46993,24 +49526,24 @@ var ts; } function isMatchingReference(source, target) { switch (target.kind) { - case 196 /* ParenthesizedExpression */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 217 /* NonNullExpression */: return isMatchingReference(source, target.expression); } switch (source.kind) { - case 73 /* Identifier */: - return target.kind === 73 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 238 /* VariableDeclaration */ || target.kind === 187 /* BindingElement */) && + case 75 /* Identifier */: + return target.kind === 75 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 241 /* VariableDeclaration */ || target.kind === 190 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 101 /* ThisKeyword */: - return target.kind === 101 /* ThisKeyword */; - case 99 /* SuperKeyword */: - return target.kind === 99 /* SuperKeyword */; - case 214 /* NonNullExpression */: - case 196 /* ParenthesizedExpression */: + case 103 /* ThisKeyword */: + return target.kind === 103 /* ThisKeyword */; + case 101 /* SuperKeyword */: + return target.kind === 101 /* SuperKeyword */; + case 217 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: return isMatchingReference(source.expression, target); - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return ts.isAccessExpression(target) && getAccessedPropertyName(source) === getAccessedPropertyName(target) && isMatchingReference(source.expression, target.expression); @@ -47018,8 +49551,8 @@ var ts; return false; } function getAccessedPropertyName(access) { - return access.kind === 190 /* PropertyAccessExpression */ ? access.name.escapedText : - ts.isStringLiteral(access.argumentExpression) || ts.isNumericLiteral(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : + return access.kind === 193 /* PropertyAccessExpression */ ? access.name.escapedText : + ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) : undefined; } function containsMatchingReference(source, target) { @@ -47031,6 +49564,15 @@ var ts; } return false; } + function optionalChainContainsReference(source, target) { + while (ts.isOptionalChain(source)) { + source = source.expression; + if (isMatchingReference(source, target)) { + return true; + } + } + return false; + } // Return true if target is a property access xxx.yyy, source is a property access xxx.zzz, the declared // type of xxx is a union type, and yyy is a property that is possibly a discriminant. We consider a property // a possible discriminant if its type differs in the constituents of containing union type, and if every @@ -47043,7 +49585,7 @@ var ts; isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), name); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 73 /* Identifier */) { + if (expr.kind === 75 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } if (ts.isAccessExpression(expr)) { @@ -47074,7 +49616,7 @@ var ts; return false; } function isSyntheticThisPropertyAccess(expr) { - return ts.isAccessExpression(expr) && expr.expression.kind === 101 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); + return ts.isAccessExpression(expr) && expr.expression.kind === 103 /* ThisKeyword */ && !!(expr.expression.flags & 8 /* Synthesized */); } function findDiscriminantProperties(sourceProperties, target) { var result; @@ -47102,14 +49644,14 @@ var ts; } } } - if (callExpression.expression.kind === 190 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 193 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } return false; } function getFlowNodeId(flow) { - if (!flow.id) { + if (!flow.id || flow.id < 0) { flow.id = nextFlowId; nextFlowId++; } @@ -47151,8 +49693,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -47257,15 +49799,15 @@ var ts; return createArrayType(checkIteratedTypeOrElementType(65 /* Destructuring */, type, undefinedType, /*errorNode*/ undefined) || errorType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 188 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 276 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 191 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 279 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 205 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 228 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 208 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 231 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element)); @@ -47282,21 +49824,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return stringType; - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || errorType; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return undefinedType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return errorType; @@ -47304,7 +49846,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 185 /* ObjectBindingPattern */ ? + var type = pattern.kind === 188 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) : @@ -47322,37 +49864,32 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 227 /* ForInStatement */) { + if (node.parent.parent.kind === 230 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 228 /* ForOfStatement */) { + if (node.parent.parent.kind === 231 /* ForOfStatement */) { return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || errorType; } return errorType; } function getInitialType(node) { - return node.kind === 238 /* VariableDeclaration */ ? + return node.kind === 241 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } - function getInitialOrAssignedType(node, reference) { - return getConstraintForLocation(node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */ ? - getInitialType(node) : - getAssignedType(node), reference); - } function isEmptyArrayAssignment(node) { - return node.kind === 238 /* VariableDeclaration */ && node.initializer && + return node.kind === 241 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 187 /* BindingElement */ && node.parent.kind === 205 /* BinaryExpression */ && + node.kind !== 190 /* BindingElement */ && node.parent.kind === 208 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return getReferenceCandidate(node.left); case 27 /* CommaToken */: return getReferenceCandidate(node.right); @@ -47362,13 +49899,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 196 /* ParenthesizedExpression */ || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */ && parent.left === node || - parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? + return parent.kind === 199 /* ParenthesizedExpression */ || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */ && parent.left === node || + parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 27 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); } return neverType; @@ -47390,8 +49927,8 @@ var ts; var witnesses = []; for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) { var clause = _a[_i]; - if (clause.kind === 272 /* CaseClause */) { - if (clause.expression.kind === 10 /* StringLiteral */) { + if (clause.kind === 275 /* CaseClause */) { + if (ts.isStringLiteralLike(clause.expression)) { witnesses.push(clause.expression.text); continue; } @@ -47474,8 +50011,7 @@ var ts; return mapType(typeWithPrimitives, function (t) { return t.flags & 4 /* String */ ? extractTypesOfKind(typeWithLiterals, 4 /* String */ | 128 /* StringLiteral */) : t.flags & 8 /* Number */ ? extractTypesOfKind(typeWithLiterals, 8 /* Number */ | 256 /* NumberLiteral */) : - t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : - t; + t.flags & 64 /* BigInt */ ? extractTypesOfKind(typeWithLiterals, 64 /* BigInt */ | 2048 /* BigIntLiteral */) : t; }); } return typeWithPrimitives; @@ -47527,8 +50063,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 131072 /* Never */)) { if (!(ts.getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -47551,33 +50087,94 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 190 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || - parent.parent.kind === 192 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 191 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 193 /* PropertyAccessExpression */ && (parent.name.escapedText === "length" || + parent.parent.kind === 195 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 194 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 205 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 60 /* EqualsToken */ && + parent.parent.kind === 208 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 62 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296 /* NumberLike */); return isLengthPushOrUnshift || isElementAssignment; } - function maybeTypePredicateCall(node) { - var links = getNodeLinks(node); - if (links.maybeTypePredicate === undefined) { - links.maybeTypePredicate = getMaybeTypePredicate(node); + function isDeclarationWithExplicitTypeAnnotation(declaration) { + return !!(declaration && (declaration.kind === 241 /* VariableDeclaration */ || declaration.kind === 155 /* Parameter */ || + declaration.kind === 158 /* PropertyDeclaration */ || declaration.kind === 157 /* PropertySignature */) && + ts.getEffectiveTypeAnnotationNode(declaration)); + } + function getExplicitTypeOfSymbol(symbol, diagnostic) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 512 /* ValueModule */)) { + return getTypeOfSymbol(symbol); + } + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { + if (isDeclarationWithExplicitTypeAnnotation(symbol.valueDeclaration)) { + return getTypeOfSymbol(symbol); + } + if (diagnostic && symbol.valueDeclaration) { + ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(symbol.valueDeclaration, ts.Diagnostics._0_is_declared_here, symbolToString(symbol))); + } } - return links.maybeTypePredicate; } - function getMaybeTypePredicate(node) { - if (node.expression.kind !== 99 /* SuperKeyword */) { - var funcType = checkNonNullExpression(node.expression); - if (funcType !== silentNeverType) { - var apparentType = getApparentType(funcType); - return apparentType !== errorType && ts.some(getSignaturesOfType(apparentType, 0 /* Call */), signatureHasTypePredicate); + // We require the dotted function name in an assertion expression to be comprised of identifiers + // that reference function, method, class or value module symbols; or variable, property or + // parameter symbols with declarations that have explicit type annotations. Such references are + // resolvable with no possibility of triggering circularities in control flow analysis. + function getTypeOfDottedName(node, diagnostic) { + if (!(node.flags & 16777216 /* InWithStatement */)) { + switch (node.kind) { + case 75 /* Identifier */: + var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node)); + return getExplicitTypeOfSymbol(symbol.flags & 2097152 /* Alias */ ? resolveAlias(symbol) : symbol, diagnostic); + case 103 /* ThisKeyword */: + return getExplicitThisType(node); + case 193 /* PropertyAccessExpression */: + var type = getTypeOfDottedName(node.expression, diagnostic); + var prop = type && getPropertyOfType(type, node.name.escapedText); + return prop && getExplicitTypeOfSymbol(prop, diagnostic); + case 199 /* ParenthesizedExpression */: + return getTypeOfDottedName(node.expression, diagnostic); } } - return false; + } + function getEffectsSignature(node) { + var links = getNodeLinks(node); + var signature = links.effectsSignature; + if (signature === undefined) { + // A call expression parented by an expression statement is a potential assertion. Other call + // expressions are potential type predicate function calls. In order to avoid triggering + // circularities in control flow analysis, we use getTypeOfDottedName when resolving the call + // target expression of an assertion. + var funcType = void 0; + if (node.parent.kind === 225 /* ExpressionStatement */) { + funcType = getTypeOfDottedName(node.expression, /*diagnostic*/ undefined); + } + else if (node.expression.kind !== 101 /* SuperKeyword */) { + if (ts.isOptionalChain(node)) { + funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression); + } + else { + funcType = checkNonNullExpression(node.expression); + } + } + var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0 /* Call */); + var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] : + ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) : + undefined; + signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature; + } + return signature === unknownSignature ? undefined : signature; + } + function hasTypePredicateOrNeverReturnType(signature) { + return !!(getTypePredicateOfSignature(signature) || + signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072 /* Never */); + } + function getTypePredicateArgument(predicate, callExpression) { + if (predicate.kind === 1 /* Identifier */ || predicate.kind === 3 /* AssertsIdentifier */) { + return callExpression.arguments[predicate.parameterIndex]; + } + var invokedExpression = ts.skipParentheses(callExpression.expression); + return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined; } function reportFlowControlError(node) { var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); @@ -47585,6 +50182,82 @@ var ts; var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); } + function isReachableFlowNode(flow) { + var result = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + lastFlowNode = flow; + lastFlowNodeReachable = result; + return result; + } + function isUnlockedReachableFlowNode(flow) { + return !(flow.flags & 4096 /* PreFinally */ && flow.lock.locked) && isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ false); + } + function isFalseExpression(expr) { + var node = ts.skipParentheses(expr); + return node.kind === 90 /* FalseKeyword */ || node.kind === 208 /* BinaryExpression */ && (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */ && (isFalseExpression(node.left) || isFalseExpression(node.right)) || + node.operatorToken.kind === 56 /* BarBarToken */ && isFalseExpression(node.left) && isFalseExpression(node.right)); + } + function isReachableFlowNodeWorker(flow, noCacheCheck) { + while (true) { + if (flow === lastFlowNode) { + return lastFlowNodeReachable; + } + var flags = flow.flags; + if (flags & 2048 /* Shared */) { + if (!noCacheCheck) { + var id = getFlowNodeId(flow); + var reachable = flowNodeReachable[id]; + return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, /*skipCacheCheck*/ true)); + } + noCacheCheck = false; + } + if (flags & (16 /* Assignment */ | 96 /* Condition */ | 256 /* ArrayMutation */ | 4096 /* PreFinally */)) { + flow = flow.antecedent; + } + else if (flags & 512 /* Call */) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && predicate.kind === 3 /* AssertsIdentifier */) { + var predicateArgument = flow.node.arguments[predicate.parameterIndex]; + if (predicateArgument && isFalseExpression(predicateArgument)) { + return false; + } + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return false; + } + } + flow = flow.antecedent; + } + else if (flags & 4 /* BranchLabel */) { + // A branching point is reachable if any branch is reachable. + return ts.some(flow.antecedents, isUnlockedReachableFlowNode); + } + else if (flags & 8 /* LoopLabel */) { + // A loop is reachable if the control flow path that leads to the top is reachable. + flow = flow.antecedents[0]; + } + else if (flags & 128 /* SwitchClause */) { + // The control flow path representing an unmatched value in a switch statement with + // no default clause is unreachable if the switch statement is exhaustive. + if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return false; + } + flow = flow.antecedent; + } + else if (flags & 8192 /* AfterFinally */) { + // Cache is unreliable once we start locking nodes + lastFlowNode = undefined; + flow.locked = true; + var result = isReachableFlowNodeWorker(flow.antecedent, /*skipCacheCheck*/ false); + flow.locked = false; + return result; + } + else { + return !(flags & 1 /* Unreachable */); + } + } + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; @@ -47596,6 +50269,7 @@ var ts; if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 133970943 /* Narrowable */)) { return declaredType; } + flowInvocationCount++; var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); sharedFlowCount = sharedFlowStart; @@ -47604,7 +50278,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = ts.getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent && reference.parent.kind === 214 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { + if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 217 /* NonNullExpression */ && getTypeWithFacts(resultType, 2097152 /* NEUndefinedOrNull */).flags & 131072 /* Never */) { return declaredType; } return resultType; @@ -47626,16 +50300,7 @@ var ts; flowDepth++; while (true) { var flags = flow.flags; - if (flags & 8192 /* Cached */) { - var key_2 = getOrSetCacheKey(); - if (key_2) { - var id = getFlowNodeId(flow); - if (flowAssignmentKeys[id] === key_2) { - return flowAssignmentTypes[id]; - } - } - } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. @@ -47647,13 +50312,13 @@ var ts; } } var type = void 0; - if (flags & 4096 /* AfterFinally */) { + if (flags & 8192 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flags & 2048 /* PreFinally */) { + else if (flags & 4096 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; @@ -47665,14 +50330,12 @@ var ts; flow = flow.antecedent; continue; } - else if (flowLoopCount === flowLoopStart) { // Only cache assignments when not within loop analysis - var key_3 = getOrSetCacheKey(); - if (key_3 && !isIncomplete(type)) { - flow.flags |= 8192 /* Cached */; - var id = getFlowNodeId(flow); - flowAssignmentKeys[id] = key_3; - flowAssignmentTypes[id] = type; - } + } + else if (flags & 512 /* Call */) { + type = getTypeAtFlowCall(flow); + if (!type) { + flow = flow.antecedent; + continue; } } else if (flags & 96 /* Condition */) { @@ -47699,11 +50362,11 @@ var ts; } else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. - var container = flow.container; + var container = flow.node; if (container && container !== flowContainer && - reference.kind !== 190 /* PropertyAccessExpression */ && - reference.kind !== 191 /* ElementAccessExpression */ && - reference.kind !== 101 /* ThisKeyword */) { + reference.kind !== 193 /* PropertyAccessExpression */ && + reference.kind !== 194 /* ElementAccessExpression */ && + reference.kind !== 103 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -47715,7 +50378,7 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flags & 1024 /* Shared */) { + if (flags & 2048 /* Shared */) { // Record visited node and the associated type in the cache. sharedFlowNodes[sharedFlowCount] = flow; sharedFlowTypes[sharedFlowCount] = type; @@ -47725,11 +50388,34 @@ var ts; return type; } } + function getInitialOrAssignedType(flow) { + var node = flow.node; + if (flow.flags & 16384 /* Cached */) { + var cached = flowAssignmentTypes[getNodeId(node)]; + if (cached) { + return cached; + } + } + var startInvocationCount = flowInvocationCount; + var type = getConstraintForLocation(node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */ ? + getInitialType(node) : + getAssignedType(node), reference); + // We cache the assigned type when getFlowTypeOfReference was recursively invoked in the + // resolution of the assigned type and we're not within loop analysis. + if (flowInvocationCount !== startInvocationCount && flowLoopCount === flowLoopStart) { + flow.flags |= 16384 /* Cached */; + flowAssignmentTypes[getNodeId(node)] = type; + } + return type; + } function getTypeAtFlowAssignment(flow) { var node = flow.node; // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } if (ts.getAssignmentTargetKind(node) === 2 /* Compound */) { var flowType = getTypeAtFlowNode(flow.antecedent); return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType)); @@ -47738,11 +50424,11 @@ var ts; if (isEmptyArrayAssignment(node)) { return getEvolvingArrayType(neverType); } - var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(node, reference)); + var assignedType = getBaseTypeOfLiteralType(getInitialOrAssignedType(flow)); return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType; } if (declaredType.flags & 1048576 /* Union */) { - return getAssignmentReducedType(declaredType, getInitialOrAssignedType(node, reference)); + return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow)); } return declaredType; } @@ -47751,27 +50437,63 @@ var ts; // reference 'x.y.z', we may be at an assignment to 'x.y' or 'x'. In that case, // return the declared type. if (containsMatchingReference(reference, node)) { + if (!isReachableFlowNode(flow)) { + return unreachableNeverType; + } // A matching dotted name might also be an expando property on a function *expression*, // in which case we continue control flow analysis back to the function's declaration if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) { var init = ts.getDeclaredExpandoInitializer(node); - if (init && (init.kind === 197 /* FunctionExpression */ || init.kind === 198 /* ArrowFunction */)) { + if (init && (init.kind === 200 /* FunctionExpression */ || init.kind === 201 /* ArrowFunction */)) { return getTypeAtFlowNode(flow.antecedent); } } return declaredType; } // for (const _ in ref) acts as a nonnull on ref - if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 227 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { + if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 230 /* ForInStatement */ && isMatchingReference(reference, node.parent.parent.expression)) { return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent))); } // Assignment doesn't affect reference return undefined; } + function narrowTypeByAssertion(type, expr) { + var node = ts.skipParentheses(expr); + if (node.kind === 90 /* FalseKeyword */) { + return unreachableNeverType; + } + if (node.kind === 208 /* BinaryExpression */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { + return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right); + } + if (node.operatorToken.kind === 56 /* BarBarToken */) { + return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]); + } + } + return narrowType(type, node, /*assumeTrue*/ true); + } + function getTypeAtFlowCall(flow) { + var signature = getEffectsSignature(flow.node); + if (signature) { + var predicate = getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : + predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : + type; + return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType)); + } + if (getReturnTypeOfSignature(signature).flags & 131072 /* Never */) { + return unreachableNeverType; + } + } + return undefined; + } function getTypeAtFlowArrayMutation(flow) { if (declaredType === autoType || declaredType === autoArrayType) { var node = flow.node; - var expr = node.kind === 192 /* CallExpression */ ? + var expr = node.kind === 195 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -47779,7 +50501,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (ts.getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -47814,7 +50536,7 @@ var ts; // *only* place a silent never type is ever generated. var assumeTrue = (flow.flags & 32 /* TrueCondition */) !== 0; var nonEvolvingType = finalizeEvolvingArrayType(type); - var narrowedType = narrowType(nonEvolvingType, flow.expression, assumeTrue); + var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue); if (narrowedType === nonEvolvingType) { return flowType; } @@ -47829,14 +50551,27 @@ var ts; if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (isMatchingReferenceDiscriminant(expr, type)) { - type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); - } - else if (expr.kind === 200 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { + else if (expr.kind === 203 /* TypeOfExpression */ && isMatchingReference(reference, expr.expression)) { type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (containsMatchingReferenceDiscriminant(reference, expr)) { - type = declaredType; + else { + if (strictNullChecks) { + if (optionalChainContainsReference(expr, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 /* Undefined */ | 131072 /* Never */)); }); + } + else if (expr.kind === 203 /* TypeOfExpression */ && optionalChainContainsReference(expr.expression, reference)) { + type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 /* Never */ || t.flags & 128 /* StringLiteral */ && t.value === "undefined"); }); + } + } + if (isMatchingReferenceDiscriminant(expr, type)) { + type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); }); + } + else if (containsMatchingReferenceDiscriminant(reference, expr)) { + type = declaredType; + } + else if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) { + return unreachableNeverType; + } } return createFlowType(type, isIncomplete(flowType)); } @@ -47846,7 +50581,7 @@ var ts; var seenIncomplete = false; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { + if (antecedent.flags & 4096 /* PreFinally */ && antecedent.lock.locked) { // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. @@ -47906,25 +50641,32 @@ var ts; var antecedentTypes = []; var subtypeReduction = false; var firstAntecedentType; - flowLoopNodes[flowLoopCount] = flow; - flowLoopKeys[flowLoopCount] = key; - flowLoopTypes[flowLoopCount] = antecedentTypes; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; - flowLoopCount++; - var flowType = getTypeAtFlowNode(antecedent); - flowLoopCount--; + var flowType = void 0; if (!firstAntecedentType) { - firstAntecedentType = flowType; + // The first antecedent of a loop junction is always the non-looping control + // flow path that leads to the top. + flowType = firstAntecedentType = getTypeAtFlowNode(antecedent); } - var type = getTypeFromFlowType(flowType); - // If we see a value appear in the cache it is a sign that control flow analysis - // was restarted and completed by checkExpressionCached. We can simply pick up - // the resulting type and bail out. - var cached_1 = cache.get(key); - if (cached_1) { - return cached_1; + else { + // All but the first antecedent are the looping control flow paths that lead + // back to the loop junction. We track these on the flow loop stack. + flowLoopNodes[flowLoopCount] = flow; + flowLoopKeys[flowLoopCount] = key; + flowLoopTypes[flowLoopCount] = antecedentTypes; + flowLoopCount++; + flowType = getTypeAtFlowNode(antecedent); + flowLoopCount--; + // If we see a value appear in the cache it is a sign that control flow analysis + // was restarted and completed by checkExpressionCached. We can simply pick up + // the resulting type and bail out. + var cached_1 = cache.get(key); + if (cached_1) { + return cached_1; + } } + var type = getTypeFromFlowType(flowType); ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control @@ -47971,6 +50713,9 @@ var ts; if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); } + if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) { + type = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } if (isMatchingReferenceDiscriminant(expr, declaredType)) { return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 /* Truthy */ : 8388608 /* Falsy */); }); } @@ -47998,19 +50743,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue); - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { + if (left_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(right_1)) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 200 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { + if (right_1.kind === 203 /* TypeOfExpression */ && ts.isStringLiteralLike(left_1)) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -48019,6 +50764,14 @@ var ts; if (isMatchingReference(reference, right_1)) { return narrowTypeByEquality(type, operator_1, left_1, assumeTrue); } + if (strictNullChecks) { + if (optionalChainContainsReference(left_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue); + } + else if (optionalChainContainsReference(right_1, reference)) { + type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue); + } + } if (isMatchingReferenceDiscriminant(left_1, declaredType)) { return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); }); } @@ -48029,9 +50782,9 @@ var ts; return declaredType; } break; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 94 /* InKeyword */: + case 96 /* InKeyword */: var target = getReferenceCandidate(expr.right); if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) { return narrowByInKeyword(type, expr.left, assumeTrue); @@ -48042,15 +50795,24 @@ var ts; } return type; } + function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) { + // We are in a branch of obj?.foo === value or obj?.foo !== value. We remove undefined and null from + // the type of obj if (a) the operator is === and the type of value doesn't include undefined or (b) the + // operator is !== and the type of value is undefined. + var effectiveTrue = operator === 34 /* EqualsEqualsToken */ || operator === 36 /* EqualsEqualsEqualsToken */ ? assumeTrue : !assumeTrue; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; + var valueNonNullish = !(getTypeFacts(getTypeOfExpression(value)) & (doubleEquals ? 262144 /* EQUndefinedOrNull */ : 65536 /* EQUndefined */)); + return effectiveTrue === valueNonNullish ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeByEquality(type, operator, value, assumeTrue) { if (type.flags & 1 /* Any */) { return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); - if ((type.flags & 2 /* Unknown */) && (operator === 35 /* EqualsEqualsEqualsToken */) && assumeTrue) { + if ((type.flags & 2 /* Unknown */) && assumeTrue && (operator === 36 /* EqualsEqualsEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */)) { if (valueType.flags & (131068 /* Primitive */ | 67108864 /* NonPrimitive */)) { return valueType; } @@ -48063,7 +50825,7 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 33 /* EqualsEqualsToken */ || operator === 34 /* ExclamationEqualsToken */; + var doubleEquals = operator === 34 /* EqualsEqualsToken */ || operator === 35 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 262144 /* EQUndefinedOrNull */ : 2097152 /* NEUndefinedOrNull */ : valueType.flags & 65536 /* Null */ ? @@ -48075,7 +50837,7 @@ var ts; return type; } if (assumeTrue) { - var filterFn = operator === 33 /* EqualsEqualsToken */ ? + var filterFn = operator === 34 /* EqualsEqualsToken */ ? (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) : function (t) { return areTypesComparable(t, valueType); }; var narrowedType = filterType(type, filterFn); @@ -48088,9 +50850,15 @@ var ts; return type; } function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) { - // We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands + // We have '==', '!=', '===', or !==' operator with 'typeof xxx' and string literal operands + if (operator === 35 /* ExclamationEqualsToken */ || operator === 37 /* ExclamationEqualsEqualsToken */) { + assumeTrue = !assumeTrue; + } var target = getReferenceCandidate(typeOfExpr.expression); if (!isMatchingReference(reference, target)) { + if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the // narrowed type of 'y' to its declared type. if (containsMatchingReference(reference, target)) { @@ -48098,9 +50866,6 @@ var ts; } return type; } - if (operator === 34 /* ExclamationEqualsToken */ || operator === 36 /* ExclamationEqualsEqualsToken */) { - assumeTrue = !assumeTrue; - } if (type.flags & 1 /* Any */ && literal.text === "function") { return type; } @@ -48133,6 +50898,10 @@ var ts; return type; } } + function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) { + var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck); + return everyClauseChecks ? getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */) : type; + } function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) { // We only narrow if all case expressions specify // values with unit types, except for the case where @@ -48265,6 +51034,9 @@ var ts; function narrowTypeByInstanceof(type, expr, assumeTrue) { var left = getReferenceCandidate(expr.left); if (!isMatchingReference(reference, left)) { + if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); + } // For a reference of the form 'x.y', an 'x instanceof T' type guard resets the // narrowed type of 'y' to its declared type. We do this because preceding 'x.y' // references might reference a different 'y' property. However, we make an exception @@ -48325,38 +51097,29 @@ var ts; isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } - function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { - if (!hasMatchingArgument(callExpression, reference) || !maybeTypePredicateCall(callExpression)) { - return type; - } - var signature = getResolvedSignature(callExpression); - var predicate = getTypePredicateOfSignature(signature); - if (!predicate) { - return type; + function narrowTypeByCallExpression(type, callExpression, assumeTrue) { + if (hasMatchingArgument(callExpression, reference)) { + var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined; + var predicate = signature && getTypePredicateOfSignature(signature); + if (predicate && (predicate.kind === 0 /* This */ || predicate.kind === 1 /* Identifier */)) { + return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue); + } } + return type; + } + function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) { // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' - if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { - return type; - } - if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) { + var predicateArgument = getTypePredicateArgument(predicate, callExpression); if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); } - if (containsMatchingReference(reference, predicateArgument)) { - return declaredType; - } - } - } - else { - var invokedExpression = ts.skipParentheses(callExpression.expression); - if (ts.isAccessExpression(invokedExpression)) { - var possibleReference = ts.skipParentheses(invokedExpression.expression); - if (isMatchingReference(reference, possibleReference)) { - return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); + if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) && + !(getTypeFacts(predicate.type) & 65536 /* EQUndefined */)) { + return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); } - if (containsMatchingReference(reference, possibleReference)) { + if (containsMatchingReference(reference, predicateArgument)) { return declaredType; } } @@ -48366,27 +51129,44 @@ var ts; // Narrow the given type based on the given expression having the assumed boolean value. The returned type // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { + // for `a?.b`, we emulate a synthetic `a !== null && a !== undefined` condition for `a` + if (ts.isExpressionOfOptionalChainRoot(expr) || + ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 /* QuestionQuestionToken */ && expr.parent.left === expr) { + return narrowTypeByOptionality(type, expr, assumeTrue); + } switch (expr.kind) { - case 73 /* Identifier */: - case 101 /* ThisKeyword */: - case 99 /* SuperKeyword */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 75 /* Identifier */: + case 103 /* ThisKeyword */: + case 101 /* SuperKeyword */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 192 /* CallExpression */: - return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 196 /* ParenthesizedExpression */: + case 195 /* CallExpression */: + return narrowTypeByCallExpression(type, expr, assumeTrue); + case 199 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 203 /* PrefixUnaryExpression */: - if (expr.operator === 52 /* ExclamationToken */) { + case 206 /* PrefixUnaryExpression */: + if (expr.operator === 53 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; } return type; } + function narrowTypeByOptionality(type, expr, assumePresent) { + if (isMatchingReference(reference, expr)) { + return getTypeWithFacts(type, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); + } + if (isMatchingReferenceDiscriminant(expr, declaredType)) { + return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 /* NEUndefinedOrNull */ : 262144 /* EQUndefinedOrNull */); }); + } + if (containsMatchingReferenceDiscriminant(reference, expr)) { + return declaredType; + } + return type; + } } function getTypeOfSymbolAtLocation(symbol, location) { symbol = symbol.exportSymbol || symbol; @@ -48394,7 +51174,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 73 /* Identifier */) { + if (location.kind === 75 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -48415,9 +51195,9 @@ var ts; function getControlFlowContainer(node) { return ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 246 /* ModuleBlock */ || - node.kind === 285 /* SourceFile */ || - node.kind === 155 /* PropertyDeclaration */; + node.kind === 249 /* ModuleBlock */ || + node.kind === 288 /* SourceFile */ || + node.kind === 158 /* PropertyDeclaration */; }); } // Check if a parameter is assigned anywhere within its declaring function. @@ -48436,10 +51216,10 @@ var ts; return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 152 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 155 /* Parameter */) { symbol.isAssigned = true; } } @@ -48454,7 +51234,7 @@ var ts; /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ function removeOptionalityFromDeclaredType(declaredType, declaration) { var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 152 /* Parameter */ && + declaration.kind === 155 /* Parameter */ && declaration.initializer && getFalsyFlags(declaredType) & 32768 /* Undefined */ && !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768 /* Undefined */); @@ -48462,10 +51242,10 @@ var ts; } function isConstraintPosition(node) { var parent = node.parent; - return parent.kind === 190 /* PropertyAccessExpression */ || - parent.kind === 192 /* CallExpression */ && parent.expression === node || - parent.kind === 191 /* ElementAccessExpression */ && parent.expression === node || - parent.kind === 187 /* BindingElement */ && parent.name === node && !!parent.initializer; + return parent.kind === 193 /* PropertyAccessExpression */ || + parent.kind === 195 /* CallExpression */ && parent.expression === node || + parent.kind === 194 /* ElementAccessExpression */ && parent.expression === node || + parent.kind === 190 /* BindingElement */ && parent.name === node && !!parent.initializer; } function typeHasNullableConstraint(type) { return type.flags & 58982400 /* InstantiableNonPrimitive */ && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304 /* Nullable */); @@ -48502,7 +51282,7 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { @@ -48523,7 +51303,7 @@ var ts; // Due to the emit for class decorators, any reference to the class from inside of the class body // must instead be rewritten to point to a temporary variable to avoid issues with the double-bind // behavior of class names in ES6. - if (declaration.kind === 241 /* ClassDeclaration */ + if (declaration.kind === 244 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -48535,14 +51315,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration.kind === 210 /* ClassExpression */) { + else if (declaration.kind === 213 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); - while (container.kind !== 285 /* SourceFile */) { + while (container.kind !== 288 /* SourceFile */) { if (container.parent === declaration) { - if (container.kind === 155 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 158 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration).flags |= 16777216 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 33554432 /* ConstructorReferenceInClass */; } @@ -48591,7 +51371,7 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 152 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 155 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; @@ -48600,8 +51380,8 @@ var ts; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 197 /* FunctionExpression */ || - flowContainer.kind === 198 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 200 /* FunctionExpression */ || + flowContainer.kind === 201 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -48609,11 +51389,11 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 3 /* AnyOrUnknown */) !== 0 || - isInTypeQuery(node) || node.parent.kind === 258 /* ExportSpecifier */) || - node.parent.kind === 214 /* NonNullExpression */ || - declaration.kind === 238 /* VariableDeclaration */ && declaration.exclamationToken || - declaration.flags & 4194304 /* Ambient */; + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || + isInTypeQuery(node) || node.parent.kind === 261 /* ExportSpecifier */) || + node.parent.kind === 217 /* NonNullExpression */ || + declaration.kind === 241 /* VariableDeclaration */ && declaration.exclamationToken || + declaration.flags & 8388608 /* Ambient */; var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) : type === autoType || type === autoArrayType ? undefinedType : getOptionalType(type); @@ -48647,7 +51427,7 @@ var ts; if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || ts.isSourceFile(symbol.valueDeclaration) || - symbol.valueDeclaration.parent.kind === 275 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 278 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -48670,7 +51450,7 @@ var ts; // mark iteration statement as containing block-scoped binding captured in some function var capturesBlockScopeBindingInLoopBody = true; if (ts.isForStatement(container) && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container) { + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container) { var part = getPartOfForStatementContainingNode(node.parent, container); if (part) { var links = getNodeLinks(part); @@ -48688,8 +51468,8 @@ var ts; } // mark variables that are declared in loop initializer and reassigned inside the body of ForStatement. // if body of ForStatement will be converted to function then we'll need a extra machinery to propagate reassigned values back. - if (container.kind === 226 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 239 /* VariableDeclarationList */).parent === container && + if (container.kind === 229 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 242 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 4194304 /* NeedsLoopOutParameter */; } @@ -48707,7 +51487,7 @@ var ts; function isAssignedInBodyOfForStatement(node, container) { // skip parenthesized nodes var current = node; - while (current.parent.kind === 196 /* ParenthesizedExpression */) { + while (current.parent.kind === 199 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -48715,9 +51495,9 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 203 /* PrefixUnaryExpression */ || current.parent.kind === 204 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 206 /* PrefixUnaryExpression */ || current.parent.kind === 207 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 44 /* PlusPlusToken */ || expr.operator === 45 /* MinusMinusToken */; + isAssigned = expr.operator === 45 /* PlusPlusToken */ || expr.operator === 46 /* MinusMinusToken */; } if (!isAssigned) { return false; @@ -48728,7 +51508,7 @@ var ts; } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 155 /* PropertyDeclaration */ || container.kind === 158 /* Constructor */) { + if (container.kind === 158 /* PropertyDeclaration */ || container.kind === 161 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -48796,37 +51576,37 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var capturedByArrowFunction = false; - if (container.kind === 158 /* Constructor */) { + if (container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } // Now skip arrow functions to get the "real" owner of 'this'. - if (container.kind === 198 /* ArrowFunction */) { + if (container.kind === 201 /* ArrowFunction */) { container = ts.getThisContainer(container, /* includeArrowFunctions */ false); capturedByArrowFunction = true; } switch (container.kind) { - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks break; - case 158 /* Constructor */: + case 161 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: if (ts.hasModifier(container, 32 /* Static */)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -48865,10 +51645,8 @@ var ts; if (isInJS && className) { var classSymbol = checkExpression(className).symbol; if (classSymbol && classSymbol.members && (classSymbol.flags & 16 /* Function */)) { - var classType = getJSClassType(classSymbol); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(classSymbol).thisType; + return getFlowTypeOfReference(node, classType); } } // Check if it's a constructor definition, can be either a variable decl or function decl @@ -48876,12 +51654,10 @@ var ts; // * /** @constructor */ function [name]() { ... } // * /** @constructor */ var x = function() { ... } else if (isInJS && - (container.kind === 197 /* FunctionExpression */ || container.kind === 240 /* FunctionDeclaration */) && + (container.kind === 200 /* FunctionExpression */ || container.kind === 243 /* FunctionDeclaration */) && ts.getJSDocClassTag(container)) { - var classType = getJSClassType(getMergedSymbol(container.symbol)); - if (classType) { - return getFlowTypeOfReference(node, classType); - } + var classType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType; + return getFlowTypeOfReference(node, classType); } var thisType = getThisTypeOfDeclaration(container) || getContextualThisParameterType(container); if (thisType) { @@ -48910,9 +51686,22 @@ var ts; } } } + function getExplicitThisType(node) { + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + if (ts.isFunctionLike(container)) { + var signature = getSignatureFromDeclaration(container); + if (signature.thisParameter) { + return getExplicitTypeOfSymbol(signature.thisParameter); + } + } + if (ts.isClassLike(container.parent)) { + var symbol = getSymbolOfNode(container.parent); + return ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; + } + } function getClassNameFromPrototypeMethod(container) { // Check if it's the RHS of a x.prototype.y = function [name]() { .... } - if (container.kind === 197 /* FunctionExpression */ && + if (container.kind === 200 /* FunctionExpression */ && ts.isBinaryExpression(container.parent) && ts.getAssignmentDeclarationKind(container.parent) === 3 /* PrototypeProperty */) { // Get the 'x' of 'x.prototype.y = container' @@ -48922,16 +51711,16 @@ var ts; .expression; // x } // x.prototype = { method() { } } - else if (container.kind === 157 /* MethodDeclaration */ && - container.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 160 /* MethodDeclaration */ && + container.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent) === 6 /* Prototype */) { return container.parent.parent.left.expression; } // x.prototype = { method: function() { } } - else if (container.kind === 197 /* FunctionExpression */ && - container.parent.kind === 276 /* PropertyAssignment */ && - container.parent.parent.kind === 189 /* ObjectLiteralExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && + container.parent.kind === 279 /* PropertyAssignment */ && + container.parent.parent.kind === 192 /* ObjectLiteralExpression */ && ts.isBinaryExpression(container.parent.parent.parent) && ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6 /* Prototype */) { return container.parent.parent.parent.left.expression; @@ -48939,7 +51728,7 @@ var ts; // Object.defineProperty(x, "method", { value: function() { } }); // Object.defineProperty(x, "method", { set: (x: () => void) => void }); // Object.defineProperty(x, "method", { get: () => function() { }) }); - else if (container.kind === 197 /* FunctionExpression */ && + else if (container.kind === 200 /* FunctionExpression */ && ts.isPropertyAssignment(container.parent) && ts.isIdentifier(container.parent.name) && (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") && @@ -48964,7 +51753,7 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 295 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 298 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].name && @@ -48978,15 +51767,15 @@ var ts; } } function isInConstructorArgumentInitializer(node, constructorDecl) { - return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 152 /* Parameter */ && n.parent === constructorDecl; }); + return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 155 /* Parameter */ && n.parent === constructorDecl; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 192 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 195 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 198 /* ArrowFunction */) { + while (container && container.kind === 201 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -48999,14 +51788,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 150 /* ComputedPropertyName */; }); - if (current && current.kind === 150 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 153 /* ComputedPropertyName */; }); + if (current && current.kind === 153 /* ComputedPropertyName */) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name); } else if (isCallExpression) { error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors); } - else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -49014,7 +51803,7 @@ var ts; } return errorType; } - if (!isCallExpression && container.kind === 158 /* Constructor */) { + if (!isCallExpression && container.kind === 161 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if (ts.hasModifier(container, 32 /* Static */) || isCallExpression) { @@ -49083,7 +51872,7 @@ var ts; // as a call expression cannot be used as the target of a destructuring assignment while a property access can. // // For element access expressions (`super[x]`), we emit a generic helper that forwards the element access in both situations. - if (container.kind === 157 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { + if (container.kind === 160 /* MethodDeclaration */ && ts.hasModifier(container, 256 /* Async */)) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -49097,7 +51886,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (container.parent.kind === 192 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return errorType; @@ -49118,7 +51907,7 @@ var ts; if (!baseClassType) { return errorType; } - if (container.kind === 158 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 161 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { // issue custom error message for super property access in constructor arguments (to be aligned with old compiler) error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return errorType; @@ -49133,7 +51922,7 @@ var ts; if (isCallExpression) { // TS 1.0 SPEC (April 2014): 4.8.1 // Super calls are only permitted in constructors of derived classes - return container.kind === 158 /* Constructor */; + return container.kind === 161 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -49141,21 +51930,21 @@ var ts; // - In a constructor, instance member function, instance member accessor, or instance member variable initializer where this references a derived class instance // - In a static member function or static member accessor // topmost container must be something that is directly nested in the class declaration\object literal expression - if (ts.isClassLike(container.parent) || container.parent.kind === 189 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 192 /* ObjectLiteralExpression */) { if (ts.hasModifier(container, 32 /* Static */)) { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */; } else { - return container.kind === 157 /* MethodDeclaration */ || - container.kind === 156 /* MethodSignature */ || - container.kind === 159 /* GetAccessor */ || - container.kind === 160 /* SetAccessor */ || - container.kind === 155 /* PropertyDeclaration */ || - container.kind === 154 /* PropertySignature */ || - container.kind === 158 /* Constructor */; + return container.kind === 160 /* MethodDeclaration */ || + container.kind === 159 /* MethodSignature */ || + container.kind === 162 /* GetAccessor */ || + container.kind === 163 /* SetAccessor */ || + container.kind === 158 /* PropertyDeclaration */ || + container.kind === 157 /* PropertySignature */ || + container.kind === 161 /* Constructor */; } } } @@ -49163,14 +51952,14 @@ var ts; } } function getContainingObjectLiteral(func) { - return (func.kind === 157 /* MethodDeclaration */ || - func.kind === 159 /* GetAccessor */ || - func.kind === 160 /* SetAccessor */) && func.parent.kind === 189 /* ObjectLiteralExpression */ ? func.parent : - func.kind === 197 /* FunctionExpression */ && func.parent.kind === 276 /* PropertyAssignment */ ? func.parent.parent : + return (func.kind === 160 /* MethodDeclaration */ || + func.kind === 162 /* GetAccessor */ || + func.kind === 163 /* SetAccessor */) && func.parent.kind === 192 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 200 /* FunctionExpression */ && func.parent.kind === 279 /* PropertyAssignment */ ? func.parent.parent : undefined; } function getThisTypeArgument(type) { - return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + return ts.getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? getTypeArguments(type)[0] : undefined; } function getThisTypeFromContextualType(type) { return mapType(type, function (t) { @@ -49178,7 +51967,7 @@ var ts; }); } function getContextualThisParameterType(func) { - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { return undefined; } if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { @@ -49205,7 +51994,7 @@ var ts; if (thisType) { return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral))); } - if (literal.parent.kind !== 276 /* PropertyAssignment */) { + if (literal.parent.kind !== 279 /* PropertyAssignment */) { break; } literal = literal.parent.parent; @@ -49219,9 +52008,9 @@ var ts; // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. var parent = func.parent; - if (parent.kind === 205 /* BinaryExpression */ && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent.kind === 208 /* BinaryExpression */ && parent.operatorToken.kind === 62 /* EqualsToken */) { var target = parent.left; - if (target.kind === 190 /* PropertyAccessExpression */ || target.kind === 191 /* ElementAccessExpression */) { + if (target.kind === 193 /* PropertyAccessExpression */ || target.kind === 194 /* ElementAccessExpression */) { var expression = target.expression; // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` if (inJs && ts.isIdentifier(expression)) { @@ -49285,9 +52074,9 @@ var ts; return getTypeFromTypeNode(typeNode); } switch (declaration.kind) { - case 152 /* Parameter */: + case 155 /* Parameter */: return getContextuallyTypedParameterType(declaration, /*forCache*/ false); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return getContextualTypeForBindingElement(declaration); // By default, do nothing and return undefined - only parameters and binding elements have context implied by a parent } @@ -49402,22 +52191,26 @@ var ts; return undefined; } // In a typed function call, an argument or substitution expression is contextually typed by the type of the corresponding parameter. - function getContextualTypeForArgument(callTarget, arg) { + function getContextualTypeForArgument(callTarget, arg, contextFlags) { var args = getEffectiveCallArguments(callTarget); var argIndex = args.indexOf(arg); // -1 for e.g. the expression of a CallExpression, or the tag of a TaggedTemplateExpression - return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex); + return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags); } - function getContextualTypeForArgumentAtIndex(callTarget, argIndex) { + function getContextualTypeForArgumentAtIndex(callTarget, argIndex, contextFlags) { // If we're already in the process of resolving the given signature, don't resolve again as // that could cause infinite recursion. Instead, return anySignature. var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget); if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) { return getEffectiveFirstArgumentForJsxSignature(signature, callTarget); } + if (contextFlags && contextFlags & 4 /* Completion */ && signature.target) { + var baseSignature = getBaseSignature(signature.target); + return intersectTypes(getTypeAtPosition(signature, argIndex), getTypeAtPosition(baseSignature, argIndex)); + } return getTypeAtPosition(signature, argIndex); } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 194 /* TaggedTemplateExpression */) { + if (template.parent.kind === 197 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -49426,7 +52219,7 @@ var ts; var binaryExpression = node.parent; var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right; switch (operatorToken.kind) { - case 60 /* EqualsToken */: + case 62 /* EqualsToken */: if (node !== right) { return undefined; } @@ -49435,7 +52228,8 @@ var ts; return undefined; } return contextSensitive === true ? getTypeOfExpression(left) : contextSensitive; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: + case 60 /* QuestionQuestionToken */: // When an || expression has a contextual type, the operands are contextually typed by that type, except // when that type originates in a binding pattern, the right operand is contextually typed by the type of // the left operand. When an || expression has no contextual type, the right operand is contextually typed @@ -49444,7 +52238,7 @@ var ts; var type = getContextualType(binaryExpression, contextFlags); return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ? getTypeOfExpression(left) : type; - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: case 27 /* CommaToken */: return node === right ? getContextualType(binaryExpression, contextFlags) : undefined; default: @@ -49472,7 +52266,7 @@ var ts; if (!decl) { return false; } - var lhs = binaryExpression.left; + var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression); var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl); if (overallAnnotation) { return getTypeFromTypeNode(overallAnnotation); @@ -49483,8 +52277,11 @@ var ts; if (parentSymbol) { var annotated = ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration); if (annotated) { - var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), lhs.name.escapedText); - return type || false; + var nameStr_1 = ts.getElementOrPropertyAccessName(lhs); + if (nameStr_1 !== undefined) { + var type = getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr_1); + return type || false; + } } return false; } @@ -49506,12 +52303,13 @@ var ts; } if (kind === 2 /* ModuleExports */) return false; - var thisAccess = binaryExpression.left; + var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression); if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, /*includeArrowFunctions*/ false))) { return false; } var thisType = checkThisExpression(thisAccess.expression); - return thisType && getTypeOfPropertyOfContextualType(thisType, thisAccess.name.escapedText) || false; + var nameStr = ts.getElementOrPropertyAccessName(thisAccess); + return nameStr !== undefined && thisType && getTypeOfPropertyOfContextualType(thisType, nameStr) || false; case 7 /* ObjectDefinePropertyValue */: case 8 /* ObjectDefinePropertyExports */: case 9 /* ObjectDefinePrototypeProperty */: @@ -49555,7 +52353,7 @@ var ts; // exists. Otherwise, it is the type of the string index signature in T, if one exists. function getContextualTypeForObjectLiteralMethod(node, contextFlags) { ts.Debug.assert(ts.isObjectLiteralMethod(node)); - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49644,25 +52442,25 @@ var ts; case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 14 /* NoSubstitutionTemplateLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 73 /* Identifier */: - case 142 /* UndefinedKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 75 /* Identifier */: + case 145 /* UndefinedKeyword */: return true; - case 190 /* PropertyAccessExpression */: - case 196 /* ParenthesizedExpression */: + case 193 /* PropertyAccessExpression */: + case 199 /* ParenthesizedExpression */: return isPossiblyDiscriminantValue(node.expression); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return !node.expression || isPossiblyDiscriminantValue(node.expression); } return false; } function discriminateContextualTypeByObjectMembers(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 276 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 279 /* PropertyAssignment */ && isPossiblyDiscriminantValue(p.initializer) && isDiscriminantProperty(contextualType, p.symbol.escapedName); }), function (prop) { return [function () { return checkExpression(prop.initializer); }, prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } function discriminateContextualTypeByJSXAttributes(node, contextualType) { - return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 268 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); + return discriminateTypeByDiscriminableItems(contextualType, ts.map(ts.filter(node.properties, function (p) { return !!p.symbol && p.kind === 271 /* JsxAttribute */ && isDiscriminantProperty(contextualType, p.symbol.escapedName) && (!p.initializer || isPossiblyDiscriminantValue(p.initializer)); }), function (prop) { return [!prop.initializer ? (function () { return trueType; }) : (function () { return checkExpression(prop.initializer); }), prop.symbol.escapedName]; }), isTypeAssignableTo, contextualType); } // Return the contextual type for a given expression node. During overload resolution, a contextual type may temporarily // be "pushed" onto a node using the contextualType property. @@ -49671,7 +52469,7 @@ var ts; getContextualTypeForObjectLiteralMethod(node, contextFlags) : getContextualType(node, contextFlags); var instantiatedType = instantiateContextualType(contextualType, node, contextFlags); - if (instantiatedType) { + if (instantiatedType && !(contextFlags && contextFlags & 2 /* NoConstraints */ && instantiatedType.flags & 8650752 /* TypeVariable */)) { var apparentType = mapType(instantiatedType, getApparentType, /*noReductions*/ true); if (apparentType.flags & 1048576 /* Union */) { if (ts.isObjectLiteralExpression(node)) { @@ -49739,7 +52537,7 @@ var ts; * @returns the contextual type of an expression. */ function getContextualType(node, contextFlags) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -49748,58 +52546,58 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 187 /* BindingElement */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 190 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 198 /* ArrowFunction */: - case 231 /* ReturnStatement */: + case 201 /* ArrowFunction */: + case 234 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return getContextualTypeForAwaitOperand(parent); - case 192 /* CallExpression */: - if (parent.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (parent.expression.kind === 95 /* ImportKeyword */) { return stringType; } /* falls through */ - case 193 /* NewExpression */: - return getContextualTypeForArgument(parent, node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 196 /* NewExpression */: + return getContextualTypeForArgument(parent, node, contextFlags); + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return ts.isConstTypeReference(parent.type) ? undefined : getTypeFromTypeNode(parent.type); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node, contextFlags); - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent, contextFlags); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent, contextFlags); - case 188 /* ArrayLiteralExpression */: { + case 191 /* ArrayLiteralExpression */: { var arrayLiteral = parent; var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags); return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); } - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node, contextFlags); - case 217 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 207 /* TemplateExpression */); + case 220 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 210 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 196 /* ParenthesizedExpression */: { + case 199 /* ParenthesizedExpression */: { // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags); } - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); - case 268 /* JsxAttribute */: - case 270 /* JsxSpreadAttribute */: + case 271 /* JsxAttribute */: + case 273 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return getContextualJsxElementAttributesType(parent); } return undefined; @@ -49954,7 +52752,7 @@ var ts; return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 197 /* FunctionExpression */ || node.kind === 198 /* ArrowFunction */; + return node.kind === 200 /* FunctionExpression */ || node.kind === 201 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -49968,7 +52766,7 @@ var ts; // all identical ignoring their return type, the result is same signature but with return type as // union type of return types from these signatures function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var typeTagSignature = getSignatureOfTypeTag(node); if (typeTagSignature) { return typeTagSignature; @@ -49982,8 +52780,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -50013,8 +52811,8 @@ var ts; return checkIteratedTypeOrElementType(33 /* Spread */, arrayOrIterableType, undefinedType, node.expression); } function hasDefaultValue(node) { - return (node.kind === 187 /* BindingElement */ && !!node.initializer) || - (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 60 /* EqualsToken */); + return (node.kind === 190 /* BindingElement */ && !!node.initializer) || + (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 62 /* EqualsToken */); } function checkArrayLiteral(node, checkMode, forceTuple) { var elements = node.elements; @@ -50026,7 +52824,7 @@ var ts; var inConstContext = isConstContext(node); for (var index = 0; index < elementCount; index++) { var e = elements[index]; - if (inDestructuringPattern && e.kind === 209 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 212 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -50051,12 +52849,12 @@ var ts; var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple); elementTypes.push(type); } - if (index < elementCount - 1 && e.kind === 209 /* SpreadElement */) { + if (index < elementCount - 1 && e.kind === 212 /* SpreadElement */) { hasNonEndingSpreadElement = true; } } if (!hasNonEndingSpreadElement) { - var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 209 /* SpreadElement */; + var hasRestElement = elementCount > 0 && elements[elementCount - 1].kind === 212 /* SpreadElement */; var minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". @@ -50098,9 +52896,9 @@ var ts; } function isNumericName(name) { switch (name.kind) { - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return isNumericComputedName(name); - case 73 /* Identifier */: + case 75 /* Identifier */: return isNumericLiteralName(name.escapedText); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: @@ -50188,7 +52986,7 @@ var ts; var spread = emptyObjectType; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 185 /* ObjectBindingPattern */ || contextualType.pattern.kind === 189 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 188 /* ObjectBindingPattern */ || contextualType.pattern.kind === 192 /* ObjectLiteralExpression */); var inConstContext = isConstContext(node); var checkFlags = inConstContext ? 8 /* Readonly */ : 0; var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node); @@ -50203,13 +53001,13 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = getSymbolOfNode(memberDecl); - var computedNameType = memberDecl.name && memberDecl.name.kind === 150 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? + var computedNameType = memberDecl.name && memberDecl.name.kind === 153 /* ComputedPropertyName */ && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ? checkComputedPropertyName(memberDecl.name) : undefined; - if (memberDecl.kind === 276 /* PropertyAssignment */ || - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 279 /* PropertyAssignment */ || + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { - var type = memberDecl.kind === 276 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : - memberDecl.kind === 277 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : + var type = memberDecl.kind === 279 /* PropertyAssignment */ ? checkPropertyAssignment(memberDecl, checkMode) : + memberDecl.kind === 280 /* ShorthandPropertyAssignment */ ? checkExpressionForMutableLocation(memberDecl.name, checkMode) : checkObjectLiteralMethod(memberDecl, checkMode); if (isInJavascript) { var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl); @@ -50232,8 +53030,8 @@ var ts; if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - var isOptional = (memberDecl.kind === 276 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 277 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 279 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 280 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216 /* Optional */; } @@ -50258,7 +53056,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 278 /* SpreadAssignment */) { + else if (memberDecl.kind === 281 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -50284,7 +53082,7 @@ var ts; // an ordinary function declaration(section 6.1) with no parameters. // A set accessor declaration is processed in the same manner // as an ordinary function declaration with a single parameter and a Void return type. - ts.Debug.assert(memberDecl.kind === 159 /* GetAccessor */ || memberDecl.kind === 160 /* SetAccessor */); + ts.Debug.assert(memberDecl.kind === 162 /* GetAccessor */ || memberDecl.kind === 163 /* SetAccessor */); checkNodeDeferred(memberDecl); } if (computedNameType && !(computedNameType.flags & 8576 /* StringOrNumberLiteralOrUnique */)) { @@ -50344,7 +53142,13 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (3 /* AnyOrUnknown */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || + if (type.flags & 63176704 /* Instantiable */) { + var constraint = getBaseConstraintOfType(type); + if (constraint !== undefined) { + return isValidSpreadType(constraint); + } + } + return !!(type.flags & (1 /* Any */ | 67108864 /* NonPrimitive */ | 524288 /* Object */ | 58982400 /* InstantiableNonPrimitive */) || getFalsyFlags(type) & 117632 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 3145728 /* UnionOrIntersection */ && ts.every(type.types, isValidSpreadType)); } @@ -50392,7 +53196,7 @@ var ts; * Returns true iff React would emit this tag name as a string rather than an identifier or qualified name */ function isJsxIntrinsicIdentifier(tagName) { - return tagName.kind === 73 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); + return tagName.kind === 75 /* Identifier */ && ts.isIntrinsicJsxName(tagName.escapedText); } function checkJsxAttribute(node, checkMode) { return node.initializer @@ -50437,7 +53241,7 @@ var ts; } } else { - ts.Debug.assert(attributeDecl.kind === 270 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 273 /* JsxSpreadAttribute */); if (attributesTable.size > 0) { spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = ts.createSymbolTable(); @@ -50460,7 +53264,7 @@ var ts; } } // Handle children attribute - var parent = openingLikeElement.parent.kind === 261 /* JsxElement */ ? openingLikeElement.parent : undefined; + var parent = openingLikeElement.parent.kind === 264 /* JsxElement */ ? openingLikeElement.parent : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { var childrenTypes = checkJsxChildren(parent, checkMode); @@ -50879,7 +53683,7 @@ var ts; */ function checkPropertyAccessibility(node, isSuper, type, prop) { var flags = ts.getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 149 /* QualifiedName */ ? node.right : node.kind === 184 /* ImportType */ ? node : node.name; + var errorNode = node.kind === 152 /* QualifiedName */ ? node.right : node.kind === 187 /* ImportType */ ? node : node.name; if (ts.getCheckFlags(prop) & 1024 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); @@ -50974,32 +53778,43 @@ var ts; function symbolHasNonMethodDeclaration(symbol) { return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192 /* Method */); }); } - function checkNonNullExpression(node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { - return checkNonNullType(checkExpression(node), node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic); + function checkNonNullExpression(node) { + return checkNonNullType(checkExpression(node), node); + } + function isNullableType(type) { + return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */); } function getNonNullableTypeIfNeeded(type) { - var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; - if (kind) { - return getNonNullableType(type); - } - return type; + return isNullableType(type) ? getNonNullableType(type) : type; + } + function reportObjectPossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Object_is_possibly_null_or_undefined : + ts.Diagnostics.Object_is_possibly_undefined : + ts.Diagnostics.Object_is_possibly_null); } - function checkNonNullType(type, node, nullDiagnostic, undefinedDiagnostic, nullOrUndefinedDiagnostic) { + function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) { + error(node, flags & 32768 /* Undefined */ ? flags & 65536 /* Null */ ? + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined : + ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null); + } + function checkNonNullTypeWithReporter(type, node, reportError) { if (strictNullChecks && type.flags & 2 /* Unknown */) { error(node, ts.Diagnostics.Object_is_of_type_unknown); return errorType; } var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304 /* Nullable */; if (kind) { - error(node, kind & 32768 /* Undefined */ ? kind & 65536 /* Null */ ? - (nullOrUndefinedDiagnostic || ts.Diagnostics.Object_is_possibly_null_or_undefined) : - (undefinedDiagnostic || ts.Diagnostics.Object_is_possibly_undefined) : - (nullDiagnostic || ts.Diagnostics.Object_is_possibly_null)); + reportError(node, kind); var t = getNonNullableType(type); return t.flags & (98304 /* Nullable */ | 131072 /* Never */) ? errorType : t; } return type; } + function checkNonNullType(type, node) { + return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError); + } function checkNonNullNonVoidType(type, node) { var nonNullType = checkNonNullType(type, node); if (nonNullType !== errorType && nonNullType.flags & 16384 /* Void */) { @@ -51008,20 +53823,24 @@ var ts; return nonNullType; } function checkPropertyAccessExpression(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.expression, node.name); + return node.flags & 32 /* OptionalChain */ ? checkPropertyAccessChain(node) : + checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name); + } + function checkPropertyAccessChain(node) { + var leftType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(leftType, node.expression); + return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType); } function checkQualifiedName(node) { - return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); + return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right); } function isMethodAccessForCall(node) { - while (node.parent.kind === 196 /* ParenthesizedExpression */) { + while (node.parent.kind === 199 /* ParenthesizedExpression */) { node = node.parent; } return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node; } - function checkPropertyAccessExpressionOrQualifiedName(node, left, right) { - var propType; - var leftType = checkNonNullExpression(left); + function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) { var parentSymbol = getNodeLinks(left).resolvedSymbol; var assignmentKind = ts.getAssignmentTargetKind(node); var apparentType = getApparentType(assignmentKind !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType); @@ -51035,6 +53854,7 @@ var ts; if (ts.isIdentifier(left) && parentSymbol && !(prop && isConstEnumOrConstEnumOnlyModule(prop))) { markAliasReferenced(parentSymbol, node); } + var propType; if (!prop) { var indexInfo = assignmentKind === 0 /* None */ || !isGenericObjectType(leftType) || isThisTypeParameter(leftType) ? getIndexInfoOfType(apparentType, 0 /* String */) : undefined; if (!(indexInfo && indexInfo.type)) { @@ -51062,9 +53882,9 @@ var ts; } else { checkPropertyNotUsedBeforeDeclaration(prop, node, right); - markPropertyAsReferenced(prop, node, left.kind === 101 /* ThisKeyword */); + markPropertyAsReferenced(prop, node, left.kind === 103 /* ThisKeyword */); getNodeLinks(node).resolvedSymbol = prop; - checkPropertyAccessibility(node, left.kind === 99 /* SuperKeyword */, apparentType, prop); + checkPropertyAccessibility(node, left.kind === 101 /* SuperKeyword */, apparentType, prop); if (assignmentKind) { if (isReferenceToReadonlyEntity(node, prop) || isReferenceThroughNamespaceImport(node)) { error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right)); @@ -51080,7 +53900,7 @@ var ts; // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. var assignmentKind = ts.getAssignmentTargetKind(node); - if (node.kind !== 191 /* ElementAccessExpression */ && node.kind !== 190 /* PropertyAccessExpression */ || + if (node.kind !== 194 /* ElementAccessExpression */ && node.kind !== 193 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || prop && !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 1048576 /* Union */)) { return propType; @@ -51090,11 +53910,11 @@ var ts; // and if we are in a constructor of the same class as the property declaration, assume that // the property is uninitialized at the top of the control flow. var assumeUninitialized = false; - if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 101 /* ThisKeyword */) { + if (strictNullChecks && strictPropertyInitialization && node.expression.kind === 103 /* ThisKeyword */) { var declaration = prop && prop.valueDeclaration; if (declaration && isInstancePropertyWithoutInitializer(declaration)) { var flowContainer = getControlFlowContainer(node); - if (flowContainer.kind === 158 /* Constructor */ && flowContainer.parent === declaration.parent) { + if (flowContainer.kind === 161 /* Constructor */ && flowContainer.parent === declaration.parent) { assumeUninitialized = true; } } @@ -51125,9 +53945,9 @@ var ts; && !isPropertyDeclaredInAncestorClass(prop)) { diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } - else if (valueDeclaration.kind === 241 /* ClassDeclaration */ && - node.parent.kind !== 165 /* TypeReference */ && - !(valueDeclaration.flags & 4194304 /* Ambient */) && + else if (valueDeclaration.kind === 244 /* ClassDeclaration */ && + node.parent.kind !== 168 /* TypeReference */ && + !(valueDeclaration.flags & 8388608 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName); } @@ -51138,22 +53958,22 @@ var ts; function isInPropertyInitializer(node) { return !!ts.findAncestor(node, function (node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return true; - case 276 /* PropertyAssignment */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 278 /* SpreadAssignment */: - case 150 /* ComputedPropertyName */: - case 217 /* TemplateSpan */: - case 271 /* JsxExpression */: - case 268 /* JsxAttribute */: - case 269 /* JsxAttributes */: - case 270 /* JsxSpreadAttribute */: - case 263 /* JsxOpeningElement */: - case 212 /* ExpressionWithTypeArguments */: - case 274 /* HeritageClause */: + case 279 /* PropertyAssignment */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 281 /* SpreadAssignment */: + case 153 /* ComputedPropertyName */: + case 220 /* TemplateSpan */: + case 274 /* JsxExpression */: + case 271 /* JsxAttribute */: + case 272 /* JsxAttributes */: + case 273 /* JsxSpreadAttribute */: + case 266 /* JsxOpeningElement */: + case 215 /* ExpressionWithTypeArguments */: + case 277 /* HeritageClause */: return false; default: return ts.isExpressionNode(node) ? false : "quit"; @@ -51193,7 +54013,7 @@ var ts; if (containingType.flags & 1048576 /* Union */ && !(containingType.flags & 131068 /* Primitive */)) { for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) { var subtype = _a[_i]; - if (!getPropertyOfType(subtype, propNode.escapedText)) { + if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0 /* String */)) { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype)); break; } @@ -51326,16 +54146,16 @@ var ts; } function isValidPropertyAccess(node, propertyName) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: - return isValidPropertyAccessWithType(node, node.expression.kind === 99 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); - case 149 /* QualifiedName */: + case 193 /* PropertyAccessExpression */: + return isValidPropertyAccessWithType(node, node.expression.kind === 101 /* SuperKeyword */, propertyName, getWidenedType(checkExpression(node.expression))); + case 152 /* QualifiedName */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getWidenedType(checkExpression(node.left))); - case 184 /* ImportType */: + case 187 /* ImportType */: return isValidPropertyAccessWithType(node, /*isSuper*/ false, propertyName, getTypeFromTypeNode(node)); } } function isValidPropertyAccessForCompletions(node, type, property) { - return isValidPropertyAccessWithType(node, node.kind === 190 /* PropertyAccessExpression */ && node.expression.kind === 99 /* SuperKeyword */, property.escapedName, type); + return isValidPropertyAccessWithType(node, node.kind === 193 /* PropertyAccessExpression */ && node.expression.kind === 101 /* SuperKeyword */, property.escapedName, type); // Previously we validated the 'this' type of methods but this adversely affected performance. See #31377 for more context. } function isValidPropertyAccessWithType(node, isSuper, propertyName, type) { @@ -51352,13 +54172,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer.kind === 242 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 73 /* Identifier */) { + else if (initializer.kind === 75 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -51375,13 +54195,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 73 /* Identifier */) { + if (e.kind === 75 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 227 /* ForInStatement */ && + if (node.kind === 230 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -51395,28 +54215,22 @@ var ts; return false; } function checkIndexedAccess(node) { - var exprType = checkNonNullExpression(node.expression); + return node.flags & 32 /* OptionalChain */ ? checkElementAccessChain(node) : + checkElementAccessExpression(node, checkNonNullExpression(node.expression)); + } + function checkElementAccessChain(node) { + var exprType = checkExpression(node.expression); + var nonOptionalType = getOptionalExpressionType(exprType, node.expression); + return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType); + } + function checkElementAccessExpression(node, exprType) { var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType; var indexExpression = node.argumentExpression; - if (!indexExpression) { - var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 193 /* NewExpression */ && node.parent.expression === node) { - var start = ts.skipTrivia(sourceFile.text, node.expression.end); - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); - } - else { - var start = node.end - "]".length; - var end = node.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Expression_expected); - } - return errorType; - } var indexType = checkExpression(indexExpression); if (objectType === errorType || objectType === silentNeverType) { return objectType; } - if (isConstEnumObjectType(objectType) && indexExpression.kind !== 10 /* StringLiteral */) { + if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) { error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal); return errorType; } @@ -51471,13 +54285,13 @@ var ts; // This gets us diagnostics for the type arguments and marks them as referenced. ts.forEach(node.typeArguments, checkSourceElement); } - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { checkExpression(node.template); } else if (ts.isJsxOpeningLikeElement(node)) { checkExpression(node.attributes); } - else if (node.kind !== 153 /* Decorator */) { + else if (node.kind !== 156 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -51496,7 +54310,7 @@ var ts; // interface B extends A { (x: 'foo'): string } // const b: B; // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] - function reorderCandidates(signatures, result) { + function reorderCandidates(signatures, result, isOptionalCall) { var lastParent; var lastSymbol; var cutoffIndex = 0; @@ -51504,8 +54318,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { - var signature = signatures_3[_i]; + for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) { + var signature = signatures_6[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -51526,7 +54340,7 @@ var ts; lastSymbol = symbol; // specialized signatures always need to be placed before non-specialized signatures regardless // of the cutoff position; see GH#1133 - if (signature.hasLiteralTypes) { + if (signatureHasLiteralTypes(signature)) { specializedIndex++; spliceIndex = specializedIndex; // The cutoff index always needs to be greater than or equal to the specialized signature index @@ -51537,11 +54351,11 @@ var ts; else { spliceIndex = index; } - result.splice(spliceIndex, 0, signature); + result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature); } } function isSpreadArgument(arg) { - return !!arg && (arg.kind === 209 /* SpreadElement */ || arg.kind === 216 /* SyntheticExpression */ && arg.isSpread); + return !!arg && (arg.kind === 212 /* SpreadElement */ || arg.kind === 219 /* SyntheticExpression */ && arg.isSpread); } function getSpreadArgumentIndex(args) { return ts.findIndex(args, isSpreadArgument); @@ -51555,9 +54369,9 @@ var ts; var callIsIncomplete = false; // In incomplete call we want to be lenient when we have too few arguments var effectiveParameterCount = getParameterCount(signature); var effectiveMinimumArguments = getMinArgumentCount(signature); - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { argCount = args.length; - if (node.template.kind === 207 /* TemplateExpression */) { + if (node.template.kind === 210 /* TemplateExpression */) { // If a tagged template expression lacks a tail literal, the call is incomplete. // Specifically, a template only can end in a TemplateTail or a Missing literal. var lastSpan = ts.last(node.template.templateSpans); // we should always have at least one span. @@ -51572,7 +54386,7 @@ var ts; callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 153 /* Decorator */) { + else if (node.kind === 156 /* Decorator */) { argCount = getDecoratorArgumentCount(node, signature); } else if (ts.isJsxOpeningLikeElement(node)) { @@ -51587,7 +54401,7 @@ var ts; else { if (!node.arguments) { // This only happens when we have something of the form: 'new C' - ts.Debug.assert(node.kind === 193 /* NewExpression */); + ts.Debug.assert(node.kind === 196 /* NewExpression */); return getMinArgumentCount(signature) === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -51680,7 +54494,7 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (node.kind !== 153 /* Decorator */) { + if (node.kind !== 156 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the inference context to avoid disturbing a resolution in progress for an @@ -51710,7 +54524,7 @@ var ts; var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags); var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper); inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType); - context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined; + context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined; } } var thisType = getThisTypeOfSignature(signature); @@ -51723,7 +54537,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode); inferTypes(context.inferences, argType, paramType); @@ -51747,7 +54561,7 @@ var ts; if (isSpreadArgument(arg)) { // We are inferring from a spread expression in the last argument position, i.e. both the parameter // and the argument are ...x forms. - return arg.kind === 216 /* SyntheticExpression */ ? + return arg.kind === 219 /* SyntheticExpression */ ? createArrayType(arg.type) : getArrayifiedType(checkExpressionWithContextualType(arg.expression, restType, context, 0 /* Normal */)); } @@ -51827,12 +54641,24 @@ var ts; return undefined; } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 193 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 196 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. var thisArgumentNode = getThisArgumentOfCall(node); - var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; + var thisArgumentType = void 0; + if (thisArgumentNode) { + thisArgumentType = checkExpression(thisArgumentNode); + if (ts.isOptionalChainRoot(thisArgumentNode.parent)) { + thisArgumentType = getNonNullableType(thisArgumentType); + } + else if (ts.isOptionalChain(thisArgumentNode.parent)) { + thisArgumentType = removeOptionalTypeMarker(thisArgumentType); + } + } + else { + thisArgumentType = voidType; + } var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1; if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) { @@ -51845,7 +54671,7 @@ var ts; var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length; for (var i = 0; i < argCount; i++) { var arg = args[i]; - if (arg.kind !== 211 /* OmittedExpression */) { + if (arg.kind !== 214 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = checkExpressionWithContextualType(arg, paramType, /*inferenceContext*/ undefined, checkMode); // If one or more arguments are still excluded (as indicated by CheckMode.SkipContextSensitive), @@ -51886,15 +54712,15 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 192 /* CallExpression */) { + if (node.kind === 195 /* CallExpression */) { var callee = ts.skipOuterExpressions(node.expression); - if (callee.kind === 190 /* PropertyAccessExpression */ || callee.kind === 191 /* ElementAccessExpression */) { + if (callee.kind === 193 /* PropertyAccessExpression */ || callee.kind === 194 /* ElementAccessExpression */) { return callee.expression; } } } function createSyntheticExpression(parent, type, isSpread) { - var result = ts.createNode(216 /* SyntheticExpression */, parent.pos, parent.end); + var result = ts.createNode(219 /* SyntheticExpression */, parent.pos, parent.end); result.parent = parent; result.type = type; result.isSpread = isSpread || false; @@ -51904,17 +54730,17 @@ var ts; * Returns the effective arguments for an expression that works like a function invocation. */ function getEffectiveCallArguments(node) { - if (node.kind === 194 /* TaggedTemplateExpression */) { + if (node.kind === 197 /* TaggedTemplateExpression */) { var template = node.template; var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())]; - if (template.kind === 207 /* TemplateExpression */) { + if (template.kind === 210 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args_3.push(span.expression); }); } return args_3; } - if (node.kind === 153 /* Decorator */) { + if (node.kind === 156 /* Decorator */) { return getEffectiveDecoratorArguments(node); } if (ts.isJsxOpeningLikeElement(node)) { @@ -51929,7 +54755,7 @@ var ts; var spreadArgument_1 = args[length - 1]; var type = flowLoopCount ? checkExpression(spreadArgument_1.expression) : checkExpressionCached(spreadArgument_1.expression); if (isTupleType(type)) { - var typeArguments = type.typeArguments || ts.emptyArray; + var typeArguments = getTypeArguments(type); var restIndex_2 = type.target.hasRestElement ? typeArguments.length - 1 : -1; var syntheticArgs = ts.map(typeArguments, function (t, i) { return createSyntheticExpression(spreadArgument_1, t, /*isSpread*/ i === restIndex_2); }); return ts.concatenate(args.slice(0, length - 1), syntheticArgs); @@ -51944,30 +54770,30 @@ var ts; var parent = node.parent; var expr = node.expression; switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: // For a class decorator, the `target` is the type of the class (e.g. the // "static" or "constructor" side of the class). return [ createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent))) ]; - case 152 /* Parameter */: + case 155 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts). var func = parent.parent; return [ - createSyntheticExpression(expr, parent.parent.kind === 158 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), + createSyntheticExpression(expr, parent.parent.kind === 161 /* Constructor */ ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType), createSyntheticExpression(expr, anyType), createSyntheticExpression(expr, numberType) ]; - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // A method or accessor declaration decorator will have two or three arguments (see // `PropertyDecorator` and `MethodDecorator` in core.d.ts). If we are emitting decorators // for ES3, we will only pass two arguments. - var hasPropDesc = parent.kind !== 155 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; + var hasPropDesc = parent.kind !== 158 /* PropertyDeclaration */ && languageVersion !== 0 /* ES3 */; return [ createSyntheticExpression(expr, getParentTypeOfClassElement(parent)), createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)), @@ -51981,17 +54807,17 @@ var ts; */ function getDecoratorArgumentCount(node, signature) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return 1; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return 2; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // For ES3 or decorators with only two parameters we supply only two arguments return languageVersion === 0 /* ES3 */ || signature.parameters.length <= 2 ? 2 : 3; - case 152 /* Parameter */: + case 155 /* Parameter */: return 3; default: return ts.Debug.fail(); @@ -52029,8 +54855,8 @@ var ts; var aboveArgCount = Number.POSITIVE_INFINITY; var argCount = args.length; var closestSignature; - for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) { - var sig = signatures_4[_i]; + for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { + var sig = signatures_7[_i]; var minCount = getMinArgumentCount(sig); var maxCount = getParameterCount(sig); if (minCount < argCount && minCount > belowArgCount) @@ -52059,7 +54885,7 @@ var ts; if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) { var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount]; if (paramDecl) { - related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(getFirstIdentifier(paramDecl.name)) : undefined); + related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided : ts.Diagnostics.An_argument_for_0_was_not_provided, !paramDecl.name ? argCount : !ts.isBindingPattern(paramDecl.name) ? ts.idText(ts.getFirstIdentifier(paramDecl.name)) : undefined); } } if (min < argCount && argCount < max) { @@ -52099,8 +54925,8 @@ var ts; // Overloads exist var belowArgCount = -Infinity; var aboveArgCount = Infinity; - for (var _i = 0, signatures_5 = signatures; _i < signatures_5.length; _i++) { - var sig = signatures_5[_i]; + for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) { + var sig = signatures_8[_i]; var min_2 = getMinTypeArgumentCount(sig.typeParameters); var max = ts.length(sig.typeParameters); if (min_2 > argCount) { @@ -52115,22 +54941,22 @@ var ts; } return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount); } - function resolveCall(node, signatures, candidatesOutArray, checkMode, fallbackError) { - var isTaggedTemplate = node.kind === 194 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 153 /* Decorator */; + function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) { + var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 156 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var reportErrors = !candidatesOutArray; var typeArguments; if (!isDecorator) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 99 /* SuperKeyword */) { + if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 101 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly - reorderCandidates(signatures, candidates); + reorderCandidates(signatures, candidates, isOptionalCall); if (!candidates.length) { if (reportErrors) { diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures)); @@ -52179,7 +55005,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 192 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = !!(checkMode & 16 /* IsForSignatureHelp */) && node.kind === 195 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -52232,7 +55058,7 @@ var ts; var min_3 = Number.MAX_VALUE; var minIndex = 0; var i_1 = 0; - var _loop_12 = function (c) { + var _loop_14 = function (c) { var chain_2 = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Overload_0_of_1_2_gave_the_following_error, i_1 + 1, candidates.length, signatureToString(c)); }; var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0 /* Normal */, /*reportErrors*/ true, chain_2); if (diags_2) { @@ -52250,7 +55076,7 @@ var ts; }; for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) { var c = candidatesForArgumentError_1[_a]; - _loop_12(c); + _loop_14(c); } var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics); ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures"); @@ -52384,35 +55210,35 @@ var ts; } var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max; var parameters = []; - var _loop_13 = function (i) { - var symbols = ts.mapDefined(candidates, function (_a) { - var parameters = _a.parameters, hasRestParameter = _a.hasRestParameter; - return hasRestParameter ? - i < parameters.length - 1 ? parameters[i] : ts.last(parameters) : - i < parameters.length ? parameters[i] : undefined; - }); + var _loop_15 = function (i) { + var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ? + i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) : + i < s.parameters.length ? s.parameters[i] : undefined; }); ts.Debug.assert(symbols.length !== 0); parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); }))); }; for (var i = 0; i < maxNonRestParam; i++) { - _loop_13(i); + _loop_15(i); } - var restParameterSymbols = ts.mapDefined(candidates, function (c) { return c.hasRestParameter ? ts.last(c.parameters) : undefined; }); - var hasRestParameter = restParameterSymbols.length !== 0; - if (hasRestParameter) { + var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; }); + var flags = 0 /* None */; + if (restParameterSymbols.length !== 0) { var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2 /* Subtype */)); parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type)); + flags |= 1 /* HasRestParameter */; + } + if (candidates.some(signatureHasLiteralTypes)) { + flags |= 2 /* HasLiteralTypes */; } return createSignature(candidates[0].declaration, /*typeParameters*/ undefined, // Before calling this we tested for `!candidates.some(c => !!c.typeParameters)`. thisParameter, parameters, /*resolvedReturnType*/ getIntersectionType(candidates.map(getReturnTypeOfSignature)), - /*typePredicate*/ undefined, minArgumentCount, hasRestParameter, - /*hasLiteralTypes*/ candidates.some(function (c) { return c.hasLiteralTypes; })); + /*typePredicate*/ undefined, minArgumentCount, flags); } function getNumNonRestParameters(signature) { var numParams = signature.parameters.length; - return signature.hasRestParameter ? numParams - 1 : numParams; + return signatureHasRestParameter(signature) ? numParams - 1 : numParams; } function createCombinedSymbolFromTypes(sources, types) { return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2 /* Subtype */)); @@ -52473,7 +55299,7 @@ var ts; return maxParamsIndex; } function resolveCallExpression(node, candidatesOutArray, checkMode) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (isTypeAny(superType)) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { @@ -52488,12 +55314,22 @@ var ts; var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node)); if (baseTypeNode) { var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); - return resolveCall(node, baseConstructors, candidatesOutArray, checkMode); + return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false); } } return resolveUntypedCall(node); } - var funcType = checkNonNullExpression(node.expression, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined, ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined); + var isOptional; + var funcType = checkExpression(node.expression); + if (ts.isCallChain(node)) { + var nonOptionalType = getOptionalExpressionType(funcType, node.expression); + isOptional = nonOptionalType !== funcType; + funcType = nonOptionalType; + } + else { + isOptional = false; + } + funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError); if (funcType === silentNeverType) { return silentNeverSignature; } @@ -52559,7 +55395,7 @@ var ts; error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional); } function isGenericFunctionReturningFunction(signature) { return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature))); @@ -52622,7 +55458,7 @@ var ts; error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class); return resolveErrorCall(node); } - return resolveCall(node, constructSignatures, candidatesOutArray, checkMode); + return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } // If expressionType's apparent type is an object type with no construct signatures but // one or more call signatures, the expression is processed as a function call. A compile-time @@ -52630,7 +55466,7 @@ var ts; // operation is Any. It is an error to have a Void this type. var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */); if (callSignatures.length) { - var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode); + var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); if (!noImplicitAny) { if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) { error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword); @@ -52715,8 +55551,8 @@ var ts; if (apparentType.flags & 1048576 /* Union */) { var types = apparentType.types; var hasSignatures = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var constituent = types_14[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var constituent = types_17[_i]; var signatures = getSignaturesOfType(constituent, kind); if (signatures.length !== 0) { hasSignatures = true; @@ -52807,23 +55643,23 @@ var ts; invocationError(node.tag, apparentType, 0 /* Call */); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; default: return ts.Debug.fail(); @@ -52860,7 +55696,7 @@ var ts; invocationErrorRecovery(apparentType, 0 /* Call */, diag); return resolveErrorCall(node); } - return resolveCall(node, callSignatures, candidatesOutArray, checkMode, headMessage); + return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage); } function createSignatureForJSXIntrinsic(node, result) { var namespace = getJsxNamespaceAt(node); @@ -52869,15 +55705,13 @@ var ts; // file would probably be preferable. var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968 /* Type */); var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968 /* Type */, node); - var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(121 /* AnyKeyword */)); + var declaration = ts.createFunctionTypeNode(/*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? ts.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : ts.createKeywordTypeNode(124 /* AnyKeyword */)); var parameterSymbol = createSymbol(1 /* FunctionScopedVariable */, "props"); parameterSymbol.type = result; return createSignature(declaration, /*typeParameters*/ undefined, /*thisParameter*/ undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, - /*returnTypePredicate*/ undefined, 1, - /*hasRestparameter*/ false, - /*hasLiteralTypes*/ false); + /*returnTypePredicate*/ undefined, 1, 0 /* None */); } function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) { if (isJsxIntrinsicIdentifier(node.tagName)) { @@ -52900,7 +55734,7 @@ var ts; error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName)); return resolveErrorCall(node); } - return resolveCall(node, signatures, candidatesOutArray, checkMode); + return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false); } /** * Sometimes, we have a decorator that could accept zero arguments, @@ -52910,22 +55744,22 @@ var ts; function isPotentiallyUncalledDecorator(decorator, signatures) { return signatures.length && ts.every(signatures, function (signature) { return signature.minArgumentCount === 0 && - !signature.hasRestParameter && + !signatureHasRestParameter(signature) && signature.parameters.length < getDecoratorArgumentCount(decorator, signature); }); } function resolveSignature(node, candidatesOutArray, checkMode) { switch (node.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray, checkMode); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode); - case 153 /* Decorator */: + case 156 /* Decorator */: return resolveDecorator(node, candidatesOutArray, checkMode); - case 263 /* JsxOpeningElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode); } throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); @@ -52976,57 +55810,52 @@ var ts; return true; // If the symbol of the node has members, treat it like a constructor. var symbol = getSymbolOfNode(func); - return !!symbol && (symbol.members !== undefined || symbol.exports !== undefined && symbol.exports.get("prototype") !== undefined); - } - return false; - } - function isJSConstructorType(type) { - if (type.flags & 524288 /* Object */) { - var resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length === 1 && isJSConstructor(resolved.callSignatures[0].declaration); + return !!symbol && ts.hasEntries(symbol.members); } return false; } - function getJSClassType(symbol) { - var inferred; - if (isJSConstructor(symbol.valueDeclaration)) { - inferred = getInferredClassType(symbol); + function mergeJSSymbols(target, source) { + if (source && (ts.hasEntries(source.exports) || ts.hasEntries(source.members))) { + var links = getSymbolLinks(source); + if (!links.inferredClassSymbol || !links.inferredClassSymbol.has("" + getSymbolId(target))) { + var inferred = isTransientSymbol(target) ? target : cloneSymbol(target); + inferred.exports = inferred.exports || ts.createSymbolTable(); + inferred.members = inferred.members || ts.createSymbolTable(); + inferred.flags |= source.flags & 32 /* Class */; + if (ts.hasEntries(source.exports)) { + mergeSymbolTable(inferred.exports, source.exports); + } + if (ts.hasEntries(source.members)) { + mergeSymbolTable(inferred.members, source.members); + } + (links.inferredClassSymbol || (links.inferredClassSymbol = ts.createMap())).set("" + getSymbolId(inferred), inferred); + return inferred; + } + return links.inferredClassSymbol.get("" + getSymbolId(target)); } - var assigned = getAssignedClassType(symbol); - return assigned && inferred ? - getIntersectionType([inferred, assigned]) : - assigned || inferred; } - function getAssignedClassType(symbol) { - var decl = symbol.valueDeclaration; + function getAssignedClassSymbol(decl) { var assignmentSymbol = decl && decl.parent && (ts.isFunctionDeclaration(decl) && getSymbolOfNode(decl) || ts.isBinaryExpression(decl.parent) && getSymbolOfNode(decl.parent.left) || ts.isVariableDeclaration(decl.parent) && getSymbolOfNode(decl.parent)); var prototype = assignmentSymbol && assignmentSymbol.exports && assignmentSymbol.exports.get("prototype"); var init = prototype && prototype.valueDeclaration && getAssignedJSPrototype(prototype.valueDeclaration); - return init ? getWidenedType(checkExpressionCached(init)) : undefined; + return init ? getSymbolOfNode(init) : undefined; } function getAssignedJSPrototype(node) { if (!node.parent) { return false; } var parent = node.parent; - while (parent && parent.kind === 190 /* PropertyAccessExpression */) { + while (parent && parent.kind === 193 /* PropertyAccessExpression */) { parent = parent.parent; } - if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 60 /* EqualsToken */) { + if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62 /* EqualsToken */) { var right = ts.getInitializerOfBinaryExpression(parent); return ts.isObjectLiteralExpression(right) && right; } } - function getInferredClassType(symbol) { - var links = getSymbolLinks(symbol); - if (!links.inferredClassType) { - links.inferredClassType = createAnonymousType(symbol, getMembersOfSymbol(symbol) || emptySymbols, ts.emptyArray, ts.emptyArray, /*stringIndexType*/ undefined, /*numberIndexType*/ undefined); - } - return links.inferredClassType; - } /** * Syntactically and semantically checks a call or new expression. * @param node The call/new expression to be checked. @@ -53041,15 +55870,15 @@ var ts; // returns a function type. We defer checking and return nonInferrableType. return nonInferrableType; } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return voidType; } - if (node.kind === 193 /* NewExpression */) { + if (node.kind === 196 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 158 /* Constructor */ && - declaration.kind !== 162 /* ConstructSignature */ && - declaration.kind !== 167 /* ConstructorType */ && + declaration.kind !== 161 /* Constructor */ && + declaration.kind !== 165 /* ConstructSignature */ && + declaration.kind !== 170 /* ConstructorType */ && !ts.isJSDocConstructSignature(declaration) && !isJSConstructor(declaration)) { // When resolved signature is a call signature (and not a construct signature) the result type is any @@ -53069,18 +55898,28 @@ var ts; if (returnType.flags & 12288 /* ESSymbolLike */ && isSymbolOrSymbolForCall(node)) { return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent)); } - var jsAssignmentType; + if (node.kind === 195 /* CallExpression */ && node.parent.kind === 225 /* ExpressionStatement */ && + returnType.flags & 16384 /* Void */ && getTypePredicateOfSignature(signature)) { + if (!ts.isDottedName(node.expression)) { + error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name); + } + else if (!getEffectsSignature(node)) { + var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation); + getTypeOfDottedName(node.expression, diagnostic); + } + } if (ts.isInJSFile(node)) { var decl = ts.getDeclarationOfExpando(node); if (decl) { var jsSymbol = getSymbolOfNode(decl); if (jsSymbol && ts.hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); + var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined); jsAssignmentType.objectFlags |= 16384 /* JSLiteral */; + return getIntersectionType([returnType, jsAssignmentType]); } } } - return jsAssignmentType ? getIntersectionType([returnType, jsAssignmentType]) : returnType; + return returnType; } function isSymbolOrSymbolForCall(node) { if (!ts.isCallExpression(node)) @@ -53118,7 +55957,7 @@ var ts; // resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal var moduleSymbol = resolveExternalModuleName(node, specifier); if (moduleSymbol) { - var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true); + var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false); if (esModuleSymbol) { return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol)); } @@ -53166,19 +56005,20 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 240 /* FunctionDeclaration */ + ? 243 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 238 /* VariableDeclaration */ + ? 241 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!decl && !!(decl.flags & 4194304 /* Ambient */); + return !!decl && !!(decl.flags & 8388608 /* Ambient */); } return false; } function checkTaggedTemplateExpression(node) { - checkGrammarTypeArguments(node, node.typeArguments); + if (!checkGrammarTaggedTemplateChain(node)) + checkGrammarTypeArguments(node, node.typeArguments); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 131072 /* MakeTemplateObject */); } @@ -53193,20 +56033,20 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return true; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return isValidConstAssertionArgument(node.expression); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var op = node.operator; var arg = node.operand; - return op === 39 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || - op === 38 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + return op === 40 /* MinusToken */ && (arg.kind === 8 /* NumericLiteral */ || arg.kind === 9 /* BigIntLiteral */) || + op === 39 /* PlusToken */ && arg.kind === 8 /* NumericLiteral */; + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: var expr = node.expression; if (ts.isIdentifier(expr)) { var symbol = getSymbolAtLocation(expr); @@ -53242,10 +56082,10 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - if (node.keywordToken === 96 /* NewKeyword */) { + if (node.keywordToken === 98 /* NewKeyword */) { return checkNewTargetMetaProperty(node); } - if (node.keywordToken === 93 /* ImportKeyword */) { + if (node.keywordToken === 95 /* ImportKeyword */) { return checkImportMetaProperty(node); } return ts.Debug.assertNever(node.keywordToken); @@ -53256,7 +56096,7 @@ var ts; error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return errorType; } - else if (container.kind === 158 /* Constructor */) { + else if (container.kind === 161 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -53270,7 +56110,7 @@ var ts; error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_esnext_or_system); } var file = ts.getSourceFileOfNode(node); - ts.Debug.assert(!!(file.flags & 1048576 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); + ts.Debug.assert(!!(file.flags & 2097152 /* PossiblyContainsImportMeta */), "Containing file is missing import meta node flag."); ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module."); return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType; } @@ -53285,7 +56125,7 @@ var ts; return type; } function getParameterNameAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return signature.parameters[pos].escapedName; } @@ -53302,17 +56142,17 @@ var ts; return tryGetTypeAtPosition(signature, pos) || anyType; } function tryGetTypeAtPosition(signature, pos) { - var paramCount = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); if (pos < paramCount) { return getTypeOfParameter(signature.parameters[pos]); } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // We want to return the value undefined for an out of bounds parameter position, // so we need to check bounds here before calling getIndexedAccessType (which // otherwise would return the type 'undefined'). var restType = getTypeOfSymbol(signature.parameters[paramCount]); var index = pos - paramCount; - if (!isTupleType(restType) || restType.target.hasRestElement || index < (restType.typeArguments || ts.emptyArray).length) { + if (!isTupleType(restType) || restType.target.hasRestElement || index < getTypeArguments(restType).length) { return getIndexedAccessType(restType, getLiteralType(index)); } } @@ -53341,16 +56181,16 @@ var ts; } function getParameterCount(signature) { var length = signature.parameters.length; - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[length - 1]); if (isTupleType(restType)) { - return length + (restType.typeArguments || ts.emptyArray).length - 1; + return length + getTypeArguments(restType).length - 1; } } return length; } function getMinArgumentCount(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); if (isTupleType(restType)) { var minLength = restType.target.minLength; @@ -53362,14 +56202,14 @@ var ts; return signature.minArgumentCount; } function hasEffectiveRestParameter(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return !isTupleType(restType) || restType.target.hasRestElement; } return false; } function getEffectiveRestType(signature) { - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]); return isTupleType(restType) ? getRestArrayTypeOfTupleType(restType) : restType; } @@ -53386,7 +56226,7 @@ var ts; return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType; } function inferFromAnnotatedParameters(signature, context, inferenceContext) { - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -53419,7 +56259,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter)); } } - var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0); for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53427,7 +56267,7 @@ var ts; assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } } - if (signature.hasRestParameter) { + if (signatureHasRestParameter(signature)) { // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.last(signature.parameters); if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { @@ -53442,7 +56282,7 @@ var ts; for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 73 /* Identifier */) { + if (element.name.kind === 75 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } else { @@ -53456,7 +56296,7 @@ var ts; if (!links.type) { links.type = contextualType; var decl = parameter.valueDeclaration; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { // if inference didn't come up with anything but unknown, fall back to the binding pattern if present. if (links.type === unknownType) { links.type = getTypeFromBindingPattern(decl.name); @@ -53511,7 +56351,7 @@ var ts; var yieldType; var nextType; var fallbackReturnType = voidType; - if (func.body.kind !== 219 /* Block */) { // Async or normal arrow function + if (func.body.kind !== 222 /* Block */) { // Async or normal arrow function returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8 /* SkipGenericFunctions */); if (isAsync) { // From within an async function you can return either a non-promise value or a promise. Any @@ -53694,10 +56534,11 @@ var ts; return facts; } function isExhaustiveSwitchStatement(node) { - if (!node.possiblyExhaustive) { - return false; - } - if (node.expression.kind === 200 /* TypeOfExpression */) { + var links = getNodeLinks(node); + return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node)); + } + function computeExhaustiveSwitchStatement(node) { + if (node.expression.kind === 203 /* TypeOfExpression */) { var operandType = getTypeOfExpression(node.expression.expression); // This cast is safe because the switch is possibly exhaustive and does not contain a default case, so there can be no undefined. var witnesses = getSwitchClauseTypeOfWitnesses(node); @@ -53717,13 +56558,7 @@ var ts; return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes); } function functionHasImplicitReturn(func) { - if (!(func.flags & 128 /* HasImplicitReturn */)) { - return false; - } - if (ts.some(func.body.statements, function (statement) { return statement.kind === 233 /* SwitchStatement */ && isExhaustiveSwitchStatement(statement); })) { - return false; - } - return true; + return func.endFlowNode && isReachableFlowNode(func.endFlowNode); } /** NOTE: Return value of `[]` means a different thing than `undefined`. `[]` means func returns `void`, `undefined` means it returns `never`. */ function checkAndAggregateReturnExpressionTypes(func, checkMode) { @@ -53763,11 +56598,11 @@ var ts; } function mayReturnNever(func) { switch (func.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return true; - case 157 /* MethodDeclaration */: - return func.parent.kind === 189 /* ObjectLiteralExpression */; + case 160 /* MethodDeclaration */: + return func.parent.kind === 192 /* ObjectLiteralExpression */; default: return false; } @@ -53793,10 +56628,10 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (func.kind === 156 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 219 /* Block */ || !functionHasImplicitReturn(func)) { + if (func.kind === 159 /* MethodSignature */ || ts.nodeIsMissing(func.body) || func.body.kind !== 222 /* Block */ || !functionHasImplicitReturn(func)) { return; } - var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; + var hasExplicitReturn = func.flags & 512 /* HasExplicitReturn */; if (type && type.flags & 131072 /* Never */) { error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point); } @@ -53826,7 +56661,7 @@ var ts; } } function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); checkNodeDeferred(node); // The identityMapper object is used to indicate that function expressions are wildcards if (checkMode && checkMode & 4 /* SkipContextSensitive */ && isContextSensitive(node)) { @@ -53837,7 +56672,7 @@ var ts; return links.contextFreeType; } var returnType = getReturnTypeFromBody(node, checkMode); - var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); + var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, 0 /* None */); var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined); returnOnlyType.objectFlags |= 1048576 /* NonInferrableType */; return links.contextFreeType = returnOnlyType; @@ -53846,7 +56681,7 @@ var ts; } // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 197 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 200 /* FunctionExpression */) { checkGrammarForGenerator(node); } var type = getTypeOfSymbol(getMergedSymbol(node.symbol)); @@ -53900,7 +56735,7 @@ var ts; type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 157 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 160 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var functionFlags = ts.getFunctionFlags(node); var returnType = getReturnTypeFromAnnotation(node); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); @@ -53913,7 +56748,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 219 /* Block */) { + if (node.body.kind === 222 /* Block */) { checkSourceElement(node.body); } else { @@ -53994,11 +56829,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) && - expr.expression.kind === 101 /* ThisKeyword */) { + (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) && + expr.expression.kind === 103 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 158 /* Constructor */)) { + if (!(func && func.kind === 161 /* Constructor */)) { return true; } // If func.parent is a class and symbol is a (readonly) property of that class, or @@ -54011,31 +56846,35 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 190 /* PropertyAccessExpression */ || expr.kind === 191 /* ElementAccessExpression */) { + if (expr.kind === 193 /* PropertyAccessExpression */ || expr.kind === 194 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 2097152 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return !!declaration && declaration.kind === 252 /* NamespaceImport */; + return !!declaration && declaration.kind === 255 /* NamespaceImport */; } } } return false; } - function checkReferenceExpression(expr, invalidReferenceMessage) { + function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipOuterExpressions(expr, 2 /* Assertions */ | 1 /* Parentheses */); - if (node.kind !== 73 /* Identifier */ && node.kind !== 190 /* PropertyAccessExpression */ && node.kind !== 191 /* ElementAccessExpression */) { + if (node.kind !== 75 /* Identifier */ && node.kind !== 193 /* PropertyAccessExpression */ && node.kind !== 194 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } + if (node.flags & 32 /* OptionalChain */) { + error(expr, invalidOptionalChainMessage); + return false; + } return true; } function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 190 /* PropertyAccessExpression */ && expr.kind !== 191 /* ElementAccessExpression */) { + if (expr.kind !== 193 /* PropertyAccessExpression */ && expr.kind !== 194 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -54057,14 +56896,14 @@ var ts; function checkAwaitExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 16384 /* AwaitContext */)) { + if (!(node.flags & 32768 /* AwaitContext */)) { // use of 'await' in non-async function var sourceFile = ts.getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos); var diagnostic = ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.await_expression_is_only_allowed_within_an_async_function); var func = ts.getContainingFunction(node); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -54091,14 +56930,14 @@ var ts; switch (node.operand.kind) { case 8 /* NumericLiteral */: switch (node.operator) { - case 39 /* MinusToken */: + case 40 /* MinusToken */: return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text)); - case 38 /* PlusToken */: + case 39 /* PlusToken */: return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text)); } break; case 9 /* BigIntLiteral */: - if (node.operator === 39 /* MinusToken */) { + if (node.operator === 40 /* MinusToken */) { return getFreshTypeOfLiteralType(getLiteralType({ negative: true, base10Value: ts.parsePseudoBigInt(node.operand.text) @@ -54106,32 +56945,32 @@ var ts; } } switch (node.operator) { - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 12288 /* ESSymbolLike */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } - if (node.operator === 38 /* PlusToken */) { + if (node.operator === 39 /* PlusToken */) { if (maybeTypeOfKind(operandType, 2112 /* BigIntLike */)) { - error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(operandType)); + error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType))); } return numberType; } return getUnaryResultType(operandType); - case 52 /* ExclamationToken */: + case 53 /* ExclamationToken */: checkTruthinessExpression(node.operand); var facts = getTypeFacts(operandType) & (4194304 /* Truthy */ | 8388608 /* Falsy */); return facts === 4194304 /* Truthy */ ? falseType : facts === 8388608 /* Falsy */ ? trueType : booleanType; - case 44 /* PlusPlusToken */: - case 45 /* MinusMinusToken */: + case 45 /* PlusPlusToken */: + case 46 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54145,7 +56984,7 @@ var ts; var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_bigint_or_an_enum_type); if (ok) { // run check only if former checks succeeded to avoid reporting cascading errors - checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access); + checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_may_not_be_an_optional_property_access); } return getUnaryResultType(operandType); } @@ -54166,8 +57005,8 @@ var ts; } if (type.flags & 3145728 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var t = types_15[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -54256,7 +57095,7 @@ var ts; if (rightIsThis === void 0) { rightIsThis = false; } var properties = node.properties; var property = properties[propertyIndex]; - if (property.kind === 276 /* PropertyAssignment */ || property.kind === 277 /* ShorthandPropertyAssignment */) { + if (property.kind === 279 /* PropertyAssignment */ || property.kind === 280 /* ShorthandPropertyAssignment */) { var name = property.name; var exprType = getLiteralTypeFromPropertyName(name); if (isTypeUsableAsPropertyName(exprType)) { @@ -54269,9 +57108,9 @@ var ts; } var elementType = getIndexedAccessType(objectLiteralType, exprType, name); var type = getFlowTypeOfDestructuring(property, elementType); - return checkDestructuringAssignment(property.kind === 277 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); + return checkDestructuringAssignment(property.kind === 280 /* ShorthandPropertyAssignment */ ? property : property.initializer, type); } - else if (property.kind === 278 /* SpreadAssignment */) { + else if (property.kind === 281 /* SpreadAssignment */) { if (propertyIndex < properties.length - 1) { error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } @@ -54314,8 +57153,8 @@ var ts; function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 211 /* OmittedExpression */) { - if (element.kind !== 209 /* SpreadElement */) { + if (element.kind !== 214 /* OmittedExpression */) { + if (element.kind !== 212 /* SpreadElement */) { var indexType = getLiteralType(elementIndex); if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused @@ -54333,7 +57172,7 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 205 /* BinaryExpression */ && restExpression.operatorToken.kind === 60 /* EqualsToken */) { + if (restExpression.kind === 208 /* BinaryExpression */ && restExpression.operatorToken.kind === 62 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { @@ -54349,7 +57188,7 @@ var ts; } function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) { var target; - if (exprOrAssignment.kind === 277 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 280 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -54365,24 +57204,27 @@ var ts; else { target = exprOrAssignment; } - if (target.kind === 205 /* BinaryExpression */ && target.operatorToken.kind === 60 /* EqualsToken */) { + if (target.kind === 208 /* BinaryExpression */ && target.operatorToken.kind === 62 /* EqualsToken */) { checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 189 /* ObjectLiteralExpression */) { + if (target.kind === 192 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType, rightIsThis); } - if (target.kind === 188 /* ArrayLiteralExpression */) { + if (target.kind === 191 /* ArrayLiteralExpression */) { return checkArrayLiteralAssignment(target, sourceType, checkMode); } return checkReferenceAssignment(target, sourceType, checkMode); } function checkReferenceAssignment(target, sourceType, checkMode) { var targetType = checkExpression(target, checkMode); - var error = target.parent.kind === 278 /* SpreadAssignment */ ? + var error = target.parent.kind === 281 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; - if (checkReferenceExpression(target, error)) { + var optionalError = target.parent.kind === 281 /* SpreadAssignment */ ? + ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access : + ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access; + if (checkReferenceExpression(target, error, optionalError)) { checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target); } return sourceType; @@ -54398,53 +57240,53 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: case 10 /* StringLiteral */: case 13 /* RegularExpressionLiteral */: - case 194 /* TaggedTemplateExpression */: - case 207 /* TemplateExpression */: + case 197 /* TaggedTemplateExpression */: + case 210 /* TemplateExpression */: case 14 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 142 /* UndefinedKeyword */: - case 197 /* FunctionExpression */: - case 210 /* ClassExpression */: - case 198 /* ArrowFunction */: - case 188 /* ArrayLiteralExpression */: - case 189 /* ObjectLiteralExpression */: - case 200 /* TypeOfExpression */: - case 214 /* NonNullExpression */: - case 262 /* JsxSelfClosingElement */: - case 261 /* JsxElement */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 145 /* UndefinedKeyword */: + case 200 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 201 /* ArrowFunction */: + case 191 /* ArrayLiteralExpression */: + case 192 /* ObjectLiteralExpression */: + case 203 /* TypeOfExpression */: + case 217 /* NonNullExpression */: + case 265 /* JsxSelfClosingElement */: + case 264 /* JsxElement */: return true; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 52 /* ExclamationToken */: - case 38 /* PlusToken */: - case 39 /* MinusToken */: - case 53 /* TildeToken */: + case 53 /* ExclamationToken */: + case 39 /* PlusToken */: + case 40 /* MinusToken */: + case 54 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 201 /* VoidExpression */: // Explicit opt-out - case 195 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 213 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 204 /* VoidExpression */: // Explicit opt-out + case 198 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 216 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -54456,15 +57298,27 @@ var ts; if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) { return checkExpression(node.right, checkMode); } + checkGrammarNullishCoalesceWithLogicalExpression(node); return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } + function checkGrammarNullishCoalesceWithLogicalExpression(node) { + var left = node.left, operatorToken = node.operatorToken, right = node.right; + if (operatorToken.kind === 60 /* QuestionQuestionToken */) { + if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 /* BarBarToken */ || left.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 /* BarBarToken */ || right.operatorToken.kind === 55 /* AmpersandAmpersandToken */)) { + grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind)); + } + } + } function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 60 /* EqualsToken */ && (left.kind === 189 /* ObjectLiteralExpression */ || left.kind === 188 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 101 /* ThisKeyword */); + if (operator === 62 /* EqualsToken */ && (left.kind === 192 /* ObjectLiteralExpression */ || left.kind === 191 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 103 /* ThisKeyword */); } var leftType; - if (operator === 54 /* AmpersandAmpersandToken */ || operator === 55 /* BarBarToken */) { + if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) { leftType = checkTruthinessExpression(left, checkMode); } else { @@ -54472,28 +57326,28 @@ var ts; } var rightType = checkExpression(right, checkMode); switch (operator) { - case 40 /* AsteriskToken */: - case 41 /* AsteriskAsteriskToken */: - case 63 /* AsteriskEqualsToken */: - case 64 /* AsteriskAsteriskEqualsToken */: - case 42 /* SlashToken */: - case 65 /* SlashEqualsToken */: - case 43 /* PercentToken */: - case 66 /* PercentEqualsToken */: - case 39 /* MinusToken */: - case 62 /* MinusEqualsToken */: - case 46 /* LessThanLessThanToken */: - case 67 /* LessThanLessThanEqualsToken */: - case 47 /* GreaterThanGreaterThanToken */: - case 68 /* GreaterThanGreaterThanEqualsToken */: - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: + case 41 /* AsteriskToken */: + case 42 /* AsteriskAsteriskToken */: + case 65 /* AsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: + case 43 /* SlashToken */: + case 67 /* SlashEqualsToken */: + case 44 /* PercentToken */: + case 68 /* PercentEqualsToken */: + case 40 /* MinusToken */: + case 64 /* MinusEqualsToken */: + case 47 /* LessThanLessThanToken */: + case 69 /* LessThanLessThanEqualsToken */: + case 48 /* GreaterThanGreaterThanToken */: + case 70 /* GreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54520,17 +57374,17 @@ var ts; resultType_1 = numberType; } // At least one is assignable to bigint, so check that both are - else if (isTypeAssignableToKind(leftType, 2112 /* BigIntLike */) && isTypeAssignableToKind(rightType, 2112 /* BigIntLike */)) { + else if (bothAreBigIntLike(leftType, rightType)) { switch (operator) { - case 48 /* GreaterThanGreaterThanGreaterThanToken */: - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* GreaterThanGreaterThanGreaterThanToken */: + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: reportOperatorError(); } resultType_1 = bigintType; } // Exactly one of leftType/rightType is assignable to bigint else { - reportOperatorError(function (awaitedLeft, awaitedRight) { return isTypeAssignableToKind(awaitedLeft, 2112 /* BigIntLike */) && isTypeAssignableToKind(awaitedRight, 2112 /* BigIntLike */); }); + reportOperatorError(bothAreBigIntLike); resultType_1 = errorType; } if (leftOk && rightOk) { @@ -54538,8 +57392,8 @@ var ts; } return resultType_1; } - case 38 /* PlusToken */: - case 61 /* PlusEqualsToken */: + case 39 /* PlusToken */: + case 63 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -54572,24 +57426,24 @@ var ts; } if (!resultType) { // Types that have a reasonably good chance of being a valid operand type. - // If both types have an awaited type of one of these, we’ll assume the user + // If both types have an awaited type of one of these, we'll assume the user // might be missing an await without doing an exhaustive check that inserting // await(s) will actually be a completely valid binary expression. var closeEnoughKind_1 = 296 /* NumberLike */ | 2112 /* BigIntLike */ | 132 /* StringLike */ | 3 /* AnyOrUnknown */; - reportOperatorError(function (awaitedLeft, awaitedRight) { - return isTypeAssignableToKind(awaitedLeft, closeEnoughKind_1) && - isTypeAssignableToKind(awaitedRight, closeEnoughKind_1); + reportOperatorError(function (left, right) { + return isTypeAssignableToKind(left, closeEnoughKind_1) && + isTypeAssignableToKind(right, closeEnoughKind_1); }); return anyType; } - if (operator === 61 /* PlusEqualsToken */) { + if (operator === 63 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 28 /* LessThanToken */: - case 30 /* GreaterThanToken */: - case 31 /* LessThanEqualsToken */: - case 32 /* GreaterThanEqualsToken */: + case 29 /* LessThanToken */: + case 31 /* GreaterThanToken */: + case 32 /* LessThanEqualsToken */: + case 33 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -54598,25 +57452,29 @@ var ts; }); } return booleanType; - case 33 /* EqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: - case 35 /* EqualsEqualsEqualsToken */: - case 36 /* ExclamationEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); }); return booleanType; - case 95 /* InstanceOfKeyword */: + case 97 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 94 /* InKeyword */: + case 96 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 54 /* AmpersandAmpersandToken */: + case 55 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 4194304 /* Truthy */ ? getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) : leftType; - case 55 /* BarBarToken */: + case 56 /* BarBarToken */: return getTypeFacts(leftType) & 8388608 /* Falsy */ ? getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2 /* Subtype */) : leftType; - case 60 /* EqualsToken */: + case 60 /* QuestionQuestionToken */: + return getTypeFacts(leftType) & 262144 /* EQUndefinedOrNull */ ? + getUnionType([getNonNullableType(leftType), rightType], 2 /* Subtype */) : + leftType; + case 62 /* EqualsToken */: var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0 /* None */; checkAssignmentDeclaration(declKind, rightType); if (isAssignmentDeclaration(declKind)) { @@ -54643,6 +57501,9 @@ var ts; default: return ts.Debug.fail(); } + function bothAreBigIntLike(left, right) { + return isTypeAssignableToKind(left, 2112 /* BigIntLike */) && isTypeAssignableToKind(right, 2112 /* BigIntLike */); + } function checkAssignmentDeclaration(kind, rightType) { if (kind === 2 /* ModuleExports */) { for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) { @@ -54660,7 +57521,7 @@ var ts; } } function isEvalNode(node) { - return node.kind === 73 /* Identifier */ && node.escapedText === "eval"; + return node.kind === 75 /* Identifier */ && node.escapedText === "eval"; } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { @@ -54675,15 +57536,15 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 50 /* BarToken */: - case 71 /* BarEqualsToken */: - return 55 /* BarBarToken */; - case 51 /* CaretToken */: - case 72 /* CaretEqualsToken */: - return 36 /* ExclamationEqualsEqualsToken */; - case 49 /* AmpersandToken */: - case 70 /* AmpersandEqualsToken */: - return 54 /* AmpersandAmpersandToken */; + case 51 /* BarToken */: + case 73 /* BarEqualsToken */: + return 56 /* BarBarToken */; + case 52 /* CaretToken */: + case 74 /* CaretEqualsToken */: + return 37 /* ExclamationEqualsEqualsToken */; + case 50 /* AmpersandToken */: + case 72 /* AmpersandEqualsToken */: + return 55 /* AmpersandAmpersandToken */; default: return undefined; } @@ -54696,7 +57557,7 @@ var ts; // requires VarExpr to be classified as a reference // A compound assignment furthermore requires VarExpr to be classified as a reference (section 4.1) // and the type of the non-compound operation to be assignable to the type of VarExpr. - if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access) + if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access) && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) { // to avoid cascading errors check assignability only if 'isReference' check succeeded and no errors were reported checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right); @@ -54730,17 +57591,23 @@ var ts; } return false; } - function reportOperatorError(awaitedTypesAreCompatible) { + function reportOperatorError(isRelated) { + var _a; var wouldWorkWithAwait = false; var errNode = errorNode || operatorToken; - var _a = getTypeNamesForErrorDisplay(leftType, rightType), leftStr = _a[0], rightStr = _a[1]; - if (awaitedTypesAreCompatible) { + if (isRelated) { var awaitedLeftType = getAwaitedType(leftType); var awaitedRightType = getAwaitedType(rightType); wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType) && !!(awaitedLeftType && awaitedRightType) - && awaitedTypesAreCompatible(awaitedLeftType, awaitedRightType); + && isRelated(awaitedLeftType, awaitedRightType); + } + var effectiveLeft = leftType; + var effectiveRight = rightType; + if (!wouldWorkWithAwait && isRelated) { + _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1]; } + var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1]; if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) { errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr); } @@ -54748,12 +57615,12 @@ var ts; function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) { var typeName; switch (operatorToken.kind) { - case 35 /* EqualsEqualsEqualsToken */: - case 33 /* EqualsEqualsToken */: + case 36 /* EqualsEqualsEqualsToken */: + case 34 /* EqualsEqualsToken */: typeName = "false"; break; - case 36 /* ExclamationEqualsEqualsToken */: - case 34 /* ExclamationEqualsToken */: + case 37 /* ExclamationEqualsEqualsToken */: + case 35 /* ExclamationEqualsToken */: typeName = "true"; } if (typeName) { @@ -54762,6 +57629,17 @@ var ts; return undefined; } } + function getBaseTypesIfUnrelated(leftType, rightType, isRelated) { + var effectiveLeft = leftType; + var effectiveRight = rightType; + var leftBase = getBaseTypeOfLiteralType(leftType); + var rightBase = getBaseTypeOfLiteralType(rightType); + if (!isRelated(leftBase, rightBase)) { + effectiveLeft = leftBase; + effectiveRight = rightBase; + } + return [effectiveLeft, effectiveRight]; + } function isYieldExpressionInClass(node) { var current = node; var parent = node.parent; @@ -54780,7 +57658,7 @@ var ts; function checkYieldExpression(node) { // Grammar checking if (produceDiagnostics) { - if (!(node.flags & 4096 /* YieldContext */) || isYieldExpressionInClass(node)) { + if (!(node.flags & 8192 /* YieldContext */) || isYieldExpressionInClass(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body); } if (isInParameterInitializerBeforeContainingFunction(node)) { @@ -54851,7 +57729,7 @@ var ts; return stringType; } function getContextNode(node) { - if (node.kind === 269 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { + if (node.kind === 272 /* JsxAttributes */ && !ts.isJsxSelfClosingElement(node.parent)) { return node.parent.parent; // Needs to be the root JsxElement, so it encompasses the attributes _and_ the children (which are essentially part of the attributes) } return node; @@ -54890,12 +57768,12 @@ var ts; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 195 /* TypeAssertionExpression */ || node.kind === 213 /* AsExpression */; + return node.kind === 198 /* TypeAssertionExpression */ || node.kind === 216 /* AsExpression */; } function checkDeclarationInitializer(declaration) { var initializer = ts.getEffectiveInitializer(declaration); var type = getTypeOfExpression(initializer, /*cache*/ true); - var padded = ts.isParameter(declaration) && declaration.name.kind === 186 /* ArrayBindingPattern */ && + var padded = ts.isParameter(declaration) && declaration.name.kind === 189 /* ArrayBindingPattern */ && isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ? padTupleType(type, declaration.name) : type; var widened = ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || @@ -54917,10 +57795,10 @@ var ts; function padTupleType(type, pattern) { var patternElements = pattern.elements; var arity = getTypeReferenceArity(type); - var elementTypes = arity ? type.typeArguments.slice() : []; + var elementTypes = arity ? getTypeArguments(type).slice() : []; for (var i = arity; i < patternElements.length; i++) { var e = patternElements[i]; - if (i < patternElements.length - 1 || !(e.kind === 187 /* BindingElement */ && e.dotDotDotToken)) { + if (i < patternElements.length - 1 || !(e.kind === 190 /* BindingElement */ && e.dotDotDotToken)) { elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false) : anyType); if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) { reportImplicitAny(e, anyType); @@ -54972,7 +57850,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } return checkExpressionForMutableLocation(node.initializer, checkMode); @@ -54983,7 +57861,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); @@ -54995,8 +57873,8 @@ var ts; var constructSignature = getSingleSignature(type, 1 /* Construct */, /*allowMembers*/ true); var signature = callSignature || constructSignature; if (signature && signature.typeParameters) { - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && !isMixinConstructorType(contextualType)) { + var contextualType = getApparentTypeOfContextualType(node, 2 /* NoConstraints */); + if (contextualType) { var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 /* Call */ : 1 /* Construct */, /*allowMembers*/ false); if (contextualSignature && !contextualSignature.typeParameters) { if (checkMode & 8 /* SkipGenericFunctions */) { @@ -55126,11 +58004,22 @@ var ts; var expr = ts.skipParentheses(node); // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (expr.kind === 192 /* CallExpression */ && expr.expression.kind !== 99 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { - var funcType = checkNonNullExpression(expr.expression); + if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) { + var isOptional = void 0; + var funcType = void 0; + if (ts.isCallChain(expr)) { + funcType = checkExpression(expr.expression); + var nonOptionalType = getOptionalExpressionType(funcType, expr.expression); + isOptional = funcType !== nonOptionalType; + funcType = checkNonNullType(nonOptionalType, expr.expression); + } + else { + isOptional = false; + funcType = checkNonNullExpression(expr.expression); + } var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { - return getReturnTypeOfSignature(signature); + return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional); } } else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) { @@ -55176,18 +58065,18 @@ var ts; // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 191 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 73 /* Identifier */ || node.kind === 149 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || - (node.parent.kind === 168 /* TypeQuery */ && node.parent.exprName === node)) || - (node.parent.kind === 258 /* ExportSpecifier */ && (compilerOptions.preserveConstEnums || node.flags & 4194304 /* Ambient */)); // We allow reexporting const enums + var ok = (node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 194 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 75 /* Identifier */ || node.kind === 152 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node) || + (node.parent.kind === 171 /* TypeQuery */ && node.parent.exprName === node)) || + (node.parent.kind === 261 /* ExportSpecifier */); // We allow reexporting const enums if (!ok) { error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment_or_type_query); } if (compilerOptions.isolatedModules) { ts.Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */)); var constEnumDeclaration = type.symbol.valueDeclaration; - if (constEnumDeclaration.flags & 4194304 /* Ambient */) { + if (constEnumDeclaration.flags & 8388608 /* Ambient */) { error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided); } } @@ -55205,20 +58094,20 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return checkIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return checkThisExpression(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkSuperExpression(node); - case 97 /* NullKeyword */: + case 99 /* NullKeyword */: return nullWideningType; case 14 /* NoSubstitutionTemplateLiteral */: case 10 /* StringLiteral */: @@ -55229,82 +58118,82 @@ var ts; case 9 /* BigIntLiteral */: checkGrammarBigIntLiteral(node); return getFreshTypeOfLiteralType(getBigIntLiteralType(node)); - case 103 /* TrueKeyword */: + case 105 /* TrueKeyword */: return trueType; - case 88 /* FalseKeyword */: + case 90 /* FalseKeyword */: return falseType; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return checkTemplateExpression(node); case 13 /* RegularExpressionLiteral */: return globalRegExpType; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return checkArrayLiteral(node, checkMode, forceTuple); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return checkObjectLiteral(node, checkMode); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return checkQualifiedName(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 192 /* CallExpression */: - if (node.expression.kind === 93 /* ImportKeyword */) { + case 195 /* CallExpression */: + if (node.expression.kind === 95 /* ImportKeyword */) { return checkImportCallExpression(node); } - /* falls through */ - case 193 /* NewExpression */: + // falls through + case 196 /* NewExpression */: return checkCallExpression(node, checkMode); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return checkParenthesizedExpression(node, checkMode); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return checkClassExpression(node); - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: return checkAssertion(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return checkNonNullAssertion(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return checkMetaProperty(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return checkDeleteExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return checkVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return checkAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return checkBinaryExpression(node, checkMode); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return checkConditionalExpression(node, checkMode); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return checkSpreadExpression(node, checkMode); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return undefinedWideningType; - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return checkYieldExpression(node); - case 216 /* SyntheticExpression */: + case 219 /* SyntheticExpression */: return node.type; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return checkJsxExpression(node, checkMode); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return checkJsxElement(node, checkMode); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node, checkMode); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return checkJsxFragment(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return checkJsxAttributes(node, checkMode); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return errorType; @@ -55341,7 +58230,7 @@ var ts; checkVariableLikeDeclaration(node); var func = ts.getContainingFunction(node); if (ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { - if (!(func.kind === 158 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 161 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -55352,10 +58241,10 @@ var ts; if (func.parameters.indexOf(node) !== 0) { error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText); } - if (func.kind === 158 /* Constructor */ || func.kind === 162 /* ConstructSignature */ || func.kind === 167 /* ConstructorType */) { + if (func.kind === 161 /* Constructor */ || func.kind === 165 /* ConstructSignature */ || func.kind === 170 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } - if (func.kind === 198 /* ArrowFunction */) { + if (func.kind === 201 /* ArrowFunction */) { error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter); } } @@ -55379,18 +58268,20 @@ var ts; } checkSourceElement(node.type); var parameterName = node.parameterName; - if (ts.isThisTypePredicate(typePredicate)) { + if (typePredicate.kind === 0 /* This */ || typePredicate.kind === 2 /* AssertsThis */) { getTypeFromThisTypeNode(parameterName); } else { if (typePredicate.parameterIndex >= 0) { - if (signature.hasRestParameter && typePredicate.parameterIndex === signature.parameters.length - 1) { + if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) { error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; - checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, - /*headMessage*/ undefined, leadingError); + if (typePredicate.type) { + var leadingError = function () { return ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); }; + checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, + /*headMessage*/ undefined, leadingError); + } } } else if (parameterName) { @@ -55411,13 +58302,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 198 /* ArrowFunction */: - case 161 /* CallSignature */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 166 /* FunctionType */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 201 /* ArrowFunction */: + case 164 /* CallSignature */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 169 /* FunctionType */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -55431,11 +58322,11 @@ var ts; continue; } var name = element.name; - if (name.kind === 73 /* Identifier */ && name.escapedText === predicateVariableName) { + if (name.kind === 75 /* Identifier */ && name.escapedText === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 186 /* ArrayBindingPattern */ || name.kind === 185 /* ObjectBindingPattern */) { + else if (name.kind === 189 /* ArrayBindingPattern */ || name.kind === 188 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -55444,13 +58335,13 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled - else if (node.kind === 166 /* FunctionType */ || node.kind === 240 /* FunctionDeclaration */ || node.kind === 167 /* ConstructorType */ || - node.kind === 161 /* CallSignature */ || node.kind === 158 /* Constructor */ || - node.kind === 162 /* ConstructSignature */) { + else if (node.kind === 169 /* FunctionType */ || node.kind === 243 /* FunctionDeclaration */ || node.kind === 170 /* ConstructorType */ || + node.kind === 164 /* CallSignature */ || node.kind === 161 /* Constructor */ || + node.kind === 165 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } var functionFlags = ts.getFunctionFlags(node); @@ -55480,10 +58371,10 @@ var ts; var returnTypeNode = ts.getEffectiveReturnTypeNode(node); if (noImplicitAny && !returnTypeNode) { switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -55513,7 +58404,7 @@ var ts; checkAsyncFunctionReturnType(node, returnTypeNode); } } - if (node.kind !== 163 /* IndexSignature */ && node.kind !== 295 /* JSDocFunctionType */) { + if (node.kind !== 166 /* IndexSignature */ && node.kind !== 298 /* JSDocFunctionType */) { registerForUnusedIdentifiersCheck(node); } } @@ -55523,7 +58414,7 @@ var ts; var staticNames = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 158 /* Constructor */) { + if (member.kind === 161 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) { @@ -55538,16 +58429,16 @@ var ts; var memberName = name && ts.getPropertyNameForPropertyNameNode(name); if (name && memberName) { switch (member.kind) { - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: addName(names, name, memberName, 1 /* GetAccessor */); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: addName(names, name, memberName, 2 /* SetAccessor */); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: addName(names, name, memberName, 3 /* GetOrSetAccessor */); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: addName(names, name, memberName, 8 /* Method */); break; } @@ -55610,7 +58501,7 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 154 /* PropertySignature */) { + if (member.kind === 157 /* PropertySignature */) { var memberName = void 0; var name = member.name; switch (name.kind) { @@ -55618,7 +58509,7 @@ var ts; case 8 /* NumericLiteral */: memberName = name.text; break; - case 73 /* Identifier */: + case 75 /* Identifier */: memberName = ts.idText(name); break; default: @@ -55635,7 +58526,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); // in case of merging interface declaration it is possible that we'll enter this check procedure several times for every declaration // to prevent this run check only for the first declaration of a given kind @@ -55655,7 +58546,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -55663,7 +58554,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -55690,7 +58581,7 @@ var ts; checkFunctionOrMethodDeclaration(node); // Abstract methods cannot have an implementation. // Extra checks are to avoid reporting multiple errors relating to the "abstractness" of the node. - if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 157 /* MethodDeclaration */ && node.body) { + if (ts.hasModifier(node, 128 /* Abstract */) && node.kind === 160 /* MethodDeclaration */ && node.body) { error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name)); } } @@ -55715,7 +58606,7 @@ var ts; return; } function isInstancePropertyWithInitializer(n) { - return n.kind === 155 /* PropertyDeclaration */ && + return n.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(n, 32 /* Static */) && !!n.initializer; } @@ -55743,9 +58634,9 @@ var ts; if (superCallShouldBeFirst) { var statements = node.body.statements; var superCallStatement = void 0; - for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { - var statement = statements_2[_i]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { + var statement = statements_3[_i]; + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -55770,9 +58661,9 @@ var ts; checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 159 /* GetAccessor */) { - if (!(node.flags & 4194304 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { - if (!(node.flags & 256 /* HasExplicitReturn */)) { + if (node.kind === 162 /* GetAccessor */) { + if (!(node.flags & 8388608 /* Ambient */) && ts.nodeIsPresent(node.body) && (node.flags & 256 /* HasImplicitReturn */)) { + if (!(node.flags & 512 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } @@ -55780,13 +58671,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } if (!hasNonBindableDynamicName(node)) { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); if (otherAccessor) { var nodeFlags = ts.getModifierFlags(node); @@ -55804,7 +58695,7 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } @@ -55852,19 +58743,16 @@ var ts; } function checkTypeReferenceNode(node) { checkGrammarTypeArguments(node, node.typeArguments); - if (node.kind === 165 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { + if (node.kind === 168 /* TypeReference */ && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) { grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments); } + ts.forEach(node.typeArguments, checkSourceElement); var type = getTypeFromTypeReference(node); if (type !== errorType) { - if (node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - ts.forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - var typeParameters = getTypeParametersForTypeReference(node); - if (typeParameters) { - checkTypeArgumentConstraints(node, typeParameters); - } + if (node.typeArguments && produceDiagnostics) { + var typeParameters = getTypeParametersForTypeReference(node); + if (typeParameters) { + checkTypeArgumentConstraints(node, typeParameters); } } if (type.flags & 32 /* Enum */ && getNodeLinks(node).resolvedSymbol.flags & 8 /* EnumMember */) { @@ -55900,16 +58788,16 @@ var ts; var seenOptionalElement = false; for (var i = 0; i < elementTypes.length; i++) { var e = elementTypes[i]; - if (e.kind === 173 /* RestType */) { + if (e.kind === 176 /* RestType */) { if (i !== elementTypes.length - 1) { grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_must_be_last_in_a_tuple_type); break; } - if (!isArrayType(getTypeFromTypeNode(e))) { + if (!isArrayType(getTypeFromTypeNode(e.type))) { error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type); } } - else if (e.kind === 172 /* OptionalType */) { + else if (e.kind === 175 /* OptionalType */) { seenOptionalElement = true; } else if (seenOptionalElement) { @@ -55930,7 +58818,7 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType, /*stringsOnly*/ false))) { - if (accessNode.kind === 191 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + if (accessNode.kind === 194 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && ts.getObjectFlags(objectType) & 32 /* Mapped */ && getMappedTypeModifiers(objectType) & 1 /* IncludeReadonly */) { error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); } @@ -55981,7 +58869,7 @@ var ts; ts.forEachChild(node, checkSourceElement); } function checkInferType(node) { - if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 176 /* ConditionalType */ && n.parent.extendsType === n; })) { + if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 179 /* ConditionalType */ && n.parent.extendsType === n; })) { grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type); } checkSourceElement(node.typeParameter); @@ -55992,16 +58880,16 @@ var ts; getTypeFromTypeNode(node); } function isPrivateWithinAmbient(node) { - return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 4194304 /* Ambient */); + return ts.hasModifier(node, 8 /* Private */) && !!(node.flags & 8388608 /* Ambient */); } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. - if (n.parent.kind !== 242 /* InterfaceDeclaration */ && - n.parent.kind !== 241 /* ClassDeclaration */ && - n.parent.kind !== 210 /* ClassExpression */ && - n.flags & 4194304 /* Ambient */) { + if (n.parent.kind !== 245 /* InterfaceDeclaration */ && + n.parent.kind !== 244 /* ClassDeclaration */ && + n.parent.kind !== 213 /* ClassExpression */ && + n.flags & 8388608 /* Ambient */) { if (!(flags & 2 /* Ambient */) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) { // It is nested in an ambient context, which means it is automatically exported flags |= 1 /* Export */; @@ -56091,7 +58979,7 @@ var ts; if (node.name && subsequentName && (ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) || !ts.isComputedPropertyName(node.name) && !ts.isComputedPropertyName(subsequentName) && ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) { - var reportError = (node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */) && + var reportError = (node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */) && ts.hasModifier(node, 32 /* Static */) !== ts.hasModifier(subsequentNode, 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -56130,8 +59018,8 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var current = declarations_4[_i]; var node = current; - var inAmbientContext = node.flags & 4194304 /* Ambient */; - var inAmbientContextOrInterface = node.parent.kind === 242 /* InterfaceDeclaration */ || node.parent.kind === 169 /* TypeLiteral */ || inAmbientContext; + var inAmbientContext = node.flags & 8388608 /* Ambient */; + var inAmbientContextOrInterface = node.parent.kind === 245 /* InterfaceDeclaration */ || node.parent.kind === 172 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -56142,10 +59030,10 @@ var ts; // 2. mixing ambient and non-ambient declarations is a separate error that will be reported - do not want to report an extra one previousDeclaration = undefined; } - if ((node.kind === 241 /* ClassDeclaration */ || node.kind === 210 /* ClassExpression */) && !inAmbientContext) { + if ((node.kind === 244 /* ClassDeclaration */ || node.kind === 213 /* ClassExpression */) && !inAmbientContext) { hasNonAmbientClass = true; } - if (node.kind === 240 /* FunctionDeclaration */ || node.kind === 157 /* MethodDeclaration */ || node.kind === 156 /* MethodSignature */ || node.kind === 158 /* Constructor */) { + if (node.kind === 243 /* FunctionDeclaration */ || node.kind === 160 /* MethodDeclaration */ || node.kind === 159 /* MethodSignature */ || node.kind === 161 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -56206,8 +59094,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_6 = signatures; _a < signatures_6.length; _a++) { - var signature = signatures_6[_a]; + for (var _a = 0, signatures_9 = signatures; _a < signatures_9.length; _a++) { + var signature = signatures_9[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { ts.addRelatedInfo(error(signature.declaration, ts.Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), ts.createDiagnosticForNode(bodyDeclaration, ts.Diagnostics.The_implementation_signature_is_declared_here)); break; @@ -56276,41 +59164,42 @@ var ts; function getDeclarationSpaces(decl) { var d = decl; switch (d.kind) { - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - // A jsdoc typedef and callback are, by definition, type aliases - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + // A jsdoc typedef and callback are, by definition, type aliases. + // falls through + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return 2 /* ExportType */; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4 /* ExportNamespace */ | 1 /* ExportValue */ : 4 /* ExportNamespace */; - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; - case 285 /* SourceFile */: + case 288 /* SourceFile */: return 2 /* ExportType */ | 1 /* ExportValue */ | 4 /* ExportNamespace */; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: // Export assigned entity name expressions act as aliases and should fall through, otherwise they export values if (!ts.isEntityNameExpression(d.expression)) { return 1 /* ExportValue */; } d = d.expression; - /* falls through */ - // The below options all declare an Alias, which is allowed to merge with other values within the importing module - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 251 /* ImportClause */: + // The below options all declare an Alias, which is allowed to merge with other values within the importing module. + // falls through + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 254 /* ImportClause */: var result_8 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_8 |= getDeclarationSpaces(d); }); return result_8; - case 238 /* VariableDeclaration */: - case 187 /* BindingElement */: - case 240 /* FunctionDeclaration */: - case 254 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 + case 241 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 243 /* FunctionDeclaration */: + case 257 /* ImportSpecifier */: // https://github.com/Microsoft/TypeScript/pull/7591 return 1 /* ExportValue */; default: return ts.Debug.failBadSyntaxKind(d); @@ -56344,7 +59233,7 @@ var ts; return typeAsPromise.promisedTypeOfPromise; } if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { - return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; + return typeAsPromise.promisedTypeOfPromise = getTypeArguments(promise)[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); // TODO: GH#18217 if (isTypeAny(thenFunction)) { @@ -56540,7 +59429,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType; if (promiseConstructorType === errorType) { - if (promiseConstructorName.kind === 73 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { + if (promiseConstructorName.kind === 75 /* Identifier */ && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(returnTypeNode, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -56559,7 +59448,7 @@ var ts; return; } // Verify there is no local declaration that could collide with the promise constructor. - var rootName = promiseConstructorName && getFirstIdentifier(promiseConstructorName); + var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName); var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551 /* Value */); if (collidingSymbol) { error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName)); @@ -56579,24 +59468,24 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 152 /* Parameter */: + case 155 /* Parameter */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages( /*details*/ undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -56616,8 +59505,8 @@ var ts; function markEntityNameOrEntityExpressionAsReference(typeName) { if (!typeName) return; - var rootName = getFirstIdentifier(typeName); - var meaning = (typeName.kind === 73 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var rootName = ts.getFirstIdentifier(typeName); + var meaning = (typeName.kind === 75 /* Identifier */ ? 788968 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ @@ -56642,29 +59531,29 @@ var ts; function getEntityNameForDecoratorMetadata(node) { if (node) { switch (node.kind) { - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return getEntityNameForDecoratorMetadataFromTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return getEntityNameForDecoratorMetadata(node.type); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return node.typeName; } } } function getEntityNameForDecoratorMetadataFromTypeList(types) { var commonEntityName; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var typeNode = types_16[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var typeNode = types_19[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var individualEntityName = getEntityNameForDecoratorMetadata(typeNode); @@ -56710,14 +59599,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 152 /* Parameter */) { + if (node.kind === 155 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -56726,23 +59615,23 @@ var ts; } } break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - var otherKind = node.kind === 159 /* GetAccessor */ ? 160 /* SetAccessor */ : 159 /* GetAccessor */; + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + var otherKind = node.kind === 162 /* GetAccessor */ ? 163 /* SetAccessor */ : 162 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind); markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node)); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node)); break; - case 152 /* Parameter */: + case 155 /* Parameter */: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); var containingSignature = node.parent; for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) { @@ -56805,7 +59694,7 @@ var ts; else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) { - error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 149 /* QualifiedName */ ? node.name.right : node.name)); + error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name_It_would_match_arguments_if_it_had_an_array_type, ts.idText(node.name.kind === 152 /* QualifiedName */ ? node.name.right : node.name)); } } } @@ -56838,9 +59727,9 @@ var ts; } function getIdentifierFromEntityNameExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return node.name; default: return undefined; @@ -56853,7 +59742,7 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name && node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 153 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -56869,7 +59758,7 @@ var ts; // checkFunctionOrConstructorSymbol wouldn't be called if we didnt ignore javascript function. var firstDeclaration = ts.find(localSymbol.declarations, // Get first non javascript function declaration - function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 65536 /* JavaScriptFile */); }); + function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072 /* JavaScriptFile */); }); // Only type check the symbol once if (node === firstDeclaration) { checkFunctionOrConstructorSymbol(localSymbol); @@ -56882,7 +59771,7 @@ var ts; } } } - var body = node.kind === 156 /* MethodSignature */ ? undefined : node.body; + var body = node.kind === 159 /* MethodSignature */ ? undefined : node.body; checkSourceElement(body); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node)); if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) { @@ -56908,7 +59797,7 @@ var ts; } function registerForUnusedIdentifiersCheck(node) { // May be in a call such as getTypeOfNode that happened to call this. But potentiallyUnusedIdentifiers is only defined in the scope of `checkSourceFile`. - if (produceDiagnostics && !(node.flags & 4194304 /* Ambient */)) { + if (produceDiagnostics && !(node.flags & 8388608 /* Ambient */)) { var sourceFile = ts.getSourceFileOfNode(node); var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path); if (!potentiallyUnusedIdentifiers) { @@ -56924,42 +59813,42 @@ var ts; for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) { var node = potentiallyUnusedIdentifiers_1[_i]; switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: checkUnusedClassMembers(node, addDiagnostic); checkUnusedTypeParameters(node, addDiagnostic); break; - case 285 /* SourceFile */: - case 245 /* ModuleDeclaration */: - case 219 /* Block */: - case 247 /* CaseBlock */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 288 /* SourceFile */: + case 248 /* ModuleDeclaration */: + case 222 /* Block */: + case 250 /* CaseBlock */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: checkUnusedLocalsAndParameters(node, addDiagnostic); break; - case 158 /* Constructor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 161 /* Constructor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: if (node.body) { // Don't report unused parameters in overloads checkUnusedLocalsAndParameters(node, addDiagnostic); } checkUnusedTypeParameters(node, addDiagnostic); break; - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 243 /* TypeAliasDeclaration */: - case 242 /* InterfaceDeclaration */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 246 /* TypeAliasDeclaration */: + case 245 /* InterfaceDeclaration */: checkUnusedTypeParameters(node, addDiagnostic); break; - case 177 /* InferType */: + case 180 /* InferType */: checkUnusedInferTypeParameter(node, addDiagnostic); break; default: @@ -56979,11 +59868,11 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 157 /* MethodDeclaration */: - case 155 /* PropertyDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - if (member.kind === 160 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { + case 160 /* MethodDeclaration */: + case 158 /* PropertyDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + if (member.kind === 163 /* SetAccessor */ && member.symbol.flags & 32768 /* GetAccessor */) { // Already would have reported an error on the getter. break; } @@ -56992,7 +59881,7 @@ var ts; addDiagnostic(member, 0 /* Local */, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol))); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { @@ -57000,8 +59889,8 @@ var ts; } } break; - case 163 /* IndexSignature */: - case 218 /* SemicolonClassElement */: + case 166 /* IndexSignature */: + case 221 /* SemicolonClassElement */: // Can't be private break; default: @@ -57028,7 +59917,7 @@ var ts; continue; var name = ts.idText(typeParameter.name); var parent = typeParameter.parent; - if (parent.kind !== 177 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { + if (parent.kind !== 180 /* InferType */ && parent.typeParameters.every(isTypeParameterUnused)) { if (seenParentsWithEveryUnused.tryAdd(parent)) { var range = ts.isJSDocTemplateTag(parent) // Whole @template tag @@ -57063,7 +59952,7 @@ var ts; return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter); } function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) { - if (nodeWithLocals.flags & 4194304 /* Ambient */) + if (nodeWithLocals.flags & 8388608 /* Ambient */) return; // Ideally we could use the ImportClause directly as a key, but must wait until we have full ES6 maps. So must store key along with value. var unusedImports = ts.createMap(); @@ -57113,7 +60002,7 @@ var ts; var importDecl = importClause.parent; var nDeclarations = (importClause.name ? 1 : 0) + (importClause.namedBindings ? - (importClause.namedBindings.kind === 252 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) + (importClause.namedBindings.kind === 255 /* NamespaceImport */ ? 1 : importClause.namedBindings.elements.length) : 0); if (nDeclarations === unuseds.length) { addDiagnostic(importDecl, 0 /* Local */, unuseds.length === 1 @@ -57131,7 +60020,7 @@ var ts; var bindingPattern = _a[0], bindingElements = _a[1]; var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 /* Parameter */ : 0 /* Local */; if (bindingPattern.elements.length === bindingElements.length) { - if (bindingElements.length === 1 && bindingPattern.parent.kind === 238 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 239 /* VariableDeclarationList */) { + if (bindingElements.length === 1 && bindingPattern.parent.kind === 241 /* VariableDeclaration */ && bindingPattern.parent.parent.kind === 242 /* VariableDeclarationList */) { addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId); } else { @@ -57152,7 +60041,7 @@ var ts; if (declarationList.declarations.length === declarations.length) { addDiagnostic(declarationList, 0 /* Local */, declarations.length === 1 ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name)) - : ts.createDiagnosticForNode(declarationList.parent.kind === 220 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); + : ts.createDiagnosticForNode(declarationList.parent.kind === 224 /* VariableStatement */ ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused)); } else { for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) { @@ -57164,24 +60053,24 @@ var ts; } function bindingNameText(name) { switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.idText(name); - case 186 /* ArrayBindingPattern */: - case 185 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name); default: return ts.Debug.assertNever(name); } } function isImportedDeclaration(node) { - return node.kind === 251 /* ImportClause */ || node.kind === 254 /* ImportSpecifier */ || node.kind === 252 /* NamespaceImport */; + return node.kind === 254 /* ImportClause */ || node.kind === 257 /* ImportSpecifier */ || node.kind === 255 /* NamespaceImport */; } function importClauseFromImported(decl) { - return decl.kind === 251 /* ImportClause */ ? decl : decl.kind === 252 /* NamespaceImport */ ? decl.parent : decl.parent.parent; + return decl.kind === 254 /* ImportClause */ ? decl : decl.kind === 255 /* NamespaceImport */ ? decl.parent : decl.parent.parent; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 219 /* Block */) { + if (node.kind === 222 /* Block */) { checkGrammarStatementInAmbientContext(node); } if (ts.isFunctionOrModuleBlock(node)) { @@ -57198,7 +60087,7 @@ var ts; } function checkCollisionWithArgumentsInGeneratedCode(node) { // no rest parameters \ declaration context \ overload - no codegen impact - if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 4194304 /* Ambient */ || ts.nodeIsMissing(node.body)) { + if (languageVersion >= 2 /* ES2015 */ || compilerOptions.noEmit || !ts.hasRestParameter(node) || node.flags & 8388608 /* Ambient */ || ts.nodeIsMissing(node.body)) { return; } ts.forEach(node.parameters, function (p) { @@ -57211,21 +60100,21 @@ var ts; if (!(identifier && identifier.escapedText === name)) { return false; } - if (node.kind === 155 /* PropertyDeclaration */ || - node.kind === 154 /* PropertySignature */ || - node.kind === 157 /* MethodDeclaration */ || - node.kind === 156 /* MethodSignature */ || - node.kind === 159 /* GetAccessor */ || - node.kind === 160 /* SetAccessor */) { + if (node.kind === 158 /* PropertyDeclaration */ || + node.kind === 157 /* PropertySignature */ || + node.kind === 160 /* MethodDeclaration */ || + node.kind === 159 /* MethodSignature */ || + node.kind === 162 /* GetAccessor */ || + node.kind === 163 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // ambient context - no codegen impact return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 152 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 155 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -57235,7 +60124,7 @@ var ts; function checkIfThisIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 73 /* Identifier */; + var isDeclaration_1 = node.kind !== 75 /* Identifier */; if (isDeclaration_1) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -57250,7 +60139,7 @@ var ts; function checkIfNewTargetIsCapturedInEnclosingScope(node) { ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 73 /* Identifier */; + var isDeclaration_2 = node.kind !== 75 /* Identifier */; if (isDeclaration_2) { error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } @@ -57276,7 +60165,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { // If the declaration happens to be in external module, report error that require and exports are reserved keywords error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57291,7 +60180,7 @@ var ts; } // In case of variable declaration, node.parent is variable statement so look at the variable statement's parent var parent = getDeclarationContainer(node); - if (parent.kind === 285 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 288 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048 /* HasAsyncFunctions */) { // If the declaration happens to be in external module, report error that Promise is a reserved identifier. error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions, ts.declarationNameToString(name), ts.declarationNameToString(name)); } @@ -57326,7 +60215,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 238 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 241 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -57338,17 +60227,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 239 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 220 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 242 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 224 /* VariableStatement */ && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; // names of block-scoped and function scoped variables can collide only // if block scoped variable is defined in the function\module\source file scope (because of variable hoisting) var namesShareScope = container && - (container.kind === 219 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 246 /* ModuleBlock */ || - container.kind === 245 /* ModuleDeclaration */ || - container.kind === 285 /* SourceFile */); + (container.kind === 222 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 249 /* ModuleBlock */ || + container.kind === 248 /* ModuleDeclaration */ || + container.kind === 288 /* SourceFile */); // here we know that function scoped variable is shadowed by block scoped one // if they are defined in the same scope - binder has already reported redeclaration error // otherwise if variable has an initializer - show error that initialization will fail @@ -57378,18 +60267,18 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 150 /* ComputedPropertyName */) { + if (node.name.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 187 /* BindingElement */) { - if (node.parent.kind === 185 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { + if (node.kind === 190 /* BindingElement */) { + if (node.parent.kind === 188 /* ObjectBindingPattern */ && languageVersion < 99 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 150 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 153 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -57403,26 +60292,26 @@ var ts; var property = getPropertyOfType(parentType, nameText); if (property) { markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined, /*isThisAccess*/ false); // A destructuring is never a write-only reference. - checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 99 /* SuperKeyword */, parentType, property); + checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 101 /* SuperKeyword */, parentType, property); } } } } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { - if (node.name.kind === 186 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + if (node.name.kind === 189 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, 512 /* Read */); } ts.forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && ts.getRootDeclaration(node).kind === 152 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 155 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (ts.isBindingPattern(node.name)) { - var needCheckInitializer = node.initializer && node.parent.parent.kind !== 227 /* ForInStatement */; + var needCheckInitializer = node.initializer && node.parent.parent.kind !== 230 /* ForInStatement */; var needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -57459,7 +60348,7 @@ var ts; ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) && ts.hasEntries(symbol.exports); - if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 227 /* ForInStatement */) { + if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 230 /* ForInStatement */) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); } } @@ -57485,10 +60374,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */) { + if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithRequireExportsInGeneratedCode(node, node.name); @@ -57497,7 +60386,7 @@ var ts; } function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) { var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration); - var message = nextDeclaration.kind === 155 /* PropertyDeclaration */ || nextDeclaration.kind === 154 /* PropertySignature */ + var message = nextDeclaration.kind === 158 /* PropertyDeclaration */ || nextDeclaration.kind === 157 /* PropertySignature */ ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2; var declName = ts.declarationNameToString(nextDeclarationName); @@ -57507,8 +60396,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 152 /* Parameter */ && right.kind === 238 /* VariableDeclaration */) || - (left.kind === 238 /* VariableDeclaration */ && right.kind === 152 /* Parameter */)) { + if ((left.kind === 155 /* Parameter */ && right.kind === 241 /* VariableDeclaration */) || + (left.kind === 241 /* VariableDeclaration */ && right.kind === 155 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -57545,13 +60434,56 @@ var ts; function checkIfStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); - checkTruthinessExpression(node.expression); + var type = checkTruthinessExpression(node.expression); + checkTestingKnownTruthyCallableType(node, type); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 221 /* EmptyStatement */) { + if (node.thenStatement.kind === 223 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); } + function checkTestingKnownTruthyCallableType(ifStatement, type) { + if (!strictNullChecks) { + return; + } + var testedNode = ts.isIdentifier(ifStatement.expression) + ? ifStatement.expression + : ts.isPropertyAccessExpression(ifStatement.expression) + ? ifStatement.expression.name + : undefined; + if (!testedNode) { + return; + } + var possiblyFalsy = getFalsyFlags(type); + if (possiblyFalsy) { + return; + } + // While it technically should be invalid for any known-truthy value + // to be tested, we de-scope to functions unrefenced in the block as a + // heuristic to identify the most common bugs. There are too many + // false positives for values sourced from type definitions without + // strictNullChecks otherwise. + var callSignatures = getSignaturesOfType(type, 0 /* Call */); + if (callSignatures.length === 0) { + return; + } + var testedFunctionSymbol = getSymbolAtLocation(testedNode); + if (!testedFunctionSymbol) { + return; + } + var functionIsUsedInBody = ts.forEachChild(ifStatement.thenStatement, function check(childNode) { + if (ts.isIdentifier(childNode)) { + var childSymbol = getSymbolAtLocation(childNode); + if (childSymbol && childSymbol.id === testedFunctionSymbol.id) { + return true; + } + } + return ts.forEachChild(childNode, check); + }); + if (!functionIsUsedInBody) { + error(ifStatement.expression, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead); + } + } function checkDoStatement(node) { // Grammar checking checkGrammarStatementInAmbientContext(node); @@ -57574,12 +60506,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 242 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -57613,14 +60545,14 @@ var ts; // via checkRightHandSideOfForOf. // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { // iteratedType may be undefined. In this case, we still want to check the structure of // varExpr, in particular making sure it's a valid LeftHandSideExpression. But we'd like // to short circuit the type relation checking as much as possible, so we pass the unknownType. @@ -57628,7 +60560,7 @@ var ts; } else { var leftType = checkExpression(varExpr); - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_may_not_be_an_optional_property_access); // iteratedType will be undefined if the rightType was missing properties/signatures // required to get its iteratedType (like [Symbol.iterator] or next). This may be // because we accessed properties from anyType, or it may have led to an error inside @@ -57652,7 +60584,7 @@ var ts; // for (let VarDecl in Expr) Statement // VarDecl must be a variable declaration without a type annotation that declares a variable of type Any, // and Expr must be an expression of type Any, an object type, or a type parameter type. - if (node.initializer.kind === 239 /* VariableDeclarationList */) { + if (node.initializer.kind === 242 /* VariableDeclarationList */) { var variable = node.initializer.declarations[0]; if (variable && ts.isBindingPattern(variable.name)) { error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); @@ -57666,7 +60598,7 @@ var ts; // and Expr must be an expression of type Any, an object type, or a type parameter type. var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 188 /* ArrayLiteralExpression */ || varExpr.kind === 189 /* ObjectLiteralExpression */) { + if (varExpr.kind === 191 /* ArrayLiteralExpression */ || varExpr.kind === 192 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -57674,7 +60606,7 @@ var ts; } else { // run check only former check succeeded to avoid cascading errors - checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); + checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_may_not_be_an_optional_property_access); } } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved @@ -58027,7 +60959,7 @@ var ts; var globalType; if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(/*reportErrors*/ false)) || isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false))) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `Iterable` and `IterableIterator` are defined by the // iteration types of their `[Symbol.iterator]()` method. The same is true for their async cousins. // While we define these as `any` and `undefined` in our libs by default, a custom lib *could* use @@ -58039,7 +60971,7 @@ var ts; // just grab its related type arguments: // - `Generator` or `AsyncGenerator` if (isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iterableCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58118,7 +61050,7 @@ var ts; // - `Generator` or `AsyncGenerator` var globalType = resolver.getGlobalIterableIteratorType(/*reportErrors*/ false); if (isReferenceToType(type, globalType)) { - var yieldType = type.typeArguments[0]; + var yieldType = getTypeArguments(type)[0]; // The "return" and "next" types of `IterableIterator` and `AsyncIterableIterator` are defined by the // iteration types of their `next`, `return`, and `throw` methods. While we define these as `any` // and `undefined` in our libs by default, a custom lib *could* use different definitions. @@ -58129,7 +61061,7 @@ var ts; } if (isReferenceToType(type, resolver.getGlobalIteratorType(/*reportErrors*/ false)) || isReferenceToType(type, resolver.getGlobalGeneratorType(/*reportErrors*/ false))) { - var _b = type.typeArguments, yieldType = _b[0], returnType = _b[1], nextType = _b[2]; + var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2]; return type[resolver.iteratorCacheKey] = createIterationTypes(yieldType, returnType, nextType); } } @@ -58165,11 +61097,11 @@ var ts; // As an optimization, if the type is an instantiation of one of the global `IteratorYieldResult` // or `IteratorReturnResult` types, then just grab its type argument. if (isReferenceToType(type, getGlobalIteratorYieldResultType(/*reportErrors*/ false))) { - var yieldType_1 = type.typeArguments[0]; + var yieldType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(yieldType_1, /*returnType*/ undefined, /*nextType*/ undefined); } if (isReferenceToType(type, getGlobalIteratorReturnResultType(/*reportErrors*/ false))) { - var returnType_1 = type.typeArguments[0]; + var returnType_1 = getTypeArguments(type)[0]; return type.iterationTypesOfIteratorResult = createIterationTypes(/*yieldType*/ undefined, returnType_1, /*nextType*/ undefined); } // Choose any constituents that can produce the requested iteration type. @@ -58233,11 +61165,13 @@ var ts; var nextType; if (methodName !== "throw") { var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType; - var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; if (methodName === "next") { - nextType = resolvedMethodParameterType; + // The value of `next(value)` is *not* awaited by async generators + nextType = methodParameterType; } else if (methodName === "return") { + // The value of `return(value)` *is* awaited by async generators + var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType; returnTypes = ts.append(returnTypes, resolvedMethodParameterType); } } @@ -58330,12 +61264,12 @@ var ts; var functionFlags = ts.getFunctionFlags(func); if (strictNullChecks || node.expression || returnType.flags & 131072 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.kind === 160 /* SetAccessor */) { + if (func.kind === 163 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 158 /* Constructor */) { + else if (func.kind === 161 /* Constructor */) { if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -58353,7 +61287,7 @@ var ts; } } } - else if (func.kind !== 158 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 161 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -58361,7 +61295,7 @@ var ts; function checkWithStatement(node) { // Grammar checking for withStatement if (!checkGrammarStatementInAmbientContext(node)) { - if (node.flags & 16384 /* AwaitContext */) { + if (node.flags & 32768 /* AwaitContext */) { grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block); } } @@ -58382,19 +61316,16 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 273 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 276 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } else { - var sourceFile = ts.getSourceFileOfNode(node); - var start = ts.skipTrivia(sourceFile.text, clause.pos); - var end = clause.statements.length > 0 ? clause.statements[0].pos : clause.end; - grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); + grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement); hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 272 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 275 /* CaseClause */) { // TypeScript 1.0 spec (April 2014): 5.9 // In a 'switch' statement, each 'case' expression must be of a type that is comparable // to or from the type of the 'switch' expression. @@ -58411,6 +61342,9 @@ var ts; } } ts.forEach(clause.statements, checkSourceElement); + if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) { + error(clause, ts.Diagnostics.Fallthrough_case_in_switch); + } }); if (node.caseBlock.locals) { registerForUnusedIdentifiersCheck(node.caseBlock); @@ -58423,7 +61357,7 @@ var ts; if (ts.isFunctionLike(current)) { return "quit"; } - if (current.kind === 234 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { + if (current.kind === 237 /* LabeledStatement */ && current.label.escapedText === node.label.escapedText) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label)); return true; } @@ -58530,8 +61464,8 @@ var ts; // this allows us to rule out cases when both property and indexer are inherited from the base class var errorNode; if (propDeclaration && name && - (propDeclaration.kind === 205 /* BinaryExpression */ || - name.kind === 150 /* ComputedPropertyName */ || + (propDeclaration.kind === 208 /* BinaryExpression */ || + name.kind === 153 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } @@ -58608,7 +61542,7 @@ var ts; function checkTypeParametersNotReferenced(root, typeParameters, index) { visit(root); function visit(node) { - if (node.kind === 165 /* TypeReference */) { + if (node.kind === 168 /* TypeReference */) { var type = getTypeFromTypeReference(node); if (type.flags & 262144 /* TypeParameter */) { for (var i = index; i < typeParameters.length; i++) { @@ -58708,7 +61642,7 @@ var ts; checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassNameCollisionWithObject(node.name); } } @@ -58721,11 +61655,12 @@ var ts; checkTypeParameterListsIdentical(symbol); checkClassForDuplicateDeclarations(node); // Only check for reserved static identifiers on non-ambient context. - if (!(node.flags & 4194304 /* Ambient */)) { + if (!(node.flags & 8388608 /* Ambient */)) { checkClassForStaticPropertyNameConflicts(node); } var baseTypeNode = ts.getEffectiveBaseTypeNode(node); if (baseTypeNode) { + ts.forEach(baseTypeNode.typeArguments, checkSourceElement); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } @@ -58763,12 +61698,9 @@ var ts; } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 8650752 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify - // that all instantiated base constructor signatures return the same type. We can simply compare the type - // references (as opposed to checking the structure of the types) because elsewhere we have already checked - // that the base type is a class or interface type (and not, for example, an anonymous object type). - // (Javascript constructor functions have this property trivially true since their return type is ignored.) + // that all instantiated base constructor signatures return the same type. var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); - if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && getReturnTypeOfSignature(sig) !== baseType_1; })) { + if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) { error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type); } } @@ -58811,7 +61743,7 @@ var ts; function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) { // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible var issuedMemberError = false; - var _loop_14 = function (member) { + var _loop_16 = function (member) { if (ts.hasStaticModifier(member)) { return "continue"; } @@ -58830,7 +61762,7 @@ var ts; }; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - _loop_14(member); + _loop_16(member); } if (!issuedMemberError) { // check again with diagnostics to generate a less-specific error @@ -58856,7 +61788,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 241 /* ClassDeclaration */ || d.kind === 242 /* InterfaceDeclaration */; + return d.kind === 244 /* ClassDeclaration */ || d.kind === 245 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -58907,7 +61839,7 @@ var ts; continue basePropertyCheck; } } - if (derivedClassDecl.kind === 210 /* ClassExpression */) { + if (derivedClassDecl.kind === 213 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -58922,17 +61854,55 @@ var ts; // either base or derived property is private - not override, skip it continue; } - if (isPrototypeProperty(base) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { - // method is overridden with method or property/accessor is overridden with property/accessor - correct case - continue; - } var errorMessage = void 0; - if (isPrototypeProperty(base)) { - if (derived.flags & 98304 /* Accessor */) { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; + var basePropertyFlags = base.flags & 98308 /* PropertyOrAccessor */; + var derivedPropertyFlags = derived.flags & 98308 /* PropertyOrAccessor */; + if (basePropertyFlags && derivedPropertyFlags) { + // property/accessor is overridden with property/accessor + if (!compilerOptions.useDefineForClassFields + || baseDeclarationFlags & 128 /* Abstract */ && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer) + || base.valueDeclaration && base.valueDeclaration.parent.kind === 245 /* InterfaceDeclaration */ + || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) { + // when the base property is abstract or from an interface, base/derived flags don't need to match + // same when the derived property is from an assignment + continue; + } + if (basePropertyFlags !== 4 /* Property */ && derivedPropertyFlags === 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_property; + } + else if (basePropertyFlags === 4 /* Property */ && derivedPropertyFlags !== 4 /* Property */) { + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; + var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 158 /* PropertyDeclaration */ && !d.initializer; }); + if (uninitialized + && !(derived.flags & 33554432 /* Transient */) + && !(baseDeclarationFlags & 128 /* Abstract */) + && !(derivedDeclarationFlags & 128 /* Abstract */) + && !derived.declarations.some(function (d) { return d.flags & 8388608 /* Ambient */; })) { + var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol)); + var propName = uninitialized.name; + if (uninitialized.exclamationToken + || !constructor + || !ts.isIdentifier(propName) + || !strictNullChecks + || !isPropertyInitializedInConstructor(propName, type, constructor)) { + var errorMessage_1 = ts.Diagnostics.Property_0_will_overwrite_the_base_property_in_1_If_this_is_intentional_add_an_initializer_Otherwise_add_a_declare_modifier_or_remove_the_redundant_declaration; + error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType)); + } + } + // correct case + continue; + } + } + else if (isPrototypeProperty(base)) { + if (isPrototypeProperty(derived) || derived.flags & 4 /* Property */) { + // method is overridden with method or property -- correct case + continue; + } + else { + ts.Debug.assert(!!(derived.flags & 98304 /* Accessor */)); + errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } } else if (base.flags & 98304 /* Accessor */) { @@ -58978,12 +61948,15 @@ var ts; return ok; } function checkPropertyInitialization(node) { - if (!strictNullChecks || !strictPropertyInitialization || node.flags & 4194304 /* Ambient */) { + if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608 /* Ambient */) { return; } var constructor = findConstructorDeclaration(node); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; + if (ts.getModifierFlags(member) & 2 /* Ambient */) { + continue; + } if (isInstancePropertyWithoutInitializer(member)) { var propName = member.name; if (ts.isIdentifier(propName)) { @@ -58998,7 +61971,7 @@ var ts; } } function isInstancePropertyWithoutInitializer(node) { - return node.kind === 155 /* PropertyDeclaration */ && + return node.kind === 158 /* PropertyDeclaration */ && !ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */) && !node.exclamationToken && !node.initializer; @@ -59022,7 +61995,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 242 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 245 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -59085,7 +62058,7 @@ var ts; } // In ambient non-const numeric enum declarations, enum members without initializers are // considered computed members (as opposed to having auto-incremented values). - if (member.parent.flags & 4194304 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { + if (member.parent.flags & 8388608 /* Ambient */ && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0 /* Numeric */) { return undefined; } // If the member declaration specifies no value, the member is considered a constant enum member. @@ -59117,7 +62090,7 @@ var ts; else if (isConstEnum) { error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values); } - else if (member.parent.flags & 4194304 /* Ambient */) { + else if (member.parent.flags & 8388608 /* Ambient */) { error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression); } else { @@ -59127,66 +62100,65 @@ var ts; return value; function evaluate(expr) { switch (expr.kind) { - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: var value_2 = evaluate(expr.operand); if (typeof value_2 === "number") { switch (expr.operator) { - case 38 /* PlusToken */: return value_2; - case 39 /* MinusToken */: return -value_2; - case 53 /* TildeToken */: return ~value_2; + case 39 /* PlusToken */: return value_2; + case 40 /* MinusToken */: return -value_2; + case 54 /* TildeToken */: return ~value_2; } } break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: var left = evaluate(expr.left); var right = evaluate(expr.right); if (typeof left === "number" && typeof right === "number") { switch (expr.operatorToken.kind) { - case 50 /* BarToken */: return left | right; - case 49 /* AmpersandToken */: return left & right; - case 47 /* GreaterThanGreaterThanToken */: return left >> right; - case 48 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 46 /* LessThanLessThanToken */: return left << right; - case 51 /* CaretToken */: return left ^ right; - case 40 /* AsteriskToken */: return left * right; - case 42 /* SlashToken */: return left / right; - case 38 /* PlusToken */: return left + right; - case 39 /* MinusToken */: return left - right; - case 43 /* PercentToken */: return left % right; - case 41 /* AsteriskAsteriskToken */: return Math.pow(left, right); + case 51 /* BarToken */: return left | right; + case 50 /* AmpersandToken */: return left & right; + case 48 /* GreaterThanGreaterThanToken */: return left >> right; + case 49 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 47 /* LessThanLessThanToken */: return left << right; + case 52 /* CaretToken */: return left ^ right; + case 41 /* AsteriskToken */: return left * right; + case 43 /* SlashToken */: return left / right; + case 39 /* PlusToken */: return left + right; + case 40 /* MinusToken */: return left - right; + case 44 /* PercentToken */: return left % right; + case 42 /* AsteriskAsteriskToken */: return Math.pow(left, right); } } - else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 38 /* PlusToken */) { + else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39 /* PlusToken */) { return left + right; } break; case 10 /* StringLiteral */: + case 14 /* NoSubstitutionTemplateLiteral */: return expr.text; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(expr); return +expr.text; - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return evaluate(expr.expression); - case 73 /* Identifier */: + case 75 /* Identifier */: var identifier = expr; if (isInfinityOrNaNString(identifier.escapedText)) { return +(identifier.escapedText); } return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText); - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: var ex = expr; if (isConstantMemberAccess(ex)) { var type = getTypeOfExpression(ex.expression); if (type.symbol && type.symbol.flags & 384 /* Enum */) { var name = void 0; - if (ex.kind === 190 /* PropertyAccessExpression */) { + if (ex.kind === 193 /* PropertyAccessExpression */) { name = ex.name.escapedText; } else { - var argument = ex.argumentExpression; - ts.Debug.assert(ts.isLiteralExpression(argument)); - name = ts.escapeLeadingUnderscores(argument.text); + name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text); } return evaluateEnumMember(expr, type.symbol, name); } @@ -59211,10 +62183,10 @@ var ts; } } function isConstantMemberAccess(node) { - return node.kind === 73 /* Identifier */ || - node.kind === 190 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || - node.kind === 191 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && - node.argumentExpression.kind === 10 /* StringLiteral */; + return node.kind === 75 /* Identifier */ || + node.kind === 193 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) || + node.kind === 194 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) && + ts.isStringLiteralLike(node.argumentExpression); } function checkEnumDeclaration(node) { if (!produceDiagnostics) { @@ -59248,7 +62220,7 @@ var ts; var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { // return true if we hit a violation of the rule, false otherwise - if (declaration.kind !== 244 /* EnumDeclaration */) { + if (declaration.kind !== 247 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -59271,9 +62243,9 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 241 /* ClassDeclaration */ || - (declaration.kind === 240 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && - !(declaration.flags & 4194304 /* Ambient */)) { + if ((declaration.kind === 244 /* ClassDeclaration */ || + (declaration.kind === 243 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + !(declaration.flags & 8388608 /* Ambient */)) { return declaration; } } @@ -59296,7 +62268,7 @@ var ts; if (produceDiagnostics) { // Grammar checking var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node); - var inAmbientContext = node.flags & 4194304 /* Ambient */; + var inAmbientContext = node.flags & 8388608 /* Ambient */; if (isGlobalAugmentation && !inAmbientContext) { error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context); } @@ -59335,7 +62307,7 @@ var ts; } // if the module merges with a class declaration in the same lexical scope, // we need to track this to ensure the correct emit. - var mergedClass = ts.getDeclarationOfKind(symbol, 241 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 244 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -59385,23 +62357,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // error each individual name in variable statement instead of marking the entire variable statement for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 187 /* BindingElement */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 241 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -59412,12 +62384,12 @@ var ts; break; } // falls through - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 240 /* FunctionDeclaration */: - case 242 /* InterfaceDeclaration */: - case 245 /* ModuleDeclaration */: - case 243 /* TypeAliasDeclaration */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 245 /* InterfaceDeclaration */: + case 248 /* ModuleDeclaration */: + case 246 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -59436,19 +62408,22 @@ var ts; break; } } - function getFirstIdentifier(node) { + function getFirstNonModuleExportsIdentifier(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return node; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: do { + if (ts.isModuleExportsAccessExpression(node.expression)) { + return node.name; + } node = node.expression; - } while (node.kind !== 73 /* Identifier */); + } while (node.kind !== 75 /* Identifier */); return node; } } @@ -59462,9 +62437,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 256 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 259 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -59494,20 +62469,21 @@ var ts; // Based on symbol.flags we can compute a set of excluded meanings (meaning that resolved alias should not have, // otherwise it will conflict with some local declaration). Note that in addition to normal flags we include matching SymbolFlags.Export* // in order to prevent collisions with declarations that were exported from the current module (they still contribute to local names). + symbol = getMergedSymbol(symbol.exportSymbol || symbol); var excludedMeanings = (symbol.flags & (111551 /* Value */ | 1048576 /* ExportValue */) ? 111551 /* Value */ : 0) | (symbol.flags & 788968 /* Type */ ? 788968 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 258 /* ExportSpecifier */ ? + var message = node.kind === 261 /* ExportSpecifier */ ? ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 : ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } // Don't allow to re-export something with no value side when `--isolatedModules` is set. if (compilerOptions.isolatedModules - && node.kind === 258 /* ExportSpecifier */ + && node.kind === 261 /* ExportSpecifier */ && !(target.flags & 111551 /* Value */) - && !(node.flags & 4194304 /* Ambient */)) { + && !(node.flags & 8388608 /* Ambient */)) { error(node, ts.Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); } } @@ -59532,7 +62508,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 255 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -59556,12 +62532,12 @@ var ts; if (ts.hasModifier(node, 1 /* Export */)) { markExportAsReferenced(node); } - if (node.moduleReference.kind !== 260 /* ExternalModuleReference */) { + if (node.moduleReference.kind !== 263 /* ExternalModuleReference */) { var target = resolveAlias(getSymbolOfNode(node)); if (target !== unknownSymbol) { if (target.flags & 111551 /* Value */) { // Target is a value symbol, check that it is not hidden by a local declaration with the same name - var moduleName = getFirstIdentifier(node.moduleReference); + var moduleName = ts.getFirstIdentifier(node.moduleReference); if (!(resolveEntityName(moduleName, 111551 /* Value */ | 1920 /* Namespace */).flags & 1920 /* Namespace */)) { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName)); } @@ -59572,7 +62548,7 @@ var ts; } } else { - if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 4194304 /* Ambient */)) { + if (moduleKind >= ts.ModuleKind.ES2015 && !(node.flags & 8388608 /* Ambient */)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -59592,10 +62568,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 246 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 246 /* ModuleBlock */ && - !node.moduleSpecifier && node.flags & 4194304 /* Ambient */; - if (node.parent.kind !== 285 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + var inAmbientExternalModule = node.parent.kind === 249 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 249 /* ModuleBlock */ && + !node.moduleSpecifier && node.flags & 8388608 /* Ambient */; + if (node.parent.kind !== 288 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -59612,7 +62588,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 285 /* SourceFile */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 245 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 288 /* SourceFile */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 248 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -59628,7 +62604,7 @@ var ts; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.escapedText, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); - if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { + if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName)); } else { @@ -59645,8 +62621,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -59659,7 +62635,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasModifiers(node)) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { var id = node.expression; var sym = resolveEntityName(id, 67108863 /* All */, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node); if (sym) { @@ -59679,10 +62655,10 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); - if ((node.flags & 4194304 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { + if ((node.flags & 8388608 /* Ambient */) && !ts.isEntityNameExpression(node.expression)) { grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); } - if (node.isExportEquals && !(node.flags & 4194304 /* Ambient */)) { + if (node.isExportEquals && !(node.flags & 8388608 /* Ambient */)) { if (moduleKind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); @@ -59708,9 +62684,9 @@ var ts; } } // Checks for export * conflicts - var exports_1 = getExportsOfModule(moduleSymbol); - if (exports_1) { - exports_1.forEach(function (_a, id) { + var exports_2 = getExportsOfModule(moduleSymbol); + if (exports_2) { + exports_2.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -59760,159 +62736,162 @@ var ts; // Only bother checking on a few construct kinds. We don't want to be excessively // hitting the cancellation token on every node we check. switch (kind) { - case 245 /* ModuleDeclaration */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 240 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 243 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } + if (kind >= 224 /* FirstStatement */ && kind <= 240 /* LastStatement */ && node.flowNode && !isReachableFlowNode(node.flowNode)) { + errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected); + } switch (kind) { - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return checkTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return checkParameter(node); - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return checkPropertyDeclaration(node); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 161 /* CallSignature */: - case 162 /* ConstructSignature */: - case 163 /* IndexSignature */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 164 /* CallSignature */: + case 165 /* ConstructSignature */: + case 166 /* IndexSignature */: return checkSignatureDeclaration(node); - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: return checkMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return checkConstructorDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return checkAccessorDeclaration(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return checkTypeReferenceNode(node); - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return checkTypePredicate(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return checkTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return checkTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return checkArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return checkTupleType(node); - case 174 /* UnionType */: - case 175 /* IntersectionType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 178 /* ParenthesizedType */: - case 172 /* OptionalType */: - case 173 /* RestType */: + case 181 /* ParenthesizedType */: + case 175 /* OptionalType */: + case 176 /* RestType */: return checkSourceElement(node.type); - case 179 /* ThisType */: + case 182 /* ThisType */: return checkThisType(node); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return checkTypeOperator(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return checkConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return checkInferType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return checkImportType(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return checkJSDocAugmentsTag(node); - case 312 /* JSDocTypedefTag */: - case 305 /* JSDocCallbackTag */: - case 306 /* JSDocEnumTag */: + case 315 /* JSDocTypedefTag */: + case 308 /* JSDocCallbackTag */: + case 309 /* JSDocEnumTag */: return checkJSDocTypeAliasTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return checkJSDocTemplateTag(node); - case 310 /* JSDocTypeTag */: + case 313 /* JSDocTypeTag */: return checkJSDocTypeTag(node); - case 307 /* JSDocParameterTag */: + case 310 /* JSDocParameterTag */: return checkJSDocParameterTag(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: checkJSDocFunctionType(node); // falls through - case 293 /* JSDocNonNullableType */: - case 292 /* JSDocNullableType */: - case 290 /* JSDocAllType */: - case 291 /* JSDocUnknownType */: - case 299 /* JSDocTypeLiteral */: + case 296 /* JSDocNonNullableType */: + case 295 /* JSDocNullableType */: + case 293 /* JSDocAllType */: + case 294 /* JSDocUnknownType */: + case 302 /* JSDocTypeLiteral */: checkJSDocTypeIsInJsFile(node); ts.forEachChild(node, checkSourceElement); return; - case 296 /* JSDocVariadicType */: + case 299 /* JSDocVariadicType */: checkJSDocVariadicType(node); return; - case 289 /* JSDocTypeExpression */: + case 292 /* JSDocTypeExpression */: return checkSourceElement(node.type); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return checkMappedType(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 219 /* Block */: - case 246 /* ModuleBlock */: + case 222 /* Block */: + case 249 /* ModuleBlock */: return checkBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return checkVariableStatement(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return checkExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return checkIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return checkDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return checkWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return checkForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return checkForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return checkForOfStatement(node); - case 229 /* ContinueStatement */: - case 230 /* BreakStatement */: + case 232 /* ContinueStatement */: + case 233 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return checkReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return checkWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return checkSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return checkLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return checkThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return checkTryStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return checkBindingElement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return checkClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return checkImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return checkExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return checkExportAssignment(node); - case 221 /* EmptyStatement */: - case 237 /* DebuggerStatement */: + case 223 /* EmptyStatement */: + case 240 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -60007,23 +62986,23 @@ var ts; currentNode = node; instantiationCount = 0; switch (node.kind) { - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: checkAccessorDeclaration(node); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: checkClassExpressionDeferred(node); break; - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: checkJsxSelfClosingElementDeferred(node); break; - case 261 /* JsxElement */: + case 264 /* JsxElement */: checkJsxElementDeferred(node); break; } @@ -60052,7 +63031,7 @@ var ts; function checkSourceFileWorker(node) { var links = getNodeLinks(node); if (!(links.flags & 1 /* TypeChecked */)) { - if (ts.skipTypeChecking(node, compilerOptions)) { + if (ts.skipTypeChecking(node, compilerOptions, host)) { return; } // Grammar checking @@ -60138,7 +63117,7 @@ var ts; } // Language service support function getSymbolsInScope(location, meaning) { - if (location.flags & 8388608 /* InWithStatement */) { + if (location.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } @@ -60153,26 +63132,26 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 285 /* SourceFile */: + case 288 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; // falls through - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 2623475 /* ModuleMember */); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // falls through // this fall-through is necessary because we would like to handle - // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: + // type parameter inside class expression similar to how we handle it in classDeclaration and interface Declaration. + // falls through + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: // If we didn't come from static member of class or interface, // add the type parameters into the symbol table // (type parameters of classDeclaration/classExpression and interface are in member property of the symbol. @@ -60181,7 +63160,7 @@ var ts; copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968 /* Type */); } break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -60223,17 +63202,17 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 73 /* Identifier */ && + return name.kind === 75 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 151 /* TypeParameter */: - case 241 /* ClassDeclaration */: - case 242 /* InterfaceDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 154 /* TypeParameter */: + case 244 /* ClassDeclaration */: + case 245 /* InterfaceDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return true; default: return false; @@ -60241,16 +63220,16 @@ var ts; } // True if the given identifier is part of a type reference function isTypeReferenceIdentifier(node) { - while (node.parent.kind === 149 /* QualifiedName */) { + while (node.parent.kind === 152 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 165 /* TypeReference */; + return node.parent.kind === 168 /* TypeReference */; } function isHeritageClauseElementIdentifier(node) { - while (node.parent.kind === 190 /* PropertyAccessExpression */) { + while (node.parent.kind === 193 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent.kind === 212 /* ExpressionWithTypeArguments */; + return node.parent.kind === 215 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -60278,13 +63257,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 149 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 152 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 249 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 252 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } - if (nodeOnRightSide.parent.kind === 255 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 258 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined; } return undefined; @@ -60310,7 +63289,7 @@ var ts; node = parent; parent = parent.parent; } - if (parent && parent.kind === 184 /* ImportType */ && parent.qualifier === node) { + if (parent && parent.kind === 187 /* ImportType */ && parent.qualifier === node) { return parent; } return undefined; @@ -60320,7 +63299,7 @@ var ts; return getSymbolOfNode(entityName.parent); } if (ts.isInJSFile(entityName) && - entityName.parent.kind === 190 /* PropertyAccessExpression */ && + entityName.parent.kind === 193 /* PropertyAccessExpression */ && entityName.parent === entityName.parent.parent.left) { // Check if this is a special property assignment var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); @@ -60328,7 +63307,7 @@ var ts; return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 255 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 258 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { // Even an entity name expression that doesn't resolve as an entityname may still typecheck as a property access expression var success = resolveEntityName(entityName, /*all meanings*/ 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, /*ignoreErrors*/ true); @@ -60338,7 +63317,7 @@ var ts; } else if (!ts.isPropertyAccessExpression(entityName) && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 249 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 252 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -60356,7 +63335,7 @@ var ts; if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0 /* None */; // In an interface or class, we're definitely interested in a type. - if (entityName.parent.kind === 212 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 215 /* ExpressionWithTypeArguments */) { meaning = 788968 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -60372,10 +63351,10 @@ var ts; return entityNameSymbol; } } - if (entityName.parent.kind === 307 /* JSDocParameterTag */) { + if (entityName.parent.kind === 310 /* JSDocParameterTag */) { return ts.getParameterSymbolFromJSDoc(entityName.parent); } - if (entityName.parent.kind === 151 /* TypeParameter */ && entityName.parent.parent.kind === 311 /* JSDocTemplateTag */) { + if (entityName.parent.kind === 154 /* TypeParameter */ && entityName.parent.parent.kind === 314 /* JSDocTemplateTag */) { ts.Debug.assert(!ts.isInJSFile(entityName)); // Otherwise `isDeclarationName` would have been true. var typeParameter = ts.getTypeParameterFromJsDoc(entityName.parent); return typeParameter && typeParameter.symbol; @@ -60385,19 +63364,19 @@ var ts; // Missing entity name. return undefined; } - if (entityName.kind === 73 /* Identifier */) { + if (entityName.kind === 75 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { var symbol = getIntrinsicTagSymbol(entityName.parent); return symbol === unknownSymbol ? undefined : symbol; } return resolveEntityName(entityName, 111551 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 190 /* PropertyAccessExpression */ || entityName.kind === 149 /* QualifiedName */) { + else if (entityName.kind === 193 /* PropertyAccessExpression */ || entityName.kind === 152 /* QualifiedName */) { var links = getNodeLinks(entityName); if (links.resolvedSymbol) { return links.resolvedSymbol; } - if (entityName.kind === 190 /* PropertyAccessExpression */) { + if (entityName.kind === 193 /* PropertyAccessExpression */) { checkPropertyAccessExpression(entityName); } else { @@ -60407,22 +63386,22 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 165 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; + var meaning = entityName.parent.kind === 168 /* TypeReference */ ? 788968 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - if (entityName.parent.kind === 164 /* TypePredicate */) { + if (entityName.parent.kind === 167 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } var parent = node.parent; var grandParent = parent.parent; - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; } @@ -60436,12 +63415,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(parent.parent); } - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (parent.kind === 187 /* BindingElement */ && - grandParent.kind === 185 /* ObjectBindingPattern */ && + else if (parent.kind === 190 /* BindingElement */ && + grandParent.kind === 188 /* ObjectBindingPattern */ && node === parent.propertyName) { var typeOfPattern = getTypeOfNode(grandParent); var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText); @@ -60451,11 +63430,11 @@ var ts; } } switch (node.kind) { - case 73 /* Identifier */: - case 190 /* PropertyAccessExpression */: - case 149 /* QualifiedName */: + case 75 /* Identifier */: + case 193 /* PropertyAccessExpression */: + case 152 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -60467,14 +63446,14 @@ var ts; return checkExpression(node).symbol; } // falls through - case 179 /* ThisType */: + case 182 /* ThisType */: return getTypeFromThisTypeNode(node).symbol; - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return checkExpression(node).symbol; - case 125 /* ConstructorKeyword */: + case 128 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 158 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 161 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -60485,7 +63464,7 @@ var ts; // 3). Dynamic import call or require in javascript // 4). type A = import("./f/*gotToDefinitionHere*/oo") if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 250 /* ImportDeclaration */ || node.parent.kind === 256 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || + ((node.parent.kind === 253 /* ImportDeclaration */ || node.parent.kind === 259 /* ExportDeclaration */) && node.parent.moduleSpecifier === node) || ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteralLike*/ false)) || ts.isImportCall(node.parent)) || (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) { return resolveExternalModuleName(node, node); @@ -60502,21 +63481,21 @@ var ts; ? getTypeFromTypeNode(grandParent.objectType) : undefined; return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); - case 81 /* DefaultKeyword */: - case 91 /* FunctionKeyword */: - case 37 /* EqualsGreaterThanToken */: - case 77 /* ClassKeyword */: + case 83 /* DefaultKeyword */: + case 93 /* FunctionKeyword */: + case 38 /* EqualsGreaterThanToken */: + case 79 /* ClassKeyword */: return getSymbolOfNode(node.parent); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal) : undefined; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: return ts.isExportAssignment(node.parent) ? ts.Debug.assertDefined(node.parent.symbol) : undefined; default: return undefined; } } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 277 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 280 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 111551 /* Value */ | 2097152 /* Alias */); } return undefined; @@ -60528,7 +63507,7 @@ var ts; resolveEntityName(node.propertyName || node.name, 111551 /* Value */ | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); } function getTypeOfNode(node) { - if (node.flags & 8388608 /* InWithStatement */) { + if (node.flags & 16777216 /* InWithStatement */) { // We cannot answer semantic questions within a with block, do not proceed any further return errorType; } @@ -60584,27 +63563,27 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfAssignmentPattern(expr) { - ts.Debug.assert(expr.kind === 189 /* ObjectLiteralExpression */ || expr.kind === 188 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 192 /* ObjectLiteralExpression */ || expr.kind === 191 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 228 /* ForOfStatement */) { + if (expr.parent.kind === 231 /* ForOfStatement */) { var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 205 /* BinaryExpression */) { + if (expr.parent.kind === 208 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || errorType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 276 /* PropertyAssignment */) { - var node_3 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); - var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_3) || errorType; - var propertyIndex = ts.indexOfNode(node_3.properties, expr.parent); - return checkObjectLiteralDestructuringPropertyAssignment(node_3, typeOfParentObjectLiteral, propertyIndex); + if (expr.parent.kind === 279 /* PropertyAssignment */) { + var node_4 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression); + var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_4) || errorType; + var propertyIndex = ts.indexOfNode(node_4.properties, expr.parent); + return checkObjectLiteralDestructuringPropertyAssignment(node_4, typeOfParentObjectLiteral, propertyIndex); } // Array literal assignment - array destructuring pattern var node = ts.cast(expr.parent, ts.isArrayLiteralExpression); @@ -60643,17 +63622,16 @@ var ts; function getClassElementPropertyKeyType(element) { var name = element.name; switch (name.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return getLiteralType(ts.idText(name)); case 8 /* NumericLiteral */: case 10 /* StringLiteral */: return getLiteralType(name.text); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(name); return isTypeAssignableToKind(nameType, 12288 /* ESSymbolLike */) ? nameType : stringType; default: - ts.Debug.fail("Unsupported property name."); - return errorType; + return ts.Debug.fail("Unsupported property name."); } } // Return the list of properties of the given type, augmented with properties from Function @@ -60705,7 +63683,7 @@ var ts; if (!ts.isGeneratedIdentifier(nodeIn)) { var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 190 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 193 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -60761,7 +63739,7 @@ var ts; } var parentSymbol_1 = getParentOfSymbol(symbol); if (parentSymbol_1) { - if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 285 /* SourceFile */) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 288 /* SourceFile */) { var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. @@ -60789,7 +63767,7 @@ var ts; } function isSymbolOfDestructuredElementOfCatchBinding(symbol) { return ts.isBindingElement(symbol.valueDeclaration) - && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 275 /* CatchClause */; + && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 278 /* CatchClause */; } function isSymbolOfDeclarationWithCollidingName(symbol) { if (symbol.flags & 418 /* BlockScoped */ && !ts.isSourceFile(symbol.valueDeclaration)) { @@ -60820,7 +63798,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 524288 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 219 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 222 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -60861,26 +63839,25 @@ var ts; } function isValueAliasDeclaration(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: - case 251 /* ImportClause */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 252 /* ImportEqualsDeclaration */: + case 254 /* ImportClause */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: var exportClause = node.exportClause; return !!exportClause && ts.some(exportClause.elements, isValueAliasDeclaration); - case 255 /* ExportAssignment */: - return node.expression - && node.expression.kind === 73 /* Identifier */ - ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) - : true; + case 258 /* ExportAssignment */: + return node.expression && node.expression.kind === 75 /* Identifier */ ? + isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : + true; } return false; } function isTopLevelValueImportEqualsWithEntityName(nodeIn) { var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 285 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 288 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -60981,15 +63958,15 @@ var ts; } function canHaveConstantValue(node) { switch (node.kind) { - case 279 /* EnumMember */: - case 190 /* PropertyAccessExpression */: - case 191 /* ElementAccessExpression */: + case 282 /* EnumMember */: + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: return true; } return false; } function getConstantValue(node) { - if (node.kind === 279 /* EnumMember */) { + if (node.kind === 282 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -61074,7 +64051,7 @@ var ts; function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) { var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor); if (!declaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } // Get type of the symbol if this is the valid symbol otherwise get type at location var symbol = getSymbolOfNode(declaration); @@ -61093,7 +64070,7 @@ var ts; function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) { var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike); if (!signatureDeclaration) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var signature = getSignatureFromDeclaration(signatureDeclaration); return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61101,7 +64078,7 @@ var ts; function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) { var expr = ts.getParseTreeNode(exprIn, ts.isExpression); if (!expr) { - return ts.createToken(121 /* AnyKeyword */); + return ts.createToken(124 /* AnyKeyword */); } var type = getWidenedType(getRegularTypeOfExpression(expr)); return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker); @@ -61225,12 +64202,12 @@ var ts; getJsxFactoryEntity: function (location) { return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity; }, getAllAccessorDeclarations: function (accessor) { accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration); // TODO: GH#18217 - var otherKind = accessor.kind === 160 /* SetAccessor */ ? 159 /* GetAccessor */ : 160 /* SetAccessor */; + var otherKind = accessor.kind === 163 /* SetAccessor */ ? 162 /* GetAccessor */ : 163 /* SetAccessor */; var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind); var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor; var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor; - var setAccessor = accessor.kind === 160 /* SetAccessor */ ? accessor : otherAccessor; - var getAccessor = accessor.kind === 159 /* GetAccessor */ ? accessor : otherAccessor; + var setAccessor = accessor.kind === 163 /* SetAccessor */ ? accessor : otherAccessor; + var getAccessor = accessor.kind === 162 /* GetAccessor */ ? accessor : otherAccessor; return { firstAccessor: firstAccessor, secondAccessor: secondAccessor, @@ -61243,10 +64220,19 @@ var ts; var parseNode = ts.getParseTreeNode(node); var parseDecl = ts.getParseTreeNode(decl); return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl); + }, + getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) { + var n = ts.getParseTreeNode(node); + ts.Debug.assert(n && n.kind === 288 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile"); + var sym = getSymbolOfNode(node); + if (!sym) { + return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled); + } + return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled); } }; function isInHeritageClause(node) { - return node.parent && node.parent.kind === 212 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 274 /* HeritageClause */; + return node.parent && node.parent.kind === 215 /* ExpressionWithTypeArguments */ && node.parent.parent && node.parent.parent.kind === 277 /* HeritageClause */; } // defined here to avoid outer scope pollution function getTypeReferenceDirectivesForEntityName(node) { @@ -61258,7 +64244,7 @@ var ts; // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries var meaning = 788968 /* Type */ | 1920 /* Namespace */; - if ((node.kind === 73 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 190 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { + if ((node.kind === 75 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 193 /* PropertyAccessExpression */ && !isInHeritageClause(node))) { meaning = 111551 /* Value */ | 1048576 /* ExportValue */; } var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -61309,7 +64295,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 285 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 288 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -61337,12 +64323,12 @@ var ts; } } function getExternalModuleFileFromDeclaration(declaration) { - var specifier = declaration.kind === 245 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); + var specifier = declaration.kind === 248 /* ModuleDeclaration */ ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration); var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, /*moduleNotFoundError*/ undefined); // TODO: GH#18217 if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 285 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 288 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -61475,7 +64461,7 @@ var ts; function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 4194304 /* Ambient */)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608 /* Ambient */)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; @@ -61484,7 +64470,7 @@ var ts; var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551 /* Value */); if (!symbol) { - error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_but_module_0_has_no_exported_member_1, ts.externalHelpersModuleNameText, name); + error(location, ts.Diagnostics.This_syntax_requires_an_imported_helper_named_1_which_does_not_exist_in_0_Consider_upgrading_your_version_of_0, ts.externalHelpersModuleNameText, name); } } } @@ -61531,14 +64517,14 @@ var ts; return false; } if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === 157 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 160 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here); } } - else if (node.kind === 159 /* GetAccessor */ || node.kind === 160 /* SetAccessor */) { + else if (node.kind === 162 /* GetAccessor */ || node.kind === 163 /* SetAccessor */) { var accessors = ts.getAllAccessorDeclarations(node.parent.members, node); if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); @@ -61555,23 +64541,23 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 134 /* ReadonlyKeyword */) { - if (node.kind === 154 /* PropertySignature */ || node.kind === 156 /* MethodSignature */) { + if (modifier.kind !== 137 /* ReadonlyKeyword */) { + if (node.kind === 157 /* PropertySignature */ || node.kind === 159 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 163 /* IndexSignature */) { + if (node.kind === 166 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 78 /* ConstKeyword */: - if (node.kind !== 244 /* EnumDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(78 /* ConstKeyword */)); + case 80 /* ConstKeyword */: + if (node.kind !== 247 /* EnumDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(80 /* ConstKeyword */)); } break; - case 116 /* PublicKeyword */: - case 115 /* ProtectedKeyword */: - case 114 /* PrivateKeyword */: + case 118 /* PublicKeyword */: + case 117 /* ProtectedKeyword */: + case 116 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); @@ -61585,11 +64571,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128 /* Abstract */) { - if (modifier.kind === 114 /* PrivateKeyword */) { + if (modifier.kind === 116 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -61598,7 +64584,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -61608,10 +64594,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + else if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -61620,18 +64606,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 134 /* ReadonlyKeyword */: + case 137 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 155 /* PropertyDeclaration */ && node.kind !== 154 /* PropertySignature */ && node.kind !== 163 /* IndexSignature */ && node.kind !== 152 /* Parameter */) { + else if (node.kind !== 158 /* PropertyDeclaration */ && node.kind !== 157 /* PropertySignature */ && node.kind !== 166 /* IndexSignature */ && node.kind !== 155 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 86 /* ExportKeyword */: + case 88 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -61644,52 +64630,52 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 81 /* DefaultKeyword */: - var container = node.parent.kind === 285 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 245 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + case 83 /* DefaultKeyword */: + var container = node.parent.kind === 288 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 248 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } flags |= 512 /* Default */; break; - case 126 /* DeclareKeyword */: + case 129 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare"); } else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if ((node.parent.flags & 4194304 /* Ambient */) && node.parent.kind === 246 /* ModuleBlock */) { + else if ((node.parent.flags & 8388608 /* Ambient */) && node.parent.kind === 249 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 119 /* AbstractKeyword */: + case 121 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 241 /* ClassDeclaration */) { - if (node.kind !== 157 /* MethodDeclaration */ && - node.kind !== 155 /* PropertyDeclaration */ && - node.kind !== 159 /* GetAccessor */ && - node.kind !== 160 /* SetAccessor */) { + if (node.kind !== 244 /* ClassDeclaration */) { + if (node.kind !== 160 /* MethodDeclaration */ && + node.kind !== 158 /* PropertyDeclaration */ && + node.kind !== 162 /* GetAccessor */ && + node.kind !== 163 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 241 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { + if (!(node.parent.kind === 244 /* ClassDeclaration */ && ts.hasModifier(node.parent, 128 /* Abstract */))) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -61701,14 +64687,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } - else if (flags & 2 /* Ambient */ || node.parent.flags & 4194304 /* Ambient */) { + else if (flags & 2 /* Ambient */ || node.parent.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 152 /* Parameter */) { + else if (node.kind === 155 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -61716,7 +64702,7 @@ var ts; break; } } - if (node.kind === 158 /* Constructor */) { + if (node.kind === 161 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -61731,13 +64717,13 @@ var ts; } return false; } - else if ((node.kind === 250 /* ImportDeclaration */ || node.kind === 249 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 253 /* ImportDeclaration */ || node.kind === 252 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 152 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 155 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -61758,38 +64744,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 163 /* IndexSignature */: - case 245 /* ModuleDeclaration */: - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: - case 152 /* Parameter */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: + case 166 /* IndexSignature */: + case 248 /* ModuleDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: + case 155 /* Parameter */: return false; default: - if (node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { return false; } switch (node.kind) { - case 240 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 122 /* AsyncKeyword */); - case 241 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AbstractKeyword */); - case 242 /* InterfaceDeclaration */: - case 220 /* VariableStatement */: - case 243 /* TypeAliasDeclaration */: + case 243 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 125 /* AsyncKeyword */); + case 244 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 121 /* AbstractKeyword */); + case 245 /* InterfaceDeclaration */: + case 224 /* VariableStatement */: + case 246 /* TypeAliasDeclaration */: return true; - case 244 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 78 /* ConstKeyword */); + case 247 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 80 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -61801,10 +64787,10 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 157 /* MethodDeclaration */: - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: - case 198 /* ArrowFunction */: + case 160 /* MethodDeclaration */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: + case 201 /* ArrowFunction */: return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); @@ -61833,7 +64819,7 @@ var ts; if (i !== (parameterCount - 1)) { return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list); } - if (!(parameter.flags & 4194304 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 + if (!(parameter.flags & 8388608 /* Ambient */)) { // Allow `...foo,` in ambient declarations; see GH#23070 checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma); } if (parameter.questionToken) { @@ -61919,15 +64905,15 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 139 /* StringKeyword */ && parameter.type.kind !== 136 /* NumberKeyword */) { + if (parameter.type.kind !== 142 /* StringKeyword */ && parameter.type.kind !== 139 /* NumberKeyword */) { var type = getTypeFromTypeNode(parameter.type); if (type.flags & 4 /* String */ || type.flags & 8 /* Number */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead, ts.getTextOfNode(parameter.name), typeToString(type), typeToString(node.type ? getTypeFromTypeNode(node.type) : anyType)); } - if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 128 /* StringLiteral */, /*strict*/ true)) { + if (type.flags & 1048576 /* Union */ && allTypesAssignableToKind(type, 384 /* StringOrNumberLiteral */, /*strict*/ true)) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead); } - return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); + return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number); } if (!node.type) { return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation); @@ -61951,11 +64937,17 @@ var ts; return checkGrammarForDisallowedTrailingComma(typeArguments) || checkGrammarForAtLeastOneTypeArgument(node, typeArguments); } + function checkGrammarTaggedTemplateChain(node) { + if (node.questionDotToken || node.flags & 32 /* OptionalChain */) { + return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain); + } + return false; + } function checkGrammarForOmittedArgument(args) { if (args) { for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 211 /* OmittedExpression */) { + if (arg.kind === 214 /* OmittedExpression */) { return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -61985,7 +64977,7 @@ var ts; if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -61998,7 +64990,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -62014,14 +65006,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 87 /* ExtendsKeyword */) { + if (heritageClause.token === 89 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 110 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 112 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -62032,21 +65024,21 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 150 /* ComputedPropertyName */) { + if (node.kind !== 153 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 205 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { + if (computedPropertyName.expression.kind === 208 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 27 /* CommaToken */) { return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name); } return false; } function checkGrammarForGenerator(node) { if (node.asteriskToken) { - ts.Debug.assert(node.kind === 240 /* FunctionDeclaration */ || - node.kind === 197 /* FunctionExpression */ || - node.kind === 157 /* MethodDeclaration */); - if (node.flags & 4194304 /* Ambient */) { + ts.Debug.assert(node.kind === 243 /* FunctionDeclaration */ || + node.kind === 200 /* FunctionExpression */ || + node.kind === 160 /* MethodDeclaration */); + if (node.flags & 8388608 /* Ambient */) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { @@ -62064,7 +65056,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 278 /* SpreadAssignment */) { + if (prop.kind === 281 /* SpreadAssignment */) { if (inDestructuring) { // a rest property cannot be destructured any further var expression = ts.skipParentheses(prop.expression); @@ -62075,21 +65067,21 @@ var ts; continue; } var name = prop.name; - if (name.kind === 150 /* ComputedPropertyName */) { + if (name.kind === 153 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 277 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 280 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } // Modifiers are never allowed on properties except for 'async' on a method declaration if (prop.modifiers) { - // tslint:disable no-unnecessary-type-assertion + // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { // TODO: GH#19955 var mod = _c[_b]; - if (mod.kind !== 122 /* AsyncKeyword */ || prop.kind !== 157 /* MethodDeclaration */) { + if (mod.kind !== 125 /* AsyncKeyword */ || prop.kind !== 160 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -62104,10 +65096,10 @@ var ts; // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; switch (prop.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); - /* tslint:disable:no-switch-case-fall-through */ - case 276 /* PropertyAssignment */: + // falls through + case 279 /* PropertyAssignment */: // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -62115,13 +65107,13 @@ var ts; } currentKind = 4 /* PropertyAssignment */; break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: currentKind = 8 /* Method */; break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: currentKind = 1 /* GetAccessor */; break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: currentKind = 2 /* SetAccessor */; break; default: @@ -62158,7 +65150,7 @@ var ts; var seen = ts.createUnderscoreEscapedMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 270 /* JsxSpreadAttribute */) { + if (attr.kind === 273 /* JsxSpreadAttribute */) { continue; } var name = attr.name, initializer = attr.initializer; @@ -62168,7 +65160,7 @@ var ts; else { return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } - if (initializer && initializer.kind === 271 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 274 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -62182,14 +65174,14 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.kind === 228 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { - if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + if (forInOrOfStatement.kind === 231 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 32768 /* AwaitContext */) === 0 /* None */) { // use of 'for-await-of' in non-async function var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement); if (!hasParseDiagnostics(sourceFile)) { var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); var func = ts.getContainingFunction(forInOrOfStatement); - if (func && func.kind !== 158 /* Constructor */) { + if (func && func.kind !== 161 /* Constructor */) { ts.Debug.assert((ts.getFunctionFlags(func) & 2 /* Async */) === 0, "Enclosing function should never be an async function."); var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async); ts.addRelatedInfo(diagnostic, relatedInfo); @@ -62200,7 +65192,7 @@ var ts; return false; } } - if (forInOrOfStatement.initializer.kind === 239 /* VariableDeclarationList */) { + if (forInOrOfStatement.initializer.kind === 242 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -62215,20 +65207,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement; return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic); } var firstDeclaration = declarations[0]; if (firstDeclaration.initializer) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer; return grammarErrorOnNode(firstDeclaration.name, diagnostic); } if (firstDeclaration.type) { - var diagnostic = forInOrOfStatement.kind === 227 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 230 /* ForInStatement */ ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation; return grammarErrorOnNode(firstDeclaration, diagnostic); @@ -62238,7 +65230,7 @@ var ts; return false; } function checkGrammarAccessor(accessor) { - if (!(accessor.flags & 4194304 /* Ambient */)) { + if (!(accessor.flags & 8388608 /* Ambient */)) { if (languageVersion < 1 /* ES5 */) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher); } @@ -62253,11 +65245,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, accessor.kind === 159 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, accessor.kind === 162 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - if (accessor.kind === 160 /* SetAccessor */) { + if (accessor.kind === 163 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -62279,23 +65271,23 @@ var ts; * A set accessor has one parameter or a `this` parameter and one more parameter. */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 159 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 162 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } function checkGrammarTypeOperatorNode(node) { - if (node.operator === 143 /* UniqueKeyword */) { - if (node.type.kind !== 140 /* SymbolKeyword */) { - return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(140 /* SymbolKeyword */)); + if (node.operator === 146 /* UniqueKeyword */) { + if (node.type.kind !== 143 /* SymbolKeyword */) { + return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(143 /* SymbolKeyword */)); } var parent = ts.walkUpParenthesizedTypes(node.parent); switch (parent.kind) { - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: var decl = parent; - if (decl.name.kind !== 73 /* Identifier */) { + if (decl.name.kind !== 75 /* Identifier */) { return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name); } if (!ts.isVariableDeclarationInVariableStatement(decl)) { @@ -62305,13 +65297,13 @@ var ts; return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: if (!ts.hasModifier(parent, 32 /* Static */) || !ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly); } break; - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: if (!ts.hasModifier(parent, 64 /* Readonly */)) { return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly); } @@ -62320,9 +65312,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here); } } - else if (node.operator === 134 /* ReadonlyKeyword */) { - if (node.type.kind !== 170 /* ArrayType */ && node.type.kind !== 171 /* TupleType */) { - return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(140 /* SymbolKeyword */)); + else if (node.operator === 137 /* ReadonlyKeyword */) { + if (node.type.kind !== 173 /* ArrayType */ && node.type.kind !== 174 /* TupleType */) { + return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(143 /* SymbolKeyword */)); } } } @@ -62335,10 +65327,10 @@ var ts; if (checkGrammarFunctionLikeDeclaration(node)) { return true; } - if (node.kind === 157 /* MethodDeclaration */) { - if (node.parent.kind === 189 /* ObjectLiteralExpression */) { + if (node.kind === 160 /* MethodDeclaration */) { + if (node.parent.kind === 192 /* ObjectLiteralExpression */) { // We only disallow modifier on a method declaration if it is a property of object-literal-expression - if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 122 /* AsyncKeyword */)) { + if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 125 /* AsyncKeyword */)) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { @@ -62361,17 +65353,17 @@ var ts; // However, property declarations disallow computed names in general, // and accessors are not allowed in ambient contexts in general, // so this error only really matters for methods. - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_ambient_context_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.kind === 157 /* MethodDeclaration */ && !node.body) { + else if (node.kind === 160 /* MethodDeclaration */ && !node.body) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_method_overload_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { return checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type); } } @@ -62382,11 +65374,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: if (node.label && current.label.escapedText === node.label.escapedText) { // found matching label - verify that label usage is correct // continue can only target labels that are on iteration statements - var isMisplacedContinueLabel = node.kind === 229 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 232 /* ContinueStatement */ && !ts.isIterationStatement(current.statement, /*lookInLabeledStatement*/ true); if (isMisplacedContinueLabel) { return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); @@ -62394,8 +65386,8 @@ var ts; return false; } break; - case 233 /* SwitchStatement */: - if (node.kind === 230 /* BreakStatement */ && !node.label) { + case 236 /* SwitchStatement */: + if (node.kind === 233 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -62410,13 +65402,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); } else { - var message = node.kind === 230 /* BreakStatement */ + var message = node.kind === 233 /* BreakStatement */ ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement; return grammarErrorOnNode(node, message); @@ -62439,13 +65431,13 @@ var ts; } } function isStringOrNumberLiteralExpression(expr) { - return expr.kind === 10 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + return ts.isStringOrNumericLiteralLike(expr) || + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function isBigIntLiteralExpression(expr) { return expr.kind === 9 /* BigIntLiteral */ || - expr.kind === 203 /* PrefixUnaryExpression */ && expr.operator === 39 /* MinusToken */ && + expr.kind === 206 /* PrefixUnaryExpression */ && expr.operator === 40 /* MinusToken */ && expr.operand.kind === 9 /* BigIntLiteral */; } function isSimpleLiteralEnumReference(expr) { @@ -62458,7 +65450,7 @@ var ts; if (initializer) { var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) || isSimpleLiteralEnumReference(initializer) || - initializer.kind === 103 /* TrueKeyword */ || initializer.kind === 88 /* FalseKeyword */ || + initializer.kind === 105 /* TrueKeyword */ || initializer.kind === 90 /* FalseKeyword */ || isBigIntLiteralExpression(initializer)); var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node); if (isConstOrReadonly && !node.type) { @@ -62475,8 +65467,8 @@ var ts; } } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 227 /* ForInStatement */ && node.parent.parent.kind !== 228 /* ForOfStatement */) { - if (node.flags & 4194304 /* Ambient */) { + if (node.parent.parent.kind !== 230 /* ForInStatement */ && node.parent.parent.kind !== 231 /* ForOfStatement */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } else if (!node.initializer) { @@ -62488,11 +65480,11 @@ var ts; } } } - if (node.exclamationToken && (node.parent.parent.kind !== 220 /* VariableStatement */ || !node.type || node.initializer || node.flags & 4194304 /* Ambient */)) { + if (node.exclamationToken && (node.parent.parent.kind !== 224 /* VariableStatement */ || !node.type || node.initializer || node.flags & 8388608 /* Ambient */)) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.Definite_assignment_assertions_can_only_be_used_along_with_a_type_annotation); } if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && - !(node.parent.parent.flags & 4194304 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { + !(node.parent.parent.flags & 8388608 /* Ambient */) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node)); @@ -62505,7 +65497,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { if (ts.idText(name) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -62522,8 +65514,8 @@ var ts; return false; } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 73 /* Identifier */) { - if (name.originalKeywordKind === 112 /* LetKeyword */) { + if (name.kind === 75 /* Identifier */) { + if (name.originalKeywordKind === 114 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -62550,15 +65542,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 223 /* IfStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 232 /* WithStatement */: - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 226 /* IfStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: return false; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -62576,12 +65568,12 @@ var ts; function checkGrammarMetaProperty(node) { var escapedText = node.name.escapedText; switch (node.keywordToken) { - case 96 /* NewKeyword */: + case 98 /* NewKeyword */: if (escapedText !== "target") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "target"); } break; - case 93 /* ImportKeyword */: + case 95 /* ImportKeyword */: if (escapedText !== "meta") { return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.escapedText, ts.tokenToString(node.keywordToken), "meta"); } @@ -62639,7 +65631,7 @@ var ts; return true; } } - else if (node.parent.kind === 242 /* InterfaceDeclaration */) { + else if (node.parent.kind === 245 /* InterfaceDeclaration */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62647,7 +65639,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 169 /* TypeLiteral */) { + else if (node.parent.kind === 172 /* TypeLiteral */) { if (checkGrammarForInvalidDynamicName(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } @@ -62655,11 +65647,11 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { checkAmbientInitializer(node); } if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer || - node.flags & 4194304 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { + node.flags & 8388608 /* Ambient */ || ts.hasModifier(node, 32 /* Static */ | 128 /* Abstract */))) { return grammarErrorOnNode(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); } } @@ -62676,13 +65668,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 242 /* InterfaceDeclaration */ || - node.kind === 243 /* TypeAliasDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 249 /* ImportEqualsDeclaration */ || - node.kind === 256 /* ExportDeclaration */ || - node.kind === 255 /* ExportAssignment */ || - node.kind === 248 /* NamespaceExportDeclaration */ || + if (node.kind === 245 /* InterfaceDeclaration */ || + node.kind === 246 /* TypeAliasDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 252 /* ImportEqualsDeclaration */ || + node.kind === 259 /* ExportDeclaration */ || + node.kind === 258 /* ExportAssignment */ || + node.kind === 251 /* NamespaceExportDeclaration */ || ts.hasModifier(node, 2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -62691,7 +65683,7 @@ var ts; function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) { for (var _i = 0, _a = file.statements; _i < _a.length; _i++) { var decl = _a[_i]; - if (ts.isDeclaration(decl) || decl.kind === 220 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 224 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -62700,10 +65692,10 @@ var ts; return false; } function checkGrammarSourceFile(node) { - return !!(node.flags & 4194304 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); + return !!(node.flags & 8388608 /* Ambient */) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node); } function checkGrammarStatementInAmbientContext(node) { - if (node.flags & 4194304 /* Ambient */) { + if (node.flags & 8388608 /* Ambient */) { // Find containing block which is either Block, ModuleBlock, SourceFile var links = getNodeLinks(node); if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) { @@ -62714,7 +65706,7 @@ var ts; // to prevent noisiness. So use a bit on the block to indicate if // this has already been reported, and don't report if it has. // - if (node.parent.kind === 219 /* Block */ || node.parent.kind === 246 /* ModuleBlock */ || node.parent.kind === 285 /* SourceFile */) { + if (node.parent.kind === 222 /* Block */ || node.parent.kind === 249 /* ModuleBlock */ || node.parent.kind === 288 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -62736,20 +65728,39 @@ var ts; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 183 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 186 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 279 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 282 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 39 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } } + // Realism (size) checking + checkNumericLiteralValueSize(node); return false; } + function checkNumericLiteralValueSize(node) { + // Scientific notation (e.g. 2e54 and 1e00000000010) can't be converted to bigint + // Literals with 15 or fewer characters aren't long enough to reach past 2^53 - 1 + // Fractional numbers (e.g. 9000000000000000.001) are inherently imprecise anyway + if (node.numericLiteralFlags & 16 /* Scientific */ || node.text.length <= 15 || node.text.indexOf(".") !== -1) { + return; + } + // We can't rely on the runtime to accurately store and compare extremely large numeric values + // Even for internal use, we use getTextOfNode: https://github.com/microsoft/TypeScript/issues/33298 + // Thus, if the runtime claims a too-large number is lower than Number.MAX_SAFE_INTEGER, + // it's likely addition operations on it will fail too + var apparentValue = +ts.getTextOfNode(node); + if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) { + return; + } + addErrorOrSuggestion(/*isError*/ false, ts.createDiagnosticForNode(node, ts.Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers)); + } function checkGrammarBigIntLiteral(node) { var literalType = ts.isLiteralTypeNode(node.parent) || ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent); @@ -62785,7 +65796,7 @@ var ts; } function checkGrammarImportCallExpression(node) { if (moduleKind === ts.ModuleKind.ES2015) { - return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_is_only_supported_when_module_flag_is_commonjs_or_esNext); + return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_commonjs_amd_system_or_umd); } if (node.typeArguments) { return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments); @@ -62809,14 +65820,14 @@ var ts; return !ts.isAccessor(declaration); } function isNotOverload(declaration) { - return (declaration.kind !== 240 /* FunctionDeclaration */ && declaration.kind !== 157 /* MethodDeclaration */) || + return (declaration.kind !== 243 /* FunctionDeclaration */ && declaration.kind !== 160 /* MethodDeclaration */) || !!declaration.body; } /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ function isDeclarationNameOrImportPropertyName(name) { switch (name.parent.kind) { - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: return ts.isIdentifier(name); default: return ts.isDeclarationName(name); @@ -62824,21 +65835,20 @@ var ts; } function isSomeImportDeclaration(decl) { switch (decl.kind) { - case 251 /* ImportClause */: // For default import - case 249 /* ImportEqualsDeclaration */: - case 252 /* NamespaceImport */: - case 254 /* ImportSpecifier */: // For rename import `x as y` + case 254 /* ImportClause */: // For default import + case 252 /* ImportEqualsDeclaration */: + case 255 /* NamespaceImport */: + case 257 /* ImportSpecifier */: // For rename import `x as y` return true; - case 73 /* Identifier */: + case 75 /* Identifier */: // For regular import, `decl` is an Identifier under the ImportSpecifier. - return decl.parent.kind === 254 /* ImportSpecifier */; + return decl.parent.kind === 257 /* ImportSpecifier */; default: return false; } } var JsxNames; (function (JsxNames) { - // tslint:disable variable-name JsxNames.JSX = "JSX"; JsxNames.IntrinsicElements = "IntrinsicElements"; JsxNames.ElementClass = "ElementClass"; @@ -62848,7 +65858,6 @@ var ts; JsxNames.IntrinsicAttributes = "IntrinsicAttributes"; JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes"; JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes"; - // tslint:enable variable-name })(JsxNames || (JsxNames = {})); function getIterationTypesKeyFromIterationTypeKind(typeKind) { switch (typeKind) { @@ -62857,6 +65866,18 @@ var ts; case 2 /* Next */: return "nextType"; } } + function signatureHasRestParameter(s) { + return !!(s.flags & 1 /* HasRestParameter */); + } + ts.signatureHasRestParameter = signatureHasRestParameter; + function signatureHasLiteralTypes(s) { + return !!(s.flags & 2 /* HasLiteralTypes */); + } + ts.signatureHasLiteralTypes = signatureHasLiteralTypes; + function signatureIsOptionalCall(s) { + return !!(s.flags & 4 /* IsOptionalCall */); + } + ts.signatureIsOptionalCall = signatureIsOptionalCall; })(ts || (ts = {})); var ts; (function (ts) { @@ -62919,6 +65940,7 @@ var ts; if (typeof value === "number") { return createNumericLiteral(value + ""); } + // eslint-disable-next-line no-in-operator if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt return createBigIntLiteral(ts.pseudoBigIntToString(value) + "n"); } @@ -62966,7 +65988,7 @@ var ts; return node; } function createIdentifier(text, typeArguments) { - var node = createSynthesizedNode(73 /* Identifier */); + var node = createSynthesizedNode(75 /* Identifier */); node.escapedText = ts.escapeLeadingUnderscores(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateFlags = 0 /* None */; @@ -63047,23 +66069,23 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(99 /* SuperKeyword */); + return createSynthesizedNode(101 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(101 /* ThisKeyword */); + return createSynthesizedNode(103 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(97 /* NullKeyword */); + return createSynthesizedNode(99 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(103 /* TrueKeyword */); + return createSynthesizedNode(105 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(88 /* FalseKeyword */); + return createSynthesizedNode(90 /* FalseKeyword */); } ts.createFalse = createFalse; // Modifiers @@ -63074,44 +66096,44 @@ var ts; function createModifiersFromModifierFlags(flags) { var result = []; if (flags & 1 /* Export */) { - result.push(createModifier(86 /* ExportKeyword */)); + result.push(createModifier(88 /* ExportKeyword */)); } if (flags & 2 /* Ambient */) { - result.push(createModifier(126 /* DeclareKeyword */)); + result.push(createModifier(129 /* DeclareKeyword */)); } if (flags & 512 /* Default */) { - result.push(createModifier(81 /* DefaultKeyword */)); + result.push(createModifier(83 /* DefaultKeyword */)); } if (flags & 2048 /* Const */) { - result.push(createModifier(78 /* ConstKeyword */)); + result.push(createModifier(80 /* ConstKeyword */)); } if (flags & 4 /* Public */) { - result.push(createModifier(116 /* PublicKeyword */)); + result.push(createModifier(118 /* PublicKeyword */)); } if (flags & 8 /* Private */) { - result.push(createModifier(114 /* PrivateKeyword */)); + result.push(createModifier(116 /* PrivateKeyword */)); } if (flags & 16 /* Protected */) { - result.push(createModifier(115 /* ProtectedKeyword */)); + result.push(createModifier(117 /* ProtectedKeyword */)); } if (flags & 128 /* Abstract */) { - result.push(createModifier(119 /* AbstractKeyword */)); + result.push(createModifier(121 /* AbstractKeyword */)); } if (flags & 32 /* Static */) { - result.push(createModifier(117 /* StaticKeyword */)); + result.push(createModifier(119 /* StaticKeyword */)); } if (flags & 64 /* Readonly */) { - result.push(createModifier(134 /* ReadonlyKeyword */)); + result.push(createModifier(137 /* ReadonlyKeyword */)); } if (flags & 256 /* Async */) { - result.push(createModifier(122 /* AsyncKeyword */)); + result.push(createModifier(125 /* AsyncKeyword */)); } return result; } ts.createModifiersFromModifierFlags = createModifiersFromModifierFlags; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(149 /* QualifiedName */); + var node = createSynthesizedNode(152 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -63130,7 +66152,7 @@ var ts; : expression; } function createComputedPropertyName(expression) { - var node = createSynthesizedNode(150 /* ComputedPropertyName */); + var node = createSynthesizedNode(153 /* ComputedPropertyName */); node.expression = parenthesizeForComputedName(expression); return node; } @@ -63143,7 +66165,7 @@ var ts; ts.updateComputedPropertyName = updateComputedPropertyName; // Signature elements function createTypeParameterDeclaration(name, constraint, defaultType) { - var node = createSynthesizedNode(151 /* TypeParameter */); + var node = createSynthesizedNode(154 /* TypeParameter */); node.name = asName(name); node.constraint = constraint; node.default = defaultType; @@ -63159,7 +66181,7 @@ var ts; } ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(152 /* Parameter */); + var node = createSynthesizedNode(155 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -63183,7 +66205,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(153 /* Decorator */); + var node = createSynthesizedNode(156 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -63196,7 +66218,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type Elements function createPropertySignature(modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(154 /* PropertySignature */); + var node = createSynthesizedNode(157 /* PropertySignature */); node.modifiers = asNodeArray(modifiers); node.name = asName(name); node.questionToken = questionToken; @@ -63216,12 +66238,12 @@ var ts; } ts.updatePropertySignature = updatePropertySignature; function createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer) { - var node = createSynthesizedNode(155 /* PropertyDeclaration */); + var node = createSynthesizedNode(158 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); - node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined; - node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined; + node.questionToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined; + node.exclamationToken = questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined; node.type = type; node.initializer = initializer; return node; @@ -63231,8 +66253,8 @@ var ts; return node.decorators !== decorators || node.modifiers !== modifiers || node.name !== name - || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 56 /* QuestionToken */ ? questionOrExclamationToken : undefined) - || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 52 /* ExclamationToken */ ? questionOrExclamationToken : undefined) + || node.questionToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 57 /* QuestionToken */ ? questionOrExclamationToken : undefined) + || node.exclamationToken !== (questionOrExclamationToken !== undefined && questionOrExclamationToken.kind === 53 /* ExclamationToken */ ? questionOrExclamationToken : undefined) || node.type !== type || node.initializer !== initializer ? updateNode(createProperty(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node) @@ -63240,7 +66262,7 @@ var ts; } ts.updateProperty = updateProperty; function createMethodSignature(typeParameters, parameters, type, name, questionToken) { - var node = createSignatureDeclaration(156 /* MethodSignature */, typeParameters, parameters, type); + var node = createSignatureDeclaration(159 /* MethodSignature */, typeParameters, parameters, type); node.name = asName(name); node.questionToken = questionToken; return node; @@ -63257,7 +66279,7 @@ var ts; } ts.updateMethodSignature = updateMethodSignature; function createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(157 /* MethodDeclaration */); + var node = createSynthesizedNode(160 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -63270,6 +66292,38 @@ var ts; return node; } ts.createMethod = createMethod; + function createMethodCall(object, methodName, argumentsList) { + return createCall(createPropertyAccess(object, asName(methodName)), + /*typeArguments*/ undefined, argumentsList); + } + function createGlobalMethodCall(globalObjectName, methodName, argumentsList) { + return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList); + } + /* @internal */ + function createObjectDefinePropertyCall(target, propertyName, attributes) { + return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]); + } + ts.createObjectDefinePropertyCall = createObjectDefinePropertyCall; + function tryAddPropertyAssignment(properties, propertyName, expression) { + if (expression) { + properties.push(createPropertyAssignment(propertyName, expression)); + return true; + } + return false; + } + /* @internal */ + function createPropertyDescriptor(attributes, singleLine) { + var properties = []; + tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable)); + tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable)); + var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable)); + isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData; + var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get); + isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor; + ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor."); + return createObjectLiteral(properties, !singleLine); + } + ts.createPropertyDescriptor = createPropertyDescriptor; function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers @@ -63285,7 +66339,7 @@ var ts; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(158 /* Constructor */); + var node = createSynthesizedNode(161 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -63305,7 +66359,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(159 /* GetAccessor */); + var node = createSynthesizedNode(162 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63328,7 +66382,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(160 /* SetAccessor */); + var node = createSynthesizedNode(163 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -63349,7 +66403,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createCallSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(161 /* CallSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(164 /* CallSignature */, typeParameters, parameters, type); } ts.createCallSignature = createCallSignature; function updateCallSignature(node, typeParameters, parameters, type) { @@ -63357,7 +66411,7 @@ var ts; } ts.updateCallSignature = updateCallSignature; function createConstructSignature(typeParameters, parameters, type) { - return createSignatureDeclaration(162 /* ConstructSignature */, typeParameters, parameters, type); + return createSignatureDeclaration(165 /* ConstructSignature */, typeParameters, parameters, type); } ts.createConstructSignature = createConstructSignature; function updateConstructSignature(node, typeParameters, parameters, type) { @@ -63365,7 +66419,7 @@ var ts; } ts.updateConstructSignature = updateConstructSignature; function createIndexSignature(decorators, modifiers, parameters, type) { - var node = createSynthesizedNode(163 /* IndexSignature */); + var node = createSynthesizedNode(166 /* IndexSignature */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.parameters = createNodeArray(parameters); @@ -63405,21 +66459,31 @@ var ts; } ts.createKeywordTypeNode = createKeywordTypeNode; function createTypePredicateNode(parameterName, type) { - var node = createSynthesizedNode(164 /* TypePredicate */); + return createTypePredicateNodeWithModifier(/*assertsModifier*/ undefined, parameterName, type); + } + ts.createTypePredicateNode = createTypePredicateNode; + function createTypePredicateNodeWithModifier(assertsModifier, parameterName, type) { + var node = createSynthesizedNode(167 /* TypePredicate */); + node.assertsModifier = assertsModifier; node.parameterName = asName(parameterName); node.type = type; return node; } - ts.createTypePredicateNode = createTypePredicateNode; + ts.createTypePredicateNodeWithModifier = createTypePredicateNodeWithModifier; function updateTypePredicateNode(node, parameterName, type) { - return node.parameterName !== parameterName + return updateTypePredicateNodeWithModifier(node, node.assertsModifier, parameterName, type); + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function updateTypePredicateNodeWithModifier(node, assertsModifier, parameterName, type) { + return node.assertsModifier !== assertsModifier + || node.parameterName !== parameterName || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) + ? updateNode(createTypePredicateNodeWithModifier(assertsModifier, parameterName, type), node) : node; } - ts.updateTypePredicateNode = updateTypePredicateNode; + ts.updateTypePredicateNodeWithModifier = updateTypePredicateNodeWithModifier; function createTypeReferenceNode(typeName, typeArguments) { - var node = createSynthesizedNode(165 /* TypeReference */); + var node = createSynthesizedNode(168 /* TypeReference */); node.typeName = asName(typeName); node.typeArguments = typeArguments && ts.parenthesizeTypeParameters(typeArguments); return node; @@ -63433,7 +66497,7 @@ var ts; } ts.updateTypeReferenceNode = updateTypeReferenceNode; function createFunctionTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(166 /* FunctionType */, typeParameters, parameters, type); + return createSignatureDeclaration(169 /* FunctionType */, typeParameters, parameters, type); } ts.createFunctionTypeNode = createFunctionTypeNode; function updateFunctionTypeNode(node, typeParameters, parameters, type) { @@ -63441,7 +66505,7 @@ var ts; } ts.updateFunctionTypeNode = updateFunctionTypeNode; function createConstructorTypeNode(typeParameters, parameters, type) { - return createSignatureDeclaration(167 /* ConstructorType */, typeParameters, parameters, type); + return createSignatureDeclaration(170 /* ConstructorType */, typeParameters, parameters, type); } ts.createConstructorTypeNode = createConstructorTypeNode; function updateConstructorTypeNode(node, typeParameters, parameters, type) { @@ -63449,7 +66513,7 @@ var ts; } ts.updateConstructorTypeNode = updateConstructorTypeNode; function createTypeQueryNode(exprName) { - var node = createSynthesizedNode(168 /* TypeQuery */); + var node = createSynthesizedNode(171 /* TypeQuery */); node.exprName = exprName; return node; } @@ -63461,7 +66525,7 @@ var ts; } ts.updateTypeQueryNode = updateTypeQueryNode; function createTypeLiteralNode(members) { - var node = createSynthesizedNode(169 /* TypeLiteral */); + var node = createSynthesizedNode(172 /* TypeLiteral */); node.members = createNodeArray(members); return node; } @@ -63473,7 +66537,7 @@ var ts; } ts.updateTypeLiteralNode = updateTypeLiteralNode; function createArrayTypeNode(elementType) { - var node = createSynthesizedNode(170 /* ArrayType */); + var node = createSynthesizedNode(173 /* ArrayType */); node.elementType = ts.parenthesizeArrayTypeMember(elementType); return node; } @@ -63485,7 +66549,7 @@ var ts; } ts.updateArrayTypeNode = updateArrayTypeNode; function createTupleTypeNode(elementTypes) { - var node = createSynthesizedNode(171 /* TupleType */); + var node = createSynthesizedNode(174 /* TupleType */); node.elementTypes = createNodeArray(elementTypes); return node; } @@ -63497,7 +66561,7 @@ var ts; } ts.updateTupleTypeNode = updateTupleTypeNode; function createOptionalTypeNode(type) { - var node = createSynthesizedNode(172 /* OptionalType */); + var node = createSynthesizedNode(175 /* OptionalType */); node.type = ts.parenthesizeArrayTypeMember(type); return node; } @@ -63509,7 +66573,7 @@ var ts; } ts.updateOptionalTypeNode = updateOptionalTypeNode; function createRestTypeNode(type) { - var node = createSynthesizedNode(173 /* RestType */); + var node = createSynthesizedNode(176 /* RestType */); node.type = type; return node; } @@ -63521,7 +66585,7 @@ var ts; } ts.updateRestTypeNode = updateRestTypeNode; function createUnionTypeNode(types) { - return createUnionOrIntersectionTypeNode(174 /* UnionType */, types); + return createUnionOrIntersectionTypeNode(177 /* UnionType */, types); } ts.createUnionTypeNode = createUnionTypeNode; function updateUnionTypeNode(node, types) { @@ -63529,7 +66593,7 @@ var ts; } ts.updateUnionTypeNode = updateUnionTypeNode; function createIntersectionTypeNode(types) { - return createUnionOrIntersectionTypeNode(175 /* IntersectionType */, types); + return createUnionOrIntersectionTypeNode(178 /* IntersectionType */, types); } ts.createIntersectionTypeNode = createIntersectionTypeNode; function updateIntersectionTypeNode(node, types) { @@ -63548,7 +66612,7 @@ var ts; : node; } function createConditionalTypeNode(checkType, extendsType, trueType, falseType) { - var node = createSynthesizedNode(176 /* ConditionalType */); + var node = createSynthesizedNode(179 /* ConditionalType */); node.checkType = ts.parenthesizeConditionalTypeMember(checkType); node.extendsType = ts.parenthesizeConditionalTypeMember(extendsType); node.trueType = trueType; @@ -63566,7 +66630,7 @@ var ts; } ts.updateConditionalTypeNode = updateConditionalTypeNode; function createInferTypeNode(typeParameter) { - var node = createSynthesizedNode(177 /* InferType */); + var node = createSynthesizedNode(180 /* InferType */); node.typeParameter = typeParameter; return node; } @@ -63578,7 +66642,7 @@ var ts; } ts.updateInferTypeNode = updateInferTypeNode; function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) { - var node = createSynthesizedNode(184 /* ImportType */); + var node = createSynthesizedNode(187 /* ImportType */); node.argument = argument; node.qualifier = qualifier; node.typeArguments = ts.parenthesizeTypeParameters(typeArguments); @@ -63596,7 +66660,7 @@ var ts; } ts.updateImportTypeNode = updateImportTypeNode; function createParenthesizedType(type) { - var node = createSynthesizedNode(178 /* ParenthesizedType */); + var node = createSynthesizedNode(181 /* ParenthesizedType */); node.type = type; return node; } @@ -63608,12 +66672,12 @@ var ts; } ts.updateParenthesizedType = updateParenthesizedType; function createThisTypeNode() { - return createSynthesizedNode(179 /* ThisType */); + return createSynthesizedNode(182 /* ThisType */); } ts.createThisTypeNode = createThisTypeNode; function createTypeOperatorNode(operatorOrType, type) { - var node = createSynthesizedNode(180 /* TypeOperator */); - node.operator = typeof operatorOrType === "number" ? operatorOrType : 130 /* KeyOfKeyword */; + var node = createSynthesizedNode(183 /* TypeOperator */); + node.operator = typeof operatorOrType === "number" ? operatorOrType : 133 /* KeyOfKeyword */; node.type = ts.parenthesizeElementTypeMember(typeof operatorOrType === "number" ? type : operatorOrType); return node; } @@ -63623,7 +66687,7 @@ var ts; } ts.updateTypeOperatorNode = updateTypeOperatorNode; function createIndexedAccessTypeNode(objectType, indexType) { - var node = createSynthesizedNode(181 /* IndexedAccessType */); + var node = createSynthesizedNode(184 /* IndexedAccessType */); node.objectType = ts.parenthesizeElementTypeMember(objectType); node.indexType = indexType; return node; @@ -63637,7 +66701,7 @@ var ts; } ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { - var node = createSynthesizedNode(182 /* MappedType */); + var node = createSynthesizedNode(185 /* MappedType */); node.readonlyToken = readonlyToken; node.typeParameter = typeParameter; node.questionToken = questionToken; @@ -63655,7 +66719,7 @@ var ts; } ts.updateMappedTypeNode = updateMappedTypeNode; function createLiteralTypeNode(literal) { - var node = createSynthesizedNode(183 /* LiteralType */); + var node = createSynthesizedNode(186 /* LiteralType */); node.literal = literal; return node; } @@ -63668,7 +66732,7 @@ var ts; ts.updateLiteralTypeNode = updateLiteralTypeNode; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(185 /* ObjectBindingPattern */); + var node = createSynthesizedNode(188 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63680,7 +66744,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(186 /* ArrayBindingPattern */); + var node = createSynthesizedNode(189 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -63692,7 +66756,7 @@ var ts; } ts.updateArrayBindingPattern = updateArrayBindingPattern; function createBindingElement(dotDotDotToken, propertyName, name, initializer) { - var node = createSynthesizedNode(187 /* BindingElement */); + var node = createSynthesizedNode(190 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; node.propertyName = asName(propertyName); node.name = asName(name); @@ -63711,7 +66775,7 @@ var ts; ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(188 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(191 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) node.multiLine = true; @@ -63725,7 +66789,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(189 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(192 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) node.multiLine = true; @@ -63739,7 +66803,7 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(190 /* PropertyAccessExpression */); + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); setEmitFlags(node, 131072 /* NoIndentation */); @@ -63747,6 +66811,9 @@ var ts; } ts.createPropertyAccess = createPropertyAccess; function updatePropertyAccess(node, expression, name) { + if (ts.isOptionalChain(node)) { + return updatePropertyAccessChain(node, expression, node.questionDotToken, name); + } // Because we are updating existed propertyAccess we want to inherit its emitFlags // instead of using the default from createPropertyAccess return node.expression !== expression @@ -63755,22 +66822,64 @@ var ts; : node; } ts.updatePropertyAccess = updatePropertyAccess; + function createPropertyAccessChain(expression, questionDotToken, name) { + var node = createSynthesizedNode(193 /* PropertyAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.name = asName(name); + setEmitFlags(node, 131072 /* NoIndentation */); + return node; + } + ts.createPropertyAccessChain = createPropertyAccessChain; + function updatePropertyAccessChain(node, expression, questionDotToken, name) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead."); + // Because we are updating an existing PropertyAccessChain we want to inherit its emitFlags + // instead of using the default from createPropertyAccess + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.name !== name + ? updateNode(setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), ts.getEmitFlags(node)), node) + : node; + } + ts.updatePropertyAccessChain = updatePropertyAccessChain; function createElementAccess(expression, index) { - var node = createSynthesizedNode(191 /* ElementAccessExpression */); + var node = createSynthesizedNode(194 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; } ts.createElementAccess = createElementAccess; function updateElementAccess(node, expression, argumentExpression) { + if (ts.isOptionalChain(node)) { + return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression); + } return node.expression !== expression || node.argumentExpression !== argumentExpression ? updateNode(createElementAccess(expression, argumentExpression), node) : node; } ts.updateElementAccess = updateElementAccess; + function createElementAccessChain(expression, questionDotToken, index) { + var node = createSynthesizedNode(194 /* ElementAccessExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.argumentExpression = asExpression(index); + return node; + } + ts.createElementAccessChain = createElementAccessChain; + function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update an ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.argumentExpression !== argumentExpression + ? updateNode(createElementAccessChain(expression, questionDotToken, argumentExpression), node) + : node; + } + ts.updateElementAccessChain = updateElementAccessChain; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(192 /* CallExpression */); + var node = createSynthesizedNode(195 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -63778,6 +66887,9 @@ var ts; } ts.createCall = createCall; function updateCall(node, expression, typeArguments, argumentsArray) { + if (ts.isOptionalChain(node)) { + return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray); + } return node.expression !== expression || node.typeArguments !== typeArguments || node.arguments !== argumentsArray @@ -63785,8 +66897,28 @@ var ts; : node; } ts.updateCall = updateCall; + function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) { + var node = createSynthesizedNode(195 /* CallExpression */); + node.flags |= 32 /* OptionalChain */; + node.expression = ts.parenthesizeForAccess(expression); + node.questionDotToken = questionDotToken; + node.typeArguments = asNodeArray(typeArguments); + node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); + return node; + } + ts.createCallChain = createCallChain; + function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) { + ts.Debug.assert(!!(node.flags & 32 /* OptionalChain */), "Cannot update a CallExpression using updateCallChain. Use updateCall instead."); + return node.expression !== expression + || node.questionDotToken !== questionDotToken + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray + ? updateNode(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node) + : node; + } + ts.updateCallChain = updateCallChain; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(193 /* NewExpression */); + var node = createSynthesizedNode(196 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -63802,7 +66934,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, typeArgumentsOrTemplate, template) { - var node = createSynthesizedNode(194 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(197 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); if (template) { node.typeArguments = asNodeArray(typeArgumentsOrTemplate); @@ -63825,7 +66957,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(195 /* TypeAssertionExpression */); + var node = createSynthesizedNode(198 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -63839,7 +66971,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(196 /* ParenthesizedExpression */); + var node = createSynthesizedNode(199 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -63851,7 +66983,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(197 /* FunctionExpression */); + var node = createSynthesizedNode(200 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -63875,12 +67007,12 @@ var ts; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(198 /* ArrowFunction */); + var node = createSynthesizedNode(201 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(37 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(38 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -63897,7 +67029,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(199 /* DeleteExpression */); + var node = createSynthesizedNode(202 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63909,7 +67041,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(200 /* TypeOfExpression */); + var node = createSynthesizedNode(203 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63921,7 +67053,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(201 /* VoidExpression */); + var node = createSynthesizedNode(204 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63933,7 +67065,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(202 /* AwaitExpression */); + var node = createSynthesizedNode(205 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -63945,7 +67077,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(203 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(206 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -63958,7 +67090,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(204 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(207 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -63971,7 +67103,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(205 /* BinaryExpression */); + var node = createSynthesizedNode(208 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -63988,11 +67120,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(206 /* ConditionalExpression */); + var node = createSynthesizedNode(209 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(56 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(57 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(57 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(58 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -64008,7 +67140,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(207 /* TemplateExpression */); + var node = createSynthesizedNode(210 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -64032,11 +67164,9 @@ var ts; rawTextScanner.setText("`" + rawText + "`"); break; case 15 /* TemplateHead */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("`" + rawText + "${"); break; case 16 /* TemplateMiddle */: - // tslint:disable-next-line no-invalid-template-strings rawTextScanner.setText("}" + rawText + "${"); break; case 17 /* TemplateTail */: @@ -64107,9 +67237,9 @@ var ts; } ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(208 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 40 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 40 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(211 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 41 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 41 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; @@ -64121,7 +67251,7 @@ var ts; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(209 /* SpreadElement */); + var node = createSynthesizedNode(212 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -64133,7 +67263,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(210 /* ClassExpression */); + var node = createSynthesizedNode(213 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64154,11 +67284,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(211 /* OmittedExpression */); + return createSynthesizedNode(214 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(212 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(215 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -64172,7 +67302,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(213 /* AsExpression */); + var node = createSynthesizedNode(216 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -64186,7 +67316,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(214 /* NonNullExpression */); + var node = createSynthesizedNode(217 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -64198,7 +67328,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createMetaProperty(keywordToken, name) { - var node = createSynthesizedNode(215 /* MetaProperty */); + var node = createSynthesizedNode(218 /* MetaProperty */); node.keywordToken = keywordToken; node.name = name; return node; @@ -64212,7 +67342,7 @@ var ts; ts.updateMetaProperty = updateMetaProperty; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(217 /* TemplateSpan */); + var node = createSynthesizedNode(220 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -64226,12 +67356,12 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createSemicolonClassElement() { - return createSynthesizedNode(218 /* SemicolonClassElement */); + return createSynthesizedNode(221 /* SemicolonClassElement */); } ts.createSemicolonClassElement = createSemicolonClassElement; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(219 /* Block */); + var block = createSynthesizedNode(222 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -64245,7 +67375,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(220 /* VariableStatement */); + var node = createSynthesizedNode(224 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -64260,11 +67390,11 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createEmptyStatement() { - return createSynthesizedNode(221 /* EmptyStatement */); + return createSynthesizedNode(223 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createExpressionStatement(expression) { - var node = createSynthesizedNode(222 /* ExpressionStatement */); + var node = createSynthesizedNode(225 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -64280,7 +67410,7 @@ var ts; /** @deprecated Use `updateExpressionStatement` instead. */ ts.updateStatement = updateExpressionStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(223 /* IfStatement */); + var node = createSynthesizedNode(226 /* IfStatement */); node.expression = expression; node.thenStatement = asEmbeddedStatement(thenStatement); node.elseStatement = asEmbeddedStatement(elseStatement); @@ -64296,7 +67426,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(224 /* DoStatement */); + var node = createSynthesizedNode(227 /* DoStatement */); node.statement = asEmbeddedStatement(statement); node.expression = expression; return node; @@ -64310,7 +67440,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(225 /* WhileStatement */); + var node = createSynthesizedNode(228 /* WhileStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64324,7 +67454,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(226 /* ForStatement */); + var node = createSynthesizedNode(229 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -64342,7 +67472,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(227 /* ForInStatement */); + var node = createSynthesizedNode(230 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = asEmbeddedStatement(statement); @@ -64358,10 +67488,10 @@ var ts; } ts.updateForIn = updateForIn; function createForOf(awaitModifier, initializer, expression, statement) { - var node = createSynthesizedNode(228 /* ForOfStatement */); + var node = createSynthesizedNode(231 /* ForOfStatement */); node.awaitModifier = awaitModifier; node.initializer = initializer; - node.expression = expression; + node.expression = ts.isCommaSequence(expression) ? createParen(expression) : expression; node.statement = asEmbeddedStatement(statement); return node; } @@ -64376,7 +67506,7 @@ var ts; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(229 /* ContinueStatement */); + var node = createSynthesizedNode(232 /* ContinueStatement */); node.label = asName(label); return node; } @@ -64388,7 +67518,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(230 /* BreakStatement */); + var node = createSynthesizedNode(233 /* BreakStatement */); node.label = asName(label); return node; } @@ -64400,7 +67530,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(231 /* ReturnStatement */); + var node = createSynthesizedNode(234 /* ReturnStatement */); node.expression = expression; return node; } @@ -64412,7 +67542,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(232 /* WithStatement */); + var node = createSynthesizedNode(235 /* WithStatement */); node.expression = expression; node.statement = asEmbeddedStatement(statement); return node; @@ -64426,7 +67556,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(233 /* SwitchStatement */); + var node = createSynthesizedNode(236 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -64440,7 +67570,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(234 /* LabeledStatement */); + var node = createSynthesizedNode(237 /* LabeledStatement */); node.label = asName(label); node.statement = asEmbeddedStatement(statement); return node; @@ -64454,7 +67584,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(235 /* ThrowStatement */); + var node = createSynthesizedNode(238 /* ThrowStatement */); node.expression = expression; return node; } @@ -64466,7 +67596,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(236 /* TryStatement */); + var node = createSynthesizedNode(239 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -64482,11 +67612,11 @@ var ts; } ts.updateTry = updateTry; function createDebuggerStatement() { - return createSynthesizedNode(237 /* DebuggerStatement */); + return createSynthesizedNode(240 /* DebuggerStatement */); } ts.createDebuggerStatement = createDebuggerStatement; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(238 /* VariableDeclaration */); + var node = createSynthesizedNode(241 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -64503,7 +67633,7 @@ var ts; ts.updateVariableDeclaration = updateVariableDeclaration; function createVariableDeclarationList(declarations, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(239 /* VariableDeclarationList */); + var node = createSynthesizedNode(242 /* VariableDeclarationList */); node.flags |= flags & 3 /* BlockScoped */; node.declarations = createNodeArray(declarations); return node; @@ -64516,7 +67646,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(240 /* FunctionDeclaration */); + var node = createSynthesizedNode(243 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -64542,7 +67672,7 @@ var ts; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(241 /* ClassDeclaration */); + var node = createSynthesizedNode(244 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64564,7 +67694,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(242 /* InterfaceDeclaration */); + var node = createSynthesizedNode(245 /* InterfaceDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64586,7 +67716,7 @@ var ts; } ts.updateInterfaceDeclaration = updateInterfaceDeclaration; function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) { - var node = createSynthesizedNode(243 /* TypeAliasDeclaration */); + var node = createSynthesizedNode(246 /* TypeAliasDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64606,7 +67736,7 @@ var ts; } ts.updateTypeAliasDeclaration = updateTypeAliasDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(244 /* EnumDeclaration */); + var node = createSynthesizedNode(247 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64625,8 +67755,8 @@ var ts; ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { if (flags === void 0) { flags = 0 /* None */; } - var node = createSynthesizedNode(245 /* ModuleDeclaration */); - node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 512 /* GlobalAugmentation */); + var node = createSynthesizedNode(248 /* ModuleDeclaration */); + node.flags |= flags & (16 /* Namespace */ | 4 /* NestedNamespace */ | 1024 /* GlobalAugmentation */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -64644,7 +67774,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(246 /* ModuleBlock */); + var node = createSynthesizedNode(249 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -64656,7 +67786,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(247 /* CaseBlock */); + var node = createSynthesizedNode(250 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -64668,7 +67798,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createNamespaceExportDeclaration(name) { - var node = createSynthesizedNode(248 /* NamespaceExportDeclaration */); + var node = createSynthesizedNode(251 /* NamespaceExportDeclaration */); node.name = asName(name); return node; } @@ -64680,7 +67810,7 @@ var ts; } ts.updateNamespaceExportDeclaration = updateNamespaceExportDeclaration; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(249 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(252 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -64698,7 +67828,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(250 /* ImportDeclaration */); + var node = createSynthesizedNode(253 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -64716,7 +67846,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(251 /* ImportClause */); + var node = createSynthesizedNode(254 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -64730,7 +67860,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(252 /* NamespaceImport */); + var node = createSynthesizedNode(255 /* NamespaceImport */); node.name = name; return node; } @@ -64742,7 +67872,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(253 /* NamedImports */); + var node = createSynthesizedNode(256 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -64754,7 +67884,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(254 /* ImportSpecifier */); + var node = createSynthesizedNode(257 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -64768,11 +67898,11 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(255 /* ExportAssignment */); + var node = createSynthesizedNode(258 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; - node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(60 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); + node.expression = isExportEquals ? ts.parenthesizeBinaryOperand(62 /* EqualsToken */, expression, /*isLeftSideOfBinary*/ false, /*leftOperand*/ undefined) : ts.parenthesizeDefaultExpression(expression); return node; } ts.createExportAssignment = createExportAssignment; @@ -64785,7 +67915,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(256 /* ExportDeclaration */); + var node = createSynthesizedNode(259 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -64802,8 +67932,13 @@ var ts; : node; } ts.updateExportDeclaration = updateExportDeclaration; + /* @internal */ + function createEmptyExports() { + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([]), /*moduleSpecifier*/ undefined); + } + ts.createEmptyExports = createEmptyExports; function createNamedExports(elements) { - var node = createSynthesizedNode(257 /* NamedExports */); + var node = createSynthesizedNode(260 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -64815,7 +67950,7 @@ var ts; } ts.updateNamedExports = updateNamedExports; function createExportSpecifier(propertyName, name) { - var node = createSynthesizedNode(258 /* ExportSpecifier */); + var node = createSynthesizedNode(261 /* ExportSpecifier */); node.propertyName = asName(propertyName); node.name = asName(name); return node; @@ -64830,7 +67965,7 @@ var ts; ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(260 /* ExternalModuleReference */); + var node = createSynthesizedNode(263 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -64844,14 +67979,14 @@ var ts; // JSDoc /* @internal */ function createJSDocTypeExpression(type) { - var node = createSynthesizedNode(289 /* JSDocTypeExpression */); + var node = createSynthesizedNode(292 /* JSDocTypeExpression */); node.type = type; return node; } ts.createJSDocTypeExpression = createJSDocTypeExpression; /* @internal */ function createJSDocTypeTag(typeExpression, comment) { - var tag = createJSDocTag(310 /* JSDocTypeTag */, "type"); + var tag = createJSDocTag(313 /* JSDocTypeTag */, "type"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64859,7 +67994,7 @@ var ts; ts.createJSDocTypeTag = createJSDocTypeTag; /* @internal */ function createJSDocReturnTag(typeExpression, comment) { - var tag = createJSDocTag(308 /* JSDocReturnTag */, "returns"); + var tag = createJSDocTag(311 /* JSDocReturnTag */, "returns"); tag.typeExpression = typeExpression; tag.comment = comment; return tag; @@ -64867,14 +68002,14 @@ var ts; ts.createJSDocReturnTag = createJSDocReturnTag; /** @internal */ function createJSDocThisTag(typeExpression) { - var tag = createJSDocTag(309 /* JSDocThisTag */, "this"); + var tag = createJSDocTag(312 /* JSDocThisTag */, "this"); tag.typeExpression = typeExpression; return tag; } ts.createJSDocThisTag = createJSDocThisTag; /* @internal */ function createJSDocParamTag(name, isBracketed, typeExpression, comment) { - var tag = createJSDocTag(307 /* JSDocParameterTag */, "param"); + var tag = createJSDocTag(310 /* JSDocParameterTag */, "param"); tag.typeExpression = typeExpression; tag.name = name; tag.isBracketed = isBracketed; @@ -64884,7 +68019,7 @@ var ts; ts.createJSDocParamTag = createJSDocParamTag; /* @internal */ function createJSDocComment(comment, tags) { - var node = createSynthesizedNode(298 /* JSDocComment */); + var node = createSynthesizedNode(301 /* JSDocComment */); node.comment = comment; node.tags = tags; return node; @@ -64898,7 +68033,7 @@ var ts; } // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(261 /* JsxElement */); + var node = createSynthesizedNode(264 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -64914,7 +68049,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(262 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(265 /* JsxSelfClosingElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64930,7 +68065,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, typeArguments, attributes) { - var node = createSynthesizedNode(263 /* JsxOpeningElement */); + var node = createSynthesizedNode(266 /* JsxOpeningElement */); node.tagName = tagName; node.typeArguments = asNodeArray(typeArguments); node.attributes = attributes; @@ -64946,7 +68081,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(264 /* JsxClosingElement */); + var node = createSynthesizedNode(267 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -64958,7 +68093,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxFragment(openingFragment, children, closingFragment) { - var node = createSynthesizedNode(265 /* JsxFragment */); + var node = createSynthesizedNode(268 /* JsxFragment */); node.openingFragment = openingFragment; node.children = createNodeArray(children); node.closingFragment = closingFragment; @@ -64980,11 +68115,11 @@ var ts; } ts.updateJsxText = updateJsxText; function createJsxOpeningFragment() { - return createSynthesizedNode(266 /* JsxOpeningFragment */); + return createSynthesizedNode(269 /* JsxOpeningFragment */); } ts.createJsxOpeningFragment = createJsxOpeningFragment; function createJsxJsxClosingFragment() { - return createSynthesizedNode(267 /* JsxClosingFragment */); + return createSynthesizedNode(270 /* JsxClosingFragment */); } ts.createJsxJsxClosingFragment = createJsxJsxClosingFragment; function updateJsxFragment(node, openingFragment, children, closingFragment) { @@ -64996,7 +68131,7 @@ var ts; } ts.updateJsxFragment = updateJsxFragment; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(268 /* JsxAttribute */); + var node = createSynthesizedNode(271 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -65010,7 +68145,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxAttributes(properties) { - var node = createSynthesizedNode(269 /* JsxAttributes */); + var node = createSynthesizedNode(272 /* JsxAttributes */); node.properties = createNodeArray(properties); return node; } @@ -65022,7 +68157,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(270 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(273 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -65034,7 +68169,7 @@ var ts; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; function createJsxExpression(dotDotDotToken, expression) { - var node = createSynthesizedNode(271 /* JsxExpression */); + var node = createSynthesizedNode(274 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -65048,7 +68183,7 @@ var ts; ts.updateJsxExpression = updateJsxExpression; // Clauses function createCaseClause(expression, statements) { - var node = createSynthesizedNode(272 /* CaseClause */); + var node = createSynthesizedNode(275 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -65062,7 +68197,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(273 /* DefaultClause */); + var node = createSynthesizedNode(276 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -65074,7 +68209,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createHeritageClause(token, types) { - var node = createSynthesizedNode(274 /* HeritageClause */); + var node = createSynthesizedNode(277 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -65087,7 +68222,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(275 /* CatchClause */); + var node = createSynthesizedNode(278 /* CatchClause */); node.variableDeclaration = ts.isString(variableDeclaration) ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -65102,7 +68237,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(276 /* PropertyAssignment */); + var node = createSynthesizedNode(279 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = ts.parenthesizeExpressionForList(initializer); @@ -65117,7 +68252,7 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(277 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(280 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; @@ -65131,7 +68266,7 @@ var ts; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; function createSpreadAssignment(expression) { - var node = createSynthesizedNode(278 /* SpreadAssignment */); + var node = createSynthesizedNode(281 /* SpreadAssignment */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -65144,7 +68279,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(279 /* EnumMember */); + var node = createSynthesizedNode(282 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -65165,7 +68300,7 @@ var ts; (typeReferences !== undefined && node.typeReferenceDirectives !== typeReferences) || (libReferences !== undefined && node.libReferenceDirectives !== libReferences) || (hasNoDefaultLib !== undefined && node.hasNoDefaultLib !== hasNoDefaultLib)) { - var updated = createSynthesizedNode(285 /* SourceFile */); + var updated = createSynthesizedNode(288 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -65249,7 +68384,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(315 /* NotEmittedStatement */); + var node = createSynthesizedNode(318 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -65261,7 +68396,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(319 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(322 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65273,7 +68408,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(318 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(321 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -65288,7 +68423,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(316 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(319 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -65304,7 +68439,7 @@ var ts; ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function flattenCommaElements(node) { if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { - if (node.kind === 317 /* CommaListExpression */) { + if (node.kind === 320 /* CommaListExpression */) { return node.elements; } if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27 /* CommaToken */) { @@ -65314,7 +68449,7 @@ var ts; return node; } function createCommaList(elements) { - var node = createSynthesizedNode(317 /* CommaListExpression */); + var node = createSynthesizedNode(320 /* CommaListExpression */); node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements)); return node; } @@ -65325,9 +68460,25 @@ var ts; : node; } ts.updateCommaList = updateCommaList; + /* @internal */ + function createSyntheticReferenceExpression(expression, thisArg) { + var node = createSynthesizedNode(323 /* SyntheticReferenceExpression */); + node.expression = expression; + node.thisArg = thisArg; + return node; + } + ts.createSyntheticReferenceExpression = createSyntheticReferenceExpression; + /* @internal */ + function updateSyntheticReferenceExpression(node, expression, thisArg) { + return node.expression !== expression + || node.thisArg !== thisArg + ? updateNode(createSyntheticReferenceExpression(expression, thisArg), node) + : node; + } + ts.updateSyntheticReferenceExpression = updateSyntheticReferenceExpression; function createBundle(sourceFiles, prepends) { if (prepends === void 0) { prepends = ts.emptyArray; } - var node = ts.createNode(286 /* Bundle */); + var node = ts.createNode(289 /* Bundle */); node.prepends = prepends; node.sourceFiles = sourceFiles; return node; @@ -65358,7 +68509,7 @@ var ts; ], function (helper) { return helper.name; })); } function createUnparsedSource() { - var node = ts.createNode(287 /* UnparsedSource */); + var node = ts.createNode(290 /* UnparsedSource */); node.prologues = ts.emptyArray; node.referencedFiles = ts.emptyArray; node.libReferenceDirectives = ts.emptyArray; @@ -65440,8 +68591,11 @@ var ts; (texts || (texts = [])).push(prependNode); break; case "internal" /* Internal */: - if (stripInternal) + if (stripInternal) { + if (!texts) + texts = []; break; + } // falls through case "text" /* Text */: (texts || (texts = [])).push(createUnparsedNode(section, node)); @@ -65490,10 +68644,10 @@ var ts; } function mapBundleFileSectionKindToSyntaxKind(kind) { switch (kind) { - case "prologue" /* Prologue */: return 280 /* UnparsedPrologue */; - case "prepend" /* Prepend */: return 281 /* UnparsedPrepend */; - case "internal" /* Internal */: return 283 /* UnparsedInternalText */; - case "text" /* Text */: return 282 /* UnparsedText */; + case "prologue" /* Prologue */: return 283 /* UnparsedPrologue */; + case "prepend" /* Prepend */: return 284 /* UnparsedPrepend */; + case "internal" /* Internal */: return 286 /* UnparsedInternalText */; + case "text" /* Text */: return 285 /* UnparsedText */; case "emitHelpers" /* EmitHelpers */: case "no-default-lib" /* NoDefaultLib */: case "reference" /* Reference */: @@ -65511,14 +68665,14 @@ var ts; return node; } function createUnparsedSyntheticReference(section, parent) { - var node = ts.createNode(284 /* UnparsedSyntheticReference */, section.pos, section.end); + var node = ts.createNode(287 /* UnparsedSyntheticReference */, section.pos, section.end); node.parent = parent; node.data = section.data; node.section = section; return node; } function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) { - var node = ts.createNode(288 /* InputFiles */); + var node = ts.createNode(291 /* InputFiles */); if (!ts.isString(javascriptTextOrReadFileText)) { var cache_1 = ts.createMap(); var textGetter_1 = function (path) { @@ -65564,8 +68718,8 @@ var ts; node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapTextOrBuildInfoPath; node.javascriptPath = javascriptPath; - node.declarationPath = declarationPath, - node.buildInfoPath = buildInfoPath; + node.declarationPath = declarationPath; + node.buildInfoPath = buildInfoPath; node.buildInfo = buildInfo; node.oldFileOfCurrentEmit = oldFileOfCurrentEmit; } @@ -65608,43 +68762,47 @@ var ts; } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 28 /* LessThanToken */, right); + return createBinary(left, 29 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 60 /* EqualsToken */, right); + return createBinary(left, 62 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 35 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 36 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 36 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 37 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 38 /* PlusToken */, right); + return createBinary(left, 39 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 39 /* MinusToken */, right); + return createBinary(left, 40 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 44 /* PlusPlusToken */); + return createPostfix(operand, 45 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 54 /* AmpersandAmpersandToken */, right); + return createBinary(left, 55 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 55 /* BarBarToken */, right); + return createBinary(left, 56 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; + function createNullishCoalesce(left, right) { + return createBinary(left, 60 /* QuestionQuestionToken */, right); + } + ts.createNullishCoalesce = createNullishCoalesce; function createLogicalNot(operand) { - return createPrefix(52 /* ExclamationToken */, operand); + return createPrefix(53 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -65664,7 +68822,10 @@ var ts; return ts.isString(name) ? createIdentifier(name) : name; } function asExpression(value) { - return ts.isString(value) || typeof value === "number" ? createLiteral(value) : value; + return typeof value === "string" ? createStringLiteral(value) : + typeof value === "number" ? createNumericLiteral("" + value) : + typeof value === "boolean" ? value ? createTrue() : createFalse() : + value; } function asNodeArray(array) { return array ? createNodeArray(array) : undefined; @@ -65708,7 +68869,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node))); @@ -65773,7 +68934,6 @@ var ts; return node; } ts.setSourceMapRange = setSourceMapRange; - // tslint:disable-next-line variable-name var SourceMapSource; /** * Create an external source map source file reference @@ -66249,7 +69409,7 @@ var ts; if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 234 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 237 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -66261,20 +69421,20 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = ts.skipParentheses(node); switch (target.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return cacheIdentifiers; - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* BigIntLiteral */: case 10 /* StringLiteral */: return false; - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -66289,7 +69449,7 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 99 /* SuperKeyword */) { + else if (callee.kind === 101 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) @@ -66301,7 +69461,7 @@ var ts; } else { switch (callee.kind) { - case 190 /* PropertyAccessExpression */: { + case 193 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66314,7 +69474,7 @@ var ts; } break; } - case 191 /* ElementAccessExpression */: { + case 194 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -66371,14 +69531,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, !!node.multiLine); - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -66656,8 +69816,8 @@ var ts; } ts.addCustomPrologue = addCustomPrologue; function findUseStrictPrologue(statements) { - for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { - var statement = statements_3[_i]; + for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) { + var statement = statements_4[_i]; if (ts.isPrologueDirective(statement)) { if (isUseStrictPrologue(statement)) { return statement; @@ -66704,7 +69864,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = ts.skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 196 /* ParenthesizedExpression */) { + if (skipped.kind === 199 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -66738,10 +69898,10 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(205 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(208 /* BinaryExpression */, binaryOperator); var emittedOperand = ts.skipPartiallyEmittedExpressions(operand); - if (!isLeftSideOfBinary && operand.kind === 198 /* ArrowFunction */ && binaryOperatorPrecedence > 4) { + if (!isLeftSideOfBinary && operand.kind === 201 /* ArrowFunction */ && binaryOperatorPrecedence > 3) { // We need to parenthesize arrow functions on the right side to avoid it being // parsed as parenthesized expression: `a && (() => {})` return true; @@ -66753,7 +69913,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 208 /* YieldExpression */) { + && operand.kind === 211 /* YieldExpression */) { return false; } return true; @@ -66790,7 +69950,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 38 /* PlusToken */) { + if (binaryOperator === 39 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -66825,10 +69985,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 40 /* AsteriskToken */ - || binaryOperator === 50 /* BarToken */ - || binaryOperator === 49 /* AmpersandToken */ - || binaryOperator === 51 /* CaretToken */; + return binaryOperator === 41 /* AsteriskToken */ + || binaryOperator === 51 /* BarToken */ + || binaryOperator === 50 /* AmpersandToken */ + || binaryOperator === 52 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -66841,25 +70001,23 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 38 /* PlusToken */) { + if (node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 39 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } var leftKind = getLiteralKindOfBinaryPlusOperand(node.left); - var literalKind = ts.isLiteralKind(leftKind) - && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) - ? leftKind - : 0 /* Unknown */; + var literalKind = ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(node.right) ? leftKind : + 0 /* Unknown */; node.cachedLiteralKind = literalKind; return literalKind; } return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(206 /* ConditionalExpression */, 56 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(209 /* ConditionalExpression */, 57 /* QuestionToken */); var emittedCondition = ts.skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); - if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1 /* GreaterThan */) { return ts.createParen(condition); } return condition; @@ -66891,8 +70049,8 @@ var ts; var needsParens = isCommaSequence(check); if (!needsParens) { switch (getLeftmostExpression(check, /*stopAtCallExpression*/ false).kind) { - case 210 /* ClassExpression */: - case 197 /* FunctionExpression */: + case 213 /* ClassExpression */: + case 200 /* FunctionExpression */: needsParens = true; } } @@ -66908,9 +70066,9 @@ var ts; function parenthesizeForNew(expression) { var leftmostExpr = getLeftmostExpression(expression, /*stopAtCallExpressions*/ true); switch (leftmostExpr.kind) { - case 192 /* CallExpression */: + case 195 /* CallExpression */: return ts.createParen(expression); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return !leftmostExpr.arguments ? ts.createParen(expression) : expression; @@ -66933,7 +70091,7 @@ var ts; // var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 193 /* NewExpression */ || emittedExpression.arguments)) { + && (emittedExpression.kind !== 196 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -66971,7 +70129,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = ts.skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(205 /* BinaryExpression */, 27 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(208 /* BinaryExpression */, 27 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -66982,29 +70140,29 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = ts.skipPartiallyEmittedExpressions(callee).kind; - if (kind === 197 /* FunctionExpression */ || kind === 198 /* ArrowFunction */) { + if (kind === 200 /* FunctionExpression */ || kind === 201 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } var leftmostExpressionKind = getLeftmostExpression(emittedExpression, /*stopAtCallExpressions*/ false).kind; - if (leftmostExpressionKind === 189 /* ObjectLiteralExpression */ || leftmostExpressionKind === 197 /* FunctionExpression */) { + if (leftmostExpressionKind === 192 /* ObjectLiteralExpression */ || leftmostExpressionKind === 200 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } return expression; } ts.parenthesizeExpressionForExpressionStatement = parenthesizeExpressionForExpressionStatement; function parenthesizeConditionalTypeMember(member) { - return member.kind === 176 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; + return member.kind === 179 /* ConditionalType */ ? ts.createParenthesizedType(member) : member; } ts.parenthesizeConditionalTypeMember = parenthesizeConditionalTypeMember; function parenthesizeElementTypeMember(member) { switch (member.kind) { - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createParenthesizedType(member); } return parenthesizeConditionalTypeMember(member); @@ -67012,9 +70170,9 @@ var ts; ts.parenthesizeElementTypeMember = parenthesizeElementTypeMember; function parenthesizeArrayTypeMember(member) { switch (member.kind) { - case 168 /* TypeQuery */: - case 180 /* TypeOperator */: - case 177 /* InferType */: + case 171 /* TypeQuery */: + case 183 /* TypeOperator */: + case 180 /* InferType */: return ts.createParenthesizedType(member); } return parenthesizeElementTypeMember(member); @@ -67040,28 +70198,28 @@ var ts; function getLeftmostExpression(node, stopAtCallExpressions) { while (true) { switch (node.kind) { - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: node = node.operand; continue; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: node = node.left; continue; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: node = node.condition; continue; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: node = node.tag; continue; - case 192 /* CallExpression */: + case 195 /* CallExpression */: if (stopAtCallExpressions) { return node; } // falls through - case 213 /* AsExpression */: - case 191 /* ElementAccessExpression */: - case 190 /* PropertyAccessExpression */: - case 214 /* NonNullExpression */: - case 316 /* PartiallyEmittedExpression */: + case 216 /* AsExpression */: + case 194 /* ElementAccessExpression */: + case 193 /* PropertyAccessExpression */: + case 217 /* NonNullExpression */: + case 319 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -67070,15 +70228,15 @@ var ts; } ts.getLeftmostExpression = getLeftmostExpression; function parenthesizeConciseBody(body) { - if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 189 /* ObjectLiteralExpression */)) { + if (!ts.isBlock(body) && (isCommaSequence(body) || getLeftmostExpression(body, /*stopAtCallExpressions*/ false).kind === 192 /* ObjectLiteralExpression */)) { return ts.setTextRange(ts.createParen(body), body); } return body; } ts.parenthesizeConciseBody = parenthesizeConciseBody; function isCommaSequence(node) { - return node.kind === 205 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || - node.kind === 317 /* CommaListExpression */; + return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 27 /* CommaToken */ || + node.kind === 320 /* CommaListExpression */; } ts.isCommaSequence = isCommaSequence; var OuterExpressionKinds; @@ -67091,13 +70249,13 @@ var ts; function isOuterExpression(node, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } switch (node.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return (kinds & 1 /* Parentheses */) !== 0; - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: - case 214 /* NonNullExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: + case 217 /* NonNullExpression */: return (kinds & 2 /* Assertions */) !== 0; - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return (kinds & 4 /* PartiallyEmittedExpressions */) !== 0; } return false; @@ -67122,7 +70280,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipAssertions(node) { - while (ts.isAssertionExpression(node) || node.kind === 214 /* NonNullExpression */) { + while (ts.isAssertionExpression(node) || node.kind === 217 /* NonNullExpression */) { node = node.expression; } return node; @@ -67130,11 +70288,11 @@ var ts; ts.skipAssertions = skipAssertions; function updateOuterExpression(outerExpression, expression) { switch (outerExpression.kind) { - case 196 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); - case 195 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); - case 213 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); - case 214 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); - case 316 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); + case 199 /* ParenthesizedExpression */: return ts.updateParen(outerExpression, expression); + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(outerExpression, outerExpression.type, expression); + case 216 /* AsExpression */: return ts.updateAsExpression(outerExpression, expression, outerExpression.type); + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(outerExpression, expression); + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } /** @@ -67152,7 +70310,7 @@ var ts; * the containing expression is created/updated. */ function isIgnorableParen(node) { - return node.kind === 196 /* ParenthesizedExpression */ + return node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node) && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) && ts.nodeIsSynthesized(ts.getCommentRange(node)) @@ -67271,10 +70429,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name)); } - if (node.kind === 250 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 253 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 256 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 259 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -67393,7 +70551,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -67405,11 +70563,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -67441,12 +70599,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 152 /* Parameter */: - case 187 /* BindingElement */: + case 155 /* Parameter */: + case 190 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 209 /* SpreadElement */: - case 278 /* SpreadAssignment */: + case 212 /* SpreadElement */: + case 281 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -67458,7 +70616,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 187 /* BindingElement */: + case 190 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -67470,7 +70628,7 @@ var ts; : propertyName; } break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -67482,7 +70640,7 @@ var ts; : propertyName; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -67505,13 +70663,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -67551,11 +70709,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 186 /* ArrayBindingPattern */: - case 188 /* ArrayLiteralExpression */: + case 189 /* ArrayBindingPattern */: + case 191 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 185 /* ObjectBindingPattern */: - case 189 /* ObjectLiteralExpression */: + case 188 /* ObjectBindingPattern */: + case 192 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -67679,7 +70837,7 @@ var ts; context.startLexicalEnvironment(); statements = visitNodes(statements, visitor, ts.isStatement, start); if (ensureUseStrict) - statements = ts.ensureUseStrict(statements); // tslint:disable-line no-unnecessary-qualifier + statements = ts.ensureUseStrict(statements); // eslint-disable-line @typescript-eslint/no-unnecessary-qualifier return ts.mergeLexicalEnvironment(statements, context.endLexicalEnvironment()); } ts.visitLexicalEnvironment = visitLexicalEnvironment; @@ -67714,278 +70872,287 @@ var ts; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */) || kind === 179 /* ThisType */) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */) || kind === 182 /* ThisType */) { return node; } switch (kind) { // Names - case 73 /* Identifier */: + case 75 /* Identifier */: return ts.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); - case 152 /* Parameter */: + case 155 /* Parameter */: return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 153 /* Decorator */: + case 156 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); // Type elements - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return ts.updatePropertySignature(node, nodesVisitor(node.modifiers, visitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too visitNode(node.questionToken || node.exclamationToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 158 /* Constructor */: + case 161 /* Constructor */: return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return ts.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return ts.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return ts.updateIndexSignature(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); // Types - case 164 /* TypePredicate */: - return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); - case 165 /* TypeReference */: + case 167 /* TypePredicate */: + return ts.updateTypePredicateNodeWithModifier(node, visitNode(node.assertsModifier, visitor), visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 168 /* TypeReference */: return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); - case 171 /* TupleType */: + case 174 /* TupleType */: return ts.updateTupleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return ts.updateOptionalTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 173 /* RestType */: + case 176 /* RestType */: return ts.updateRestTypeNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 174 /* UnionType */: + case 177 /* UnionType */: return ts.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return ts.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return ts.updateConditionalTypeNode(node, visitNode(node.checkType, visitor, ts.isTypeNode), visitNode(node.extendsType, visitor, ts.isTypeNode), visitNode(node.trueType, visitor, ts.isTypeNode), visitNode(node.falseType, visitor, ts.isTypeNode)); - case 177 /* InferType */: + case 180 /* InferType */: return ts.updateInferTypeNode(node, visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration)); - case 184 /* ImportType */: + case 187 /* ImportType */: return ts.updateImportTypeNode(node, visitNode(node.argument, visitor, ts.isTypeNode), visitNode(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); - case 182 /* MappedType */: + case 185 /* MappedType */: return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameterDeclaration), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updatePropertyAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier)); + } return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateElementAccessChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), visitNode(node.argumentExpression, visitor, ts.isExpression)); + } return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 192 /* CallExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + return ts.updateCallChain(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.questionDotToken, visitor, ts.isToken), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + } return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 213 /* AsExpression */: + case 216 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return ts.updateMetaProperty(node, visitNode(node.name, visitor, ts.isIdentifier)); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 219 /* Block */: + case 222 /* Block */: return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return ts.updateExpressionStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return ts.updateForOf(node, visitNode(node.awaitModifier, visitor, ts.isToken), visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return ts.updateInterfaceDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isTypeElement)); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return ts.updateTypeAliasDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return ts.updateNamespaceExportDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 263 /* JsxOpeningElement */: + case 266 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return ts.updateJsxFragment(node, visitNode(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingFragment, visitor, ts.isJsxClosingFragment)); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return ts.updateCommaList(node, nodesVisitor(node.elements, visitor, ts.isExpression)); default: // No need to visit nodes with no children. @@ -68027,58 +71194,58 @@ var ts; var cbNodes = cbNodeArray || cbNode; var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 148 /* LastToken */)) { + if ((kind > 0 /* FirstToken */ && kind <= 151 /* LastToken */)) { return initial; } // We do not yet support types. - if ((kind >= 164 /* TypePredicate */ && kind <= 183 /* LiteralType */)) { + if ((kind >= 167 /* TypePredicate */ && kind <= 186 /* LiteralType */)) { return initial; } var result = initial; switch (node.kind) { // Leaf nodes - case 218 /* SemicolonClassElement */: - case 221 /* EmptyStatement */: - case 211 /* OmittedExpression */: - case 237 /* DebuggerStatement */: - case 315 /* NotEmittedStatement */: + case 221 /* SemicolonClassElement */: + case 223 /* EmptyStatement */: + case 214 /* OmittedExpression */: + case 240 /* DebuggerStatement */: + case 318 /* NotEmittedStatement */: // No need to visit nodes with no children. break; // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: result = reduceNode(node.expression, cbNode, result); break; // Signature elements - case 152 /* Parameter */: + case 155 /* Parameter */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 153 /* Decorator */: + case 156 /* Decorator */: result = reduceNode(node.expression, cbNode, result); break; // Type member - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.questionToken, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68087,12 +71254,12 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 158 /* Constructor */: + case 161 /* Constructor */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.body, cbNode, result); break; - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68100,7 +71267,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68108,50 +71275,50 @@ var ts; result = reduceNode(node.body, cbNode, result); break; // Binding patterns - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: result = reduceNodes(node.elements, cbNodes, result); break; - case 187 /* BindingElement */: + case 190 /* BindingElement */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Expression - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: result = reduceNodes(node.elements, cbNodes, result); break; - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: result = reduceNodes(node.properties, cbNodes, result); break; - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.argumentExpression, cbNode, result); break; - case 192 /* CallExpression */: + case 195 /* CallExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 193 /* NewExpression */: + case 196 /* NewExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNodes(node.arguments, cbNodes, result); break; - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: result = reduceNode(node.tag, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); result = reduceNode(node.template, cbNode, result); break; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: result = reduceNode(node.type, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); @@ -68159,123 +71326,123 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.parameters, cbNodes, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 196 /* ParenthesizedExpression */: - case 199 /* DeleteExpression */: - case 200 /* TypeOfExpression */: - case 201 /* VoidExpression */: - case 202 /* AwaitExpression */: - case 208 /* YieldExpression */: - case 209 /* SpreadElement */: - case 214 /* NonNullExpression */: + case 199 /* ParenthesizedExpression */: + case 202 /* DeleteExpression */: + case 203 /* TypeOfExpression */: + case 204 /* VoidExpression */: + case 205 /* AwaitExpression */: + case 211 /* YieldExpression */: + case 212 /* SpreadElement */: + case 217 /* NonNullExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: result = reduceNode(node.operand, cbNode, result); break; - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: result = reduceNode(node.left, cbNode, result); result = reduceNode(node.right, cbNode, result); break; - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.whenTrue, cbNode, result); result = reduceNode(node.whenFalse, cbNode, result); break; - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: result = reduceNode(node.head, cbNode, result); result = reduceNodes(node.templateSpans, cbNodes, result); break; - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.typeParameters, cbNodes, result); result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: result = reduceNode(node.expression, cbNode, result); result = reduceNodes(node.typeArguments, cbNodes, result); break; - case 213 /* AsExpression */: + case 216 /* AsExpression */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.type, cbNode, result); break; // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.literal, cbNode, result); break; // Element - case 219 /* Block */: + case 222 /* Block */: result = reduceNodes(node.statements, cbNodes, result); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.declarationList, cbNode, result); break; - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.thenStatement, cbNode, result); result = reduceNode(node.elseStatement, cbNode, result); break; - case 224 /* DoStatement */: + case 227 /* DoStatement */: result = reduceNode(node.statement, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 225 /* WhileStatement */: - case 232 /* WithStatement */: + case 228 /* WhileStatement */: + case 235 /* WithStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 226 /* ForStatement */: + case 229 /* ForStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.condition, cbNode, result); result = reduceNode(node.incrementor, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: result = reduceNode(node.initializer, cbNode, result); result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 231 /* ReturnStatement */: - case 235 /* ThrowStatement */: + case 234 /* ReturnStatement */: + case 238 /* ThrowStatement */: result = reduceNode(node.expression, cbNode, result); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: result = reduceNode(node.expression, cbNode, result); result = reduceNode(node.caseBlock, cbNode, result); break; - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: result = reduceNode(node.label, cbNode, result); result = reduceNode(node.statement, cbNode, result); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: result = reduceNode(node.tryBlock, cbNode, result); result = reduceNode(node.catchClause, cbNode, result); result = reduceNode(node.finallyBlock, cbNode, result); break; - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.type, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: result = reduceNodes(node.declarations, cbNodes, result); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68284,7 +71451,7 @@ var ts; result = reduceNode(node.type, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); @@ -68292,140 +71459,140 @@ var ts; result = reduceNodes(node.heritageClauses, cbNodes, result); result = reduceNodes(node.members, cbNodes, result); break; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNodes(node.members, cbNodes, result); break; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.body, cbNode, result); break; - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: result = reduceNodes(node.statements, cbNodes, result); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: result = reduceNodes(node.clauses, cbNodes, result); break; - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.name, cbNode, result); result = reduceNode(node.moduleReference, cbNode, result); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: result = reduceNodes(node.decorators, cbNodes, result); result = reduceNodes(node.modifiers, cbNodes, result); result = reduceNode(node.importClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.namedBindings, cbNode, result); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: result = reduceNode(node.name, cbNode, result); break; - case 253 /* NamedImports */: - case 257 /* NamedExports */: + case 256 /* NamedImports */: + case 260 /* NamedExports */: result = reduceNodes(node.elements, cbNodes, result); break; - case 254 /* ImportSpecifier */: - case 258 /* ExportSpecifier */: + case 257 /* ImportSpecifier */: + case 261 /* ExportSpecifier */: result = reduceNode(node.propertyName, cbNode, result); result = reduceNode(node.name, cbNode, result); break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.expression, cbNode, result); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: result = ts.reduceLeft(node.decorators, cbNode, result); result = ts.reduceLeft(node.modifiers, cbNode, result); result = reduceNode(node.exportClause, cbNode, result); result = reduceNode(node.moduleSpecifier, cbNode, result); break; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: result = reduceNode(node.expression, cbNode, result); break; // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: result = reduceNode(node.openingElement, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingElement, cbNode, result); break; - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: result = reduceNode(node.openingFragment, cbNode, result); result = ts.reduceLeft(node.children, cbNode, result); result = reduceNode(node.closingFragment, cbNode, result); break; - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: result = reduceNode(node.tagName, cbNode, result); result = reduceNodes(node.typeArguments, cbNode, result); result = reduceNode(node.attributes, cbNode, result); break; - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: result = reduceNodes(node.properties, cbNodes, result); break; - case 264 /* JsxClosingElement */: + case 267 /* JsxClosingElement */: result = reduceNode(node.tagName, cbNode, result); break; - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: result = reduceNode(node.expression, cbNode, result); break; - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: result = reduceNode(node.expression, cbNode, result); break; // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: result = reduceNode(node.expression, cbNode, result); // falls through - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: result = reduceNodes(node.statements, cbNodes, result); break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: result = reduceNodes(node.types, cbNodes, result); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: result = reduceNode(node.variableDeclaration, cbNode, result); result = reduceNode(node.block, cbNode, result); break; // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.objectAssignmentInitializer, cbNode, result); break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: result = reduceNode(node.expression, cbNode, result); break; // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: result = reduceNode(node.name, cbNode, result); result = reduceNode(node.initializer, cbNode, result); break; // Top-level nodes - case 285 /* SourceFile */: + case 288 /* SourceFile */: result = reduceNodes(node.statements, cbNodes, result); break; // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: result = reduceNode(node.expression, cbNode, result); break; - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: result = reduceNodes(node.elements, cbNodes, result); break; default: @@ -68498,7 +71665,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 212 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 215 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -68571,19 +71738,20 @@ var ts; exit(); return sourceIndex; } + /* eslint-disable boolean-trivia, no-null/no-null */ function setSourceContent(sourceIndex, content) { enter(); if (content !== null) { if (!sourcesContent) sourcesContent = []; while (sourcesContent.length < sourceIndex) { - // tslint:disable-next-line:no-null-keyword boolean-trivia sourcesContent.push(null); } sourcesContent[sourceIndex] = content; } exit(); } + /* eslint-enable boolean-trivia, no-null/no-null */ function addName(name) { enter(); if (!nameToNameIndexMap) @@ -68786,12 +71954,11 @@ var ts; } } ts.tryGetSourceMappingURL = tryGetSourceMappingURL; + /* eslint-disable no-null/no-null */ function isStringOrNull(x) { - // tslint:disable-next-line:no-null-keyword return typeof x === "string" || x === null; } function isRawSourceMap(x) { - // tslint:disable-next-line:no-null-keyword return x !== null && typeof x === "object" && x.version === 3 @@ -68803,6 +71970,7 @@ var ts; && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString)); } ts.isRawSourceMap = isRawSourceMap; + /* eslint-enable no-null/no-null */ function tryParseRawSourceMap(text) { try { var parsed = JSON.parse(text); @@ -69171,7 +72339,7 @@ var ts; function chainBundle(transformSourceFile) { return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - return node.kind === 285 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); + return node.kind === 288 /* SourceFile */ ? transformSourceFile(node) : transformBundle(node); } function transformBundle(node) { return ts.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends); @@ -69218,7 +72386,7 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" @@ -69231,13 +72399,13 @@ var ts; hasImportDefault = true; } break; - case 249 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 260 /* ExternalModuleReference */) { + case 252 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 263 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -69267,13 +72435,13 @@ var ts; } } break; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -69281,7 +72449,7 @@ var ts; } } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -69301,7 +72469,7 @@ var ts; } } break; - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -69399,7 +72567,7 @@ var ts; return index; } var statement = statements[index]; - if (statement.kind === 222 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 225 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -69429,42 +72597,28 @@ var ts; } ts.helperString = helperString; /** - * Gets all property declarations with initializers on either the static or instance side of a class. + * Gets all the static or all the instance property declarations of a class * * @param node The class node. * @param isStatic A value indicating whether to get properties from the static or instance side of the class. */ - function getInitializedProperties(node, isStatic) { - return ts.filter(node.members, isStatic ? isStaticInitializedProperty : isInstanceInitializedProperty); + function getProperties(node, requireInitializer, isStatic) { + return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); }); } - ts.getInitializedProperties = getInitializedProperties; + ts.getProperties = getProperties; /** - * Gets a value indicating whether a class element is a static property declaration with an initializer. - * - * @param member The class element node. - */ - function isStaticInitializedProperty(member) { - return isInitializedProperty(member) && ts.hasStaticModifier(member); - } - ts.isStaticInitializedProperty = isStaticInitializedProperty; - /** - * Gets a value indicating whether a class element is an instance property declaration with an initializer. - * - * @param member The class element node. - */ - function isInstanceInitializedProperty(member) { - return isInitializedProperty(member) && !ts.hasStaticModifier(member); - } - ts.isInstanceInitializedProperty = isInstanceInitializedProperty; - /** - * Gets a value indicating whether a class element is either a static or an instance property declaration with an initializer. + * Is a class element either a static or an instance property declaration with an initializer? * * @param member The class element node. * @param isStatic A value indicating whether the member should be a static or instance member. */ - function isInitializedProperty(member) { - return member.kind === 155 /* PropertyDeclaration */ - && member.initializer !== undefined; + function isInitializedOrStaticProperty(member, requireInitializer, isStatic) { + return ts.isPropertyDeclaration(member) + && (!!member.initializer || !requireInitializer) + && ts.hasStaticModifier(member) === isStatic; + } + function isInitializedProperty(member, requireInitializer) { + return ts.isPropertyDeclaration(member) && (!!member.initializer || !requireInitializer); } ts.isInitializedProperty = isInitializedProperty; })(ts || (ts = {})); @@ -69990,8 +73144,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -70017,14 +73171,14 @@ var ts; var applicableSubstitutions; return transformSourceFileOrBundle; function transformSourceFileOrBundle(node) { - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { return transformBundle(node); } return transformSourceFile(node); } function transformBundle(node) { return ts.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { return ts.createUnparsedSourceFile(prepend, "js"); } return prepend; @@ -70075,16 +73229,16 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 285 /* SourceFile */: - case 247 /* CaseBlock */: - case 246 /* ModuleBlock */: - case 219 /* Block */: + case 288 /* SourceFile */: + case 250 /* CaseBlock */: + case 249 /* ModuleBlock */: + case 222 /* Block */: currentLexicalScope = node; currentNameScope = undefined; currentScopeFirstDeclarationsOfName = undefined; break; - case 241 /* ClassDeclaration */: - case 240 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 243 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -70096,7 +73250,7 @@ var ts; // These nodes should always have names unless they are default-exports; // however, class declaration parsing allows for undefined names, so syntactically invalid // programs may also have an undefined name. - ts.Debug.assert(node.kind === 241 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); + ts.Debug.assert(node.kind === 244 /* ClassDeclaration */ || ts.hasModifier(node, 512 /* Default */)); } if (ts.isClassDeclaration(node)) { // XXX: should probably also cover interfaces and type aliases that can have type variables? @@ -70139,10 +73293,10 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 255 /* ExportAssignment */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 258 /* ExportAssignment */: + case 259 /* ExportDeclaration */: return visitEllidableStatement(node); default: return visitorWorker(node); @@ -70163,13 +73317,13 @@ var ts; return node; } switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); default: ts.Debug.fail("Unhandled ellided statement"); @@ -70189,11 +73343,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 256 /* ExportDeclaration */ || - node.kind === 250 /* ImportDeclaration */ || - node.kind === 251 /* ImportClause */ || - (node.kind === 249 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 260 /* ExternalModuleReference */)) { + if (node.kind === 259 /* ExportDeclaration */ || + node.kind === 253 /* ImportDeclaration */ || + node.kind === 254 /* ImportClause */ || + (node.kind === 252 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 263 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -70217,19 +73371,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Property declarations are not TypeScript syntax, but they must be visited // for the decorator transformation. return visitPropertyDeclaration(node); - case 163 /* IndexSignature */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 166 /* IndexSignature */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return ts.Debug.failBadSyntaxKind(node); @@ -70239,7 +73393,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 86 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 88 /* ExportKeyword */) { return undefined; } return node; @@ -70256,67 +73410,71 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 119 /* AbstractKeyword */: - case 78 /* ConstKeyword */: - case 126 /* DeclareKeyword */: - case 134 /* ReadonlyKeyword */: - // TypeScript accessibility and readonly modifiers are elided. - case 170 /* ArrayType */: - case 171 /* TupleType */: - case 172 /* OptionalType */: - case 173 /* RestType */: - case 169 /* TypeLiteral */: - case 164 /* TypePredicate */: - case 151 /* TypeParameter */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 124 /* BooleanKeyword */: - case 139 /* StringKeyword */: - case 136 /* NumberKeyword */: - case 133 /* NeverKeyword */: - case 107 /* VoidKeyword */: - case 140 /* SymbolKeyword */: - case 167 /* ConstructorType */: - case 166 /* FunctionType */: - case 168 /* TypeQuery */: - case 165 /* TypeReference */: - case 174 /* UnionType */: - case 175 /* IntersectionType */: - case 176 /* ConditionalType */: - case 178 /* ParenthesizedType */: - case 179 /* ThisType */: - case 180 /* TypeOperator */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 183 /* LiteralType */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 121 /* AbstractKeyword */: + case 80 /* ConstKeyword */: + case 129 /* DeclareKeyword */: + case 137 /* ReadonlyKeyword */: + // TypeScript accessibility and readonly modifiers are elided + // falls through + case 173 /* ArrayType */: + case 174 /* TupleType */: + case 175 /* OptionalType */: + case 176 /* RestType */: + case 172 /* TypeLiteral */: + case 167 /* TypePredicate */: + case 154 /* TypeParameter */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 127 /* BooleanKeyword */: + case 142 /* StringKeyword */: + case 139 /* NumberKeyword */: + case 136 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 143 /* SymbolKeyword */: + case 170 /* ConstructorType */: + case 169 /* FunctionType */: + case 171 /* TypeQuery */: + case 168 /* TypeReference */: + case 177 /* UnionType */: + case 178 /* IntersectionType */: + case 179 /* ConditionalType */: + case 181 /* ParenthesizedType */: + case 182 /* ThisType */: + case 183 /* TypeOperator */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 186 /* LiteralType */: // TypeScript type nodes are elided. - case 163 /* IndexSignature */: + // falls through + case 166 /* IndexSignature */: // TypeScript index signatures are elided. - case 153 /* Decorator */: + // falls through + case 156 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 243 /* TypeAliasDeclaration */: + // falls through + case 246 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. return undefined; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // TypeScript property declarations are elided. However their names are still visited, and can potentially be retained if they could have sideeffects return visitPropertyDeclaration(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: // TypeScript namespace export declarations are elided. return undefined; - case 158 /* Constructor */: + case 161 /* Constructor */: return visitConstructor(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: // This may be a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70326,7 +73484,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: // This may be a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -70336,35 +73494,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: // This may be a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: // This may be a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -70374,35 +73532,35 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 195 /* TypeAssertionExpression */: - case 213 /* AsExpression */: + case 198 /* TypeAssertionExpression */: + case 216 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -70440,7 +73598,7 @@ var ts; if (ts.some(staticProperties)) facts |= 1 /* HasStaticInitializedProperties */; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */) + if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */) facts |= 64 /* IsDerivedClass */; if (shouldEmitDecorateCallForClass(node)) facts |= 2 /* HasConstructorDecorators */; @@ -70469,7 +73627,7 @@ var ts; if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasModifier(node, 1 /* Export */))) { return ts.visitEachChild(node, visitor, context); } - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var facts = getClassFacts(node, staticProperties); if (facts & 128 /* UseImmediatelyInvokedFunctionExpression */) { context.startLexicalEnvironment(); @@ -70812,12 +73970,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -70970,7 +74128,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 155 /* PropertyDeclaration */ + ? member.kind === 158 /* PropertyDeclaration */ // We emit `void 0` here to indicate to `__decorate` that it can invoke `Object.defineProperty` directly, but that it // should not invoke `Object.getOwnPropertyDescriptor`. ? ts.createVoidZero() @@ -71071,13 +74229,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(37 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(38 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -71093,10 +74251,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */ - || kind === 155 /* PropertyDeclaration */; + return kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */ + || kind === 158 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -71106,7 +74264,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 157 /* MethodDeclaration */; + return node.kind === 160 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -71117,12 +74275,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return true; } return false; @@ -71139,15 +74297,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 152 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 155 /* Parameter */: return serializeTypeNode(node.type); - case 160 /* SetAccessor */: - case 159 /* GetAccessor */: + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: return serializeTypeNode(getAccessorTypeNode(node)); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: - case 157 /* MethodDeclaration */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -71184,7 +74342,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 159 /* GetAccessor */) { + if (container && node.kind === 162 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -71229,69 +74387,69 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 107 /* VoidKeyword */: - case 142 /* UndefinedKeyword */: - case 97 /* NullKeyword */: - case 133 /* NeverKeyword */: + case 109 /* VoidKeyword */: + case 145 /* UndefinedKeyword */: + case 99 /* NullKeyword */: + case 136 /* NeverKeyword */: return ts.createVoidZero(); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 166 /* FunctionType */: - case 167 /* ConstructorType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: return ts.createIdentifier("Function"); - case 170 /* ArrayType */: - case 171 /* TupleType */: + case 173 /* ArrayType */: + case 174 /* TupleType */: return ts.createIdentifier("Array"); - case 164 /* TypePredicate */: - case 124 /* BooleanKeyword */: + case 167 /* TypePredicate */: + case 127 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 139 /* StringKeyword */: + case 142 /* StringKeyword */: return ts.createIdentifier("String"); - case 137 /* ObjectKeyword */: + case 140 /* ObjectKeyword */: return ts.createIdentifier("Object"); - case 183 /* LiteralType */: + case 186 /* LiteralType */: switch (node.literal.kind) { case 10 /* StringLiteral */: return ts.createIdentifier("String"); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); case 9 /* BigIntLiteral */: return getGlobalBigIntNameWithFallback(); - case 103 /* TrueKeyword */: - case 88 /* FalseKeyword */: + case 105 /* TrueKeyword */: + case 90 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: return ts.Debug.failBadSyntaxKind(node.literal); } - case 136 /* NumberKeyword */: + case 139 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 147 /* BigIntKeyword */: + case 150 /* BigIntKeyword */: return getGlobalBigIntNameWithFallback(); - case 140 /* SymbolKeyword */: + case 143 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return serializeTypeReferenceNode(node); - case 175 /* IntersectionType */: - case 174 /* UnionType */: + case 178 /* IntersectionType */: + case 177 /* UnionType */: return serializeTypeList(node.types); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return serializeTypeList([node.trueType, node.falseType]); - case 180 /* TypeOperator */: - if (node.operator === 134 /* ReadonlyKeyword */) { + case 183 /* TypeOperator */: + if (node.operator === 137 /* ReadonlyKeyword */) { return serializeTypeNode(node.type); } break; - case 168 /* TypeQuery */: - case 181 /* IndexedAccessType */: - case 182 /* MappedType */: - case 169 /* TypeLiteral */: - case 121 /* AnyKeyword */: - case 144 /* UnknownKeyword */: - case 179 /* ThisType */: - case 184 /* ImportType */: + case 171 /* TypeQuery */: + case 184 /* IndexedAccessType */: + case 185 /* MappedType */: + case 172 /* TypeLiteral */: + case 124 /* AnyKeyword */: + case 147 /* UnknownKeyword */: + case 182 /* ThisType */: + case 187 /* ImportType */: break; default: return ts.Debug.failBadSyntaxKind(node); @@ -71302,15 +74460,15 @@ var ts; // Note when updating logic here also update getEntityNameForDecoratorMetadata // so that aliases can be marked as referenced var serializedUnion; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var typeNode = types_17[_i]; - while (typeNode.kind === 178 /* ParenthesizedType */) { + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var typeNode = types_20[_i]; + while (typeNode.kind === 181 /* ParenthesizedType */) { typeNode = typeNode.type; // Skip parens if need be } - if (typeNode.kind === 133 /* NeverKeyword */) { + if (typeNode.kind === 136 /* NeverKeyword */) { continue; // Always elide `never` from the union/intersection if possible } - if (!strictNullChecks && (typeNode.kind === 97 /* NullKeyword */ || typeNode.kind === 142 /* UndefinedKeyword */)) { + if (!strictNullChecks && (typeNode.kind === 99 /* NullKeyword */ || typeNode.kind === 145 /* UndefinedKeyword */)) { continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks } var serializedIndividual = serializeTypeNode(typeNode); @@ -71390,12 +74548,12 @@ var ts; * @param node The entity name to serialize. */ function serializeEntityNameAsExpressionFallback(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { // A -> typeof A !== undefined && A var copied = serializeEntityNameAsExpression(node); return createCheckedValue(copied, copied); } - if (node.left.kind === 73 /* Identifier */) { + if (node.left.kind === 75 /* Identifier */) { // A.B -> typeof A !== undefined && A.B return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node)); } @@ -71411,7 +74569,7 @@ var ts; */ function serializeEntityNameAsExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.getMutableClone(node); @@ -71419,7 +74577,7 @@ var ts; name.original = undefined; name.parent = ts.getParseTreeNode(currentLexicalScope); // ensure the parent is set to a parse tree node. return name; - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return serializeQualifiedNameAsExpression(node); } } @@ -71503,7 +74661,7 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 110 /* ImplementsKeyword */) { + if (node.token === 112 /* ImplementsKeyword */) { // implements clauses are elided return undefined; } @@ -71966,12 +75124,12 @@ var ts; // enums in any other scope are emitted as a `let` declaration. var statement = ts.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) - ], currentLexicalScope.kind === 285 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); + ], currentLexicalScope.kind === 288 /* SourceFile */ ? 0 /* None */ : 1 /* Let */)); ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 244 /* EnumDeclaration */) { + if (node.kind === 247 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -72096,7 +75254,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 246 /* ModuleBlock */) { + if (body.kind === 249 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -72142,13 +75300,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 246 /* ModuleBlock */) { + if (body.kind !== 249 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 245 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 248 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -72189,7 +75347,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 252 /* NamespaceImport */) { + if (node.kind === 255 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -72402,7 +75560,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -72410,7 +75568,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72420,17 +75578,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(73 /* Identifier */); - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); + context.enableSubstitution(75 /* Identifier */); + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(245 /* ModuleDeclaration */); + context.enableEmitNotification(248 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 245 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 248 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 244 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 247 /* EnumDeclaration */; } /** * Hook for node emit. @@ -72489,11 +75647,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -72531,9 +75689,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 285 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 245 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 244 /* EnumDeclaration */); + if (container && container.kind !== 288 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 248 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 247 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -72555,9 +75713,10 @@ var ts; ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); if (!compilerOptions.removeComments) { - var propertyName = ts.isPropertyAccessExpression(node) - ? ts.declarationNameToString(node.name) - : ts.getTextOfNode(node.argumentExpression); + var originalNode = ts.getOriginalNode(node, ts.isAccessExpression); + var propertyName = ts.isPropertyAccessExpression(originalNode) + ? ts.declarationNameToString(originalNode.name) + : ts.getTextOfNode(originalNode.argumentExpression); ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } return substitute; @@ -72661,7 +75820,9 @@ var ts; var pendingStatements; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { - if (node.isDeclarationFile) { + var options = context.getCompilerOptions(); + if (node.isDeclarationFile + || options.useDefineForClassFields && options.target === 99 /* ESNext */) { return node; } var visited = ts.visitEachChild(node, visitor, context); @@ -72672,11 +75833,11 @@ var ts; if (!(node.transformFlags & 1048576 /* ContainsClassFields */)) return node; switch (node.kind) { - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); } return ts.visitEachChild(node, visitor, context); @@ -72688,20 +75849,20 @@ var ts; */ function classElementVisitor(node) { switch (node.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors for classes using class fields are transformed in // `visitClassDeclaration` or `visitClassExpression`. return undefined; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 157 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 160 /* MethodDeclaration */: // Visit the name of the member (if it's a computed property name). return ts.visitEachChild(node, classElementVisitor, context); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return visitPropertyDeclaration(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return node; default: return visitor(node); @@ -72731,7 +75892,7 @@ var ts; // Create a temporary variable to store a computed property name (if necessary). // If it's not inlineable, then we emit an expression after the class which assigns // the property name to the temporary variable. - var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer); + var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields); if (expr && !ts.isSimpleInlineableExpression(expr)) { (pendingExpressions || (pendingExpressions = [])).push(expr); } @@ -72744,7 +75905,7 @@ var ts; var savedPendingExpressions = pendingExpressions; pendingExpressions = undefined; var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var statements = [ ts.updateClassDeclaration(node, /*decorators*/ undefined, node.modifiers, node.name, @@ -72760,9 +75921,9 @@ var ts; // From ES6 specification: // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); if (ts.some(staticProperties)) { - addInitializedPropertyStatements(statements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(statements, staticProperties, ts.getInternalName(node)); } return statements; } @@ -72780,9 +75941,9 @@ var ts; // class declaration transformation. The VariableStatement visitor will insert // these statements after the class expression variable statement. var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node)); - var staticProperties = ts.getInitializedProperties(node, /*isStatic*/ true); + var staticProperties = ts.getProperties(node, /*requireInitializer*/ true, /*isStatic*/ true); var extendsClauseElement = ts.getEffectiveBaseTypeNode(node); - var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */); + var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */); var classExpression = ts.updateClassExpression(node, node.modifiers, node.name, /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass)); if (ts.some(staticProperties) || ts.some(pendingExpressions)) { @@ -72794,7 +75955,7 @@ var ts; } pendingExpressions = savedPendingExpressions; if (pendingStatements && ts.some(staticProperties)) { - addInitializedPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); + addPropertyStatements(pendingStatements, staticProperties, ts.getInternalName(node)); } return classExpression; } @@ -72835,8 +75996,8 @@ var ts; } function transformConstructor(node, isDerivedClass) { var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration); - var containsPropertyInitializer = ts.forEach(node.members, ts.isInitializedProperty); - if (!containsPropertyInitializer) { + var containsProperty = ts.forEach(node.members, function (m) { return ts.isInitializedProperty(m, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields); }); + if (!containsProperty) { return constructor; } var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context); @@ -72849,7 +76010,7 @@ var ts; /*modifiers*/ undefined, parameters, body), constructor || node), constructor)); } function transformConstructorBody(node, constructor, isDerivedClass) { - var properties = ts.getInitializedProperties(node, /*isStatic*/ false); + var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false); // Only generate synthetic constructor when there are property initializers to move. if (!constructor && !ts.some(properties)) { return ts.visitFunctionBody(/*node*/ undefined, visitor, context); @@ -72893,7 +76054,7 @@ var ts; indexOfFirstStatement += parameterPropertyDeclarationCount; } } - addInitializedPropertyStatements(statements, properties, ts.createThis()); + addPropertyStatements(statements, properties, ts.createThis()); // Add existing statements, skipping the initial super call. if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); @@ -72910,7 +76071,7 @@ var ts; * @param properties An array of property declarations to transform. * @param receiver The receiver on which each property should be assigned. */ - function addInitializedPropertyStatements(statements, properties, receiver) { + function addPropertyStatements(statements, properties, receiver) { for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var property = properties_6[_i]; var statement = ts.createExpressionStatement(transformInitializedProperty(property, receiver)); @@ -72947,19 +76108,29 @@ var ts; */ function transformInitializedProperty(property, receiver) { // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) + var emitAssignment = !context.getCompilerOptions().useDefineForClassFields; var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression) ? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name)) : property.name; - var initializer = ts.visitNode(property.initializer, visitor, ts.isExpression); - var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); - return ts.createAssignment(memberAccess, initializer); + var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero(); + if (emitAssignment) { + var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName); + return ts.createAssignment(memberAccess, initializer); + } + else { + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + var descriptor = ts.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true }); + return ts.createObjectDefinePropertyCall(receiver, name, descriptor); + } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1 /* ClassAliases */) === 0) { enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -72979,7 +76150,7 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); } return node; @@ -73097,34 +76268,34 @@ var ts; return node; } switch (node.kind) { - case 122 /* AsyncKeyword */: + case 125 /* AsyncKeyword */: // ES2017 async modifier should be elided for targets < ES2017 return undefined; - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 158 /* Constructor */: - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 161 /* Constructor */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73133,27 +76304,27 @@ var ts; function asyncBodyVisitor(node) { if (ts.isNodeWithPossibleHoistedDeclaration(node)) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatementInAsyncBody(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatementInAsyncBody(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatementInAsyncBody(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatementInAsyncBody(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClauseInAsyncBody(node); - case 219 /* Block */: - case 233 /* SwitchStatement */: - case 247 /* CaseBlock */: - case 272 /* CaseClause */: - case 273 /* DefaultClause */: - case 236 /* TryStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: - case 223 /* IfStatement */: - case 232 /* WithStatement */: - case 234 /* LabeledStatement */: + case 222 /* Block */: + case 236 /* SwitchStatement */: + case 250 /* CaseBlock */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: + case 239 /* TryStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: + case 226 /* IfStatement */: + case 235 /* WithStatement */: + case 237 /* LabeledStatement */: return ts.visitEachChild(node, asyncBodyVisitor, context); default: return ts.Debug.assertNever(node, "Unhandled node."); @@ -73354,7 +76525,7 @@ var ts; var original = ts.getOriginalNode(node, ts.isFunctionLike); var nodeType = original.type; var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 198 /* ArrowFunction */; + var isArrowFunction = node.kind === 201 /* ArrowFunction */; var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192 /* CaptureArguments */) !== 0; // An async function is emit as an outer function that calls an inner // generator function. To preserve lexical bindings, we pass the current @@ -73445,17 +76616,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -73503,23 +76674,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -73539,11 +76710,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -73611,7 +76782,7 @@ var ts; function createAwaiterHelper(context, hasLexicalThis, hasLexicalArguments, promiseConstructor, body) { context.requestEmitHelper(ts.awaiterHelper); var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ [], @@ -73683,7 +76854,7 @@ var ts; return visitorWorker(node, /*noDestructuringValue*/ true); } function visitorNoAsyncModifier(node) { - if (node.kind === 122 /* AsyncKeyword */) { + if (node.kind === 125 /* AsyncKeyword */) { return undefined; } return node; @@ -73705,62 +76876,62 @@ var ts; return node; } switch (node.kind) { - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return visitAwaitExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return visitVoidExpression(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return doOutsideOfTopLevel(visitConstructorDeclaration, node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return doOutsideOfTopLevel(visitMethodDeclaration, node); - case 159 /* GetAccessor */: + case 162 /* GetAccessor */: return doOutsideOfTopLevel(visitGetAccessorDeclaration, node); - case 160 /* SetAccessor */: + case 163 /* SetAccessor */: return doOutsideOfTopLevel(visitSetAccessorDeclaration, node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return doOutsideOfTopLevel(visitFunctionDeclaration, node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return doOutsideOfTopLevel(visitFunctionExpression, node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); - case 190 /* PropertyAccessExpression */: - if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 99 /* SuperKeyword */) { + case 193 /* PropertyAccessExpression */: + if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 101 /* SuperKeyword */) { capturedSuperProperties.set(node.name.escapedText, true); } return ts.visitEachChild(node, visitor, context); - case 191 /* ElementAccessExpression */: - if (capturedSuperProperties && node.expression.kind === 99 /* SuperKeyword */) { + case 194 /* ElementAccessExpression */: + if (capturedSuperProperties && node.expression.kind === 101 /* SuperKeyword */) { hasSuperElementAccess = true; } return ts.visitEachChild(node, visitor, context); - case 241 /* ClassDeclaration */: - case 210 /* ClassExpression */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: return doOutsideOfTopLevel(visitDefault, node); default: return ts.visitEachChild(node, visitor, context); @@ -73794,7 +76965,7 @@ var ts; function visitLabeledStatement(node) { if (enclosingFunctionFlags & 2 /* Async */) { var statement = ts.unwrapInnermostStatementOfLabel(node); - if (statement.kind === 228 /* ForOfStatement */ && statement.awaitModifier) { + if (statement.kind === 231 /* ForOfStatement */ && statement.awaitModifier) { return visitForOfStatement(statement, node); } return ts.restoreEnclosingLabel(ts.visitEachChild(statement, visitor, context), node); @@ -73806,7 +76977,7 @@ var ts; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 278 /* SpreadAssignment */) { + if (e.kind === 281 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -73815,7 +76986,7 @@ var ts; objects.push(ts.visitNode(target, visitor, ts.isExpression)); } else { - chunkObject = ts.append(chunkObject, e.kind === 276 /* PropertyAssignment */ + chunkObject = ts.append(chunkObject, e.kind === 279 /* PropertyAssignment */ ? ts.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression)) : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } @@ -73849,7 +77020,7 @@ var ts; // If we translate the above to `__assign({}, k, l)`, the `l` will evaluate before `k` is spread and we // end up with `{ a: 1, b: 2, c: 3 }` var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 189 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 192 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } var expression = objects[0]; @@ -74146,7 +77317,7 @@ var ts; capturedSuperProperties = ts.createUnderscoreEscapedMap(); hasSuperElementAccess = false; var returnStatement = ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(40 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*modifiers*/ undefined, ts.createToken(41 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), /*typeParameters*/ undefined, /*parameters*/ [], /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset))), !topLevel)); @@ -74215,17 +77386,17 @@ var ts; enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; // We need to enable substitutions for call, property access, and element access // if we need to rewrite super calls. - context.enableSubstitution(192 /* CallExpression */); - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(191 /* ElementAccessExpression */); + context.enableSubstitution(195 /* CallExpression */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(194 /* ElementAccessExpression */); // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(241 /* ClassDeclaration */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(158 /* Constructor */); + context.enableEmitNotification(244 /* ClassDeclaration */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(161 /* Constructor */); // We need to be notified when entering the generated accessor arrow functions. - context.enableEmitNotification(220 /* VariableStatement */); + context.enableEmitNotification(224 /* VariableStatement */); } } /** @@ -74273,23 +77444,23 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return substituteElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return substituteCallExpression(node); } return node; } function substitutePropertyAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return ts.setTextRange(ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), node.name), node); } return node; } function substituteElementAccessExpression(node) { - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { return createSuperElementAccessInAsyncMethod(node.argumentExpression, node); } return node; @@ -74309,11 +77480,11 @@ var ts; } function isSuperContainer(node) { var kind = node.kind; - return kind === 241 /* ClassDeclaration */ - || kind === 158 /* Constructor */ - || kind === 157 /* MethodDeclaration */ - || kind === 159 /* GetAccessor */ - || kind === 160 /* SetAccessor */; + return kind === 244 /* ClassDeclaration */ + || kind === 161 /* Constructor */ + || kind === 160 /* MethodDeclaration */ + || kind === 162 /* GetAccessor */ + || kind === 163 /* SetAccessor */; } function createSuperElementAccessInAsyncMethod(argumentExpression, location) { if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { @@ -74336,8 +77507,7 @@ var ts; }; function createAssignHelper(context, attributesSegments) { if (context.getCompilerOptions().target >= 2 /* ES2015 */) { - return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), - /*typeArguments*/ undefined, attributesSegments); + return ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); } context.requestEmitHelper(ts.assignHelper); return ts.createCall(ts.getUnscopedHelperName("__assign"), @@ -74412,7 +77582,7 @@ var ts; return node; } switch (node.kind) { - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); default: return ts.visitEachChild(node, visitor, context); @@ -74431,6 +77601,7 @@ var ts; var ts; (function (ts) { function transformESNext(context) { + var hoistVariableDeclaration = context.hoistVariableDeclaration; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { if (node.isDeclarationFile) { @@ -74443,10 +77614,143 @@ var ts; return node; } switch (node.kind) { + case 193 /* PropertyAccessExpression */: + case 194 /* ElementAccessExpression */: + case 195 /* CallExpression */: + if (node.flags & 32 /* OptionalChain */) { + var updated = visitOptionalExpression(node, /*captureThisArg*/ false); + ts.Debug.assertNotNode(updated, ts.isSyntheticReference); + return updated; + } + return ts.visitEachChild(node, visitor, context); + case 208 /* BinaryExpression */: + if (node.operatorToken.kind === 60 /* QuestionQuestionToken */) { + return transformNullishCoalescingExpression(node); + } + return ts.visitEachChild(node, visitor, context); default: return ts.visitEachChild(node, visitor, context); } } + function flattenChain(chain) { + var links = [chain]; + while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) { + chain = ts.cast(chain.expression, ts.isOptionalChain); + links.unshift(chain); + } + return { expression: chain.expression, chain: links }; + } + function visitNonOptionalParenthesizedExpression(node, captureThisArg) { + var expression = visitNonOptionalExpression(node.expression, captureThisArg); + if (ts.isSyntheticReference(expression)) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + return ts.createSyntheticReferenceExpression(ts.updateParen(node, expression.expression), expression.thisArg); + } + return ts.updateParen(node, expression); + } + function visitNonOptionalPropertyAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a.b` -> { expression: `(_a = a).b`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updatePropertyAccess(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalElementAccessExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + ts.Debug.assertNotNode(expression, ts.isSyntheticReference); + var thisArg; + if (captureThisArg) { + // `a[b]` -> { expression: `(_a = a)[b]`, thisArg: `_a` } + thisArg = ts.createTempVariable(hoistVariableDeclaration); + expression = ts.createParen(ts.createAssignment(thisArg, expression)); + } + expression = ts.updateElementAccess(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression)); + return thisArg ? ts.createSyntheticReferenceExpression(expression, thisArg) : expression; + } + function visitNonOptionalCallExpression(node, captureThisArg) { + if (ts.isOptionalChain(node)) { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return visitOptionalExpression(node, captureThisArg); + } + return ts.visitEachChild(node, visitor, context); + } + function visitNonOptionalExpression(node, captureThisArg) { + switch (node.kind) { + case 199 /* ParenthesizedExpression */: return visitNonOptionalParenthesizedExpression(node, captureThisArg); + case 193 /* PropertyAccessExpression */: return visitNonOptionalPropertyAccessExpression(node, captureThisArg); + case 194 /* ElementAccessExpression */: return visitNonOptionalElementAccessExpression(node, captureThisArg); + case 195 /* CallExpression */: return visitNonOptionalCallExpression(node, captureThisArg); + default: return ts.visitNode(node, visitor, ts.isExpression); + } + } + function visitOptionalExpression(node, captureThisArg) { + var _a = flattenChain(node), expression = _a.expression, chain = _a.chain; + var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0])); + var temp = ts.createTempVariable(hoistVariableDeclaration); + var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined; + var leftExpression = ts.isSyntheticReference(left) ? left.expression : left; + var rightExpression = temp; + var thisArg; + for (var i = 0; i < chain.length; i++) { + var segment = chain[i]; + switch (segment.kind) { + case 193 /* PropertyAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createPropertyAccess(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier)); + break; + case 194 /* ElementAccessExpression */: + if (i === chain.length - 1 && captureThisArg) { + thisArg = ts.createTempVariable(hoistVariableDeclaration); + rightExpression = ts.createParen(ts.createAssignment(thisArg, rightExpression)); + } + rightExpression = ts.createElementAccess(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression)); + break; + case 195 /* CallExpression */: + if (i === 0 && leftThisArg) { + rightExpression = ts.createFunctionCall(rightExpression, leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + else { + rightExpression = ts.createCall(rightExpression, + /*typeArguments*/ undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression)); + } + break; + } + ts.setOriginalNode(rightExpression, segment); + } + var target = ts.createConditional(ts.createLogicalOr(ts.createStrictEquality(ts.createAssignment(temp, leftExpression), ts.createNull()), ts.createStrictEquality(temp, ts.createVoidZero())), ts.createVoidZero(), rightExpression); + return thisArg ? ts.createSyntheticReferenceExpression(target, thisArg) : target; + } + function createNotNullCondition(node) { + return ts.createBinary(ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createNull()), ts.createToken(55 /* AmpersandAmpersandToken */), ts.createBinary(node, ts.createToken(37 /* ExclamationEqualsEqualsToken */), ts.createVoidZero())); + } + function transformNullishCoalescingExpression(node) { + var expressions = []; + var left = ts.visitNode(node.left, visitor, ts.isExpression); + if (!ts.isIdentifier(left)) { + var temp = ts.createTempVariable(hoistVariableDeclaration); + expressions.push(ts.createAssignment(temp, left)); + left = temp; + } + expressions.push(ts.createParen(ts.createConditional(createNotNullCondition(left), left, ts.visitNode(node.right, visitor, ts.isExpression)))); + return ts.inlineExpressions(expressions); + } } ts.transformESNext = transformESNext; })(ts || (ts = {})); @@ -74481,13 +77785,13 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ false); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74497,13 +77801,13 @@ var ts; switch (node.kind) { case 11 /* JsxText */: return visitJsxText(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return visitJsxExpression(node); - case 261 /* JsxElement */: + case 264 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return visitJsxFragment(node, /*isChild*/ true); default: return ts.Debug.failBadSyntaxKind(node); @@ -74578,7 +77882,7 @@ var ts; literal.singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile); return ts.setTextRange(literal, node); } - else if (node.kind === 271 /* JsxExpression */) { + else if (node.kind === 274 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -74672,7 +77976,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 261 /* JsxElement */) { + if (node.kind === 264 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -74978,7 +78282,7 @@ var ts; return node; } switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -74986,9 +78290,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 64 /* AsteriskAsteriskEqualsToken */: + case 66 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 41 /* AsteriskAsteriskToken */: + case 42 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -75191,13 +78495,13 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */) !== 0 - && node.kind === 231 /* ReturnStatement */ + && node.kind === 234 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined - || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 219 /* Block */))) + || (hierarchyFacts & 8192 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 222 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatement(node)) || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } @@ -75210,72 +78514,72 @@ var ts; } } function callExpressionVisitor(node) { - if (node.kind === 99 /* SuperKeyword */) { + if (node.kind === 101 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 117 /* StaticKeyword */: + case 119 /* StaticKeyword */: return undefined; // elide static keyword - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return visitClassExpression(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return visitParameter(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return visitArrowFunction(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 73 /* Identifier */: + case 75 /* Identifier */: return visitIdentifier(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 230 /* BreakStatement */: - case 229 /* ContinueStatement */: + case 233 /* BreakStatement */: + case 232 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return visitExpressionStatement(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); case 14 /* NoSubstitutionTemplateLiteral */: case 15 /* TemplateHead */: @@ -75286,28 +78590,28 @@ var ts; return visitStringLiteral(node); case 8 /* NumericLiteral */: return visitNumericLiteral(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return visitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return visitSpreadElement(node); - case 99 /* SuperKeyword */: + case 101 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return visitThisKeyword(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return visitMetaProperty(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -75398,14 +78702,14 @@ var ts; // it is possible if either // - break/continue is labeled and label is located inside the converted loop // - break/continue is non-labeled and located in non-converted loop/switch statement - var jump = node.kind === 230 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 233 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; var label = node.label; if (!label) { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -75416,7 +78720,7 @@ var ts; } } else { - if (node.kind === 230 /* BreakStatement */) { + if (node.kind === 233 /* BreakStatement */) { labelMarker = "break-" + label.escapedText; setLabeledJump(convertedLoopState, /*isBreak*/ true, ts.idText(label), labelMarker); } @@ -75674,7 +78978,7 @@ var ts; function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) { // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 97 /* NullKeyword */; + var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 99 /* NullKeyword */; // When the subclass does not have a constructor, we synthesize a *default* constructor using the following // representation: // @@ -75812,11 +79116,11 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 231 /* ReturnStatement */) { + if (statement.kind === 234 /* ReturnStatement */) { return true; } // An if-statement with two covered branches is covered. - else if (statement.kind === 223 /* IfStatement */) { + else if (statement.kind === 226 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && @@ -75824,7 +79128,7 @@ var ts; } } // A block is covered if it has a last statement which is covered. - else if (statement.kind === 219 /* Block */) { + else if (statement.kind === 222 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -75979,10 +79283,10 @@ var ts; return false; } // `declarationName` is the name of the local declaration for the parameter. - var declarationName = parameter.name.kind === 73 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var declarationName = parameter.name.kind === 75 /* Identifier */ ? ts.getMutableClone(parameter.name) : ts.createTempVariable(/*recordTempVariable*/ undefined); ts.setEmitFlags(declarationName, 48 /* NoSourceMap */); // `expressionName` is the name of the parameter used in expressions. - var expressionName = parameter.name.kind === 73 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; + var expressionName = parameter.name.kind === 75 /* Identifier */ ? ts.getSynthesizedClone(parameter.name) : declarationName; var restIndex = node.parameters.length - 1; var temp = ts.createLoopVariable(); // var param = []; @@ -76006,7 +79310,7 @@ var ts; ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); prologueStatements.push(forStatement); - if (parameter.name.kind !== 73 /* Identifier */) { + if (parameter.name.kind !== 75 /* Identifier */) { // do the actual destructuring of the rest parameter if necessary prologueStatements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, expressionName))), parameter), 1048576 /* CustomPrologue */)); @@ -76022,7 +79326,7 @@ var ts; * @param node A node. */ function insertCaptureThisForNodeIfNeeded(statements, node) { - if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 198 /* ArrowFunction */) { + if (hierarchyFacts & 32768 /* CapturedLexicalThis */ && node.kind !== 201 /* ArrowFunction */) { insertCaptureThisForNode(statements, node, ts.createThis()); return true; } @@ -76043,25 +79347,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return statements; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 240 /* FunctionDeclaration */: - case 197 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 200 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 95 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 97 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: return ts.Debug.failBadSyntaxKind(node); @@ -76090,20 +79394,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 158 /* Constructor */: + case 161 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -76129,12 +79433,22 @@ var ts; function transformClassMethodDeclarationToStatement(receiver, member, container) { var commentRange = ts.getCommentRange(member); var sourceMapRange = ts.getSourceMapRange(member); - var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); var memberFunction = transformFunctionLikeToExpression(member, /*location*/ member, /*name*/ undefined, container); + var e; + if (context.getCompilerOptions().useDefineForClassFields) { + var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName); + var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression + : ts.isIdentifier(propertyName) ? ts.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText)) + : propertyName; + e = ts.createObjectDefinePropertyCall(receiver, name, ts.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true })); + } + else { + var memberName = ts.createMemberAccessForPropertyName(receiver, ts.visitNode(member.name, visitor, ts.isPropertyName), /*location*/ member.name); + e = ts.createAssignment(memberName, memberFunction); + } ts.setEmitFlags(memberFunction, 1536 /* NoComments */); ts.setSourceMapRange(memberFunction, sourceMapRange); - var statement = ts.setTextRange(ts.createExpressionStatement(ts.createAssignment(memberName, memberFunction)), - /*location*/ member); + var statement = ts.setTextRange(ts.createExpressionStatement(e), /*location*/ member); ts.setOriginalNode(statement, member); ts.setCommentRange(statement, commentRange); // The location for the statement is used to emit comments only. @@ -76291,7 +79605,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 240 /* FunctionDeclaration */ || node.kind === 197 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 243 /* FunctionDeclaration */ || node.kind === 200 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* FunctionSubtreeExcludes */, 0 /* None */); @@ -76335,7 +79649,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 198 /* ArrowFunction */); + ts.Debug.assert(node.kind === 201 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -76403,9 +79717,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateExpressionStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateExpressionStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -76424,9 +79738,9 @@ var ts; // expression. If we are in a state where we do not need the destructuring value, // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -76461,7 +79775,7 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 60 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 62 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); ts.setTextRange(assignment, decl); } assignments = ts.append(assignments, assignment); @@ -76635,14 +79949,14 @@ var ts; } function visitIterationStatement(node, outermostLabeledStatement) { switch (node.kind) { - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node, outermostLabeledStatement); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node, outermostLabeledStatement); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node, outermostLabeledStatement); } } @@ -76830,7 +80144,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 150 /* ComputedPropertyName */) { + if (property.name.kind === 153 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -76885,7 +80199,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -76951,11 +80265,11 @@ var ts; } function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) { switch (node.kind) { - case 226 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); - case 227 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); - case 228 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); - case 224 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); - case 225 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); + case 229 /* ForStatement */: return convertForStatement(node, initializerFunction, convertedLoopBody); + case 230 /* ForInStatement */: return convertForInStatement(node, convertedLoopBody); + case 231 /* ForOfStatement */: return convertForOfStatement(node, convertedLoopBody); + case 227 /* DoStatement */: return convertDoStatement(node, convertedLoopBody); + case 228 /* WhileStatement */: return convertWhileStatement(node, convertedLoopBody); default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected"); } } @@ -76980,11 +80294,11 @@ var ts; function createConvertedLoopState(node) { var loopInitializer; switch (node.kind) { - case 226 /* ForStatement */: - case 227 /* ForInStatement */: - case 228 /* ForOfStatement */: + case 229 /* ForStatement */: + case 230 /* ForInStatement */: + case 231 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 239 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 242 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -77135,7 +80449,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, /*parameters*/ undefined, @@ -77197,7 +80511,7 @@ var ts; currentState.conditionVariable = ts.createUniqueName("inc"); statements.push(ts.createIf(currentState.conditionVariable, ts.createStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), ts.createStatement(ts.createAssignment(currentState.conditionVariable, ts.createTrue())))); if (shouldConvertConditionOfForStatement(node)) { - statements.push(ts.createIf(ts.createPrefix(52 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); + statements.push(ts.createIf(ts.createPrefix(53 /* ExclamationToken */, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(ts.createBreak(), visitor, ts.isStatement))); } } if (ts.isBlock(statement)) { @@ -77235,7 +80549,7 @@ var ts; /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, containsYield ? ts.createToken(40 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(41 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, currentState.loopParameters, /*type*/ undefined, loopBody), emitFlags)) @@ -77246,7 +80560,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 60 /* EqualsToken */, source); + return ts.createBinary(target, 62 /* EqualsToken */, source); } function copyOutParameters(outParams, partFlags, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -77259,7 +80573,7 @@ var ts; function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) { var call = ts.createCall(initFunctionExpressionName, /*typeArguments*/ undefined, []); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; return ts.createStatement(callResult); } @@ -77273,7 +80587,7 @@ var ts; !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(state.loopParameters, function (p) { return p.name; })); var callResult = containsYield - ? ts.createYield(ts.createToken(40 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + ? ts.createYield(ts.createToken(41 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) : call; if (isSimpleLoop) { statements.push(ts.createExpressionStatement(callResult)); @@ -77294,10 +80608,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 35 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 36 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -77383,20 +80697,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine)); } break; - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -77503,7 +80817,7 @@ var ts; var updated; var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (node.kind === 159 /* GetAccessor */) { + if (node.kind === 162 /* GetAccessor */) { updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); } else { @@ -77556,7 +80870,7 @@ var ts; return visitTypeScriptClassWrapper(node); } var expression = ts.skipOuterExpressions(node.expression); - if (expression.kind === 99 /* SuperKeyword */ || + if (expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(expression) || ts.some(node.arguments, ts.isSpreadElement)) { return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ true); @@ -77680,10 +80994,10 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. if (node.transformFlags & 4096 /* ContainsRestOrSpread */ || - node.expression.kind === 99 /* SuperKeyword */ || + node.expression.kind === 101 /* SuperKeyword */ || ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall = void 0; @@ -77701,7 +81015,7 @@ var ts; // _super.apply(this, a.concat([b])) // _super.m.apply(this, a.concat([b])) // _super.prototype.m.apply(this, a.concat([b])) - resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); + resultingCall = ts.createFunctionApply(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), transformAndSpreadElements(node.arguments, /*needsUniqueCopy*/ false, /*multiLine*/ false, /*hasTrailingComma*/ false)); } else { // [source] @@ -77713,10 +81027,10 @@ var ts; // _super.call(this, a) // _super.m.call(this, a) // _super.prototype.m.call(this, a) - resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 99 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), + resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), node.expression.kind === 101 /* SuperKeyword */ ? thisArg : ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 99 /* SuperKeyword */) { + if (node.expression.kind === 101 /* SuperKeyword */) { var initializer = ts.createLogicalOr(resultingCall, createActualThis()); resultingCall = assignToCapturedThis ? ts.createAssignment(ts.createFileLevelUniqueName("_this"), initializer) @@ -78004,13 +81318,11 @@ var ts; * Visits the `super` keyword */ function visitSuperKeyword(isExpressionOfCall) { - return hierarchyFacts & 8 /* NonStaticClassElement */ - && !isExpressionOfCall - ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") - : ts.createFileLevelUniqueName("_super"); + return hierarchyFacts & 8 /* NonStaticClassElement */ && !isExpressionOfCall ? ts.createPropertyAccess(ts.createFileLevelUniqueName("_super"), "prototype") : + ts.createFileLevelUniqueName("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 96 /* NewKeyword */ && node.name.escapedText === "target") { + if (node.keywordToken === 98 /* NewKeyword */ && node.name.escapedText === "target") { hierarchyFacts |= 16384 /* NewTarget */; return ts.createFileLevelUniqueName("_newTarget"); } @@ -78042,7 +81354,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } } /** @@ -78052,14 +81364,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(101 /* ThisKeyword */); - context.enableEmitNotification(158 /* Constructor */); - context.enableEmitNotification(157 /* MethodDeclaration */); - context.enableEmitNotification(159 /* GetAccessor */); - context.enableEmitNotification(160 /* SetAccessor */); - context.enableEmitNotification(198 /* ArrowFunction */); - context.enableEmitNotification(197 /* FunctionExpression */); - context.enableEmitNotification(240 /* FunctionDeclaration */); + context.enableSubstitution(103 /* ThisKeyword */); + context.enableEmitNotification(161 /* Constructor */); + context.enableEmitNotification(160 /* MethodDeclaration */); + context.enableEmitNotification(162 /* GetAccessor */); + context.enableEmitNotification(163 /* SetAccessor */); + context.enableEmitNotification(201 /* ArrowFunction */); + context.enableEmitNotification(200 /* FunctionExpression */); + context.enableEmitNotification(243 /* FunctionDeclaration */); } } /** @@ -78100,10 +81412,10 @@ var ts; */ function isNameOfDeclarationWithCollidingName(node) { switch (node.parent.kind) { - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: - case 244 /* EnumDeclaration */: - case 238 /* VariableDeclaration */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: + case 247 /* EnumDeclaration */: + case 241 /* VariableDeclaration */: return node.parent.name === node && resolver.isDeclarationWithCollidingName(node.parent); } @@ -78116,9 +81428,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 101 /* ThisKeyword */: + case 103 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -78185,19 +81497,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 222 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 225 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 192 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 195 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 99 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 101 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 209 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 212 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -78252,15 +81564,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(263 /* JsxOpeningElement */); - context.enableEmitNotification(264 /* JsxClosingElement */); - context.enableEmitNotification(262 /* JsxSelfClosingElement */); + context.enableEmitNotification(266 /* JsxOpeningElement */); + context.enableEmitNotification(267 /* JsxClosingElement */); + context.enableEmitNotification(265 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(190 /* PropertyAccessExpression */); - context.enableSubstitution(276 /* PropertyAssignment */); + context.enableSubstitution(193 /* PropertyAccessExpression */); + context.enableSubstitution(279 /* PropertyAssignment */); return ts.chainBundle(transformSourceFile); /** * Transforms an ES5 source file to ES3. @@ -78279,9 +81591,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 263 /* JsxOpeningElement */: - case 264 /* JsxClosingElement */: - case 262 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 267 /* JsxClosingElement */: + case 265 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -78338,7 +81650,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined); - if (token !== undefined && token >= 74 /* FirstReservedWord */ && token <= 109 /* LastReservedWord */) { + if (token !== undefined && token >= 76 /* FirstReservedWord */ && token <= 111 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -78613,13 +81925,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -78632,24 +81944,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return visitAccessorDeclaration(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return visitBreakStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return visitContinueStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 131072 /* ContainsYield */) { @@ -78670,21 +81982,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return visitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return visitConditionalExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return visitYieldExpression(node); - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return visitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -78697,9 +82009,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return visitFunctionExpression(node); default: return ts.Debug.failBadSyntaxKind(node); @@ -78898,23 +82210,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 61 /* FirstCompoundAssignment */ - && kind <= 72 /* LastCompoundAssignment */; + return kind >= 63 /* FirstCompoundAssignment */ + && kind <= 74 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 61 /* PlusEqualsToken */: return 38 /* PlusToken */; - case 62 /* MinusEqualsToken */: return 39 /* MinusToken */; - case 63 /* AsteriskEqualsToken */: return 40 /* AsteriskToken */; - case 64 /* AsteriskAsteriskEqualsToken */: return 41 /* AsteriskAsteriskToken */; - case 65 /* SlashEqualsToken */: return 42 /* SlashToken */; - case 66 /* PercentEqualsToken */: return 43 /* PercentToken */; - case 67 /* LessThanLessThanEqualsToken */: return 46 /* LessThanLessThanToken */; - case 68 /* GreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanToken */; - case 69 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanGreaterThanToken */; - case 70 /* AmpersandEqualsToken */: return 49 /* AmpersandToken */; - case 71 /* BarEqualsToken */: return 50 /* BarToken */; - case 72 /* CaretEqualsToken */: return 51 /* CaretToken */; + case 63 /* PlusEqualsToken */: return 39 /* PlusToken */; + case 64 /* MinusEqualsToken */: return 40 /* MinusToken */; + case 65 /* AsteriskEqualsToken */: return 41 /* AsteriskToken */; + case 66 /* AsteriskAsteriskEqualsToken */: return 42 /* AsteriskAsteriskToken */; + case 67 /* SlashEqualsToken */: return 43 /* SlashToken */; + case 68 /* PercentEqualsToken */: return 44 /* PercentToken */; + case 69 /* LessThanLessThanEqualsToken */: return 47 /* LessThanLessThanToken */; + case 70 /* GreaterThanGreaterThanEqualsToken */: return 48 /* GreaterThanGreaterThanToken */; + case 71 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 49 /* GreaterThanGreaterThanGreaterThanToken */; + case 72 /* AmpersandEqualsToken */: return 50 /* AmpersandToken */; + case 73 /* BarEqualsToken */: return 51 /* BarToken */; + case 74 /* CaretEqualsToken */: return 52 /* CaretToken */; } } /** @@ -78927,7 +82239,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -78939,7 +82251,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -79026,7 +82338,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 54 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 55 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -79315,35 +82627,35 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: return transformAndEmitBlock(node); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return transformAndEmitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return transformAndEmitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return transformAndEmitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return transformAndEmitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return transformAndEmitTryStatement(node); default: return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); @@ -79773,7 +83085,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 273 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 276 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -79786,7 +83098,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 272 /* CaseClause */) { + if (clause.kind === 275 /* CaseClause */) { if (containsYield(clause.expression) && pendingClauses.length > 0) { break; } @@ -79959,11 +83271,10 @@ var ts; return node; } function cacheExpression(node) { - var temp; if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } - temp = ts.createTempVariable(hoistVariableDeclaration); + var temp = ts.createTempVariable(hoistVariableDeclaration); emitAssignment(temp, node, /*location*/ node); return temp; } @@ -80098,7 +83409,7 @@ var ts; if (!renamedCatchVariables) { renamedCatchVariables = ts.createMap(); renamedCatchVariableDeclarations = []; - context.enableSubstitution(73 /* Identifier */); + context.enableSubstitution(75 /* Identifier */); } renamedCatchVariables.set(text, true); renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; @@ -81015,12 +84326,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -81348,23 +84659,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return visitExportDeclaration(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return ts.visitEachChild(node, moduleExpressionElementVisitor, context); @@ -81391,24 +84702,24 @@ var ts; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var elem = _a[_i]; switch (elem.kind) { - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: if (destructuringNeedsFlattening(elem.initializer)) { return true; } break; - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: if (destructuringNeedsFlattening(elem.name)) { return true; } break; - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: if (destructuringNeedsFlattening(elem.expression)) { return true; } break; - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return false; default: ts.Debug.assertNever(elem, "Unhandled object member kind"); } @@ -81886,7 +85197,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -81941,10 +85252,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -82126,8 +85437,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -82143,7 +85454,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -82205,12 +85516,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 204 /* PostfixUnaryExpression */: - case 203 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -82231,7 +85542,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -82299,15 +85610,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 44 /* PlusPlusToken */ ? 61 /* PlusEqualsToken */ : 62 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 207 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 45 /* PlusPlusToken */ ? 63 /* PlusEqualsToken */ : 64 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) { @@ -82383,13 +85694,13 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(73 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(277 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols - context.enableSubstitution(205 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(203 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(204 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(215 /* MetaProperty */); // Substitutes 'import.meta' - context.enableEmitNotification(285 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(75 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(280 /* ShorthandPropertyAssignment */); // Substitutes expression identifiers for imported symbols + context.enableSubstitution(208 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(206 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(207 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(218 /* MetaProperty */); // Substitutes 'import.meta' + context.enableEmitNotification(288 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -82611,7 +85922,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 256 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 259 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -82636,7 +85947,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 256 /* ExportDeclaration */) { + if (externalImport.kind !== 259 /* ExportDeclaration */) { continue; } if (!externalImport.exportClause) { @@ -82705,28 +86016,28 @@ var ts; function createSettersArray(exportStarFunction, dependencyGroups) { var setters = []; for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) { - var group_1 = dependencyGroups_1[_i]; + var group_2 = dependencyGroups_1[_i]; // derive a unique name for parameter from the first named entry in the group - var localName = ts.forEach(group_1.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); + var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(i, currentSourceFile); }); var parameterName = localName ? ts.getGeneratedNameForNode(localName) : ts.createUniqueName(""); var statements = []; - for (var _a = 0, _b = group_1.externalImports; _a < _b.length; _a++) { + for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) { var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); // TODO: GH#18217 switch (entry.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } // falls through - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createExpressionStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -82776,15 +86087,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return visitImportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -82960,7 +86271,7 @@ var ts; function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 285 /* SourceFile */ + && (enclosingBlockScopedContainer.kind === 288 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -83024,7 +86335,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 220 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 224 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -83086,10 +86397,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -83269,43 +86580,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return visitVariableStatement(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return visitClassDeclaration(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return visitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return visitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return visitForOfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return visitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return visitWhileStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return visitLabeledStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return visitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return visitSwitchStatement(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return visitCaseBlock(node); - case 272 /* CaseClause */: + case 275 /* CaseClause */: return visitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return visitDefaultClause(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return visitTryStatement(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return visitCatchClause(node); - case 219 /* Block */: + case 222 /* Block */: return visitBlock(node); - case 318 /* MergeDeclarationMarker */: + case 321 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 319 /* EndOfDeclarationMarker */: + case 322 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringAndImportCallVisitor(node); @@ -83552,7 +86863,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 285 /* SourceFile */; + return container !== undefined && container.kind === 288 /* SourceFile */; } else { return false; @@ -83568,8 +86879,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: return undefined; } return node; @@ -83585,7 +86896,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 285 /* SourceFile */) { + if (node.kind === 288 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -83635,7 +86946,7 @@ var ts; */ function substituteUnspecified(node) { switch (node.kind) { - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return substituteShorthandPropertyAssignment(node); } return node; @@ -83669,14 +86980,14 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return substituteExpressionIdentifier(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return substituteBinaryExpression(node); - case 203 /* PrefixUnaryExpression */: - case 204 /* PostfixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return substituteMetaProperty(node); } return node; @@ -83762,22 +87073,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 44 /* PlusPlusToken */ || node.operator === 45 /* MinusMinusToken */) + if ((node.operator === 45 /* PlusPlusToken */ || node.operator === 46 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 204 /* PostfixUnaryExpression */ + var expression = node.kind === 207 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) { var exportName = exportedNames_5[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 204 /* PostfixUnaryExpression */) { - expression = node.operator === 44 /* PlusPlusToken */ + if (node.kind === 207 /* PostfixUnaryExpression */) { + expression = node.operator === 45 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -83804,7 +87115,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 285 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 288 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -83843,8 +87154,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(285 /* SourceFile */); - context.enableSubstitution(73 /* Identifier */); + context.enableEmitNotification(288 /* SourceFile */); + context.enableSubstitution(75 /* Identifier */); var helperNameSubstitutions; return ts.chainBundle(transformSourceFile); function transformSourceFile(node) { @@ -83868,10 +87179,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -83978,7 +87289,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84007,7 +87318,7 @@ var ts; ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84054,7 +87365,7 @@ var ts; return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]); } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84063,8 +87374,8 @@ var ts; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === 155 /* PropertyDeclaration */ || node.kind === 190 /* PropertyAccessExpression */ || node.kind === 154 /* PropertySignature */ || - (node.kind === 152 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { + else if (node.kind === 158 /* PropertyDeclaration */ || node.kind === 193 /* PropertyAccessExpression */ || node.kind === 157 /* PropertySignature */ || + (node.kind === 155 /* Parameter */ && ts.hasModifier(node.parent, 8 /* Private */))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -84073,7 +87384,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 241 /* ClassDeclaration */ || node.kind === 152 /* Parameter */) { + else if (node.parent.kind === 244 /* ClassDeclaration */ || node.kind === 155 /* Parameter */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84098,7 +87409,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Getters can infer the return type from the returned expression, but setters cannot, so the // "_from_external_module_1_but_cannot_be_named" case cannot occur. if (ts.hasModifier(node, 32 /* Static */)) { @@ -84137,26 +87448,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have return types that cannot be named diagnosticMessage = symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84164,7 +87475,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84178,7 +87489,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : @@ -84203,30 +87514,30 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 158 /* Constructor */: + case 161 /* Constructor */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; - case 162 /* ConstructSignature */: - case 167 /* ConstructorType */: + case 165 /* ConstructSignature */: + case 170 /* ConstructorType */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; - case 161 /* CallSignature */: + case 164 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -84234,7 +87545,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -84247,13 +87558,20 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 240 /* FunctionDeclaration */: - case 166 /* FunctionType */: + case 243 /* FunctionDeclaration */: + case 169 /* FunctionType */: return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; + case 163 /* SetAccessor */: + case 162 /* GetAccessor */: + return symbolAccessibilityResult.errorModuleName ? + symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 : + ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1; default: return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); } @@ -84262,39 +87580,39 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 182 /* MappedType */: + case 185 /* MappedType */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1; break; - case 167 /* ConstructorType */: - case 162 /* ConstructSignature */: + case 170 /* ConstructorType */: + case 165 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 161 /* CallSignature */: + case 164 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: + case 160 /* MethodDeclaration */: + case 159 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 244 /* ClassDeclaration */) { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 166 /* FunctionType */: - case 240 /* FunctionDeclaration */: + case 169 /* FunctionType */: + case 243 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -84309,9 +87627,9 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 241 /* ClassDeclaration */) { + if (node.parent.parent.kind === 244 /* ClassDeclaration */) { // Class or Interface implemented/extended is inaccessible - diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 110 /* ImplementsKeyword */ ? + diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 112 /* ImplementsKeyword */ ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 : ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1; } @@ -84346,11 +87664,8 @@ var ts; var ts; (function (ts) { function getDeclarationDiagnostics(host, resolver, file) { - if (file && ts.isSourceFileJS(file)) { - return []; // No declaration diagnostics for js for now - } var compilerOptions = host.getCompilerOptions(); - var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJS), [transformDeclarations], /*allowDtsFiles*/ false); + var result = ts.transformNodes(resolver, host, compilerOptions, file ? [file] : host.getSourceFiles(), [transformDeclarations], /*allowDtsFiles*/ false); return result.diagnostics; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; @@ -84360,7 +87675,7 @@ var ts; } function isInternalDeclaration(node, currentSourceFile) { var parseTreeNode = ts.getParseTreeNode(node); - if (parseTreeNode && parseTreeNode.kind === 152 /* Parameter */) { + if (parseTreeNode && parseTreeNode.kind === 155 /* Parameter */) { var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode); var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined; var text = currentSourceFile.text; @@ -84424,7 +87739,6 @@ var ts; var emittedImports; // must be declared in container so it can be `undefined` while transformer's first pass var resolver = context.getEmitResolver(); var options = context.getCompilerOptions(); - var newLine = ts.getNewLineCharacter(options); var noResolve = options.noResolve, stripInternal = options.stripInternal; return transformRoot; function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) { @@ -84507,20 +87821,29 @@ var ts; context.addDiagnostic(ts.createDiagnosticForNode(errorNameNode, ts.Diagnostics.The_inferred_type_of_0_cannot_be_named_without_a_reference_to_1_This_is_likely_not_portable_A_type_annotation_is_necessary, ts.declarationNameToString(errorNameNode), specifier)); } } - function createEmptyExports() { - return ts.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.createNamedExports([]), /*moduleSpecifier*/ undefined); + function transformDeclarationsForJS(sourceFile, bundled) { + var oldDiag = getSymbolAccessibilityDiagnostic; + getSymbolAccessibilityDiagnostic = function (s) { return ({ + diagnosticMessage: s.errorModuleName + ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit + : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit, + errorNode: s.errorNode || sourceFile + }); }; + var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled); + getSymbolAccessibilityDiagnostic = oldDiag; + return result; } function transformRoot(node) { - if (node.kind === 285 /* SourceFile */ && (node.isDeclarationFile || ts.isSourceFileJS(node))) { + if (node.kind === 288 /* SourceFile */ && node.isDeclarationFile) { return node; } - if (node.kind === 286 /* Bundle */) { + if (node.kind === 289 /* Bundle */) { isBundledEmit = true; refs = ts.createMap(); libs = ts.createMap(); var hasNoDefaultLib_1 = false; var bundle = ts.createBundle(ts.map(node.sourceFiles, function (sourceFile) { - if (sourceFile.isDeclarationFile || ts.isSourceFileJS(sourceFile)) + if (sourceFile.isDeclarationFile) return undefined; // Omit declaration files from bundle results, too // TODO: GH#18217 hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib; currentSourceFile = sourceFile; @@ -84533,18 +87856,18 @@ var ts; resultHasScopeMarker = false; collectReferences(sourceFile, refs); collectLibs(sourceFile, libs); - if (ts.isExternalModule(sourceFile)) { + if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) { resultHasExternalModuleIndicator = false; // unused in external module bundle emit (all external modules are within module blocks, therefore are known to be modules) needsDeclare = false; - var statements_4 = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); - var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(126 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements_4)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); + var statements = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var newFile = ts.updateSourceFileNode(sourceFile, [ts.createModuleDeclaration([], [ts.createModifier(129 /* DeclareKeyword */)], ts.createLiteral(ts.getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), ts.createModuleBlock(ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)))], /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); return newFile; } needsDeclare = true; - var updated = ts.visitNodes(sourceFile.statements, visitDeclarationStatements); + var updated = ts.isSourceFileJS(sourceFile) ? ts.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements); return ts.updateSourceFileNode(sourceFile, transformAndReplaceLatePaintedStatements(updated), /*isDeclarationFile*/ true, /*referencedFiles*/ [], /*typeReferences*/ [], /*hasNoDefaultLib*/ false, /*libReferences*/ []); }), ts.mapDefined(node.prepends, function (prepend) { - if (prepend.kind === 288 /* InputFiles */) { + if (prepend.kind === 291 /* InputFiles */) { var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal); hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib; collectReferences(sourceFile, refs); @@ -84581,12 +87904,20 @@ var ts; var references = []; var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, /*forceDtsPaths*/ true).declarationFilePath)); var referenceVisitor = mapReferencesIntoArray(references, outputFilePath); - var statements = ts.visitNodes(node.statements, visitDeclarationStatements); - var combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); - refs.forEach(referenceVisitor); - emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); - if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { - combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [createEmptyExports()])), combinedStatements); + var combinedStatements; + if (ts.isSourceFileJS(currentSourceFile)) { + combinedStatements = ts.createNodeArray(transformDeclarationsForJS(node)); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + } + else { + var statements = ts.visitNodes(node.statements, visitDeclarationStatements); + combinedStatements = ts.setTextRange(ts.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements); + refs.forEach(referenceVisitor); + emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax); + if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) { + combinedStatements = ts.setTextRange(ts.createNodeArray(__spreadArrays(combinedStatements, [ts.createEmptyExports()])), combinedStatements); + } } var updated = ts.updateSourceFileNode(node, combinedStatements, /*isDeclarationFile*/ true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences()); updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit; @@ -84673,11 +88004,11 @@ var ts; return ret; } function filterBindingPatternInitializers(name) { - if (name.kind === 73 /* Identifier */) { + if (name.kind === 75 /* Identifier */) { return name; } else { - if (name.kind === 186 /* ArrayBindingPattern */) { + if (name.kind === 189 /* ArrayBindingPattern */) { return ts.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement)); } else { @@ -84685,7 +88016,7 @@ var ts; } } function visitBindingElement(elem) { - if (elem.kind === 211 /* OmittedExpression */) { + if (elem.kind === 214 /* OmittedExpression */) { return elem; } return ts.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined); @@ -84698,7 +88029,7 @@ var ts; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p); } var newParam = ts.updateParameter(p, - /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(56 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param + /*decorators*/ undefined, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || ts.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param ensureNoInitializer(p)); if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; @@ -84723,19 +88054,19 @@ var ts; // Literal const declarations will have an initializer ensured rather than a type return; } - var shouldUseResolverType = node.kind === 152 /* Parameter */ && + var shouldUseResolverType = node.kind === 155 /* Parameter */ && (resolver.isRequiredInitializedParameter(node) || resolver.isOptionalUninitializedParameterProperty(node)); if (type && !shouldUseResolverType) { return ts.visitNode(type, visitDeclarationSubtree); } if (!ts.getParseTreeNode(node)) { - return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(121 /* AnyKeyword */); + return type ? ts.visitNode(type, visitDeclarationSubtree) : ts.createKeywordTypeNode(124 /* AnyKeyword */); } - if (node.kind === 160 /* SetAccessor */) { + if (node.kind === 163 /* SetAccessor */) { // Set accessors with no associated type node (from it's param or get accessor return) are `any` since they are never contextually typed right now // (The inferred type here will be void, but the old declaration emitter printed `any`, so this replicates that) - return ts.createKeywordTypeNode(121 /* AnyKeyword */); + return ts.createKeywordTypeNode(124 /* AnyKeyword */); } errorNameNode = node.name; var oldDiag; @@ -84743,12 +88074,12 @@ var ts; oldDiag = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node); } - if (node.kind === 238 /* VariableDeclaration */ || node.kind === 187 /* BindingElement */) { + if (node.kind === 241 /* VariableDeclaration */ || node.kind === 190 /* BindingElement */) { return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } - if (node.kind === 152 /* Parameter */ - || node.kind === 155 /* PropertyDeclaration */ - || node.kind === 154 /* PropertySignature */) { + if (node.kind === 155 /* Parameter */ + || node.kind === 158 /* PropertyDeclaration */ + || node.kind === 157 /* PropertySignature */) { if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -84759,26 +88090,26 @@ var ts; if (!suppressNewDiagnosticContexts) { getSymbolAccessibilityDiagnostic = oldDiag; } - return returnValue || ts.createKeywordTypeNode(121 /* AnyKeyword */); + return returnValue || ts.createKeywordTypeNode(124 /* AnyKeyword */); } } function isDeclarationAndNotVisible(node) { node = ts.getParseTreeNode(node); switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: return !resolver.isDeclarationVisible(node); // The following should be doing their own visibility checks based on filtering their members - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return !getBindingNameVisible(node); - case 249 /* ImportEqualsDeclaration */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 252 /* ImportEqualsDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return false; } return false; @@ -84859,7 +88190,7 @@ var ts; function rewriteModuleSpecifier(parent, input) { if (!input) return undefined; // TODO: GH#18217 - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 245 /* ModuleDeclaration */ && parent.kind !== 184 /* ImportType */); + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 248 /* ModuleDeclaration */ && parent.kind !== 187 /* ImportType */); if (ts.isStringLiteralLike(input)) { if (isBundledEmit) { var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent); @@ -84879,7 +88210,7 @@ var ts; function transformImportEqualsDeclaration(decl) { if (!resolver.isDeclarationVisible(decl)) return; - if (decl.moduleReference.kind === 260 /* ExternalModuleReference */) { + if (decl.moduleReference.kind === 263 /* ExternalModuleReference */) { // Rewrite external module names if necessary var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl); return ts.updateImportEqualsDeclaration(decl, @@ -84906,7 +88237,7 @@ var ts; return visibleDefaultBinding && ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, /*namedBindings*/ undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier)); } - if (decl.importClause.namedBindings.kind === 252 /* NamespaceImport */) { + if (decl.importClause.namedBindings.kind === 255 /* NamespaceImport */) { // Namespace import (optionally with visible default) var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; return visibleDefaultBinding || namedBindings ? ts.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, ts.updateImportClause(decl.importClause, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined; @@ -84955,11 +88286,11 @@ var ts; var result = lateStatementReplacementMap.get(key); lateStatementReplacementMap.delete(key); if (result) { - if (ts.isArray(result) ? ts.some(result, needsScopeMarker) : needsScopeMarker(result)) { + if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) { // Top-level declarations in .d.ts files are always considered exported even without a modifier unless there's an export assignment or specifier needsScopeFixMarker = true; } - if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, isExternalModuleIndicator) : isExternalModuleIndicator(result))) { + if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) { resultHasExternalModuleIndicator = true; } } @@ -84969,13 +88300,6 @@ var ts; return statement; } } - function isExternalModuleIndicator(result) { - // Exported top-level member indicates moduleness - return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasModifier(result, 1 /* Export */); - } - function needsScopeMarker(result) { - return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasModifier(result, 1 /* Export */) && !ts.isAmbientModule(result); - } function visitDeclarationSubtree(input) { if (shouldStripInternal(input)) return; @@ -85002,7 +88326,7 @@ var ts; // We'd see a TDZ violation at runtime var canProduceDiagnostic = ts.canProduceDiagnostics(input); var oldWithinObjectLiteralType = suppressNewDiagnosticContexts; - var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 169 /* TypeLiteral */ || input.kind === 182 /* MappedType */) && input.parent.kind !== 243 /* TypeAliasDeclaration */); + var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 172 /* TypeLiteral */ || input.kind === 185 /* MappedType */) && input.parent.kind !== 246 /* TypeAliasDeclaration */); // Emit methods which are private as properties with no type information if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) { if (ts.hasModifier(input, 8 /* Private */)) { @@ -85023,75 +88347,65 @@ var ts; } if (isProcessedComponent(input)) { switch (input.kind) { - case 212 /* ExpressionWithTypeArguments */: { + case 215 /* ExpressionWithTypeArguments */: { if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) { checkEntityNameVisibility(input.expression, enclosingDeclaration); } var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateExpressionWithTypeArguments(node, ts.parenthesizeTypeParameters(node.typeArguments), node.expression)); } - case 165 /* TypeReference */: { + case 168 /* TypeReference */: { checkEntityNameVisibility(input.typeName, enclosingDeclaration); var node = ts.visitEachChild(input, visitDeclarationSubtree, context); return cleanup(ts.updateTypeReferenceNode(node, node.typeName, ts.parenthesizeTypeParameters(node.typeArguments))); } - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return cleanup(ts.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); - case 158 /* Constructor */: { + case 161 /* Constructor */: { var isPrivate = ts.hasModifier(input, 8 /* Private */); // A constructor declaration may not have a type annotation - var ctor = ts.createSignatureDeclaration(158 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), + var ctor = ts.createSignatureDeclaration(161 /* Constructor */, isPrivate ? undefined : ensureTypeParams(input, input.typeParameters), // TODO: GH#18217 isPrivate ? undefined : updateParamsList(input, input.parameters, 0 /* None */), /*type*/ undefined); ctor.modifiers = ts.createNodeArray(ensureModifiers(input)); return cleanup(ctor); } - case 157 /* MethodDeclaration */: { - var sig = ts.createSignatureDeclaration(156 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); + case 160 /* MethodDeclaration */: { + var sig = ts.createSignatureDeclaration(159 /* MethodSignature */, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)); sig.name = input.name; sig.modifiers = ts.createNodeArray(ensureModifiers(input)); sig.questionToken = input.questionToken; return cleanup(sig); } - case 159 /* GetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - var isPrivate = ts.hasModifier(input, 8 /* Private */); - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); - return cleanup(ts.updateGetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 160 /* SetAccessor */: { - // For now, only emit class accessors as accessors if they were already declared in an ambient context. - if (input.flags & 4194304 /* Ambient */) { - return cleanup(ts.updateSetAccessor(input, - /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), - /*body*/ undefined)); - } - var newNode = ensureAccessor(input); - return cleanup(newNode); - } - case 155 /* PropertyDeclaration */: + case 162 /* GetAccessor */: { + var isPrivate = ts.hasModifier(input, 8 /* Private */); + var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); + return cleanup(ts.updateGetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, isPrivate), !isPrivate ? ensureType(input, accessorType) : undefined, + /*body*/ undefined)); + } + case 163 /* SetAccessor */: { + return cleanup(ts.updateSetAccessor(input, + /*decorators*/ undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasModifier(input, 8 /* Private */)), + /*body*/ undefined)); + } + case 158 /* PropertyDeclaration */: return cleanup(ts.updateProperty(input, /*decorators*/ undefined, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return cleanup(ts.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, !ts.hasModifier(input, 8 /* Private */) ? ensureType(input, input.type) : undefined, ensureNoInitializer(input))); - case 156 /* MethodSignature */: { + case 159 /* MethodSignature */: { return cleanup(ts.updateMethodSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type), input.name, input.questionToken)); } - case 161 /* CallSignature */: { + case 164 /* CallSignature */: { return cleanup(ts.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type))); } - case 163 /* IndexSignature */: { + case 166 /* IndexSignature */: { return cleanup(ts.updateIndexSignature(input, - /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(121 /* AnyKeyword */))); + /*decorators*/ undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || ts.createKeywordTypeNode(124 /* AnyKeyword */))); } - case 238 /* VariableDeclaration */: { + case 241 /* VariableDeclaration */: { if (ts.isBindingPattern(input.name)) { return recreateBindingPattern(input.name); } @@ -85099,13 +88413,13 @@ var ts; suppressNewDiagnosticContexts = true; // Variable declaration types also suppress new diagnostic contexts, provided the contexts wouldn't be made for binding pattern types return cleanup(ts.updateVariableDeclaration(input, input.name, ensureType(input, input.type), ensureNoInitializer(input))); } - case 151 /* TypeParameter */: { + case 154 /* TypeParameter */: { if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) { return cleanup(ts.updateTypeParameterDeclaration(input, input.name, /*constraint*/ undefined, /*defaultType*/ undefined)); } return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context)); } - case 176 /* ConditionalType */: { + case 179 /* ConditionalType */: { // We have to process conditional types in a special way because for visibility purposes we need to push a new enclosingDeclaration // just for the `infer` types in the true branch. It's an implicit declaration scope that only applies to _part_ of the type. var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree); @@ -85117,13 +88431,13 @@ var ts; var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree); return cleanup(ts.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType)); } - case 166 /* FunctionType */: { + case 169 /* FunctionType */: { return cleanup(ts.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 167 /* ConstructorType */: { + case 170 /* ConstructorType */: { return cleanup(ts.updateConstructorTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree))); } - case 184 /* ImportType */: { + case 187 /* ImportType */: { if (!ts.isLiteralImportTypeNode(input)) return cleanup(input); return cleanup(ts.updateImportTypeNode(input, ts.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf)); @@ -85152,7 +88466,7 @@ var ts; } } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 157 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 160 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function visitDeclarationStatements(input) { if (!isPreservedDeclarationStatement(input)) { @@ -85162,7 +88476,7 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 256 /* ExportDeclaration */: { + case 259 /* ExportDeclaration */: { if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } @@ -85171,13 +88485,13 @@ var ts; // Rewrite external module names if necessary return ts.updateExportDeclaration(input, /*decorators*/ undefined, input.modifiers, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier)); } - case 255 /* ExportAssignment */: { + case 258 /* ExportAssignment */: { // Always visible if the parent node isn't dropped for being not visible if (ts.isSourceFile(input.parent)) { resultHasExternalModuleIndicator = true; } resultHasScopeMarker = true; - if (input.expression.kind === 73 /* Identifier */) { + if (input.expression.kind === 75 /* Identifier */) { return input; } else { @@ -85187,7 +88501,7 @@ var ts; errorNode: input }); }; var varDecl = ts.createVariableDeclaration(newId, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); return [statement, ts.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; } } @@ -85212,10 +88526,10 @@ var ts; if (shouldStripInternal(input)) return; switch (input.kind) { - case 249 /* ImportEqualsDeclaration */: { + case 252 /* ImportEqualsDeclaration */: { return transformImportEqualsDeclaration(input); } - case 250 /* ImportDeclaration */: { + case 253 /* ImportDeclaration */: { return transformImportDeclaration(input); } } @@ -85236,14 +88550,14 @@ var ts; } var previousNeedsDeclare = needsDeclare; switch (input.kind) { - case 243 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all + case 246 /* TypeAliasDeclaration */: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(ts.updateTypeAliasDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode))); - case 242 /* InterfaceDeclaration */: { + case 245 /* InterfaceDeclaration */: { return cleanup(ts.updateInterfaceDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree))); } - case 240 /* FunctionDeclaration */: { + case 243 /* FunctionDeclaration */: { // Generators lose their generator-ness, excepting their return type var clean = cleanup(ts.updateFunctionDeclaration(input, /*decorators*/ undefined, ensureModifiers(input), @@ -85258,7 +88572,7 @@ var ts; fakespace_1.symbol = props[0].parent; var declarations = ts.mapDefined(props, function (p) { if (!ts.isPropertyAccessExpression(p.valueDeclaration)) { - return undefined; + return undefined; // TODO GH#33569: Handle element access expressions that created late bound names (rather than silently omitting them) } getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker); @@ -85291,17 +88605,17 @@ var ts; return clean; } } - case 245 /* ModuleDeclaration */: { + case 248 /* ModuleDeclaration */: { needsDeclare = false; var inner = input.body; - if (inner && inner.kind === 246 /* ModuleBlock */) { + if (inner && inner.kind === 249 /* ModuleBlock */) { var oldNeedsScopeFix = needsScopeFixMarker; var oldHasScopeFix = resultHasScopeMarker; resultHasScopeMarker = false; needsScopeFixMarker = false; var statements = ts.visitNodes(inner.statements, visitDeclarationStatements); var lateStatements = transformAndReplaceLatePaintedStatements(statements); - if (input.flags & 4194304 /* Ambient */) { + if (input.flags & 8388608 /* Ambient */) { needsScopeFixMarker = false; // If it was `declare`'d everything is implicitly exported already, ignore late printed "privates" } // With the final list of statements, there are 3 possibilities: @@ -85310,7 +88624,7 @@ var ts; // 3. Some things are exported, some are not, and there's no marker - add an empty marker if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) { if (needsScopeFixMarker) { - lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [createEmptyExports()])); + lateStatements = ts.createNodeArray(__spreadArrays(lateStatements, [ts.createEmptyExports()])); } else { lateStatements = ts.visitNodes(lateStatements, stripExportModifiers); @@ -85337,7 +88651,7 @@ var ts; /*decorators*/ undefined, mods, input.name, body)); } } - case 241 /* ClassDeclaration */: { + case 244 /* ClassDeclaration */: { var modifiers = ts.createNodeArray(ensureModifiers(input)); var typeParameters = ensureTypeParams(input, input.typeParameters); var ctor = ts.getFirstConstructorWithBody(input); @@ -85348,7 +88662,7 @@ var ts; if (!ts.hasModifier(param, 92 /* ParameterPropertyModifier */) || shouldStripInternal(param)) return; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param); - if (param.name.kind === 73 /* Identifier */) { + if (param.name.kind === 75 /* Identifier */) { return preserveJsDoc(ts.createProperty( /*decorators*/ undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param); } @@ -85378,7 +88692,7 @@ var ts; } var members = ts.createNodeArray(ts.concatenate(parameterProperties, ts.visitNodes(input.members, visitDeclarationSubtree))); var extendsClause_1 = ts.getEffectiveBaseTypeNode(input); - if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 97 /* NullKeyword */) { + if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 99 /* NullKeyword */) { // We must add a temporary declaration for the extends clause expression var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default"; var newId_1 = ts.createOptimisticUniqueName(oldId + "_base"); @@ -85388,16 +88702,16 @@ var ts; typeName: input.name }); }; var varDecl = ts.createVariableDeclaration(newId_1, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); - var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(126 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); + var statement = ts.createVariableStatement(needsDeclare ? [ts.createModifier(129 /* DeclareKeyword */)] : [], ts.createVariableDeclarationList([varDecl], 2 /* Const */)); var heritageClauses = ts.createNodeArray(ts.map(input.heritageClauses, function (clause) { - if (clause.token === 87 /* ExtendsKeyword */) { + if (clause.token === 89 /* ExtendsKeyword */) { var oldDiag_2 = getSymbolAccessibilityDiagnostic; getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]); var newClause = ts.updateHeritageClause(clause, ts.map(clause.types, function (t) { return ts.updateExpressionWithTypeArguments(t, ts.visitNodes(t.typeArguments, visitDeclarationSubtree), newId_1); })); getSymbolAccessibilityDiagnostic = oldDiag_2; return newClause; } - return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 97 /* NullKeyword */; })), visitDeclarationSubtree)); + return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 99 /* NullKeyword */; })), visitDeclarationSubtree)); })); return [statement, cleanup(ts.updateClassDeclaration(input, /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members))]; // TODO: GH#18217 @@ -85408,10 +88722,10 @@ var ts; /*decorators*/ undefined, modifiers, input.name, typeParameters, heritageClauses, members)); } } - case 220 /* VariableStatement */: { + case 224 /* VariableStatement */: { return cleanup(transformVariableStatement(input)); } - case 244 /* EnumDeclaration */: { + case 247 /* EnumDeclaration */: { return cleanup(ts.updateEnumDeclaration(input, /*decorators*/ undefined, ts.createNodeArray(ensureModifiers(input)), input.name, ts.createNodeArray(ts.mapDefined(input.members, function (m) { if (shouldStripInternal(m)) return; @@ -85430,7 +88744,7 @@ var ts; if (canProdiceDiagnostic) { getSymbolAccessibilityDiagnostic = oldDiag; } - if (input.kind === 245 /* ModuleDeclaration */) { + if (input.kind === 248 /* ModuleDeclaration */) { needsDeclare = previousNeedsDeclare; } if (node === input) { @@ -85451,7 +88765,7 @@ var ts; return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); })); } function recreateBindingElement(e) { - if (e.kind === 211 /* OmittedExpression */) { + if (e.kind === 214 /* OmittedExpression */) { return; } if (e.name) { @@ -85501,7 +88815,7 @@ var ts; function ensureModifierFlags(node) { var mask = 3071 /* All */ ^ (4 /* Public */ | 256 /* Async */); // No async modifiers in declaration files var additions = (needsDeclare && !isAlwaysType(node)) ? 2 /* Ambient */ : 0 /* None */; - var parentIsFile = node.parent.kind === 285 /* SourceFile */; + var parentIsFile = node.parent.kind === 288 /* SourceFile */; if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) { mask ^= 2 /* Ambient */; additions = 0 /* None */; @@ -85522,43 +88836,15 @@ var ts; } return accessorType; } - function ensureAccessor(node) { - var accessors = resolver.getAllAccessorDeclarations(node); - if (node.kind !== accessors.firstAccessor.kind) { - return; - } - var accessorType = getTypeAnnotationFromAllAccessorDeclarations(node, accessors); - var prop = ts.createProperty(/*decorators*/ undefined, maskModifiers(node, /*mask*/ undefined, (!accessors.setAccessor) ? 64 /* Readonly */ : 0 /* None */), node.name, node.questionToken, ensureType(node, accessorType), /*initializer*/ undefined); - var leadingsSyntheticCommentRanges = accessors.secondAccessor && ts.getLeadingCommentRangesOfNode(accessors.secondAccessor, currentSourceFile); - if (leadingsSyntheticCommentRanges) { - var _loop_15 = function (range) { - if (range.kind === 3 /* MultiLineCommentTrivia */) { - var text = currentSourceFile.text.slice(range.pos + 2, range.end - 2); - var lines = text.split(/\r\n?|\n/g); - if (lines.length > 1) { - var lastLines = lines.slice(1); - var indentation_1 = ts.guessIndentation(lastLines); - text = __spreadArrays([lines[0]], ts.map(lastLines, function (l) { return l.slice(indentation_1); })).join(newLine); - } - ts.addSyntheticLeadingComment(prop, range.kind, text, range.hasTrailingNewLine); - } - }; - for (var _i = 0, leadingsSyntheticCommentRanges_1 = leadingsSyntheticCommentRanges; _i < leadingsSyntheticCommentRanges_1.length; _i++) { - var range = leadingsSyntheticCommentRanges_1[_i]; - _loop_15(range); - } - } - return prop; - } function transformHeritageClauses(nodes) { return ts.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return ts.updateHeritageClause(clause, ts.visitNodes(ts.createNodeArray(ts.filter(clause.types, function (t) { - return ts.isEntityNameExpression(t.expression) || (clause.token === 87 /* ExtendsKeyword */ && t.expression.kind === 97 /* NullKeyword */); + return ts.isEntityNameExpression(t.expression) || (clause.token === 89 /* ExtendsKeyword */ && t.expression.kind === 99 /* NullKeyword */); })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; })); } } ts.transformDeclarations = transformDeclarations; function isAlwaysType(node) { - if (node.kind === 242 /* InterfaceDeclaration */) { + if (node.kind === 245 /* InterfaceDeclaration */) { return true; } return false; @@ -85583,7 +88869,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 159 /* GetAccessor */ + return accessor.kind === 162 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -85592,52 +88878,52 @@ var ts; } function canHaveLiteralInitializer(node) { switch (node.kind) { - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: return !ts.hasModifier(node, 8 /* Private */); - case 152 /* Parameter */: - case 238 /* VariableDeclaration */: + case 155 /* Parameter */: + case 241 /* VariableDeclaration */: return true; } return false; } function isPreservedDeclarationStatement(node) { switch (node.kind) { - case 240 /* FunctionDeclaration */: - case 245 /* ModuleDeclaration */: - case 249 /* ImportEqualsDeclaration */: - case 242 /* InterfaceDeclaration */: - case 241 /* ClassDeclaration */: - case 243 /* TypeAliasDeclaration */: - case 244 /* EnumDeclaration */: - case 220 /* VariableStatement */: - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 248 /* ModuleDeclaration */: + case 252 /* ImportEqualsDeclaration */: + case 245 /* InterfaceDeclaration */: + case 244 /* ClassDeclaration */: + case 246 /* TypeAliasDeclaration */: + case 247 /* EnumDeclaration */: + case 224 /* VariableStatement */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: + case 258 /* ExportAssignment */: return true; } return false; } function isProcessedComponent(node) { switch (node.kind) { - case 162 /* ConstructSignature */: - case 158 /* Constructor */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 155 /* PropertyDeclaration */: - case 154 /* PropertySignature */: - case 156 /* MethodSignature */: - case 161 /* CallSignature */: - case 163 /* IndexSignature */: - case 238 /* VariableDeclaration */: - case 151 /* TypeParameter */: - case 212 /* ExpressionWithTypeArguments */: - case 165 /* TypeReference */: - case 176 /* ConditionalType */: - case 166 /* FunctionType */: - case 167 /* ConstructorType */: - case 184 /* ImportType */: + case 165 /* ConstructSignature */: + case 161 /* Constructor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 158 /* PropertyDeclaration */: + case 157 /* PropertySignature */: + case 159 /* MethodSignature */: + case 164 /* CallSignature */: + case 166 /* IndexSignature */: + case 241 /* VariableDeclaration */: + case 154 /* TypeParameter */: + case 215 /* ExpressionWithTypeArguments */: + case 168 /* TypeReference */: + case 179 /* ConditionalType */: + case 169 /* FunctionType */: + case 170 /* ConstructorType */: + case 187 /* ImportType */: return true; } return false; @@ -85766,7 +89052,7 @@ var ts; * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { - var enabledSyntaxKindFeatures = new Array(320 /* Count */); + var enabledSyntaxKindFeatures = new Array(324 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -86051,15 +89337,15 @@ var ts; * If an array, the full list of source files to emit. * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit. */ - function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, emitOnlyDtsFiles, onlyBuildInfo, includeBuildInfo) { - if (emitOnlyDtsFiles === void 0) { emitOnlyDtsFiles = false; } + function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) { + if (forceDtsEmit === void 0) { forceDtsEmit = false; } var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile); var options = host.getCompilerOptions(); if (options.outFile || options.out) { var prepends = host.getPrependNodes(); if (sourceFiles.length || prepends.length) { var bundle = ts.createBundle(sourceFiles, prepends); - var result = action(getOutputPathsFor(bundle, host, emitOnlyDtsFiles), bundle); + var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle); if (result) { return result; } @@ -86069,22 +89355,21 @@ var ts; if (!onlyBuildInfo) { 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); + var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile); if (result) { return result; } } } if (includeBuildInfo) { - var buildInfoPath = getOutputPathForBuildInfo(host.getCompilerOptions()); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(host.getCompilerOptions()); if (buildInfoPath) return action({ buildInfoPath: buildInfoPath }, /*sourceFileOrBundle*/ undefined); } } } ts.forEachEmittedFile = forEachEmittedFile; - /*@internal*/ - function getOutputPathForBuildInfo(options) { + function getTsBuildInfoEmitOutputFilePath(options) { var configFile = options.configFilePath; if (!ts.isIncrementalCompilation(options)) return undefined; @@ -86107,7 +89392,7 @@ var ts; } return buildInfoExtensionLess + ".tsbuildinfo" /* TsBuildInfo */; } - ts.getOutputPathForBuildInfo = getOutputPathForBuildInfo; + ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath; /*@internal*/ function getOutputPathsForBundle(options, forceDtsPaths) { var outPath = options.outFile || options.out; @@ -86115,14 +89400,14 @@ var ts; var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options); var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" /* Dts */ : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; - var buildInfoPath = getOutputPathForBuildInfo(options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options); return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath }; } ts.getOutputPathsForBundle = getOutputPathsForBundle; /*@internal*/ function getOutputPathsFor(sourceFile, host, forceDtsPaths) { var options = host.getCompilerOptions(); - if (sourceFile.kind === 286 /* Bundle */) { + if (sourceFile.kind === 289 /* Bundle */) { return getOutputPathsForBundle(options, forceDtsPaths); } else { @@ -86132,9 +89417,7 @@ var ts; ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath; var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options); - // For legacy reasons (ie, we have baselines capturing the behavior), js files don't report a .d.ts output path - this would only matter if `declaration` and `allowJs` were both on, which is currently an error - var isJs = ts.isSourceFileJS(sourceFile); - var declarationFilePath = ((forceDtsPaths || ts.getEmitDeclarations(options)) && !isJs) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; + var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined; var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined; return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined }; } @@ -86175,7 +89458,7 @@ var ts; } /* @internal */ function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase) { - ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(inputFileName)); + ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)); return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir), ".d.ts" /* Dts */); } ts.getOutputDeclarationFileName = getOutputDeclarationFileName; @@ -86192,43 +89475,73 @@ var ts; outputFileName : undefined; } + function createAddOutput() { + var outputs; + return { addOutput: addOutput, getOutputs: getOutputs }; + function addOutput(path) { + if (path) { + (outputs || (outputs = [])).push(path); + } + } + function getOutputs() { + return outputs || ts.emptyArray; + } + } + function getSingleOutputFileNames(configFile, addOutput) { + var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; + addOutput(jsFilePath); + addOutput(sourceMapFilePath); + addOutput(declarationFilePath); + addOutput(declarationMapPath); + addOutput(buildInfoPath); + } + function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput) { + if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) + return; + var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); + addOutput(js); + if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) + return; + if (js && configFile.options.sourceMap) { + addOutput(js + ".map"); + } + if (ts.getEmitDeclarations(configFile.options)) { + var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); + addOutput(dts); + if (configFile.options.declarationMap) { + addOutput(dts + ".map"); + } + } + } /*@internal*/ function getAllProjectOutputs(configFile, ignoreCase) { - var outputs; - var addOutput = function (path) { return path && (outputs || (outputs = [])).push(path); }; + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; if (configFile.options.outFile || configFile.options.out) { - var _a = getOutputPathsForBundle(configFile.options, /*forceDtsPaths*/ false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath; - addOutput(jsFilePath); - addOutput(sourceMapFilePath); - addOutput(declarationFilePath); - addOutput(declarationMapPath); - addOutput(buildInfoPath); + getSingleOutputFileNames(configFile, addOutput); } else { for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) { var inputFileName = _c[_b]; - if (ts.fileExtensionIs(inputFileName, ".d.ts" /* Dts */)) - continue; - var js = getOutputJSFileName(inputFileName, configFile, ignoreCase); - addOutput(js); - if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) - continue; - if (js && configFile.options.sourceMap) { - addOutput(js + ".map"); - } - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { - var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); - addOutput(dts); - if (configFile.options.declarationMap) { - addOutput(dts + ".map"); - } - } + getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput); } - addOutput(getOutputPathForBuildInfo(configFile.options)); + addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options)); } - return outputs || ts.emptyArray; + return getOutputs(); } ts.getAllProjectOutputs = getAllProjectOutputs; + function getOutputFileNames(commandLine, inputFileName, ignoreCase) { + inputFileName = ts.normalizePath(inputFileName); + ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line"); + var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs; + if (commandLine.options.outFile || commandLine.options.out) { + getSingleOutputFileNames(commandLine, addOutput); + } + else { + getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput); + } + return getOutputs(); + } + ts.getOutputFileNames = getOutputFileNames; /*@internal*/ function getFirstProjectOutput(configFile, ignoreCase) { if (configFile.options.outFile || configFile.options.out) { @@ -86244,11 +89557,11 @@ var ts; return jsFilePath; if (ts.fileExtensionIs(inputFileName, ".json" /* Json */)) continue; - if (ts.getEmitDeclarations(configFile.options) && ts.hasTSFileExtension(inputFileName)) { + if (ts.getEmitDeclarations(configFile.options)) { return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase); } } - var buildInfoPath = getOutputPathForBuildInfo(configFile.options); + var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options); if (buildInfoPath) return buildInfoPath; return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output"); @@ -86256,7 +89569,7 @@ var ts; ts.getFirstProjectOutput = getFirstProjectOutput; /*@internal*/ // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature - function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo) { + function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) { var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers; var compilerOptions = host.getCompilerOptions(); var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined; @@ -86270,7 +89583,7 @@ var ts; var exportedModulesFromDeclarationEmit; // Emit each output file enter(); - forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), emitOnlyDtsFiles, onlyBuildInfo, !targetSourceFile); + forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile), forceDtsEmit, onlyBuildInfo, !targetSourceFile); exit(); return { emitSkipped: emitSkipped, @@ -86366,17 +89679,20 @@ var ts; bundleBuildInfo.js = printer.bundleFileInfo; } function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) { - if (!sourceFileOrBundle || !(declarationFilePath && !ts.isInJSFile(sourceFileOrBundle))) { + if (!sourceFileOrBundle) + return; + if (!declarationFilePath) { + if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly) + emitSkipped = true; return; } var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles; // Setup and perform the transformation to retrieve declarations from the input files - var nonJsFiles = ts.filter(sourceFiles, ts.isSourceFileNotJS); - var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(nonJsFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : nonJsFiles; + var inputListOrBundle = (compilerOptions.outFile || compilerOptions.out) ? [ts.createBundle(sourceFiles, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : sourceFiles; if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) { // Checker wont collect the linked aliases since thats only done when declaration is enabled. // Do that here when emitting only dts files - nonJsFiles.forEach(collectLinkedAliases); + sourceFiles.forEach(collectLinkedAliases); } var declarationTransform = ts.transformNodes(resolver, host, compilerOptions, inputListOrBundle, declarationTransformers, /*allowDtsFiles*/ false); if (ts.length(declarationTransform.diagnostics)) { @@ -86408,7 +89724,7 @@ var ts; }); var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit; emitSkipped = emitSkipped || declBlocked; - if (!declBlocked || emitOnlyDtsFiles) { + if (!declBlocked || forceDtsEmit) { ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform"); printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, { sourceMap: compilerOptions.declarationMap, @@ -86416,7 +89732,7 @@ var ts; mapRoot: compilerOptions.mapRoot, extendedDiagnostics: compilerOptions.extendedDiagnostics, }); - if (emitOnlyDtsFiles && declarationTransform.transformed[0].kind === 285 /* SourceFile */) { + if (forceDtsEmit && declarationTransform.transformed[0].kind === 288 /* SourceFile */) { var sourceFile = declarationTransform.transformed[0]; exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit; } @@ -86427,7 +89743,7 @@ var ts; } function collectLinkedAliases(node) { if (ts.isExportAssignment(node)) { - if (node.expression.kind === 73 /* Identifier */) { + if (node.expression.kind === 75 /* Identifier */) { resolver.collectLinkedAliases(node.expression, /*setVisibility*/ true); } return; @@ -86439,8 +89755,8 @@ var ts; ts.forEachChild(node, collectLinkedAliases); } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) { - var bundle = sourceFileOrBundle.kind === 286 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 285 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 289 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 288 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; var sourceMapGenerator; if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) { @@ -86481,7 +89797,7 @@ var ts; } function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) { return (mapOptions.sourceMap || mapOptions.inlineSourceMap) - && (sourceFileOrBundle.kind !== 285 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); + && (sourceFileOrBundle.kind !== 288 /* SourceFile */ || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json" /* Json */)); } function getSourceRoot(mapOptions) { // Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the @@ -86588,10 +89904,11 @@ var ts; getAllAccessorDeclarations: ts.notImplemented, getSymbolOfExternalModuleSpecifier: ts.notImplemented, isBindingCapturedByNode: ts.notImplemented, + getDeclarationStatementsForSourceFile: ts.notImplemented, }; function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) { var sourceFiles = bundle.sourceFiles.map(function (fileName) { - var sourceFile = ts.createNode(285 /* SourceFile */, 0, 0); + var sourceFile = ts.createNode(288 /* SourceFile */, 0, 0); sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames()); sourceFile.text = ""; sourceFile.statements = ts.createNodeArray(); @@ -86603,7 +89920,7 @@ var ts; sourceFile.text = prologueInfo.text; sourceFile.end = prologueInfo.text.length; sourceFile.statements = ts.createNodeArray(prologueInfo.directives.map(function (directive) { - var statement = ts.createNode(222 /* ExpressionStatement */, directive.pos, directive.end); + var statement = ts.createNode(225 /* ExpressionStatement */, directive.pos, directive.end); statement.expression = ts.createNode(10 /* StringLiteral */, directive.expression.pos, directive.expression.end); statement.expression.text = directive.expression.text; return statement; @@ -86749,6 +90066,8 @@ var ts; var detachedCommentsInfo; var hasWrittenComment = false; var commentsDisabled = !!printerOptions.removeComments; + var lastNode; + var lastSubstitution; var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit; reset(); return { @@ -86777,9 +90096,9 @@ var ts; break; } switch (node.kind) { - case 285 /* SourceFile */: return printFile(node); - case 286 /* Bundle */: return printBundle(node); - case 287 /* UnparsedSource */: return printUnparsedSource(node); + case 288 /* SourceFile */: return printFile(node); + case 289 /* Bundle */: return printBundle(node); + case 290 /* UnparsedSource */: return printUnparsedSource(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -86948,8 +90267,7 @@ var ts; if (sourceFile) { setSourceFile(sourceFile); } - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(hint, node); + pipelineEmit(hint, node); } function setSourceFile(sourceFile) { currentSourceFile = sourceFile; @@ -86961,7 +90279,7 @@ var ts; } function setWriter(_writer, _sourceMapGenerator) { if (_writer && printerOptions.omitTrailingSemicolon) { - _writer = ts.getTrailingSemicolonOmittingWriter(_writer); + _writer = ts.getTrailingSemicolonDeferringWriter(_writer); } writer = _writer; // TODO: GH#18217 sourceMapGenerator = _sourceMapGenerator; @@ -86977,6 +90295,8 @@ var ts; currentSourceFile = undefined; currentLineMap = undefined; detachedCommentsInfo = undefined; + lastNode = undefined; + lastSubstitution = undefined; setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined); } function getCurrentLineMap() { @@ -86986,21 +90306,32 @@ var ts; if (node === undefined) return; var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(4 /* Unspecified */, node); + var substitute = pipelineEmit(4 /* Unspecified */, node); recordBundleFileInternalSectionEnd(prevSourceFileTextKind); + return substitute; } function emitIdentifierName(node) { if (node === undefined) return; - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(2 /* IdentifierName */, node); + return pipelineEmit(2 /* IdentifierName */, node); } function emitExpression(node) { if (node === undefined) return; + return pipelineEmit(1 /* Expression */, node); + } + function pipelineEmit(emitHint, node) { + var savedLastNode = lastNode; + var savedLastSubstitution = lastSubstitution; + lastNode = node; + lastSubstitution = undefined; var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(1 /* Expression */, node); + pipelinePhase(emitHint, node); + ts.Debug.assert(lastNode === node); + var substitute = lastSubstitution; + lastNode = savedLastNode; + lastSubstitution = savedLastSubstitution; + return substitute || node; } function getPipelinePhase(phase, node) { switch (phase) { @@ -87015,12 +90346,12 @@ var ts; } // falls through case 2 /* Comments */: - if (!commentsDisabled && node.kind !== 285 /* SourceFile */) { + if (!commentsDisabled && node.kind !== 288 /* SourceFile */) { return pipelineEmitWithComments; } // falls through case 3 /* SourceMaps */: - if (!sourceMapsDisabled && node.kind !== 285 /* SourceFile */ && !ts.isInJsonFile(node)) { + if (!sourceMapsDisabled && node.kind !== 288 /* SourceFile */ && !ts.isInJsonFile(node)) { return pipelineEmitWithSourceMap; } // falls through @@ -87034,10 +90365,13 @@ var ts; return getPipelinePhase(currentPhase + 1, node); } function pipelineEmitWithNotification(hint, node) { + ts.Debug.assert(lastNode === node); var pipelinePhase = getNextPipelinePhase(0 /* Notification */, node); onEmitNode(hint, node, pipelinePhase); + ts.Debug.assert(lastNode === node); } function pipelineEmitWithHint(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); if (hint === 0 /* SourceFile */) return emitSourceFile(ts.cast(node, ts.isSourceFile)); if (hint === 2 /* IdentifierName */) @@ -87057,279 +90391,279 @@ var ts; case 16 /* TemplateMiddle */: case 17 /* TemplateTail */: return emitLiteral(node); - case 287 /* UnparsedSource */: - case 281 /* UnparsedPrepend */: + case 290 /* UnparsedSource */: + case 284 /* UnparsedPrepend */: return emitUnparsedSourceOrPrepend(node); - case 280 /* UnparsedPrologue */: + case 283 /* UnparsedPrologue */: return writeUnparsedNode(node); - case 282 /* UnparsedText */: - case 283 /* UnparsedInternalText */: + case 285 /* UnparsedText */: + case 286 /* UnparsedInternalText */: return emitUnparsedTextLike(node); - case 284 /* UnparsedSyntheticReference */: + case 287 /* UnparsedSyntheticReference */: return emitUnparsedSyntheticReference(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 149 /* QualifiedName */: + case 152 /* QualifiedName */: return emitQualifiedName(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 151 /* TypeParameter */: + case 154 /* TypeParameter */: return emitTypeParameter(node); - case 152 /* Parameter */: + case 155 /* Parameter */: return emitParameter(node); - case 153 /* Decorator */: + case 156 /* Decorator */: return emitDecorator(node); // Type members - case 154 /* PropertySignature */: + case 157 /* PropertySignature */: return emitPropertySignature(node); - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 156 /* MethodSignature */: + case 159 /* MethodSignature */: return emitMethodSignature(node); - case 157 /* MethodDeclaration */: + case 160 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 158 /* Constructor */: + case 161 /* Constructor */: return emitConstructor(node); - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return emitAccessorDeclaration(node); - case 161 /* CallSignature */: + case 164 /* CallSignature */: return emitCallSignature(node); - case 162 /* ConstructSignature */: + case 165 /* ConstructSignature */: return emitConstructSignature(node); - case 163 /* IndexSignature */: + case 166 /* IndexSignature */: return emitIndexSignature(node); // Types - case 164 /* TypePredicate */: + case 167 /* TypePredicate */: return emitTypePredicate(node); - case 165 /* TypeReference */: + case 168 /* TypeReference */: return emitTypeReference(node); - case 166 /* FunctionType */: + case 169 /* FunctionType */: return emitFunctionType(node); - case 295 /* JSDocFunctionType */: + case 298 /* JSDocFunctionType */: return emitJSDocFunctionType(node); - case 167 /* ConstructorType */: + case 170 /* ConstructorType */: return emitConstructorType(node); - case 168 /* TypeQuery */: + case 171 /* TypeQuery */: return emitTypeQuery(node); - case 169 /* TypeLiteral */: + case 172 /* TypeLiteral */: return emitTypeLiteral(node); - case 170 /* ArrayType */: + case 173 /* ArrayType */: return emitArrayType(node); - case 171 /* TupleType */: + case 174 /* TupleType */: return emitTupleType(node); - case 172 /* OptionalType */: + case 175 /* OptionalType */: return emitOptionalType(node); - case 174 /* UnionType */: + case 177 /* UnionType */: return emitUnionType(node); - case 175 /* IntersectionType */: + case 178 /* IntersectionType */: return emitIntersectionType(node); - case 176 /* ConditionalType */: + case 179 /* ConditionalType */: return emitConditionalType(node); - case 177 /* InferType */: + case 180 /* InferType */: return emitInferType(node); - case 178 /* ParenthesizedType */: + case 181 /* ParenthesizedType */: return emitParenthesizedType(node); - case 212 /* ExpressionWithTypeArguments */: + case 215 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 179 /* ThisType */: + case 182 /* ThisType */: return emitThisType(); - case 180 /* TypeOperator */: + case 183 /* TypeOperator */: return emitTypeOperator(node); - case 181 /* IndexedAccessType */: + case 184 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 182 /* MappedType */: + case 185 /* MappedType */: return emitMappedType(node); - case 183 /* LiteralType */: + case 186 /* LiteralType */: return emitLiteralType(node); - case 184 /* ImportType */: + case 187 /* ImportType */: return emitImportTypeNode(node); - case 290 /* JSDocAllType */: + case 293 /* JSDocAllType */: writePunctuation("*"); return; - case 291 /* JSDocUnknownType */: + case 294 /* JSDocUnknownType */: writePunctuation("?"); return; - case 292 /* JSDocNullableType */: + case 295 /* JSDocNullableType */: return emitJSDocNullableType(node); - case 293 /* JSDocNonNullableType */: + case 296 /* JSDocNonNullableType */: return emitJSDocNonNullableType(node); - case 294 /* JSDocOptionalType */: + case 297 /* JSDocOptionalType */: return emitJSDocOptionalType(node); - case 173 /* RestType */: - case 296 /* JSDocVariadicType */: + case 176 /* RestType */: + case 299 /* JSDocVariadicType */: return emitRestOrJSDocVariadicType(node); // Binding patterns - case 185 /* ObjectBindingPattern */: + case 188 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 186 /* ArrayBindingPattern */: + case 189 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 187 /* BindingElement */: + case 190 /* BindingElement */: return emitBindingElement(node); // Misc - case 217 /* TemplateSpan */: + case 220 /* TemplateSpan */: return emitTemplateSpan(node); - case 218 /* SemicolonClassElement */: + case 221 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 219 /* Block */: + case 222 /* Block */: return emitBlock(node); - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: return emitVariableStatement(node); - case 221 /* EmptyStatement */: + case 223 /* EmptyStatement */: return emitEmptyStatement(/*isEmbeddedStatement*/ false); - case 222 /* ExpressionStatement */: + case 225 /* ExpressionStatement */: return emitExpressionStatement(node); - case 223 /* IfStatement */: + case 226 /* IfStatement */: return emitIfStatement(node); - case 224 /* DoStatement */: + case 227 /* DoStatement */: return emitDoStatement(node); - case 225 /* WhileStatement */: + case 228 /* WhileStatement */: return emitWhileStatement(node); - case 226 /* ForStatement */: + case 229 /* ForStatement */: return emitForStatement(node); - case 227 /* ForInStatement */: + case 230 /* ForInStatement */: return emitForInStatement(node); - case 228 /* ForOfStatement */: + case 231 /* ForOfStatement */: return emitForOfStatement(node); - case 229 /* ContinueStatement */: + case 232 /* ContinueStatement */: return emitContinueStatement(node); - case 230 /* BreakStatement */: + case 233 /* BreakStatement */: return emitBreakStatement(node); - case 231 /* ReturnStatement */: + case 234 /* ReturnStatement */: return emitReturnStatement(node); - case 232 /* WithStatement */: + case 235 /* WithStatement */: return emitWithStatement(node); - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: return emitSwitchStatement(node); - case 234 /* LabeledStatement */: + case 237 /* LabeledStatement */: return emitLabeledStatement(node); - case 235 /* ThrowStatement */: + case 238 /* ThrowStatement */: return emitThrowStatement(node); - case 236 /* TryStatement */: + case 239 /* TryStatement */: return emitTryStatement(node); - case 237 /* DebuggerStatement */: + case 240 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 238 /* VariableDeclaration */: + case 241 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 241 /* ClassDeclaration */: + case 244 /* ClassDeclaration */: return emitClassDeclaration(node); - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 246 /* ModuleBlock */: + case 249 /* ModuleBlock */: return emitModuleBlock(node); - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: return emitCaseBlock(node); - case 248 /* NamespaceExportDeclaration */: + case 251 /* NamespaceExportDeclaration */: return emitNamespaceExportDeclaration(node); - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: return emitImportDeclaration(node); - case 251 /* ImportClause */: + case 254 /* ImportClause */: return emitImportClause(node); - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: return emitNamespaceImport(node); - case 253 /* NamedImports */: + case 256 /* NamedImports */: return emitNamedImports(node); - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: return emitImportSpecifier(node); - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: return emitExportAssignment(node); - case 256 /* ExportDeclaration */: + case 259 /* ExportDeclaration */: return emitExportDeclaration(node); - case 257 /* NamedExports */: + case 260 /* NamedExports */: return emitNamedExports(node); - case 258 /* ExportSpecifier */: + case 261 /* ExportSpecifier */: return emitExportSpecifier(node); - case 259 /* MissingDeclaration */: + case 262 /* MissingDeclaration */: return; // Module references - case 260 /* ExternalModuleReference */: + case 263 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 11 /* JsxText */: return emitJsxText(node); - case 263 /* JsxOpeningElement */: - case 266 /* JsxOpeningFragment */: + case 266 /* JsxOpeningElement */: + case 269 /* JsxOpeningFragment */: return emitJsxOpeningElementOrFragment(node); - case 264 /* JsxClosingElement */: - case 267 /* JsxClosingFragment */: + case 267 /* JsxClosingElement */: + case 270 /* JsxClosingFragment */: return emitJsxClosingElementOrFragment(node); - case 268 /* JsxAttribute */: + case 271 /* JsxAttribute */: return emitJsxAttribute(node); - case 269 /* JsxAttributes */: + case 272 /* JsxAttributes */: return emitJsxAttributes(node); - case 270 /* JsxSpreadAttribute */: + case 273 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 271 /* JsxExpression */: + case 274 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 272 /* CaseClause */: + case 275 /* CaseClause */: return emitCaseClause(node); - case 273 /* DefaultClause */: + case 276 /* DefaultClause */: return emitDefaultClause(node); - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: return emitHeritageClause(node); - case 275 /* CatchClause */: + case 278 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 276 /* PropertyAssignment */: + case 279 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 277 /* ShorthandPropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 278 /* SpreadAssignment */: + case 281 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 279 /* EnumMember */: + case 282 /* EnumMember */: return emitEnumMember(node); // JSDoc nodes (only used in codefixes currently) - case 307 /* JSDocParameterTag */: - case 313 /* JSDocPropertyTag */: + case 310 /* JSDocParameterTag */: + case 316 /* JSDocPropertyTag */: return emitJSDocPropertyLikeTag(node); - case 308 /* JSDocReturnTag */: - case 310 /* JSDocTypeTag */: - case 309 /* JSDocThisTag */: - case 306 /* JSDocEnumTag */: + case 311 /* JSDocReturnTag */: + case 313 /* JSDocTypeTag */: + case 312 /* JSDocThisTag */: + case 309 /* JSDocEnumTag */: return emitJSDocSimpleTypedTag(node); - case 302 /* JSDocAugmentsTag */: + case 305 /* JSDocAugmentsTag */: return emitJSDocAugmentsTag(node); - case 311 /* JSDocTemplateTag */: + case 314 /* JSDocTemplateTag */: return emitJSDocTemplateTag(node); - case 312 /* JSDocTypedefTag */: + case 315 /* JSDocTypedefTag */: return emitJSDocTypedefTag(node); - case 305 /* JSDocCallbackTag */: + case 308 /* JSDocCallbackTag */: return emitJSDocCallbackTag(node); - case 300 /* JSDocSignature */: + case 303 /* JSDocSignature */: return emitJSDocSignature(node); - case 299 /* JSDocTypeLiteral */: + case 302 /* JSDocTypeLiteral */: return emitJSDocTypeLiteral(node); - case 304 /* JSDocClassTag */: - case 301 /* JSDocTag */: + case 307 /* JSDocClassTag */: + case 304 /* JSDocTag */: return emitJSDocSimpleTag(node); - case 298 /* JSDocComment */: + case 301 /* JSDocComment */: return emitJSDoc(node); // Transformation nodes (ignored) } if (ts.isExpression(node)) { hint = 1 /* Expression */; if (substituteNode !== ts.noEmitSubstitution) { - node = substituteNode(hint, node); + lastSubstitution = node = substituteNode(hint, node); } } else if (ts.isToken(node)) { @@ -87347,83 +90681,83 @@ var ts; case 14 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 73 /* Identifier */: + case 75 /* Identifier */: return emitIdentifier(node); // Reserved words - case 88 /* FalseKeyword */: - case 97 /* NullKeyword */: - case 99 /* SuperKeyword */: - case 103 /* TrueKeyword */: - case 101 /* ThisKeyword */: - case 93 /* ImportKeyword */: + case 90 /* FalseKeyword */: + case 99 /* NullKeyword */: + case 101 /* SuperKeyword */: + case 105 /* TrueKeyword */: + case 103 /* ThisKeyword */: + case 95 /* ImportKeyword */: writeTokenNode(node, writeKeyword); return; // Expressions - case 188 /* ArrayLiteralExpression */: + case 191 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 189 /* ObjectLiteralExpression */: + case 192 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 190 /* PropertyAccessExpression */: + case 193 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 191 /* ElementAccessExpression */: + case 194 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 192 /* CallExpression */: + case 195 /* CallExpression */: return emitCallExpression(node); - case 193 /* NewExpression */: + case 196 /* NewExpression */: return emitNewExpression(node); - case 194 /* TaggedTemplateExpression */: + case 197 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 196 /* ParenthesizedExpression */: + case 199 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 197 /* FunctionExpression */: + case 200 /* FunctionExpression */: return emitFunctionExpression(node); - case 198 /* ArrowFunction */: + case 201 /* ArrowFunction */: return emitArrowFunction(node); - case 199 /* DeleteExpression */: + case 202 /* DeleteExpression */: return emitDeleteExpression(node); - case 200 /* TypeOfExpression */: + case 203 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 201 /* VoidExpression */: + case 204 /* VoidExpression */: return emitVoidExpression(node); - case 202 /* AwaitExpression */: + case 205 /* AwaitExpression */: return emitAwaitExpression(node); - case 203 /* PrefixUnaryExpression */: + case 206 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 204 /* PostfixUnaryExpression */: + case 207 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 205 /* BinaryExpression */: + case 208 /* BinaryExpression */: return emitBinaryExpression(node); - case 206 /* ConditionalExpression */: + case 209 /* ConditionalExpression */: return emitConditionalExpression(node); - case 207 /* TemplateExpression */: + case 210 /* TemplateExpression */: return emitTemplateExpression(node); - case 208 /* YieldExpression */: + case 211 /* YieldExpression */: return emitYieldExpression(node); - case 209 /* SpreadElement */: + case 212 /* SpreadElement */: return emitSpreadExpression(node); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return emitClassExpression(node); - case 211 /* OmittedExpression */: + case 214 /* OmittedExpression */: return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: return emitAsExpression(node); - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: return emitNonNullExpression(node); - case 215 /* MetaProperty */: + case 218 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 261 /* JsxElement */: + case 264 /* JsxElement */: return emitJsxElement(node); - case 262 /* JsxSelfClosingElement */: + case 265 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); - case 265 /* JsxFragment */: + case 268 /* JsxFragment */: return emitJsxFragment(node); // Transformation nodes - case 316 /* PartiallyEmittedExpression */: + case 319 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); - case 317 /* CommaListExpression */: + case 320 /* CommaListExpression */: return emitCommaList(node); } } @@ -87436,8 +90770,11 @@ var ts; emit(node.constraint); } function pipelineEmitWithSubstitution(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(1 /* Substitution */, node); - pipelinePhase(hint, substituteNode(hint, node)); + lastSubstitution = substituteNode(hint, node); + pipelinePhase(hint, lastSubstitution); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function getHelpersFromBundledSourceFiles(bundle) { var result; @@ -87463,7 +90800,7 @@ var ts; } function emitHelpers(node) { var helpersEmitted = false; - var bundle = node.kind === 286 /* Bundle */ ? node : undefined; + var bundle = node.kind === 289 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -87563,7 +90900,7 @@ var ts; var pos = getTextPosWithWriteLine(); writeUnparsedNode(unparsed); if (bundleFileInfo) { - updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 282 /* UnparsedText */ ? + updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 285 /* UnparsedText */ ? "text" /* Text */ : "internal" /* Internal */); } @@ -87596,7 +90933,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -87632,7 +90969,7 @@ var ts; emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); - if (node.parent && node.parent.kind === 295 /* JSDocFunctionType */ && !node.name) { + if (node.parent && node.parent.kind === 298 /* JSDocFunctionType */ && !node.name) { emit(node.type); } else { @@ -87694,7 +91031,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeKeyword(node.kind === 159 /* GetAccessor */ ? "get" : "set"); + writeKeyword(node.kind === 162 /* GetAccessor */ ? "get" : "set"); writeSpace(); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); @@ -87735,11 +91072,17 @@ var ts; // Types // function emitTypePredicate(node) { + if (node.assertsModifier) { + emit(node.assertsModifier); + writeSpace(); + } emit(node.parameterName); - writeSpace(); - writeKeyword("is"); - writeSpace(); - emit(node.type); + if (node.type) { + writeSpace(); + writeKeyword("is"); + writeSpace(); + emit(node.type); + } } function emitTypeReference(node) { emit(node.typeName); @@ -87871,18 +91214,17 @@ var ts; } if (node.readonlyToken) { emit(node.readonlyToken); - if (node.readonlyToken.kind !== 134 /* ReadonlyKeyword */) { + if (node.readonlyToken.kind !== 137 /* ReadonlyKeyword */) { writeKeyword("readonly"); } writeSpace(); } writePunctuation("["); - var pipelinePhase = getPipelinePhase(0 /* Notification */, node.typeParameter); - pipelinePhase(3 /* MappedTypeParameter */, node.typeParameter); + pipelineEmit(3 /* MappedTypeParameter */, node.typeParameter); writePunctuation("]"); if (node.questionToken) { emit(node.questionToken); - if (node.questionToken.kind !== 56 /* QuestionToken */) { + if (node.questionToken.kind !== 57 /* QuestionToken */) { writePunctuation("?"); } } @@ -87962,66 +91304,57 @@ var ts; } } function emitPropertyAccessExpression(node) { - var indentBeforeDot = false; - var indentAfterDot = false; - var dotRangeFirstCommentStart = ts.skipTrivia(currentSourceFile.text, node.expression.end, - /*stopAfterLineBreak*/ false, - /*stopAtComments*/ true); - var dotRangeStart = ts.skipTrivia(currentSourceFile.text, dotRangeFirstCommentStart); - var dotRangeEnd = dotRangeStart + 1; - if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { - var dotToken = ts.createToken(24 /* DotToken */); - dotToken.pos = node.expression.end; - dotToken.end = dotRangeEnd; - indentBeforeDot = needsIndentation(node, node.expression, dotToken); - indentAfterDot = needsIndentation(node, dotToken, node.name); - } - emitExpression(node.expression); + var expression = ts.cast(emitExpression(node.expression), ts.isExpression); + var token = ts.getDotOrQuestionDotToken(node); + var indentBeforeDot = needsIndentation(node, node.expression, token); + var indentAfterDot = needsIndentation(node, token, node.name); increaseIndentIf(indentBeforeDot, /*writeSpaceIfNotIndenting*/ false); - var dotHasCommentTrivia = dotRangeFirstCommentStart !== dotRangeStart; - var shouldEmitDotDot = !indentBeforeDot && needsDotDotForPropertyAccess(node.expression, dotHasCommentTrivia); + var shouldEmitDotDot = token.kind !== 28 /* QuestionDotToken */ && + mayNeedDotDotForPropertyAccess(expression) && + !writer.hasTrailingComment() && + !writer.hasTrailingWhitespace(); if (shouldEmitDotDot) { writePunctuation("."); } - emitTokenWithComment(24 /* DotToken */, node.expression.end, writePunctuation, node); + emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node); increaseIndentIf(indentAfterDot, /*writeSpaceIfNotIndenting*/ false); emit(node.name); decreaseIndentIf(indentBeforeDot, indentAfterDot); } // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal - function needsDotDotForPropertyAccess(expression, dotHasTrivia) { + function mayNeedDotDotForPropertyAccess(expression) { expression = ts.skipPartiallyEmittedExpressions(expression); if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression, /*neverAsciiEscape*/ true); // If he number will be printed verbatim and it doesn't already contain a dot, add one // if the expression doesn't have any comments that will be emitted. - return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)) && - (!dotHasTrivia || printerOptions.removeComments); + return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24 /* DotToken */)); } - else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { + else if (ts.isAccessExpression(expression)) { // check if constant enum value is integer var constantValue = ts.getConstantValue(expression); // isFinite handles cases when constantValue is undefined return typeof constantValue === "number" && isFinite(constantValue) - && Math.floor(constantValue) === constantValue - && printerOptions.removeComments; + && Math.floor(constantValue) === constantValue; } } function emitElementAccessExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTokenWithComment(22 /* OpenBracketToken */, node.expression.end, writePunctuation, node); emitExpression(node.argumentExpression); emitTokenWithComment(23 /* CloseBracketToken */, node.argumentExpression.end, writePunctuation, node); } function emitCallExpression(node) { emitExpression(node.expression); + emit(node.questionDotToken); emitTypeArguments(node, node.typeArguments); emitExpressionList(node, node.arguments, 2576 /* CallExpressionArguments */); } function emitNewExpression(node) { - emitTokenWithComment(96 /* NewKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(98 /* NewKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTypeArguments(node, node.typeArguments); @@ -88061,22 +91394,22 @@ var ts; emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { - emitTokenWithComment(82 /* DeleteKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(84 /* DeleteKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitTypeOfExpression(node) { - emitTokenWithComment(105 /* TypeOfKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(107 /* TypeOfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitVoidExpression(node) { - emitTokenWithComment(107 /* VoidKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(109 /* VoidKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } function emitAwaitExpression(node) { - emitTokenWithComment(123 /* AwaitKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(126 /* AwaitKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); } @@ -88101,9 +91434,9 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 203 /* PrefixUnaryExpression */ - && ((node.operator === 38 /* PlusToken */ && (operand.operator === 38 /* PlusToken */ || operand.operator === 44 /* PlusPlusToken */)) - || (node.operator === 39 /* MinusToken */ && (operand.operator === 39 /* MinusToken */ || operand.operator === 45 /* MinusMinusToken */))); + return operand.kind === 206 /* PrefixUnaryExpression */ + && ((node.operator === 39 /* PlusToken */ && (operand.operator === 39 /* PlusToken */ || operand.operator === 45 /* PlusPlusToken */)) + || (node.operator === 40 /* MinusToken */ && (operand.operator === 40 /* MinusToken */ || operand.operator === 46 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); @@ -88116,7 +91449,7 @@ var ts; emitExpression(node.left); increaseIndentIf(indentBeforeOperator, isCommaOperator); emitLeadingCommentsOfPosition(node.operatorToken.pos); - writeTokenNode(node.operatorToken, node.operatorToken.kind === 94 /* InKeyword */ ? writeKeyword : writeOperator); + writeTokenNode(node.operatorToken, node.operatorToken.kind === 96 /* InKeyword */ ? writeKeyword : writeOperator); emitTrailingCommentsOfPosition(node.operatorToken.end, /*prefixSpace*/ true); // Binary operators should have a space before the comment starts increaseIndentIf(indentAfterOperator, /*writeSpaceIfNotIndenting*/ true); emitExpression(node.right); @@ -88144,7 +91477,7 @@ var ts; emitList(node, node.templateSpans, 262144 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - emitTokenWithComment(118 /* YieldKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(120 /* YieldKeyword */, node.pos, writeKeyword, node); emit(node.asteriskToken); emitExpressionWithLeadingSpace(node.expression); } @@ -88221,7 +91554,7 @@ var ts; } } function emitIfStatement(node) { - var openParenPos = emitTokenWithComment(92 /* IfKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(94 /* IfKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88229,8 +91562,8 @@ var ts; emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - emitTokenWithComment(84 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); - if (node.elseStatement.kind === 223 /* IfStatement */) { + emitTokenWithComment(86 /* ElseKeyword */, node.thenStatement.end, writeKeyword, node); + if (node.elseStatement.kind === 226 /* IfStatement */) { writeSpace(); emit(node.elseStatement); } @@ -88240,14 +91573,14 @@ var ts; } } function emitWhileClause(node, startPos) { - var openParenPos = emitTokenWithComment(108 /* WhileKeyword */, startPos, writeKeyword, node); + var openParenPos = emitTokenWithComment(110 /* WhileKeyword */, startPos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); } function emitDoStatement(node) { - emitTokenWithComment(83 /* DoKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(85 /* DoKeyword */, node.pos, writeKeyword, node); emitEmbeddedStatement(node, node.statement); if (ts.isBlock(node.statement)) { writeSpace(); @@ -88256,14 +91589,14 @@ var ts; writeLineOrSpace(node); } emitWhileClause(node, node.statement.end); - writePunctuation(";"); + writeTrailingSemicolon(); } function emitWhileStatement(node) { emitWhileClause(node, node.pos); emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); var pos = emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, /*contextNode*/ node); emitForBinding(node.initializer); @@ -88275,25 +91608,25 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(94 /* InKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(96 /* InKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = emitTokenWithComment(90 /* ForKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(92 /* ForKeyword */, node.pos, writeKeyword, node); writeSpace(); emitWithTrailingSpace(node.awaitModifier); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitForBinding(node.initializer); writeSpace(); - emitTokenWithComment(148 /* OfKeyword */, node.initializer.end, writeKeyword, node); + emitTokenWithComment(151 /* OfKeyword */, node.initializer.end, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitTokenWithComment(21 /* CloseParenToken */, node.expression.end, writePunctuation, node); @@ -88301,7 +91634,7 @@ var ts; } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { emit(node); } else { @@ -88310,12 +91643,12 @@ var ts; } } function emitContinueStatement(node) { - emitTokenWithComment(79 /* ContinueKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(81 /* ContinueKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } function emitBreakStatement(node) { - emitTokenWithComment(74 /* BreakKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(76 /* BreakKeyword */, node.pos, writeKeyword, node); emitWithLeadingSpace(node.label); writeTrailingSemicolon(); } @@ -88343,12 +91676,12 @@ var ts; return pos; } function emitReturnStatement(node) { - emitTokenWithComment(98 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); + emitTokenWithComment(100 /* ReturnKeyword */, node.pos, writeKeyword, /*contextNode*/ node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitWithStatement(node) { - var openParenPos = emitTokenWithComment(109 /* WithKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(111 /* WithKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88356,7 +91689,7 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = emitTokenWithComment(100 /* SwitchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(102 /* SwitchKeyword */, node.pos, writeKeyword, node); writeSpace(); emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); emitExpression(node.expression); @@ -88366,17 +91699,17 @@ var ts; } function emitLabeledStatement(node) { emit(node.label); - emitTokenWithComment(57 /* ColonToken */, node.label.end, writePunctuation, node); + emitTokenWithComment(58 /* ColonToken */, node.label.end, writePunctuation, node); writeSpace(); emit(node.statement); } function emitThrowStatement(node) { - emitTokenWithComment(102 /* ThrowKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(104 /* ThrowKeyword */, node.pos, writeKeyword, node); emitExpressionWithLeadingSpace(node.expression); writeTrailingSemicolon(); } function emitTryStatement(node) { - emitTokenWithComment(104 /* TryKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(106 /* TryKeyword */, node.pos, writeKeyword, node); writeSpace(); emit(node.tryBlock); if (node.catchClause) { @@ -88385,13 +91718,13 @@ var ts; } if (node.finallyBlock) { writeLineOrSpace(node); - emitTokenWithComment(89 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); + emitTokenWithComment(91 /* FinallyKeyword */, (node.catchClause || node.tryBlock).end, writeKeyword, node); writeSpace(); emit(node.finallyBlock); } } function emitDebuggerStatement(node) { - writeToken(80 /* DebuggerKeyword */, node.pos, writeKeyword); + writeToken(82 /* DebuggerKeyword */, node.pos, writeKeyword); writeTrailingSemicolon(); } // @@ -88416,7 +91749,7 @@ var ts; writeKeyword("function"); emit(node.asteriskToken); writeSpace(); - emitIdentifierName(node.name); // TODO: GH#18217 + emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } function emitBlockCallback(_hint, body) { @@ -88588,7 +91921,7 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - if (~node.flags & 512 /* GlobalAugmentation */) { + if (~node.flags & 1024 /* GlobalAugmentation */) { writeKeyword(node.flags & 16 /* Namespace */ ? "namespace" : "module"); writeSpace(); } @@ -88596,7 +91929,7 @@ var ts; var body = node.body; if (!body) return writeTrailingSemicolon(); - while (body.kind === 245 /* ModuleDeclaration */) { + while (body.kind === 248 /* ModuleDeclaration */) { writePunctuation("."); emit(body.name); body = body.body; @@ -88617,17 +91950,17 @@ var ts; } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); emit(node.name); writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, node.name.end, writePunctuation, node); + emitTokenWithComment(62 /* EqualsToken */, node.name.end, writePunctuation, node); writeSpace(); emitModuleReference(node.moduleReference); writeTrailingSemicolon(); } function emitModuleReference(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88636,12 +91969,12 @@ var ts; } function emitImportDeclaration(node) { emitModifiers(node, node.modifiers); - emitTokenWithComment(93 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); + emitTokenWithComment(95 /* ImportKeyword */, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node); writeSpace(); if (node.importClause) { emit(node.importClause); writeSpace(); - emitTokenWithComment(145 /* FromKeyword */, node.importClause.end, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, node.importClause.end, writeKeyword, node); writeSpace(); } emitExpression(node.moduleSpecifier); @@ -88656,9 +91989,9 @@ var ts; emit(node.namedBindings); } function emitNamespaceImport(node) { - var asPos = emitTokenWithComment(40 /* AsteriskToken */, node.pos, writePunctuation, node); + var asPos = emitTokenWithComment(41 /* AsteriskToken */, node.pos, writePunctuation, node); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, asPos, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, asPos, writeKeyword, node); writeSpace(); emit(node.name); } @@ -88669,42 +92002,42 @@ var ts; emitImportOrExportSpecifier(node); } function emitExportAssignment(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.isExportEquals) { - emitTokenWithComment(60 /* EqualsToken */, nextPos, writeOperator, node); + emitTokenWithComment(62 /* EqualsToken */, nextPos, writeOperator, node); } else { - emitTokenWithComment(81 /* DefaultKeyword */, nextPos, writeKeyword, node); + emitTokenWithComment(83 /* DefaultKeyword */, nextPos, writeKeyword, node); } writeSpace(); emitExpression(node.expression); writeTrailingSemicolon(); } function emitExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.exportClause) { emit(node.exportClause); } else { - nextPos = emitTokenWithComment(40 /* AsteriskToken */, nextPos, writePunctuation, node); + nextPos = emitTokenWithComment(41 /* AsteriskToken */, nextPos, writePunctuation, node); } if (node.moduleSpecifier) { writeSpace(); var fromPos = node.exportClause ? node.exportClause.end : nextPos; - emitTokenWithComment(145 /* FromKeyword */, fromPos, writeKeyword, node); + emitTokenWithComment(148 /* FromKeyword */, fromPos, writeKeyword, node); writeSpace(); emitExpression(node.moduleSpecifier); } writeTrailingSemicolon(); } function emitNamespaceExportDeclaration(node) { - var nextPos = emitTokenWithComment(86 /* ExportKeyword */, node.pos, writeKeyword, node); + var nextPos = emitTokenWithComment(88 /* ExportKeyword */, node.pos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(120 /* AsKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(122 /* AsKeyword */, nextPos, writeKeyword, node); writeSpace(); - nextPos = emitTokenWithComment(132 /* NamespaceKeyword */, nextPos, writeKeyword, node); + nextPos = emitTokenWithComment(135 /* NamespaceKeyword */, nextPos, writeKeyword, node); writeSpace(); emit(node.name); writeTrailingSemicolon(); @@ -88724,7 +92057,7 @@ var ts; if (node.propertyName) { emit(node.propertyName); writeSpace(); - emitTokenWithComment(120 /* AsKeyword */, node.propertyName.end, writeKeyword, node); + emitTokenWithComment(122 /* AsKeyword */, node.propertyName.end, writeKeyword, node); writeSpace(); } emit(node.name); @@ -88802,7 +92135,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 73 /* Identifier */) { + if (node.kind === 75 /* Identifier */) { emitExpression(node); } else { @@ -88813,13 +92146,13 @@ var ts; // Clauses // function emitCaseClause(node) { - emitTokenWithComment(75 /* CaseKeyword */, node.pos, writeKeyword, node); + emitTokenWithComment(77 /* CaseKeyword */, node.pos, writeKeyword, node); writeSpace(); emitExpression(node.expression); emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end); } function emitDefaultClause(node) { - var pos = emitTokenWithComment(81 /* DefaultKeyword */, node.pos, writeKeyword, node); + var pos = emitTokenWithComment(83 /* DefaultKeyword */, node.pos, writeKeyword, node); emitCaseOrDefaultClauseRest(node, node.statements, pos); } function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) { @@ -88831,12 +92164,12 @@ var ts; ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile)); var format = 163969 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { - writeToken(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + writeToken(58 /* ColonToken */, colonPos, writePunctuation, parentNode); writeSpace(); format &= ~(1 /* MultiLine */ | 128 /* Indented */); } else { - emitTokenWithComment(57 /* ColonToken */, colonPos, writePunctuation, parentNode); + emitTokenWithComment(58 /* ColonToken */, colonPos, writePunctuation, parentNode); } emitList(parentNode, statements, format); } @@ -88847,7 +92180,7 @@ var ts; emitList(node, node.types, 528 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = emitTokenWithComment(76 /* CatchKeyword */, node.pos, writeKeyword, node); + var openParenPos = emitTokenWithComment(78 /* CatchKeyword */, node.pos, writeKeyword, node); writeSpace(); if (node.variableDeclaration) { emitTokenWithComment(20 /* OpenParenToken */, openParenPos, writePunctuation, node); @@ -88917,7 +92250,7 @@ var ts; } } if (node.tags) { - if (node.tags.length === 1 && node.tags[0].kind === 310 /* JSDocTypeTag */ && !node.comment) { + if (node.tags.length === 1 && node.tags[0].kind === 313 /* JSDocTypeTag */ && !node.comment) { writeSpace(); emit(node.tags[0]); } @@ -88951,7 +92284,7 @@ var ts; function emitJSDocTypedefTag(tag) { emitJSDocTagName(tag.tagName); if (tag.typeExpression) { - if (tag.typeExpression.kind === 289 /* JSDocTypeExpression */) { + if (tag.typeExpression.kind === 292 /* JSDocTypeExpression */) { emitJSDocTypeExpression(tag.typeExpression); } else { @@ -88970,7 +92303,7 @@ var ts; emit(tag.fullName); } emitJSDocComment(tag.comment); - if (tag.typeExpression && tag.typeExpression.kind === 299 /* JSDocTypeLiteral */) { + if (tag.typeExpression && tag.typeExpression.kind === 302 /* JSDocTypeLiteral */) { emitJSDocTypeLiteral(tag.typeExpression); } } @@ -89104,8 +92437,8 @@ var ts; bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference" /* Reference */, data: directive.fileName }); writeLine(); } - for (var _d = 0, types_18 = types; _d < types_18.length; _d++) { - var directive = types_18[_d]; + for (var _d = 0, types_21 = types; _d < types_21.length; _d++) { + var directive = types_21[_d]; var pos = writer.getTextPos(); writeComment("/// "); if (bundleFileInfo) @@ -89285,7 +92618,7 @@ var ts; function emitInitializer(node, equalCommentStartPos, container) { if (node) { writeSpace(); - emitTokenWithComment(60 /* EqualsToken */, equalCommentStartPos, writeOperator, container); + emitTokenWithComment(62 /* EqualsToken */, equalCommentStartPos, writeOperator, container); writeSpace(); emitExpression(node); } @@ -89323,8 +92656,7 @@ var ts; writeLine(); increaseIndent(); if (ts.isEmptyStatement(node)) { - var pipelinePhase = getPipelinePhase(0 /* Notification */, node); - pipelinePhase(5 /* EmbeddedStatement */, node); + pipelineEmit(5 /* EmbeddedStatement */, node); } else { emit(node); @@ -89731,6 +93063,9 @@ var ts; return (format & 65536 /* PreferNewLine */) !== 0; } function needsIndentation(parent, node1, node2) { + if (ts.getEmitFlags(parent) & 131072 /* NoIndentation */) { + return false; + } parent = skipSynthesizedParentheses(parent); node1 = skipSynthesizedParentheses(node1); node2 = skipSynthesizedParentheses(node2); @@ -89748,7 +93083,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 196 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 199 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -89813,81 +93148,81 @@ var ts; if (!node) return; switch (node.kind) { - case 219 /* Block */: + case 222 /* Block */: ts.forEach(node.statements, generateNames); break; - case 234 /* LabeledStatement */: - case 232 /* WithStatement */: - case 224 /* DoStatement */: - case 225 /* WhileStatement */: + case 237 /* LabeledStatement */: + case 235 /* WithStatement */: + case 227 /* DoStatement */: + case 228 /* WhileStatement */: generateNames(node.statement); break; - case 223 /* IfStatement */: + case 226 /* IfStatement */: generateNames(node.thenStatement); generateNames(node.elseStatement); break; - case 226 /* ForStatement */: - case 228 /* ForOfStatement */: - case 227 /* ForInStatement */: + case 229 /* ForStatement */: + case 231 /* ForOfStatement */: + case 230 /* ForInStatement */: generateNames(node.initializer); generateNames(node.statement); break; - case 233 /* SwitchStatement */: + case 236 /* SwitchStatement */: generateNames(node.caseBlock); break; - case 247 /* CaseBlock */: + case 250 /* CaseBlock */: ts.forEach(node.clauses, generateNames); break; - case 272 /* CaseClause */: - case 273 /* DefaultClause */: + case 275 /* CaseClause */: + case 276 /* DefaultClause */: ts.forEach(node.statements, generateNames); break; - case 236 /* TryStatement */: + case 239 /* TryStatement */: generateNames(node.tryBlock); generateNames(node.catchClause); generateNames(node.finallyBlock); break; - case 275 /* CatchClause */: + case 278 /* CatchClause */: generateNames(node.variableDeclaration); generateNames(node.block); break; - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: generateNames(node.declarationList); break; - case 239 /* VariableDeclarationList */: + case 242 /* VariableDeclarationList */: ts.forEach(node.declarations, generateNames); break; - case 238 /* VariableDeclaration */: - case 152 /* Parameter */: - case 187 /* BindingElement */: - case 241 /* ClassDeclaration */: + case 241 /* VariableDeclaration */: + case 155 /* Parameter */: + case 190 /* BindingElement */: + case 244 /* ClassDeclaration */: generateNameIfNeeded(node.name); break; - case 240 /* FunctionDeclaration */: + case 243 /* FunctionDeclaration */: generateNameIfNeeded(node.name); if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { ts.forEach(node.parameters, generateNames); generateNames(node.body); } break; - case 185 /* ObjectBindingPattern */: - case 186 /* ArrayBindingPattern */: + case 188 /* ObjectBindingPattern */: + case 189 /* ArrayBindingPattern */: ts.forEach(node.elements, generateNames); break; - case 250 /* ImportDeclaration */: + case 253 /* ImportDeclaration */: generateNames(node.importClause); break; - case 251 /* ImportClause */: + case 254 /* ImportClause */: generateNameIfNeeded(node.name); generateNames(node.namedBindings); break; - case 252 /* NamespaceImport */: + case 255 /* NamespaceImport */: generateNameIfNeeded(node.name); break; - case 253 /* NamedImports */: + case 256 /* NamedImports */: ts.forEach(node.elements, generateNames); break; - case 254 /* ImportSpecifier */: + case 257 /* ImportSpecifier */: generateNameIfNeeded(node.propertyName || node.name); break; } @@ -89896,12 +93231,12 @@ var ts; if (!node) return; switch (node.kind) { - case 276 /* PropertyAssignment */: - case 277 /* ShorthandPropertyAssignment */: - case 155 /* PropertyDeclaration */: - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 279 /* PropertyAssignment */: + case 280 /* ShorthandPropertyAssignment */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: generateNameIfNeeded(node.name); break; } @@ -90081,25 +93416,25 @@ var ts; */ function generateNameForNode(node, flags) { switch (node.kind) { - case 73 /* Identifier */: + case 75 /* Identifier */: return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16 /* Optimistic */), !!(flags & 8 /* ReservedInNestedScopes */)); - case 245 /* ModuleDeclaration */: - case 244 /* EnumDeclaration */: + case 248 /* ModuleDeclaration */: + case 247 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 250 /* ImportDeclaration */: - case 256 /* ExportDeclaration */: + case 253 /* ImportDeclaration */: + case 259 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 240 /* FunctionDeclaration */: - case 241 /* ClassDeclaration */: - case 255 /* ExportAssignment */: + case 243 /* FunctionDeclaration */: + case 244 /* ClassDeclaration */: + case 258 /* ExportAssignment */: return generateNameForExportDefault(); - case 210 /* ClassExpression */: + case 213 /* ClassExpression */: return generateNameForClassExpression(); - case 157 /* MethodDeclaration */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: + case 160 /* MethodDeclaration */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: return generateNameForMethodOrAccessor(node); - case 150 /* ComputedPropertyName */: + case 153 /* ComputedPropertyName */: return makeTempVariableName(0 /* Auto */, /*reserveInNestedScopes*/ true); default: return makeTempVariableName(0 /* Auto */); @@ -90142,11 +93477,12 @@ var ts; } // Comments function pipelineEmitWithComments(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); enterComment(); hasWrittenComment = false; var emitFlags = ts.getEmitFlags(node); var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var isEmittedNode = node.kind !== 315 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 318 /* NotEmittedStatement */; // We have to explicitly check that the node is JsxText because if the compilerOptions.jsx is "preserve" we will not do any transformation. // It is expensive to walk entire tree just to set one kind of node to have no comments. var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0 || node.kind === 11 /* JsxText */; @@ -90170,7 +93506,7 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 239 /* VariableDeclarationList */) { + if (node.kind === 242 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } @@ -90200,6 +93536,7 @@ var ts; } } exitComment(); + ts.Debug.assert(lastNode === node || lastSubstitution === node); } function emitLeadingSynthesizedComment(comment) { if (comment.kind === 2 /* SingleLineCommentTrivia */) { @@ -90413,6 +93750,7 @@ var ts; return node.parsedSourceMap || undefined; } function pipelineEmitWithSourceMap(hint, node) { + ts.Debug.assert(lastNode === node || lastSubstitution === node); var pipelinePhase = getNextPipelinePhase(3 /* SourceMaps */, node); if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) { pipelinePhase(hint, node); @@ -90427,7 +93765,7 @@ var ts; else { var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b; var emitFlags = ts.getEmitFlags(node); - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitSourcePos(source, skipSourceTrivia(source, pos)); @@ -90440,12 +93778,13 @@ var ts; else { pipelinePhase(hint, node); } - if (node.kind !== 315 /* NotEmittedStatement */ + if (node.kind !== 318 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitSourcePos(source, end); } } + ts.Debug.assert(lastNode === node || lastSubstitution === node); } /** * Skips trivia such as comments and white-space that can be optionally overridden by the source-map source @@ -91369,6 +94708,8 @@ var ts; return resolutions; } ts.loadWithLocalCache = loadWithLocalCache; + /* @internal */ + ts.inferredTypesContainingFile = "__inferred type names__.ts"; /** * Determines if program structure is upto date or needs to be recreated */ @@ -91473,15 +94814,17 @@ var ts; var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions; // TODO: GH#18217 var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences; var oldProgram = createProgramOptions.oldProgram; - var program; var processingDefaultLibFiles; var processingOtherFiles; var files; + var symlinks; var commonSourceDirectory; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; var ambientModuleNameToUnmodifiedFileName = ts.createMap(); + // Todo:: Use this to report why file was included in --extendedDiagnostics + var refFileMap; var cachedSemanticDiagnosticsForFile = {}; var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); @@ -91563,11 +94906,13 @@ var ts; var resolvedProjectReferences; var projectReferenceRedirects; var mapFromFileToProjectReferenceRedirects; + var mapFromToProjectReferenceRedirectSource; + var useSourceOfProjectReferenceRedirect = !!host.useSourceOfProjectReferenceRedirect && host.useSourceOfProjectReferenceRedirect(); var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options); // We set `structuralIsReused` to `undefined` because `tryReuseStructureFromOldProgram` calls `tryReuseStructureFromOldProgram` which checks // `structuralIsReused`, which would be a TDZ violation if it was not set in advance to `undefined`. var structuralIsReused; - structuralIsReused = tryReuseStructureFromOldProgram(); + structuralIsReused = tryReuseStructureFromOldProgram(); // eslint-disable-line prefer-const if (structuralIsReused !== 2 /* Completely */) { processingDefaultLibFiles = []; processingOtherFiles = []; @@ -91575,20 +94920,36 @@ var ts; if (!resolvedProjectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); } + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } if (rootNames.length) { for (var _i = 0, resolvedProjectReferences_1 = resolvedProjectReferences; _i < resolvedProjectReferences_1.length; _i++) { var parsedRef = resolvedProjectReferences_1[_i]; if (!parsedRef) continue; var out = parsedRef.commandLine.options.outFile || parsedRef.commandLine.options.out; - if (out) { - processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + if (useSourceOfProjectReferenceRedirect) { + if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { + var fileName = _b[_a]; + processSourceFile(fileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + } } - else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { - for (var _a = 0, _b = parsedRef.commandLine.fileNames; _a < _b.length; _a++) { - var fileName = _b[_a]; - if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) && ts.hasTSFileExtension(fileName)) { - processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + else { + if (out) { + processSourceFile(ts.changeExtension(out, ".d.ts"), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } + else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) { + for (var _c = 0, _d = parsedRef.commandLine.fileNames; _c < _d.length; _c++) { + var fileName = _d[_c]; + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + processSourceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames()), /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined); + } } } } @@ -91601,7 +94962,7 @@ var ts; if (typeReferences.length) { // This containingFilename needs to match with the one used in managed-side var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(); - var containingFilename = ts.combinePaths(containingDirectory, "__inferred type names__.ts"); + var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile); var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (var i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); @@ -91637,8 +94998,8 @@ var ts; // not part of the new program. if (oldProgram && host.onReleaseOldSourceFile) { var oldSourceFiles = oldProgram.getSourceFiles(); - for (var _c = 0, oldSourceFiles_1 = oldSourceFiles; _c < oldSourceFiles_1.length; _c++) { - var oldSourceFile = oldSourceFiles_1[_c]; + for (var _e = 0, oldSourceFiles_1 = oldSourceFiles; _e < oldSourceFiles_1.length; _e++) { + var oldSourceFile = oldSourceFiles_1[_e]; var newFile = getSourceFileByPath(oldSourceFile.resolvedPath); if (shouldCreateNewSourceFile || !newFile || // old file wasnt redirect but new file is @@ -91654,12 +95015,13 @@ var ts; } // unconditionally set oldProgram to undefined to prevent it from being captured in closure oldProgram = undefined; - program = { + var program = { getRootFileNames: function () { return rootNames; }, getSourceFile: getSourceFile, getSourceFileByPath: getSourceFileByPath, getSourceFiles: function () { return files; }, getMissingFilePaths: function () { return missingFilePaths; }, + getRefFileMap: function () { return refFileMap; }, getCompilerOptions: function () { return options; }, getSyntacticDiagnostics: getSyntacticDiagnostics, getOptionsDiagnostics: getOptionsDiagnostics, @@ -91696,7 +95058,9 @@ var ts; getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath, forEachResolvedProjectReference: forEachResolvedProjectReference, - emitBuildInfo: emitBuildInfo + isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect, + emitBuildInfo: emitBuildInfo, + getProbableSymlinks: getProbableSymlinks }; verifyCompilerOptions(); ts.performance.mark("afterProgram"); @@ -91723,9 +95087,14 @@ var ts; function toPath(fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); } + function isValidSourceFileForEmit(file) { + // source file is allowed to be emitted and its not source of project reference redirect + return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect) && + !isSourceOfProjectReferenceRedirect(file.fileName); + } function getCommonSourceDirectory() { if (commonSourceDirectory === undefined) { - var emittedFiles = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect); }); + var emittedFiles = ts.filter(files, function (file) { return isValidSourceFileForEmit(file); }); if (options.rootDir && checkSourceFilesBelongToPath(emittedFiles, options.rootDir)) { // If a rootDir is specified use it as the commonSourceDirectory commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory); @@ -91929,6 +95298,12 @@ var ts; } if (projectReferences) { resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile); + if (host.setResolvedProjectReferenceCallbacks) { + host.setResolvedProjectReferenceCallbacks({ + getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect, + forEachResolvedProjectReference: forEachResolvedProjectReference + }); + } } // check if program source files has changed in the way that can affect structure of the program var newSourceFiles = []; @@ -92019,7 +95394,7 @@ var ts; // moduleAugmentations has changed oldProgram.structureIsReused = 1 /* SafeModules */; } - if ((oldSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 1572864 /* PermanentlySetIncrementalFlags */)) { + if ((oldSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */) !== (newSourceFile.flags & 3145728 /* PermanentlySetIncrementalFlags */)) { // dynamicImport has changed oldProgram.structureIsReused = 1 /* SafeModules */; } @@ -92056,28 +95431,26 @@ var ts; for (var _d = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _d < modifiedSourceFiles_1.length; _d++) { var _e = modifiedSourceFiles_1[_d], oldSourceFile = _e.oldFile, newSourceFile = _e.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.originalFileName, currentDirectory); - if (resolveModuleNamesWorker) { - var moduleNames = getModuleNames(newSourceFile); - var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); - // ensure that module resolution results are still correct - var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); - if (resolutionsChanged) { - oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); - } - else { - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - } + var moduleNames = getModuleNames(newSourceFile); + var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile); + // ensure that module resolution results are still correct + var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); + if (resolutionsChanged) { + oldProgram.structureIsReused = 1 /* SafeModules */; + newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } if (resolveTypeReferenceDirectiveNamesWorker) { // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ref.fileName.toLocaleLowerCase(); }); - var resolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); + var resolutions_1 = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFilePath, getResolvedProjectReferenceToRedirect(newSourceFile.originalFileName)); // ensure that types resolutions are still correct - var resolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); - if (resolutionsChanged) { + var resolutionsChanged_1 = ts.hasChangesInResolutions(typesReferenceDirectives, resolutions_1, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo); + if (resolutionsChanged_1) { oldProgram.structureIsReused = 1 /* SafeModules */; - newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions); + newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, resolutions_1); } else { newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; @@ -92091,11 +95464,19 @@ var ts; return oldProgram.structureIsReused = 1 /* SafeModules */; } missingFilePaths = oldProgram.getMissingFilePaths(); + refFileMap = oldProgram.getRefFileMap(); // update fileName -> file mapping for (var _f = 0, newSourceFiles_1 = newSourceFiles; _f < newSourceFiles_1.length; _f++) { var newSourceFile = newSourceFiles_1[_f]; var filePath = newSourceFile.path; addFileToFilesByName(newSourceFile, filePath, newSourceFile.resolvedPath); + if (useSourceOfProjectReferenceRedirect) { + var redirectProject = getProjectReferenceRedirectProject(newSourceFile.fileName); + if (redirectProject && !(redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out)) { + var redirect = getProjectReferenceOutputName(redirectProject, newSourceFile.fileName); + addFileToFilesByName(newSourceFile, toPath(redirect), /*redirectedPath*/ undefined); + } + } // Set the file as found during node modules search if it was found that way in old progra, if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(newSourceFile.resolvedPath))) { sourceFilesFoundSearchingNodeModules.set(filePath, true); @@ -92115,7 +95496,8 @@ var ts; function getEmitHost(writeFileCallback) { return __assign(__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, getLibFileFromReference: program.getLibFileFromReference, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, - getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, 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) { + getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect, + getProbableSymlinks: getProbableSymlinks, 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)) @@ -92180,15 +95562,15 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.has(toPath(emitFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) { var declarationDiagnostics = []; - if (!emitOnlyDtsFiles) { + if (!forceDtsEmit) { if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; } @@ -92220,7 +95602,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile, cancellationToken); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, + /*onlyBuildInfo*/ false, forceDtsEmit); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -92295,15 +95678,16 @@ var ts; } function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { - if (ts.skipTypeChecking(sourceFile, options)) { + if (ts.skipTypeChecking(sourceFile, options, program)) { return ts.emptyArray; } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options); + var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false; // By default, only type-check .ts, .tsx, 'Deferred' and 'External' files (external files are added by plugins) - var includeBindAndCheckDiagnostics = sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || - sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */; + var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 /* TS */ || sourceFile.scriptKind === 4 /* TSX */ || + sourceFile.scriptKind === 5 /* External */ || isCheckJs || sourceFile.scriptKind === 7 /* Deferred */); var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray; var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); @@ -92362,22 +95746,22 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 152 /* Parameter */: - case 155 /* PropertyDeclaration */: + case 155 /* Parameter */: + case 158 /* PropertyDeclaration */: + case 160 /* MethodDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } // falls through - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: - case 238 /* VariableDeclaration */: + case 159 /* MethodSignature */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: + case 241 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -92385,41 +95769,41 @@ var ts; } } switch (node.kind) { - case 249 /* ImportEqualsDeclaration */: + case 252 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 255 /* ExportAssignment */: + case 258 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 274 /* HeritageClause */: + case 277 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 110 /* ImplementsKeyword */) { + if (heritageClause.token === 112 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 242 /* InterfaceDeclaration */: + case 245 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 245 /* ModuleDeclaration */: + case 248 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 243 /* TypeAliasDeclaration */: + case 246 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 244 /* EnumDeclaration */: + case 247 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 214 /* NonNullExpression */: + case 217 /* NonNullExpression */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.non_null_assertions_can_only_be_used_in_a_ts_file)); return; - case 213 /* AsExpression */: + case 216 /* AsExpression */: diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; - case 195 /* TypeAssertionExpression */: + case 198 /* TypeAssertionExpression */: ts.Debug.fail(); // Won't parse these in a JS file anyway, as they are interpreted as JSX. } var prevParent = parent; @@ -92432,51 +95816,52 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } switch (parent.kind) { - case 241 /* ClassDeclaration */: - case 157 /* MethodDeclaration */: - case 156 /* MethodSignature */: - case 158 /* Constructor */: - case 159 /* GetAccessor */: - case 160 /* SetAccessor */: - case 197 /* FunctionExpression */: - case 240 /* FunctionDeclaration */: - case 198 /* ArrowFunction */: + case 244 /* ClassDeclaration */: + case 213 /* ClassExpression */: + case 160 /* MethodDeclaration */: + case 161 /* Constructor */: + case 162 /* GetAccessor */: + case 163 /* SetAccessor */: + case 200 /* FunctionExpression */: + case 243 /* FunctionDeclaration */: + case 201 /* ArrowFunction */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } // falls through - case 220 /* VariableStatement */: + case 224 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 220 /* VariableStatement */); + return checkModifiers(parent.modifiers, parent.kind === 224 /* VariableStatement */); } break; - case 155 /* PropertyDeclaration */: + case 158 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 117 /* StaticKeyword */) { + if (modifier.kind !== 119 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 152 /* Parameter */: + case 155 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 192 /* CallExpression */: - case 193 /* NewExpression */: - case 212 /* ExpressionWithTypeArguments */: - case 262 /* JsxSelfClosingElement */: - case 263 /* JsxOpeningElement */: + case 195 /* CallExpression */: + case 196 /* NewExpression */: + case 215 /* ExpressionWithTypeArguments */: + case 265 /* JsxSelfClosingElement */: + case 266 /* JsxOpeningElement */: + case 197 /* TaggedTemplateExpression */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -92493,24 +95878,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 78 /* ConstKeyword */: + case 80 /* ConstKeyword */: if (isConstValid) { continue; } // to report error, // falls through - case 116 /* PublicKeyword */: - case 114 /* PrivateKeyword */: - case 115 /* ProtectedKeyword */: - case 134 /* ReadonlyKeyword */: - case 126 /* DeclareKeyword */: - case 119 /* AbstractKeyword */: + case 118 /* PublicKeyword */: + case 116 /* PrivateKeyword */: + case 117 /* ProtectedKeyword */: + case 137 /* ReadonlyKeyword */: + case 129 /* DeclareKeyword */: + case 121 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 117 /* StaticKeyword */: - case 86 /* ExportKeyword */: - case 81 /* DefaultKeyword */: + case 119 /* StaticKeyword */: + case 88 /* ExportKeyword */: + case 83 /* DefaultKeyword */: } } } @@ -92585,8 +95970,8 @@ var ts; return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.kind === 73 /* Identifier */ - ? b.kind === 73 /* Identifier */ && a.escapedText === b.escapedText + return a.kind === 75 /* Identifier */ + ? b.kind === 75 /* Identifier */ && a.escapedText === b.escapedText : b.kind === 10 /* StringLiteral */ && a.text === b.text; } function collectExternalModuleReferences(file) { @@ -92616,7 +96001,7 @@ var ts; var node = _a[_i]; collectModuleReferences(node, /*inAmbientModule*/ false); } - if ((file.flags & 524288 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { + if ((file.flags & 1048576 /* PossiblyContainsDynamicImport */) || isJavaScriptFile) { collectDynamicImportOrRequireCalls(file); } file.imports = imports || ts.emptyArray; @@ -92667,7 +96052,7 @@ var ts; } function collectDynamicImportOrRequireCalls(file) { var r = /import|require/g; - while (r.exec(file.text) !== null) { + while (r.exec(file.text) !== null) { // eslint-disable-line no-null/no-null var node = getNodeAtPosition(file, r.lastIndex); if (ts.isRequireCall(node, /*checkArgumentIsStringLiteralLike*/ true)) { imports = ts.append(imports, node.arguments[0]); @@ -92748,24 +96133,18 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId); }, // TODO: GH#18217 + function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, refFile) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, refFile, packageId); }, // TODO: GH#18217 function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } - fileProcessingDiagnostics.add(refFile !== undefined && refEnd !== undefined && refPos !== undefined - ? ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, diagnostic], args)) : ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([diagnostic], args))); - }, refFile); + return fileProcessingDiagnostics.add(createRefFileDiagnostic.apply(void 0, __spreadArrays([refFile, diagnostic], args))); + }, refFile && refFile.file); } - function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile, refPos, refEnd) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); - } + function reportFileNamesDifferOnlyInCasingError(fileName, existingFileName, refFile) { + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, fileName, existingFileName)); } function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) { var redirect = Object.create(redirectTarget); @@ -92788,15 +96167,36 @@ var ts; return redirect; } // Get source file from normalized fileName - function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, refPos, refEnd, packageId) { + function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, refFile, packageId) { + if (useSourceOfProjectReferenceRedirect) { + var source = getSourceOfProjectReferenceRedirect(fileName); + if (!source && + host.realpath && + options.preserveSymlinks && + ts.isDeclarationFileName(fileName) && + ts.stringContains(fileName, ts.nodeModulesPathPart)) { + // use host's cached realpath + var realPath = host.realpath(fileName); + if (realPath !== fileName) + source = getSourceOfProjectReferenceRedirect(realPath); + } + if (source) { + var file_1 = ts.isString(source) ? + findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) : + undefined; + if (file_1) + addFileToFilesByName(file_1, path, /*redirectedPath*/ undefined); + return file_1; + } + } var originalFileName = fileName; if (filesByName.has(path)) { - var file_1 = filesByName.get(path); + var file_2 = filesByName.get(path); // try to check if we've already seen this file but with a different casing in path // NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected - if (file_1 && options.forceConsistentCasingInFileNames) { + if (file_2 && options.forceConsistentCasingInFileNames) { var inputName = fileName; - var checkedName = file_1.fileName; + var checkedName = file_2.fileName; var isRedirect = toPath(checkedName) !== toPath(inputName); if (isRedirect) { inputName = getProjectReferenceRedirect(fileName) || fileName; @@ -92805,34 +96205,35 @@ var ts; var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory); var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(inputName, currentDirectory); if (checkedAbsolutePath !== inputAbsolutePath) { - reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(inputName, checkedName, refFile); } } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { - sourceFilesFoundSearchingNodeModules.set(file_1.path, false); + if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) { + sourceFilesFoundSearchingNodeModules.set(file_2.path, false); if (!options.noResolve) { - processReferencedFiles(file_1, isDefaultLib); - processTypeReferenceDirectives(file_1); + processReferencedFiles(file_2, isDefaultLib); + processTypeReferenceDirectives(file_2); } if (!options.noLib) { - processLibReferenceDirectives(file_1); + processLibReferenceDirectives(file_2); } - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } // See if we need to reprocess the imports due to prior skipped imports - else if (file_1 && modulesWithElidedImports.get(file_1.path)) { + else if (file_2 && modulesWithElidedImports.get(file_2.path)) { if (currentNodeModulesDepth < maxNodeModuleJsDepth) { - modulesWithElidedImports.set(file_1.path, false); - processImportedModules(file_1); + modulesWithElidedImports.set(file_2.path, false); + processImportedModules(file_2); } } - return file_1 || undefined; + addFileToRefFileMap(file_2 || undefined, refFile); + return file_2 || undefined; } var redirectedPath; - if (refFile) { + if (refFile && !useSourceOfProjectReferenceRedirect) { var redirectProject = getProjectReferenceRedirectProject(fileName); if (redirectProject) { if (redirectProject.commandLine.options.outFile || redirectProject.commandLine.options.out) { @@ -92850,14 +96251,7 @@ var ts; } } // We haven't looked for this file, do so now and cache result - var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { - if (refFile !== undefined && refPos !== undefined && refEnd !== undefined) { - fileProcessingDiagnostics.add(ts.createFileDiagnostic(refFile, refPos, refEnd - refPos, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - else { - fileProcessingDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); - } - }, shouldCreateNewSourceFile); + var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, hostErrorMessage)); }, shouldCreateNewSourceFile); if (packageId) { var packageIdKey = ts.packageIdToString(packageId); var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); @@ -92888,7 +96282,7 @@ var ts; // for case-sensitive file systems check if we've already seen some file with similar filename ignoring case var existingFile = filesByNameIgnoreCase.get(pathLowerCase); if (existingFile) { - reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile, refPos, refEnd); + reportFileNamesDifferOnlyInCasingError(fileName, existingFile.fileName, refFile); } else { filesByNameIgnoreCase.set(pathLowerCase, file); @@ -92911,8 +96305,18 @@ var ts; processingOtherFiles.push(file); } } + addFileToRefFileMap(file, refFile); return file; } + function addFileToRefFileMap(file, refFile) { + if (refFile && file) { + (refFileMap || (refFileMap = ts.createMultiMap())).add(file.path, { + kind: refFile.kind, + index: refFile.index, + file: refFile.file.path + }); + } + } function addFileToFilesByName(file, path, redirectedPath) { if (redirectedPath) { filesByName.set(redirectedPath, file); @@ -92927,8 +96331,8 @@ var ts; return referencedProject && getProjectReferenceOutputName(referencedProject, fileName); } function getProjectReferenceRedirectProject(fileName) { - // Ignore dts or any of the non ts files - if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */) || !ts.fileExtensionIsOneOf(fileName, ts.supportedTSExtensions)) { + // Ignore dts + if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { return undefined; } // If this file is produced by a referenced project, we need to rewrite it to @@ -92967,6 +96371,35 @@ var ts; return cb(resolvedRef, resolvedRefPath); }); } + function getSourceOfProjectReferenceRedirect(file) { + if (!ts.isDeclarationFileName(file)) + return undefined; + if (mapFromToProjectReferenceRedirectSource === undefined) { + mapFromToProjectReferenceRedirectSource = ts.createMap(); + forEachResolvedProjectReference(function (resolvedRef) { + if (resolvedRef) { + var out = resolvedRef.commandLine.options.outFile || resolvedRef.commandLine.options.out; + if (out) { + // Dont know which source file it means so return true? + var outputDts = ts.changeExtension(out, ".d.ts" /* Dts */); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true); + } + else { + ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) { + if (!ts.fileExtensionIs(fileName, ".d.ts" /* Dts */)) { + var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, host.useCaseSensitiveFileNames()); + mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName); + } + }); + } + } + }); + } + return mapFromToProjectReferenceRedirectSource.get(toPath(file)); + } + function isSourceOfProjectReferenceRedirect(fileName) { + return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName); + } function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) { var seenResolvedRefs; return worker(projectReferences, resolvedProjectReferences, /*parent*/ undefined, cbResolvedRef, cbRef); @@ -93001,9 +96434,17 @@ var ts; return projectReferenceRedirects.get(projectReferencePath) || undefined; } function processReferencedFiles(file, isDefaultLib) { - ts.forEach(file.referencedFiles, function (ref) { + ts.forEach(file.referencedFiles, function (ref, index) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.originalFileName); - processSourceFile(referencedFileName, isDefaultLib, /*ignoreNoDefaultLib*/ false, /*packageId*/ undefined, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, + /*ignoreNoDefaultLib*/ false, + /*packageId*/ undefined, { + kind: ts.RefFileKind.ReferenceFile, + index: index, + file: file, + pos: ref.pos, + end: ref.end + }); }); } function processTypeReferenceDirectives(file) { @@ -93019,10 +96460,16 @@ var ts; // store resolved type directive on the file var fileName = ref.fileName.toLocaleLowerCase(); ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { + kind: ts.RefFileKind.TypeReferenceDirective, + index: i, + file: file, + pos: ref.pos, + end: ref.end + }); } } - function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile, refPos, refEnd) { + function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, refFile) { // If we already found this library as a primary reference - nothing to do var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective); if (previousResolution && previousResolution.primary) { @@ -93034,7 +96481,7 @@ var ts; currentNodeModulesDepth++; if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); // TODO: GH#18217 + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); // TODO: GH#18217 } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -93044,8 +96491,7 @@ var ts; if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) { var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, // TODO: GH#18217 - ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName)); } } // don't overwrite previous resolution result @@ -93053,14 +96499,14 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile); } } if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--; } else { - fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); // TODO: GH#18217 + fileProcessingDiagnostics.add(createRefFileDiagnostic(refFile, ts.Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective)); } if (saveResolution) { resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective); @@ -93078,20 +96524,20 @@ var ts; var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts"); var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity); var message = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0; - fileProcessingDiagnostics.add(createDiagnostic(file, libReference.pos, libReference.end, message, libName, suggestion)); + fileProcessingDiagnostics.add(ts.createFileDiagnostic(file, libReference.pos, libReference.end - libReference.pos, message, libName, suggestion)); } }); } - function createDiagnostic(refFile, refPos, refEnd, message) { + function createRefFileDiagnostic(refFile, message) { var args = []; - for (var _i = 4; _i < arguments.length; _i++) { - args[_i - 4] = arguments[_i]; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; } - if (refFile === undefined || refPos === undefined || refEnd === undefined) { + if (!refFile) { return ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args)); } else { - return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, refPos, refEnd - refPos, message], args)); + return ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile.file, refFile.pos, refFile.end - refFile.pos, message], args)); } } function getCanonicalFileName(fileName) { @@ -93131,14 +96577,22 @@ var ts; && i < file.imports.length && !elideImport && !(isJsFile && !options.allowJs) - && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 2097152 /* JSDoc */)); + && (ts.isInJSFile(file.imports[i]) || !(file.imports[i].flags & 4194304 /* JSDoc */)); if (elideImport) { modulesWithElidedImports.set(file.path, true); } else if (shouldAddFile) { var path = toPath(resolvedFileName); var pos = ts.skipTrivia(file.text, file.imports[i].pos); - findSourceFile(resolvedFileName, path, /*isDefaultLib*/ false, /*ignoreNoDefaultLib*/ false, file, pos, file.imports[i].end, resolution.packageId); + findSourceFile(resolvedFileName, path, + /*isDefaultLib*/ false, + /*ignoreNoDefaultLib*/ false, { + kind: ts.RefFileKind.Import, + index: i, + file: file, + pos: pos, + end: file.imports[i].end + }, resolution.packageId); } if (isFromNodeModulesSearch) { currentNodeModulesDepth--; @@ -93157,12 +96611,15 @@ var ts; function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) { var allFilesBelongToPath = true; var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); + var rootPaths; 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) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory)); + if (!rootPaths) + rootPaths = ts.arrayToSet(rootNames, toPath); + addProgramDiagnosticAtRefPath(sourceFile, rootPaths, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, rootDirectory); allFilesBelongToPath = false; } } @@ -93219,9 +96676,6 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks"); } if (options.isolatedModules) { - if (ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, getEmitDeclarationOptionName(options), "isolatedModules"); - } if (options.out) { createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules"); } @@ -93259,14 +96713,12 @@ var ts; verifyProjectReferences(); // List of collected files is complete; validate exhautiveness if this is a project with a file list if (options.composite) { - var rootPaths = rootNames.map(toPath); + var rootPaths = ts.arrayToSet(rootNames, toPath); for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { var file = files_3[_i]; // Ignore file that is not emitted - if (!ts.sourceFileMayBeEmitted(file, options, isSourceFileFromExternalLibrary, getResolvedProjectReferenceToRedirect)) - continue; - if (rootPaths.indexOf(file.path) === -1) { - programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || "")); + if (isValidSourceFileForEmit(file) && !rootPaths.has(file.path)) { + addProgramDiagnosticAtRefPath(file, rootPaths, ts.Diagnostics.File_0_is_not_listed_within_the_file_list_of_project_1_Projects_must_list_all_files_or_use_an_include_pattern, file.fileName, options.configFilePath || ""); } } } @@ -93382,8 +96834,8 @@ var ts; createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir"); } } - if (!options.noEmit && options.allowJs && ts.getEmitDeclarations(options)) { - createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", getEmitDeclarationOptionName(options)); + if (options.useDefineForClassFields && languageVersion === 0 /* ES3 */) { + createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields"); } if (options.checkJs && !options.allowJs) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); @@ -93448,8 +96900,41 @@ var ts; } } } + function addProgramDiagnosticAtRefPath(file, rootPaths, message) { + var _a, _b; + var args = []; + for (var _i = 3; _i < arguments.length; _i++) { + args[_i - 3] = arguments[_i]; + } + var refPaths = refFileMap && refFileMap.get(file.path); + var refPathToReportErrorOn = ts.forEach(refPaths, function (refPath) { return rootPaths.has(refPath.file) ? refPath : undefined; }) || + ts.elementAt(refPaths, 0); + if (refPathToReportErrorOn) { + var refFile = ts.Debug.assertDefined(getSourceFileByPath(refPathToReportErrorOn.file)); + var kind = refPathToReportErrorOn.kind, index = refPathToReportErrorOn.index; + var pos = void 0, end = void 0; + switch (kind) { + case ts.RefFileKind.Import: + pos = ts.skipTrivia(refFile.text, refFile.imports[index].pos); + end = refFile.imports[index].end; + break; + case ts.RefFileKind.ReferenceFile: + (_a = refFile.referencedFiles[index], pos = _a.pos, end = _a.end); + break; + case ts.RefFileKind.TypeReferenceDirective: + (_b = refFile.typeReferenceDirectives[index], pos = _b.pos, end = _b.end); + break; + default: + return ts.Debug.assertNever(kind); + } + programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArrays([refFile, pos, end - pos, message], args))); + } + else { + programDiagnostics.add(ts.createCompilerDiagnostic.apply(void 0, __spreadArrays([message], args))); + } + } function verifyProjectReferences() { - var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getOutputPathForBuildInfo(options) : undefined; + var buildInfoPath = !options.noEmit && !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined; forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, index, parent) { var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index]; var parentFile = parent && parent.sourceFile; @@ -93476,7 +96961,7 @@ var ts; createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path); } } - if (!parent && buildInfoPath && buildInfoPath === ts.getOutputPathForBuildInfo(options)) { + if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) { createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path); hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true); } @@ -93551,7 +97036,7 @@ var ts; } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = null; // tslint:disable-line:no-null-keyword + _compilerOptionsObjectLiteralSyntax = null; // eslint-disable-line no-null/no-null var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile); if (jsonObjectLiteral) { for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) { @@ -93610,6 +97095,12 @@ var ts; function isSameFile(file1, file2) { return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; } + function getProbableSymlinks() { + if (host.getSymlinks) { + return host.getSymlinks(); + } + return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory())); + } } ts.createProgram = createProgram; /* @internal */ @@ -93655,9 +97146,6 @@ var ts; return ts.resolveConfigFileProjectName(passedInRef.path); } ts.resolveProjectReferencePath = resolveProjectReferencePath; - function getEmitDeclarationOptionName(options) { - return options.declaration ? "declaration" : "composite"; - } /* @internal */ /** * Returns a DiagnosticMessage if we won't include a resolved module due to its extension. @@ -93707,9 +97195,9 @@ var ts; /*@internal*/ var ts; (function (ts) { - function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers) { + function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) { var outputFiles = []; - var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit); return { outputFiles: outputFiles, emitSkipped: emitResult.emitSkipped, exportedModulesFromDeclarationEmit: emitResult.exportedModulesFromDeclarationEmit }; function writeFile(fileName, text, writeByteOrderMark) { outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text }); @@ -93955,7 +97443,10 @@ var ts; } } else { - var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, /*emitOnlyDtsFiles*/ true, cancellationToken); + var emitOutput_1 = ts.getFileEmitOutput(programOfThisState, sourceFile, + /*emitOnlyDtsFiles*/ true, cancellationToken, + /*customTransformers*/ undefined, + /*forceDtsEmit*/ true); var firstDts_1 = emitOutput_1.outputFiles && programOfThisState.getCompilerOptions().declarationMap ? emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined : @@ -94067,6 +97558,7 @@ var ts; return referencesInFile.has(referencedFilePath) ? filePath : undefined; })); } + BuilderState.getReferencedByPaths = getReferencedByPaths; /** * For script files that contains only ambient external modules, although they are not actually external module files, * they can only be consumed via importing elements from them. Regular script files cannot consume them. Therefore, @@ -94170,6 +97662,11 @@ var ts; /*@internal*/ var ts; (function (ts) { + var BuilderFileEmit; + (function (BuilderFileEmit) { + BuilderFileEmit[BuilderFileEmit["DtsOnly"] = 0] = "DtsOnly"; + BuilderFileEmit[BuilderFileEmit["Full"] = 1] = "Full"; + })(BuilderFileEmit = ts.BuilderFileEmit || (ts.BuilderFileEmit = {})); function hasSameKeys(map1, map2) { // Has same size and every key is present in both maps return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); }); @@ -94183,8 +97680,7 @@ var ts; var compilerOptions = newProgram.getCompilerOptions(); state.compilerOptions = compilerOptions; // With --out or --outFile, any change affects all semantic diagnostics so no need to cache them - // With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors - if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) { + if (!compilerOptions.outFile && !compilerOptions.out) { state.semanticDiagnosticsPerFile = ts.createMap(); } state.changedFilesSet = ts.createMap(); @@ -94207,7 +97703,8 @@ var ts; ts.copyEntries(changedFilesSet, state.changedFilesSet); } if (!compilerOptions.outFile && !compilerOptions.out && oldState.affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit; + state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice(); + state.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(oldState.affectedFilesPendingEmitKind); state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex; } } @@ -94253,16 +97750,17 @@ var ts; }); if (oldCompilerOptions && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed - addToAffectedFilesPendingEmit(state, newProgram.getSourceFiles().map(function (f) { return f.path; })); + newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.path, 1 /* Full */); }); ts.Debug.assert(state.seenAffectedFiles === undefined); state.seenAffectedFiles = ts.createMap(); } + state.emittedBuildInfo = !state.changedFilesSet.size && !state.affectedFilesPendingEmit; return state; } function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) { if (!diagnostics.length) return ts.emptyArray; - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory())); return diagnostics.map(function (diagnostic) { var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath); result.reportsUnnecessary = diagnostic.reportsUnnecessary; @@ -94307,7 +97805,8 @@ var ts; newState.semanticDiagnosticsFromOldState = ts.cloneMapOrUndefined(state.semanticDiagnosticsFromOldState); newState.program = state.program; newState.compilerOptions = state.compilerOptions; - newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit; + newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice(); + newState.affectedFilesPendingEmitKind = ts.cloneMapOrUndefined(state.affectedFilesPendingEmitKind); newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex; newState.seenEmittedFiles = ts.cloneMapOrUndefined(state.seenEmittedFiles); newState.programEmitComplete = state.programEmitComplete; @@ -94384,13 +97883,18 @@ var ts; var seenEmittedFiles = state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap()); for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) { var affectedFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]); - if (affectedFile && !seenEmittedFiles.has(affectedFile.path)) { - // emit this file - state.affectedFilesPendingEmitIndex = i; - return affectedFile; + if (affectedFile) { + var seenKind = seenEmittedFiles.get(affectedFile.path); + var emitKind = ts.Debug.assertDefined(ts.Debug.assertDefined(state.affectedFilesPendingEmitKind).get(affectedFile.path)); + if (seenKind === undefined || seenKind < emitKind) { + // emit this file + state.affectedFilesPendingEmitIndex = i; + return { affectedFile: affectedFile, emitKind: emitKind }; + } } } state.affectedFilesPendingEmit = undefined; + state.affectedFilesPendingEmitKind = undefined; state.affectedFilesPendingEmitIndex = undefined; } return undefined; @@ -94409,7 +97913,7 @@ var ts; var options_2 = program_1.getCompilerOptions(); ts.forEach(program_1.getSourceFiles(), function (f) { return program_1.isSourceFileDefaultLibrary(f) && - !ts.skipTypeChecking(f, options_2) && + !ts.skipTypeChecking(f, options_2, program_1) && removeSemanticDiagnosticsOf(state, f.path); }); } @@ -94434,7 +97938,7 @@ var ts; ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.assertDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap); // If not dts emit, nothing more to do if (ts.getEmitDeclarations(state.compilerOptions)) { - addToAffectedFilesPendingEmit(state, [path]); + addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */); } } } @@ -94452,15 +97956,40 @@ var ts; state.semanticDiagnosticsPerFile.delete(path); return !state.semanticDiagnosticsFromOldState.size; } + function isChangedSignagure(state, path) { + var newSignature = ts.Debug.assertDefined(state.currentAffectedFilesSignatures).get(path); + var oldSignagure = ts.Debug.assertDefined(state.fileInfos.get(path)).signature; + return newSignature !== oldSignagure; + } /** * Iterate on referencing modules that export entities from affected file */ function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) { // If there was change in signature (dts output) for the changed file, // then only we need to handle pending file emit - if (!state.exportedModulesMap || state.affectedFiles.length === 1 || !state.changedFilesSet.has(affectedFile.path)) { + if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.path)) { return; } + if (!isChangedSignagure(state, affectedFile.path)) + return; + // Since isolated modules dont change js files, files affected by change in signature is itself + // But we need to cleanup semantic diagnostics and queue dts emit for affected files + if (state.compilerOptions.isolatedModules) { + var seenFileNamesMap = ts.createMap(); + seenFileNamesMap.set(affectedFile.path, true); + var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath); + while (queue.length > 0) { + var currentPath = queue.pop(); + if (!seenFileNamesMap.has(currentPath)) { + seenFileNamesMap.set(currentPath, true); + var result = fn(state, currentPath); + if (result && isChangedSignagure(state, currentPath)) { + var currentSourceFile = ts.Debug.assertDefined(state.program).getSourceFileByPath(currentPath); + queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath)); + } + } + } + } ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap); var seenFileAndExportsOfFile = ts.createMap(); // Go through exported modules from cache first @@ -94528,7 +98057,7 @@ var ts; * This is called after completing operation on the next affected file. * The operations here are postponed to ensure that cancellation during the iteration is handled correctly */ - function doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, isEmitResult) { + function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) { if (isBuildInfoEmit) { state.emittedBuildInfo = true; } @@ -94538,8 +98067,8 @@ var ts; } else { state.seenAffectedFiles.set(affected.path, true); - if (isEmitResult) { - (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, true); + if (emitKind !== undefined) { + (state.seenEmittedFiles || (state.seenEmittedFiles = ts.createMap())).set(affected.path, emitKind); } if (isPendingEmit) { state.affectedFilesPendingEmitIndex++; @@ -94552,15 +98081,15 @@ var ts; /** * Returns the result with affected file */ - function toAffectedFileResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit); + function toAffectedFileResult(state, result, affected) { + doneWithAffectedFile(state, affected); return { result: result, affected: affected }; } /** * Returns the result with affected file */ - function toAffectedFileEmitResult(state, result, affected, isPendingEmit, isBuildInfoEmit) { - doneWithAffectedFile(state, affected, isPendingEmit, isBuildInfoEmit, /*isEmitResult*/ true); + function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) { + doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit); return { result: result, affected: affected }; } /** @@ -94590,7 +98119,7 @@ var ts; if (state.compilerOptions.outFile || state.compilerOptions.out) return undefined; var currentDirectory = ts.Debug.assertDefined(state.program).getCurrentDirectory(); - var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getOutputPathForBuildInfo(state.compilerOptions), currentDirectory)); + var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory)); var fileInfos = {}; state.fileInfos.forEach(function (value, key) { var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key); @@ -94783,11 +98312,12 @@ var ts; */ function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { var affected = getNextAffectedFile(state, cancellationToken, computeHash); + var emitKind = 1 /* Full */; var isPendingEmitFile = false; if (!affected) { if (!state.compilerOptions.out && !state.compilerOptions.outFile) { - affected = getNextAffectedFilePendingEmit(state); - if (!affected) { + var pendingAffectedFile = getNextAffectedFilePendingEmit(state); + if (!pendingAffectedFile) { if (state.emittedBuildInfo) { return undefined; } @@ -94795,10 +98325,11 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, + affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1 /* Full */, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true); } + (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind); isPendingEmitFile = true; } else { @@ -94814,7 +98345,7 @@ var ts; return toAffectedFileEmitResult(state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile); + ts.Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile); } /** * Emits the JavaScript and declaration files. @@ -94870,7 +98401,7 @@ var ts; } // Add file to affected file pending emit to handle for later emit time if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) { - addToAffectedFilesPendingEmit(state, [affected.path]); + addToAffectedFilesPendingEmit(state, affected.path, 1 /* Full */); } // Get diagnostics for the affected file if its not ignored if (ignoreSourceFile && ignoreSourceFile(affected)) { @@ -94902,7 +98433,7 @@ var ts; } // When semantic builder asks for diagnostics of the whole program, // ensure that all the affected files are handled - // tslint:disable-next-line no-empty + // eslint-disable-next-line no-empty while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) { } var diagnostics; @@ -94914,8 +98445,14 @@ var ts; } } ts.createBuilderProgram = createBuilderProgram; - function addToAffectedFilesPendingEmit(state, affectedFilesPendingEmit) { - state.affectedFilesPendingEmit = ts.concatenate(state.affectedFilesPendingEmit, affectedFilesPendingEmit); + function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) { + if (!state.affectedFilesPendingEmit) + state.affectedFilesPendingEmit = []; + if (!state.affectedFilesPendingEmitKind) + state.affectedFilesPendingEmitKind = ts.createMap(); + var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit); + state.affectedFilesPendingEmit.push(affectedFilePendingEmit); + state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind); // affectedFilesPendingEmitIndex === undefined // - means the emit state.affectedFilesPendingEmit was undefined before adding current affected files // so start from 0 as array would be affectedFilesPendingEmit @@ -94948,7 +98485,7 @@ var ts; } var state = { fileInfos: fileInfos, - compilerOptions: convertFromReusableCompilerOptions(program.options, toAbsolutePath), + compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath), referencedMap: getMapOfReferencedSet(program.referencedMap, toPath), exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath), semanticDiagnosticsPerFile: program.semanticDiagnosticsPerFile && ts.arrayToMap(program.semanticDiagnosticsPerFile, function (value) { return toPath(ts.isString(value) ? value : value[0]); }, function (value) { return ts.isString(value) ? ts.emptyArray : value[1]; }), @@ -94984,33 +98521,6 @@ var ts; } } ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo; - function convertFromReusableCompilerOptions(options, toAbsolutePath) { - var result = {}; - var optionsNameMap = ts.getOptionNameMap().optionNameMap; - for (var name in options) { - if (ts.hasProperty(options, name)) { - result[name] = convertFromReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath); - } - } - if (result.configFilePath) { - result.configFilePath = toAbsolutePath(result.configFilePath); - } - return result; - } - function convertFromReusableCompilerOptionValue(option, value, toAbsolutePath) { - if (option) { - if (option.type === "list") { - var values = value; - if (option.element.isFilePath && values.length) { - return values.map(toAbsolutePath); - } - } - else if (option.isFilePath) { - return toAbsolutePath(value); - } - } - return value; - } function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) { return { getState: ts.notImplemented, @@ -95077,15 +98587,27 @@ var ts; // ignore "/user", "c:/users" or "c:/folderAtRoot" return false; } - if (dirPath.charCodeAt(0) !== 47 /* slash */ && - dirPath.substr(rootLength, nextDirectorySeparator).search(/users/i) === -1) { + var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1); + var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47 /* slash */; + if (isNonDirectorySeparatorRoot && + dirPath.search(/[a-zA-Z]:/) !== 0 && // Non dos style paths + pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) { // Dos style nextPart + nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1); + if (nextDirectorySeparator === -1) { + // ignore "//vda1cs4850/c$/folderAtRoot" + return false; + } + pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1); + } + if (isNonDirectorySeparatorRoot && + pathPartForUserCheck.search(/users\//i) !== 0) { // Paths like c:/folderAtRoot/subFolder are allowed return true; } for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) { searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1; if (searchIndex === 0) { - // Folder isnt at expected minimun levels + // Folder isnt at expected minimum levels return false; } } @@ -95331,7 +98853,7 @@ var ts; if (isInDirectoryPath(rootPath, failedLookupLocationPath)) { // Ensure failed look up is normalized path failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory()); - ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); // tslint:disable-line + ts.Debug.assert(failedLookupLocation.length === failedLookupLocationPath.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath); var subDirectoryInRoot = failedLookupLocationPath.indexOf(ts.directorySeparator, rootPath.length + 1); if (subDirectoryInRoot !== -1) { // Instead of watching root, watch directory in root to avoid watching excluded directories not needed for module resolution @@ -95542,6 +99064,10 @@ var ts; // Mark the file as needing re-evaluation of module resolution instead of using it blindly. resolution.isInvalidated = true; (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = ts.createMap())).set(containingFilePath, true); + // When its a file with inferred types resolution, invalidate type reference directive resolution + if (containingFilePath.endsWith(ts.inferredTypesContainingFile)) { + resolutionHost.onChangedAutomaticTypeDirectiveNames(); + } } }); }); @@ -95727,8 +99253,9 @@ var ts; function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) { return { relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 /* Relative */ : 1 /* NonRelative */, - ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? 2 /* JsExtension */ - : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, + ending: ts.hasJSOrJsonFileExtension(oldImportSpecifier) ? + 2 /* JsExtension */ : + ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 /* Index */ : 0 /* Minimal */, }; } function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, oldImportSpecifier) { @@ -95744,13 +99271,19 @@ var ts; return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, getPreferences(preferences, compilerOptions, importingSourceFile)); } moduleSpecifiers.getModuleSpecifier = getModuleSpecifier; + function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host, files, redirectTargetsMap) { + var info = getInfo(importingSourceFileName, host); + var modulePaths = getAllModulePaths(files, importingSourceFileName, nodeModulesFileName, info.getCanonicalFileName, host, redirectTargetsMap); + return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions, /*packageNameOnly*/ true); }); + } + moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName; function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, files, redirectTargetsMap, preferences) { var info = getInfo(importingSourceFileName, host); var modulePaths = getAllModulePaths(files, importingSourceFileName, toFileName, info.getCanonicalFileName, host, redirectTargetsMap); return ts.firstDefined(modulePaths, function (moduleFileName) { return tryGetModuleNameAsNodeModule(moduleFileName, info, host, compilerOptions); }) || getLocalModuleSpecifier(toFileName, info, compilerOptions, preferences); } - // Returns an import for each symlink and for the realpath. + /** Returns an import for each symlink and for the realpath. */ function getModuleSpecifiers(moduleSymbol, compilerOptions, importingSourceFile, host, files, userPreferences, redirectTargetsMap) { var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol); if (ambient) @@ -95809,38 +99342,12 @@ var ts; return ts.pathIsRelative(text) ? ts.hasJSOrJsonFileExtension(text) : undefined; }) || false; } - function stringsEqual(a, b, getCanonicalFileName) { - return getCanonicalFileName(a) === getCanonicalFileName(b); - } - // KLUDGE: Don't assume one 'node_modules' links to another. More likely a single directory inside the node_modules is the symlink. - // ALso, don't assume that an `@foo` directory is linked. More likely the contents of that are linked. - function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) { - return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@"); - } - function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) { - var aParts = ts.getPathComponents(ts.toPath(a, cwd, getCanonicalFileName)); - var bParts = ts.getPathComponents(ts.toPath(b, cwd, getCanonicalFileName)); - while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) && - !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) && - stringsEqual(aParts[aParts.length - 1], bParts[bParts.length - 1], getCanonicalFileName)) { - aParts.pop(); - bParts.pop(); - } - return [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)]; - } - function discoverProbableSymlinks(files, getCanonicalFileName, cwd) { - var result = ts.createMap(); - var symlinks = ts.flatten(ts.mapDefined(files, function (sf) { - return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) { - return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined; - }))); - })); - for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) { - var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1]; - var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName), commonResolved = _b[0], commonOriginal = _b[1]; - result.set(commonOriginal, commonResolved); - } - return result; + function numberOfDirectorySeparators(str) { + var match = str.match(/\//g); + return match ? match.length : 0; + } + function comparePathsByNumberOfDirectrorySeparators(a, b) { + return ts.compareValues(numberOfDirectorySeparators(a), numberOfDirectorySeparators(b)); } /** * Looks for existing imports that use symlinks to this module. @@ -95851,7 +99358,9 @@ var ts; var importedFileNames = redirects ? __spreadArrays(redirects, [importedFileName]) : [importedFileName]; var cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); }); - var links = discoverProbableSymlinks(files, getCanonicalFileName, cwd); + var links = host.getProbableSymlinks + ? host.getProbableSymlinks(files) + : ts.discoverProbableSymlinks(files, getCanonicalFileName, cwd); var result = []; var compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? ts.compareStringsCaseSensitive : ts.compareStringsCaseInsensitive; links.forEach(function (resolved, path) { @@ -95868,7 +99377,31 @@ var ts; } }); result.push.apply(result, targets); - return result; + if (result.length < 2) + return result; + // Sort by paths closest to importing file Name directory + var allFileNames = ts.arrayToMap(result, ts.identity, getCanonicalFileName); + var sortedPaths = []; + var _loop_17 = function (directory) { + var directoryStart = ts.ensureTrailingDirectorySeparator(directory); + var pathsInDirectory; + allFileNames.forEach(function (canonicalFileName, fileName) { + if (ts.startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push.apply(sortedPaths, pathsInDirectory); + } + }; + for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0; directory = ts.getDirectoryPath(directory)) { + _loop_17(directory); + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol) { var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); }); @@ -95910,7 +99443,7 @@ var ts; ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions) : ts.removeFileExtension(relativePath); } - function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options) { + function tryGetModuleNameAsNodeModule(moduleFileName, _a, host, options, packageNameOnly) { var getCanonicalFileName = _a.getCanonicalFileName, sourceDirectory = _a.sourceDirectory; if (!host.fileExists || !host.readFile) { return undefined; @@ -95919,28 +99452,34 @@ var ts; if (!parts) { return undefined; } + var packageJsonContent; var packageRootPath = moduleFileName.substring(0, parts.packageRootIndex); - var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); - var packageJsonContent = host.fileExists(packageJsonPath) - ? JSON.parse(host.readFile(packageJsonPath)) - : undefined; - var versionPaths = packageJsonContent && packageJsonContent.typesVersions - ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) - : undefined; - if (versionPaths) { - var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); - var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); - if (fromPaths !== undefined) { - moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + if (!packageNameOnly) { + var packageJsonPath = ts.combinePaths(packageRootPath, "package.json"); + packageJsonContent = host.fileExists(packageJsonPath) + ? JSON.parse(host.readFile(packageJsonPath)) + : undefined; + var versionPaths = packageJsonContent && packageJsonContent.typesVersions + ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions) + : undefined; + if (versionPaths) { + var subModuleName = moduleFileName.slice(parts.packageRootIndex + 1); + var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0 /* Minimal */, options), versionPaths.paths); + if (fromPaths !== undefined) { + moduleFileName = ts.combinePaths(moduleFileName.slice(0, parts.packageRootIndex), fromPaths); + } } } // Simplify the full file path to something that can be resolved by Node. // If the module could be imported by a directory name, use that directory's name - var moduleSpecifier = getDirectoryOrExtensionlessFileName(moduleFileName); + var moduleSpecifier = packageNameOnly ? moduleFileName : getDirectoryOrExtensionlessFileName(moduleFileName); + var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation(); // Get a path that's relative to node_modules or the importing file's path // if node_modules folder is in this folder or any of its parent folders, no need to keep it. - if (!ts.startsWith(sourceDirectory, getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)))) + var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex)); + if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) { return undefined; + } // If the module was found in @types, get the actual Node package name var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1); var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName); @@ -96131,6 +99670,15 @@ var ts; ? newLine + newLine : newLine; } + /** + * Get locale specific time based on whether we are in test mode + */ + function getLocaleTimeString(system) { + return !system.now ? + new Date().toLocaleTimeString() : + system.now().toLocaleTimeString("en-US", { timeZone: "UTC" }); + } + ts.getLocaleTimeString = getLocaleTimeString; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ @@ -96138,7 +99686,7 @@ var ts; return pretty ? function (diagnostic, newLine, options) { clearScreenIfNotWatchingForFileChanges(system, diagnostic, options); - var output = "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] "; + var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine); system.write(output); } : @@ -96147,7 +99695,7 @@ var ts; if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) { output += newLine; } - output += new Date().toLocaleTimeString() + " - "; + output += getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine); system.write(output); }; @@ -96156,7 +99704,7 @@ var ts; /** Parses config file using System interface */ function parseConfigFileWithSystem(configFileName, optionsToExtend, system, reportDiagnostic) { var host = system; - host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(ts.sys, reportDiagnostic, diagnostic); }; + host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); }; var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host); host.onUnRecoverableConfigFileDiagnostic = undefined; // TODO: GH#18217 return result; @@ -96180,7 +99728,7 @@ var ts; } ts.getErrorSummaryText = getErrorSummaryText; function listFiles(program, writeFileName) { - if (program.getCompilerOptions().listFiles) { + if (program.getCompilerOptions().listFiles || program.getCompilerOptions().listFilesOnly) { ts.forEach(program.getSourceFiles(), function (file) { writeFileName(file.fileName); }); @@ -96191,6 +99739,7 @@ var ts; * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ function emitFilesAndReportErrors(program, reportDiagnostic, writeFileName, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) { + var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly; // First get and report any syntactic errors. var diagnostics = program.getConfigFileParsingDiagnostics().slice(); var configFileParsingDiagnosticsLength = diagnostics.length; @@ -96199,13 +99748,17 @@ var ts; // semantic errors. if (diagnostics.length === configFileParsingDiagnosticsLength) { ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken)); - ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); - if (diagnostics.length === configFileParsingDiagnosticsLength) { - ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + if (!isListFilesOnly) { + ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken)); + if (diagnostics.length === configFileParsingDiagnosticsLength) { + ts.addRange(diagnostics, program.getSemanticDiagnostics(/*sourceFile*/ undefined, cancellationToken)); + } } } // Emit and report any errors we ran into. - var emitResult = program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + var emitResult = isListFilesOnly + ? { emitSkipped: true, diagnostics: ts.emptyArray } + : program.emit(/*targetSourceFile*/ undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics; ts.addRange(diagnostics, emitDiagnostics); ts.sortAndDeduplicateDiagnostics(diagnostics).forEach(reportDiagnostic); @@ -96354,7 +99907,9 @@ var ts; function createProgramHost(system, createProgram) { var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); }); var host = system; - host; // tslint:disable-line no-unused-expression (TODO: `host` is unused!) + // TODO: `host` is unused! + // eslint-disable-next-line no-unused-expressions + host; return { useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; }, getNewLine: function () { return system.newLine; }, @@ -96388,7 +99943,7 @@ var ts; result.afterProgramCreate = function (builderProgram) { var compilerOptions = builderProgram.getCompilerOptions(); var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; }); - emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions); }); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); }); }; return result; } @@ -96437,7 +99992,7 @@ var ts; function readBuilderProgram(compilerOptions, host) { if (compilerOptions.out || compilerOptions.outFile) return undefined; - var buildInfoPath = ts.getOutputPathForBuildInfo(compilerOptions); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions); if (!buildInfoPath) return undefined; var content = host.readFile(buildInfoPath); @@ -96995,12 +100550,22 @@ var ts; function isDeclarationFile(fileName) { return ts.fileExtensionIs(fileName, ".d.ts" /* Dts */); } + /*@internal*/ + function isCircularBuildOrder(buildOrder) { + return !!buildOrder && !!buildOrder.buildOrder; + } + ts.isCircularBuildOrder = isCircularBuildOrder; + /*@internal*/ + function getBuildOrderFromAnyBuildOrder(anyBuildOrder) { + return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder; + } + ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder; /** * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic */ function createBuilderStatusReporter(system, pretty) { return function (diagnostic) { - var output = pretty ? "[" + ts.formatColorAndReset(new Date().toLocaleTimeString(), ts.ForegroundColorEscapeSequences.Grey) + "] " : new Date().toLocaleTimeString() + " - "; + var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - "; output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine); system.write(output); }; @@ -97156,11 +100721,14 @@ var ts; var permanentMarks = ts.createMap(); var circularityReportStack = []; var buildOrder; + var circularDiagnostics; for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) { var root = roots_1[_i]; visit(root); } - return buildOrder || ts.emptyArray; + return circularDiagnostics ? + { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } : + buildOrder || ts.emptyArray; function visit(configFileName, inCircularContext) { var projPath = toResolvedConfigFilePath(state, configFileName); // Already visited @@ -97169,8 +100737,7 @@ var ts; // Circular if (temporaryMarks.has(projPath)) { if (!inCircularContext) { - // TODO:: Do we report this as error? - reportStatus(state, ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")); + (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n"))); } return; } @@ -97194,11 +100761,9 @@ var ts; } function createStateBuildOrder(state) { var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); })); - if (ts.arrayIsEqualTo(state.buildOrder, buildOrder)) - return state.buildOrder; // Clear all to ResolvedConfigFilePaths cache to start fresh state.resolvedConfigFilePaths.clear(); - var currentProjects = ts.arrayToSet(buildOrder, function (resolved) { return toResolvedConfigFilePath(state, resolved); }); + var currentProjects = ts.arrayToSet(getBuildOrderFromAnyBuildOrder(buildOrder), function (resolved) { return toResolvedConfigFilePath(state, resolved); }); var noopOnDelete = { onDeleteValue: ts.noop }; // Config file cache ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete); @@ -97219,6 +100784,8 @@ var ts; function getBuildOrderFor(state, project, onlyReferences) { var resolvedProject = project && resolveProjectName(state, project); var buildOrderFromState = getBuildOrder(state); + if (isCircularBuildOrder(buildOrderFromState)) + return buildOrderFromState; if (resolvedProject) { var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject); var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; }); @@ -97226,6 +100793,7 @@ var ts; return undefined; } var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState; + ts.Debug.assert(!isCircularBuildOrder(buildOrder)); ts.Debug.assert(!onlyReferences || resolvedProject !== undefined); ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject); return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder; @@ -97297,7 +100865,7 @@ var ts; reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode); } enableCache(state); - var buildOrder = getBuildOrder(state); + var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state)); buildOrder.forEach(function (configFileName) { return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None); }); @@ -97637,6 +101205,8 @@ var ts; function getNextInvalidatedProject(state, buildOrder, reportQueue) { if (!state.projectPendingBuild.size) return undefined; + if (isCircularBuildOrder(buildOrder)) + return undefined; if (state.currentInvalidatedProject) { // Only if same buildOrder the currentInvalidated project can be sent again return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ? @@ -97693,8 +101263,11 @@ var ts; if (status.type === ts.UpToDateStatusType.UpstreamBlocked) { reportAndStoreErrors(state, projectPath, config.errors); projectPendingBuild.delete(projectPath); - if (options.verbose) - reportStatus(state, ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + if (options.verbose) { + reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built : + ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName); + } continue; } if (status.type === ts.UpToDateStatusType.ContainerOnly) { @@ -97865,10 +101438,12 @@ var ts; continue; } // An upstream project is blocked - if (refStatus.type === ts.UpToDateStatusType.Unbuildable) { + if (refStatus.type === ts.UpToDateStatusType.Unbuildable || + refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) { return { type: ts.UpToDateStatusType.UpstreamBlocked, - upstreamProjectName: ref.path + upstreamProjectName: ref.path, + upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked }; } // If the upstream project is out of date, then so are we (someone shouldn't have asked, though?) @@ -97927,7 +101502,7 @@ var ts; } if (!state.buildInfoChecked.has(resolvedPath)) { state.buildInfoChecked.set(resolvedPath, true); - var buildInfoPath = ts.getOutputPathForBuildInfo(project.options); + var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options); if (buildInfoPath) { var value = state.readFileWithCache(buildInfoPath); var buildInfo = value && ts.getBuildInfo(value); @@ -98075,33 +101650,34 @@ var ts; setupInitialBuild(state, cancellationToken); var reportQueue = true; var successfulProjects = 0; - var errorProjects = 0; while (true) { var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue); if (!invalidatedProject) break; reportQueue = false; invalidatedProject.done(cancellationToken); - if (state.diagnostics.has(invalidatedProject.projectPath)) { - errorProjects++; - } - else { + if (!state.diagnostics.has(invalidatedProject.projectPath)) successfulProjects++; - } } disableCache(state); reportErrorSummary(state, buildOrder); startWatching(state, buildOrder); - return errorProjects ? - successfulProjects ? - ts.ExitStatus.DiagnosticsPresent_OutputsGenerated : - ts.ExitStatus.DiagnosticsPresent_OutputsSkipped : - ts.ExitStatus.Success; + return isCircularBuildOrder(buildOrder) + ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped + : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); }) + ? ts.ExitStatus.Success + : successfulProjects + ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated + : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped; } function clean(state, project, onlyReferences) { var buildOrder = getBuildOrderFor(state, project, onlyReferences); if (!buildOrder) return ts.ExitStatus.InvalidProject_OutputsSkipped; + if (isCircularBuildOrder(buildOrder)) { + reportErrors(state, buildOrder.circularDiagnostics); + return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped; + } var options = state.options, host = state.host; var filesToDelete = options.dry ? [] : undefined; for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) { @@ -98244,8 +101820,8 @@ var ts; if (!state.watchAllProjectsPending) return; state.watchAllProjectsPending = false; - for (var _i = 0, buildOrder_2 = buildOrder; _i < buildOrder_2.length; _i++) { - var resolved = buildOrder_2[_i]; + for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) { + var resolved = _a[_i]; var resolvedPath = toResolvedConfigFilePath(state, resolved); // Watch this file watchConfigFile(state, resolved, resolvedPath); @@ -98277,6 +101853,7 @@ var ts; }, invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); }, buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); }, + getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); }, }; } function relName(state, path) { @@ -98313,23 +101890,33 @@ var ts; reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]); } function reportErrorSummary(state, buildOrder) { - if (!state.needsSummary || (!state.watch && !state.host.reportErrorSummary)) + if (!state.needsSummary) return; state.needsSummary = false; + var canReportSummary = state.watch || !!state.host.reportErrorSummary; var diagnostics = state.diagnostics; - // Report errors from the other projects - buildOrder.forEach(function (project) { - var projectPath = toResolvedConfigFilePath(state, project); - if (!state.projectErrorsReported.has(projectPath)) { - reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); - } - }); var totalErrors = 0; - diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + if (isCircularBuildOrder(buildOrder)) { + reportBuildQueue(state, buildOrder.buildOrder); + reportErrors(state, buildOrder.circularDiagnostics); + if (canReportSummary) + totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics); + } + else { + // Report errors from the other projects + buildOrder.forEach(function (project) { + var projectPath = toResolvedConfigFilePath(state, project); + if (!state.projectErrorsReported.has(projectPath)) { + reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray); + } + }); + if (canReportSummary) + diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); }); + } if (state.watch) { reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors); } - else { + else if (state.host.reportErrorSummary) { state.host.reportErrorSummary(totalErrors); } } @@ -98362,13 +101949,16 @@ var ts; case ts.UpToDateStatusType.UpstreamOutOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_its_dependency_1_is_out_of_date, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.UpstreamBlocked: - return reportStatus(state, ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); + return reportStatus(state, status.upstreamProjectBlocked ? + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built : + ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName)); case ts.UpToDateStatusType.Unbuildable: return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason); case ts.UpToDateStatusType.TsVersionOutputOfDate: return reportStatus(state, ts.Diagnostics.Project_0_is_out_of_date_because_output_for_it_was_generated_with_version_1_that_differs_with_current_version_2, relName(state, configFileName), status.version, ts.version); case ts.UpToDateStatusType.ContainerOnly: // Don't report status on "solution" projects + // falls through case ts.UpToDateStatusType.ComputingUpstream: // Should never leak from getUptoDateStatusWorker break; @@ -98390,7 +101980,6 @@ var ts; (function (ts) { var server; (function (server) { - // tslint:disable variable-name server.ActionSet = "action::set"; server.ActionInvalidate = "action::invalidate"; server.ActionPackageInstalled = "action::packageInstalled"; @@ -99030,6 +102619,8 @@ var ts; this.sendResponse({ kind: server.EventBeginInstallTypes, eventId: requestId, + // qualified explicitly to prevent occasional shadowing + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier typingsInstallerVersion: ts.version, projectName: req.projectName }); @@ -99077,7 +102668,9 @@ var ts; projectName: req.projectName, packagesToInstall: scopedTypings, installSuccess: ok, - typingsInstallerVersion: ts.version // tslint:disable-line no-unnecessary-qualifier (qualified explicitly to prevent occasional shadowing) + // qualified explicitly to prevent occasional shadowing + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier + typingsInstallerVersion: ts.version }; _this.sendResponse(response); } diff --git a/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json b/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json index 2eb27cd90..062df5844 100644 --- a/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json @@ -441,7 +441,7 @@ "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391": "函数实现缺失或未立即出现在声明之后。", "Function_implementation_name_must_be_0_2389": "函数实现名称必须为“{0}”。", "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024": "由于函数不具有返回类型批注并且在它的一个返回表达式中得到直接或间接引用,因此它隐式具有返回类型 \"any\"。", - "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "函数缺少结束返回语句,返回类型不包括 \"undefined\"。", + "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "函数缺少结束 return 语句,返回类型不包括 \"undefined\"。", "Function_overload_must_be_static_2387": "函数重载必须为静态。", "Function_overload_must_not_be_static_2388": "函数重载不能为静态。", "Generate_get_and_set_accessors_95046": "生成 \"get\" 和 \"set\" 访问器", @@ -536,7 +536,7 @@ "JSX_elements_cannot_have_multiple_attributes_with_the_same_name_17001": "JSX 元素不能具有多个名称相同的特性。", "JSX_expressions_must_have_one_parent_element_2657": "JSX 表达式必须具有一个父元素。", "JSX_fragment_has_no_corresponding_closing_tag_17014": "JSX 片段没有相应的结束标记。", - "JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma_17017": "使用内联 JSX 工厂杂注时,不支持 JSX 片段", + "JSX_fragment_is_not_supported_when_using_an_inline_JSX_factory_pragma_17017": "使用内联 JSX 工厂 pragma 时,不支持 JSX 片段", "JSX_fragment_is_not_supported_when_using_jsxFactory_17016": "使用 --jsxFactory 时不支持 JSX 片段", "JSX_spread_child_must_be_an_array_type_2609": "JSX 扩展子属性必须为数组类型。", "Jump_target_cannot_cross_function_boundary_1107": "跳转目标不能跨越函数边界。", diff --git a/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json b/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json index bd1443da4..6496c4afa 100644 --- a/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +++ b/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json @@ -1,12 +1,12 @@ { - "A_0_modifier_cannot_be_used_with_an_import_declaration_1079": "'{0}' 修飾詞無法與匯入宣告並用。", - "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045": "'{0}' 修飾詞無法與介面宣告並用。", + "A_0_modifier_cannot_be_used_with_an_import_declaration_1079": "'{0}' 修飾元無法與匯入宣告並用。", + "A_0_modifier_cannot_be_used_with_an_interface_declaration_1045": "'{0}' 修飾元無法與介面宣告並用。", "A_0_parameter_must_be_the_first_parameter_2680": "'{0}' 參數必須為第一個參數。", "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463": "實作簽章中不得省略繫結模式參數。", "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105": "'break' 陳述式只可在封入的反覆項目或 switch 陳述式內使用。", "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116": "'break' 陳述式只可跳至封入之陳述式的標籤。", "A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments_2500": "類別只能實作具有選擇性型別引數的識別碼/限定名稱。", - "A_class_declaration_without_the_default_modifier_must_have_a_name_1211": "不具 'default' 修飾詞的類別宣告必須要有名稱。", + "A_class_declaration_without_the_default_modifier_must_have_a_name_1211": "不具 'default' 修飾元的類別宣告必須要有名稱。", "A_class_may_only_extend_another_class_2311": "每個類別只可擴充另一個類別。", "A_class_may_only_implement_another_class_or_interface_2422": "每個類別只可實作另一個類別或介面。", "A_class_member_cannot_have_the_0_keyword_1248": "類別成員不能含有 '{0}' 關鍵字。", @@ -25,8 +25,8 @@ "A_constructor_cannot_have_a_this_parameter_2681": "建構函式不能含有 'this' 參數。", "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104": "'continue' 陳述式只可在封入的反覆項目陳述式內使用。", "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115": "'continue' 陳述式只可跳至封入之反覆項目陳述式的標籤。", - "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038": "不得在現有環境內容中使用 'declare' 修飾詞。", - "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046": ".d.ts 檔案中的最上層宣告需要 'declare' 修飾詞。", + "A_declare_modifier_cannot_be_used_in_an_already_ambient_context_1038": "不得在現有環境內容中使用 'declare' 修飾元。", + "A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file_1046": ".d.ts 檔案中的最上層宣告需要 'declare' 修飾元。", "A_decorator_can_only_decorate_a_method_implementation_not_an_overload_1249": "一個裝飾項目只能裝飾一項方法實作,而不能多載。", "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113": "'default' 子句在 'switch' 陳述式中不得出現一次以上。", "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319": "預設匯出只能在 ECMAScript 樣式的模組中使用。", @@ -93,15 +93,15 @@ "Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression_2513": "無法透過 super 運算式存取類別 '{1}' 中的抽象方法 '{0}'。", "Abstract_methods_can_only_appear_within_an_abstract_class_1244": "抽象方法只可出現在抽象類別中。", "Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor_2715": "無法從建構函式存取類別 '{1}' 中的抽象屬性 '{0}'。", - "Accessibility_modifier_already_seen_1028": "已有存取範圍修飾詞。", + "Accessibility_modifier_already_seen_1028": "已有存取範圍修飾元。", "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056": "只有當目標為 ECMAScript 5 及更高版本時,才可使用存取子。", "Accessors_must_both_be_abstract_or_non_abstract_2676": "存取子必須兩者均為抽象或非抽象。", "Add_0_to_existing_import_declaration_from_1_90015": "從 \"{1}\" 將 '{0}' 新增至現有的匯入宣告", "Add_0_to_unresolved_variable_90008": "對未解析的變數新增 '{0}.'", - "Add_all_missing_async_modifiers_95041": "新增缺少的所有 'async' 修飾詞", + "Add_all_missing_async_modifiers_95041": "新增缺少的所有 'async' 修飾元", "Add_all_missing_members_95022": "新增遺漏的所有成員", "Add_all_missing_super_calls_95039": "新增缺少的所有 super 呼叫", - "Add_async_modifier_to_containing_function_90029": "將 async 修飾詞新增至包含的函式", + "Add_async_modifier_to_containing_function_90029": "將 async 修飾元新增至包含的函式", "Add_braces_to_arrow_function_95059": "將大括號新增至箭號函式", "Add_definite_assignment_assertion_to_property_0_95020": "將明確指派判斷提示新增至屬性 '{0}'", "Add_definite_assignment_assertions_to_all_uninitialized_properties_95028": "為所有未初始化的屬性新增明確的指派判斷提示", @@ -119,7 +119,7 @@ "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__5068": "新增 tsconfig.json 檔案有助於組織同時包含 TypeScript 及 JavaScript 檔案的專案。若要深入了解,請前往 https://aka.ms/tsconfig。", "Additional_Checks_6176": "其他檢查", "Advanced_Options_6178": "進階選項", - "All_declarations_of_0_must_have_identical_modifiers_2687": "'{0}' 的所有宣告都必須有相同修飾詞。", + "All_declarations_of_0_must_have_identical_modifiers_2687": "'{0}' 的所有宣告都必須有相同修飾元。", "All_declarations_of_0_must_have_identical_type_parameters_2428": "'{0}' 的所有宣告都必須具有相同的類型參數。", "All_declarations_of_an_abstract_method_must_be_consecutive_2516": "抽象方法的所有宣告必須連續。", "All_destructured_elements_are_unused_6198": "不會使用所有未經結構化的項目。", @@ -145,20 +145,20 @@ "An_export_assignment_can_only_be_used_in_a_module_1231": "匯出指派只可用於模組中。", "An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements_2309": "匯出指派不得用於具有其他匯出項目的模組中。", "An_export_assignment_cannot_be_used_in_a_namespace_1063": "命名空間中不可使用匯出指派。", - "An_export_assignment_cannot_have_modifiers_1120": "匯出指派不得有修飾詞。", + "An_export_assignment_cannot_have_modifiers_1120": "匯出指派不得有修飾元。", "An_export_declaration_can_only_be_used_in_a_module_1233": "匯出宣告只可用於模組中。", - "An_export_declaration_cannot_have_modifiers_1193": "匯出宣告不得有修飾詞。", + "An_export_declaration_cannot_have_modifiers_1193": "匯出宣告不得有修飾元。", "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198": "擴充的 Unicode 逸出值必須介於 0x0 與 0x10FFFF (不含) 之間。", "An_implementation_cannot_be_declared_in_ambient_contexts_1183": "不得在環境內容中宣告實作。", "An_import_declaration_can_only_be_used_in_a_namespace_or_module_1232": "匯入宣告只可用於命名空間或模組中。", - "An_import_declaration_cannot_have_modifiers_1191": "匯入宣告不得有修飾詞。", + "An_import_declaration_cannot_have_modifiers_1191": "匯入宣告不得有修飾元。", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691": "匯入路徑的結尾不得為 '{0}' 副檔名。請考慮改為匯入 '{1}'。", "An_index_expression_argument_must_be_of_type_string_number_symbol_or_any_2342": "索引運算式引數必須是 'string'、'number'、'symbol' 或 'any' 類型。", "An_index_signature_cannot_have_a_rest_parameter_1017": "索引簽章不得有剩餘參數。", "An_index_signature_must_have_a_type_annotation_1021": "索引簽章必須有類型註釋。", "An_index_signature_must_have_exactly_one_parameter_1096": "索引簽章只可有一個參數。", "An_index_signature_parameter_cannot_have_a_question_mark_1019": "索引簽章參數不得有問號。", - "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018": "索引簽章參數不得有存取範圍修飾詞。", + "An_index_signature_parameter_cannot_have_an_accessibility_modifier_1018": "索引簽章參數不得有存取範圍修飾元。", "An_index_signature_parameter_cannot_have_an_initializer_1020": "索引簽章參數不得有初始設定式。", "An_index_signature_parameter_must_have_a_type_annotation_1022": "索引簽章參數必須有類型註釋。", "An_index_signature_parameter_type_cannot_be_a_type_alias_Consider_writing_0_Colon_1_Colon_2_instead_1336": "索引簽章參數類型不能是類型別名。請考慮改為撰寫 '[{0}: {1}]: {2}'。", @@ -183,7 +183,7 @@ "Array_element_destructuring_pattern_expected_1181": "必須是陣列項目解構模式。", "Asterisk_Slash_expected_1010": "必須是 '*/'。", "Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_2669": "全域範圍的增強指定只能在外部模組宣告或環境模組宣告直接巢狀。", - "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670": "除非全域範圍的增強指定已顯示在環境內容中,否則應含有 'declare' 修飾詞。", + "Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambien_2670": "除非全域範圍的增強指定已顯示在環境內容中,否則應含有 'declare' 修飾元。", "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140": "專案 '{0}' 中已啟用鍵入的自動探索。正在使用快取位置 '{2}' 執行模組 '{1}' 的額外解析傳遞。", "Base_class_expressions_cannot_reference_class_type_parameters_2562": "基底類別運算式無法參考類別型別參數。", "Base_constructor_return_type_0_is_not_a_class_or_interface_type_2509": "基底建構函式傳回型別 '{0}' 不是類別或介面類型。", @@ -441,7 +441,7 @@ "Function_implementation_is_missing_or_not_immediately_following_the_declaration_2391": "遺漏函式實作,或函式實作未緊接在宣告之後。", "Function_implementation_name_must_be_0_2389": "函式實作名稱必須是 '{0}'。", "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024": "函式因為沒有傳回型別註解,並在其中一個傳回運算式中直接或間接參考了自己,所以隱含了傳回型別 'any'。", - "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "函式缺少結束傳回陳述式,且傳回類型不包括 'undefined'。", + "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366": "函式缺少結束 return 陳述式,且傳回類型不包括 'undefined'。", "Function_overload_must_be_static_2387": "函式多載必須為靜態。", "Function_overload_must_not_be_static_2388": "函式多載不可為靜態。", "Generate_get_and_set_accessors_95046": "產生 'get' 與 'set' 存取子", @@ -565,7 +565,7 @@ "Method_0_cannot_have_an_implementation_because_it_is_marked_abstract_1245": "因為方法 '{0}' 已標記為抽象,所以不可具有實作。", "Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2_4101": "匯出介面的方法 '{0}' 具有或使用私用模組 '{2}' 的名稱 '{1}'。", "Method_0_of_exported_interface_has_or_is_using_private_name_1_4102": "匯出介面的方法 '{0}' 具有或使用私用名稱 '{1}'。", - "Modifiers_cannot_appear_here_1184": "此處不得出現修飾詞。", + "Modifiers_cannot_appear_here_1184": "此處不得出現修飾元。", "Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_1340": "模組 '{0}' 未參考任何類型,但在此用為類型。", "Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here_1339": "模組 '{0}' 未參考任何值,但在此用為值。", "Module_0_has_already_exported_a_member_named_1_Consider_explicitly_re_exporting_to_resolve_the_ambig_2308": "模組 {0} 已匯出名為 '{1}' 的成員。請考慮明確重新匯出項目以解決模稜兩可的情形。", @@ -1009,26 +1009,26 @@ "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506": "'{0}' 在其本身的基底運算式中直接或間接受到參考。", "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502": "'{0}' 在其本身的類型註釋中直接或間接受到參考。", "_0_list_cannot_be_empty_1097": "'{0}' 清單不得為空白。", - "_0_modifier_already_seen_1030": "已有 '{0}' 修飾詞。", - "_0_modifier_cannot_appear_on_a_class_element_1031": "類別項目不得有 '{0}' 修飾詞。", - "_0_modifier_cannot_appear_on_a_constructor_declaration_1089": "建構函式宣告不得有 '{0}' 修飾詞。", - "_0_modifier_cannot_appear_on_a_data_property_1043": "資料屬性不得有 '{0}' 修飾詞。", - "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044": "模組或命名空間元素不能有 '{0}' 修飾詞。", - "_0_modifier_cannot_appear_on_a_parameter_1090": "參數不得有 '{0}' 修飾詞。", - "_0_modifier_cannot_appear_on_a_type_member_1070": "類型成員不能有 '{0}' 修飾詞。", - "_0_modifier_cannot_appear_on_an_index_signature_1071": "索引簽章不能有 '{0}' 修飾詞。", - "_0_modifier_cannot_be_used_here_1042": "無法在此處使用 '{0}' 修飾詞。", - "_0_modifier_cannot_be_used_in_an_ambient_context_1040": "無法在環境內容中使用 '{0}' 修飾詞。", - "_0_modifier_cannot_be_used_with_1_modifier_1243": "'{0}' 修飾詞無法與 '{1}' 修飾詞並用。", - "_0_modifier_cannot_be_used_with_a_class_declaration_1041": "'{0}' 修飾詞無法與類別宣告並用。", - "_0_modifier_must_precede_1_modifier_1029": "'{0}' 修飾詞必須在 '{1}' 修飾詞之前。", + "_0_modifier_already_seen_1030": "已有 '{0}' 修飾元。", + "_0_modifier_cannot_appear_on_a_class_element_1031": "類別項目不得有 '{0}' 修飾元。", + "_0_modifier_cannot_appear_on_a_constructor_declaration_1089": "建構函式宣告不得有 '{0}' 修飾元。", + "_0_modifier_cannot_appear_on_a_data_property_1043": "資料屬性不得有 '{0}' 修飾元。", + "_0_modifier_cannot_appear_on_a_module_or_namespace_element_1044": "模組或命名空間元素不能有 '{0}' 修飾元。", + "_0_modifier_cannot_appear_on_a_parameter_1090": "參數不得有 '{0}' 修飾元。", + "_0_modifier_cannot_appear_on_a_type_member_1070": "類型成員不能有 '{0}' 修飾元。", + "_0_modifier_cannot_appear_on_an_index_signature_1071": "索引簽章不能有 '{0}' 修飾元。", + "_0_modifier_cannot_be_used_here_1042": "無法在此處使用 '{0}' 修飾元。", + "_0_modifier_cannot_be_used_in_an_ambient_context_1040": "無法在環境內容中使用 '{0}' 修飾元。", + "_0_modifier_cannot_be_used_with_1_modifier_1243": "'{0}' 修飾元無法與 '{1}' 修飾元並用。", + "_0_modifier_cannot_be_used_with_a_class_declaration_1041": "'{0}' 修飾元無法與類別宣告並用。", + "_0_modifier_must_precede_1_modifier_1029": "'{0}' 修飾元必須在 '{1}' 修飾元之前。", "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702": "'{0}' 只參考類型,但在這裡用作命名空間。", "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693": "'{0}' 只會參考類型,但此處將其用為值。", "_0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead_2686": "'{0}' 指的是全域的 UMD,但目前的檔案為模組。請考慮改為新增匯入。", "_0_tag_already_specified_1223": "已指定 '{0}' 標記。", "_0_tag_cannot_be_used_independently_as_a_top_level_JSDoc_tag_1253": "'{0}' 標記不得獨立用作頂層 JSDoc 標記。", "_0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type_7010": "缺少傳回型別註解的 '{0}' 隱含了 '{1}' 傳回型別。", - "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242": "'abstract' 修飾詞只能出現在類別宣告、方法宣告或屬性宣告。", + "abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration_1242": "'abstract' 修飾元只能出現在類別宣告、方法宣告或屬性宣告。", "await_expression_is_only_allowed_within_an_async_function_1308": "只有非同步函式才允許 'await' 運算式。", "await_expressions_cannot_be_used_in_a_parameter_initializer_2524": "'await' 運算式不得用於參數初始設定式。", "baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1_6106": "'baseUrl' 選項已設為 '{0}'。此值將用於解析非相對的模組名稱 '{1}'。", @@ -1044,7 +1044,7 @@ "delete_this_Project_0_is_up_to_date_because_it_was_previously_built_6360": "刪除此項目 - 因為先前已建置專案 '{0}',所以其為最新狀態", "enum_declarations_can_only_be_used_in_a_ts_file_8015": "「列舉宣告」只可用於 .ts 檔案中。", "export_can_only_be_used_in_a_ts_file_8003": "'export=' 只可用於 .ts 檔案中。", - "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668": "'export' 修飾詞無法套用至環境模組或模組增強指定,原因是這二者永遠會顯示。", + "export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always__2668": "'export' 修飾元無法套用至環境模組或模組增強指定,原因是這二者永遠會顯示。", "extends_clause_already_seen_1172": "已經有 'extends' 子句。", "extends_clause_must_precede_implements_clause_1173": "'extends' 子句必須在 'implements' 子句之前。", "extends_clause_of_exported_class_0_has_or_is_using_private_name_1_4020": "匯出類別 '{0}' 的 'extends' 子句具有或使用私用名稱 '{1}'。", @@ -1069,7 +1069,7 @@ "package_json_has_0_field_1_that_references_2_6101": "'package.json' 有參考 '{2}' 的 '{0}' 欄位 '{1}'。", "parameter_modifiers_can_only_be_used_in_a_ts_file_8012": "'parameter modifiers' 只可用於 .ts 檔案中。", "paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0_6091": "'paths' 選項已指定,將尋找符合模組名稱 '{0}' 的模式。", - "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024": "'readonly' 修飾詞只能出現在屬性宣告或索引簽章。", + "readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature_1024": "'readonly' 修飾元只能出現在屬性宣告或索引簽章。", "require_call_may_be_converted_to_an_import_80005": "'require' 呼叫可能會轉換為匯入。", "rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0_6107": "'rootDirs' 選項已設定。該選項將用於解析相對的模組名稱 '{0}'。", "super_can_only_be_referenced_in_a_derived_class_2335": "只有衍生類別中才可參考 'super'。", diff --git a/node_modules/typescript/package.json b/node_modules/typescript/package.json index 6c34253ce..73c848846 100644 --- a/node_modules/typescript/package.json +++ b/node_modules/typescript/package.json @@ -1,8 +1,8 @@ { "_from": "typescript@^3.6.3", - "_id": "typescript@3.6.4", + "_id": "typescript@3.7.2", "_inBundle": false, - "_integrity": "sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==", + "_integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", "_location": "/typescript", "_phantomChildren": {}, "_requested": { @@ -16,10 +16,11 @@ "fetchSpec": "^3.6.3" }, "_requiredBy": [ - "/" + "#DEV:/", + "#USER" ], - "_resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.4.tgz", - "_shasum": "b18752bb3792bc1a0281335f7f6ebf1bbfc5b91d", + "_resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", + "_shasum": "27e489b95fa5909445e9fef5ee48d81697ad18fb", "_spec": "typescript@^3.6.3", "_where": "/Users/frankmcmanus/Documents/_dev/Typescript/website", "author": { @@ -33,7 +34,11 @@ "fs": false, "os": false, "path": false, - "@microsoft/typescript-etw": false + "crypto": false, + "buffer": false, + "@microsoft/typescript-etw": false, + "source-map-support": false, + "inspector": false }, "bugs": { "url": "https://github.com/Microsoft/TypeScript/issues" @@ -47,7 +52,6 @@ "@types/browserify": "latest", "@types/chai": "latest", "@types/convert-source-map": "latest", - "@types/del": "latest", "@types/glob": "latest", "@types/gulp": "^4.0.5", "@types/gulp-concat": "latest", @@ -69,15 +73,25 @@ "@types/through2": "latest", "@types/travis-fold": "latest", "@types/xml2js": "^0.4.0", + "@typescript-eslint/eslint-plugin": "2.3.2", + "@typescript-eslint/experimental-utils": "2.3.2", + "@typescript-eslint/parser": "2.3.2", + "async": "latest", "azure-devops-node-api": "^8.0.0", "browser-resolve": "^1.11.2", "browserify": "latest", "chai": "latest", "chalk": "latest", "convert-source-map": "latest", - "del": "latest", + "del": "5.1.0", + "eslint": "6.5.1", + "eslint-formatter-autolinkable-stylish": "1.0.3", + "eslint-plugin-import": "2.18.2", + "eslint-plugin-jsdoc": "15.9.9", + "eslint-plugin-no-null": "1.0.2", "fancy-log": "latest", "fs-extra": "^6.0.1", + "glob": "latest", "gulp": "^4.0.0", "gulp-concat": "latest", "gulp-insert": "latest", @@ -101,7 +115,6 @@ "source-map-support": "latest", "through2": "latest", "travis-fold": "latest", - "tslint": "latest", "typescript": "next", "vinyl": "latest", "vinyl-sourcemaps-apply": "latest", @@ -133,12 +146,17 @@ "gulp": "gulp", "jake": "gulp", "lint": "gulp lint", + "lint:ci": "gulp lint --ci", + "lint:compiler": "gulp lint-compiler", + "lint:scripts": "gulp lint-scripts", + "prepare": "gulp build-eslint-rules", "pretest": "gulp tests", "setup-hooks": "node scripts/link-hooks.js", "start": "node lib/tsc", "test": "gulp runtests-parallel --light=false", + "test:eslint-rules": "gulp run-eslint-rules-tests", "update-costly-tests": "node scripts/costly-tests.js" }, "typings": "./lib/typescript.d.ts", - "version": "3.6.4" + "version": "3.7.2" } diff --git a/package-lock.json b/package-lock.json index 78149ba67..655057700 100644 --- a/package-lock.json +++ b/package-lock.json @@ -336,6 +336,24 @@ "@babel/plugin-syntax-json-strings": "^7.2.0" } }, + "@babel/plugin-proposal-nullish-coalescing-operator": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.7.4.tgz", + "integrity": "sha512-TbYHmr1Gl1UC7Vo2HVuj/Naci5BEGNZ0AJhzqD2Vpr6QPFWpUmBRLrIDjedzx7/CShq0bRDS2gI4FIs77VHLVQ==", + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.7.4" + } + }, + "@babel/plugin-proposal-numeric-separator": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.7.4.tgz", + "integrity": "sha512-CG605v7lLpVgVldSY6kxsN9ui1DxFOyepBfuX2AzU2TNriMAYApoU55mrGw9Jr4TlrTzPCG10CL8YXyi+E/iPw==", + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-numeric-separator": "^7.7.4" + } + }, "@babel/plugin-proposal-object-rest-spread": { "version": "7.5.5", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.5.5.tgz", @@ -354,6 +372,15 @@ "@babel/plugin-syntax-optional-catch-binding": "^7.2.0" } }, + "@babel/plugin-proposal-optional-chaining": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.7.4.tgz", + "integrity": "sha512-JmgaS+ygAWDR/STPe3/7y0lNlHgS+19qZ9aC06nYLwQ/XB7c0q5Xs+ksFU3EDnp9EiEsO0dnRAOKeyLHTZuW3A==", + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-optional-chaining": "^7.7.4" + } + }, "@babel/plugin-proposal-unicode-property-regex": { "version": "7.4.4", "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.4.4.tgz", @@ -412,6 +439,22 @@ "@babel/helper-plugin-utils": "^7.0.0" } }, + "@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.7.4.tgz", + "integrity": "sha512-XKh/yIRPiQTOeBg0QJjEus5qiSKucKAiApNtO1psqG7D17xmE+X2i5ZqBEuSvo0HRuyPaKaSN/Gy+Ha9KFQolw==", + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-numeric-separator": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.7.4.tgz", + "integrity": "sha512-vmlUUBlLuFnbpaR+1kKIdo62xQEN+THWbtAHSEilo+0rHl2dKKCn6GLUVKpI848wL/T0ZPQgAy8asRJ9yYEjog==", + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, "@babel/plugin-syntax-object-rest-spread": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.2.0.tgz", @@ -428,6 +471,14 @@ "@babel/helper-plugin-utils": "^7.0.0" } }, + "@babel/plugin-syntax-optional-chaining": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.7.4.tgz", + "integrity": "sha512-2MqYD5WjZSbJdUagnJvIdSfkb/ucOC9/1fRJxm7GAxY6YQLWlUvkfxoNbUPcPLHJyetKUDQ4+yyuUyAoc0HriA==", + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, "@babel/plugin-syntax-top-level-await": { "version": "7.7.0", "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.7.0.tgz", @@ -437,9 +488,9 @@ } }, "@babel/plugin-syntax-typescript": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.3.3.tgz", - "integrity": "sha512-dGwbSMA1YhVS8+31CnPR7LB4pcbrzcV99wQzby4uAfrkZPYZlQ7ImwdpzLqi6Z6IL02b8IAL379CaMwo0x5Lag==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.7.4.tgz", + "integrity": "sha512-77blgY18Hud4NM1ggTA8xVT/dBENQf17OpiToSa2jSmEY3fWXD2jwrdVlO4kq5yzUTeF15WSQ6b4fByNvJcjpQ==", "requires": { "@babel/helper-plugin-utils": "^7.0.0" } @@ -798,26 +849,139 @@ } }, "@babel/plugin-transform-typescript": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.6.3.tgz", - "integrity": "sha512-aiWINBrPMSC3xTXRNM/dfmyYuPNKY/aexYqBgh0HBI5Y+WO5oRAqW/oROYeYHrF4Zw12r9rK4fMk/ZlAmqx/FQ==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.7.4.tgz", + "integrity": "sha512-X8e3tcPEKnwwPVG+vP/vSqEShkwODOEeyQGod82qrIuidwIrfnsGn11qPM1jBLF4MqguTXXYzm58d0dY+/wdpg==", "requires": { - "@babel/helper-create-class-features-plugin": "^7.6.0", + "@babel/helper-create-class-features-plugin": "^7.7.4", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-syntax-typescript": "^7.2.0" + "@babel/plugin-syntax-typescript": "^7.7.4" }, "dependencies": { + "@babel/generator": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.7.4.tgz", + "integrity": "sha512-m5qo2WgdOJeyYngKImbkyQrnUN1mPceaG5BV+G0E3gWsa4l/jCSryWJdM2x8OuGAOyh+3d5pVYfZWCiNFtynxg==", + "requires": { + "@babel/types": "^7.7.4", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + } + }, "@babel/helper-create-class-features-plugin": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.6.0.tgz", - "integrity": "sha512-O1QWBko4fzGju6VoVvrZg0RROCVifcLxiApnGP3OWfWzvxRZFCoBD81K5ur5e3bVY2Vf/5rIJm8cqPKn8HUJng==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.7.4.tgz", + "integrity": "sha512-l+OnKACG4uiDHQ/aJT8dwpR+LhCJALxL0mJ6nzjB25e5IPwqV1VOsY7ah6UB1DG+VOXAIMtuC54rFJGiHkxjgA==", "requires": { - "@babel/helper-function-name": "^7.1.0", - "@babel/helper-member-expression-to-functions": "^7.5.5", - "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/helper-function-name": "^7.7.4", + "@babel/helper-member-expression-to-functions": "^7.7.4", + "@babel/helper-optimise-call-expression": "^7.7.4", "@babel/helper-plugin-utils": "^7.0.0", - "@babel/helper-replace-supers": "^7.5.5", - "@babel/helper-split-export-declaration": "^7.4.4" + "@babel/helper-replace-supers": "^7.7.4", + "@babel/helper-split-export-declaration": "^7.7.4" + } + }, + "@babel/helper-function-name": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.4.tgz", + "integrity": "sha512-AnkGIdiBhEuiwdoMnKm7jfPfqItZhgRaZfMg1XX3bS25INOnLPjPG1Ppnajh8eqgt5kPJnfqrRHqFqmjKDZLzQ==", + "requires": { + "@babel/helper-get-function-arity": "^7.7.4", + "@babel/template": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.4.tgz", + "integrity": "sha512-QTGKEdCkjgzgfJ3bAyRwF4yyT3pg+vDgan8DSivq1eS0gwi+KGKE5x8kRcbeFTb/673mkO5SN1IZfmCfA5o+EA==", + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.7.4.tgz", + "integrity": "sha512-9KcA1X2E3OjXl/ykfMMInBK+uVdfIVakVe7W7Lg3wfXUNyS3Q1HWLFRwZIjhqiCGbslummPDnmb7vIekS0C1vw==", + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.7.4.tgz", + "integrity": "sha512-VB7gWZ2fDkSuqW6b1AKXkJWO5NyNI3bFL/kK79/30moK57blr6NbH8xcl2XcKCwOmJosftWunZqfO84IGq3ZZg==", + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-replace-supers": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.7.4.tgz", + "integrity": "sha512-pP0tfgg9hsZWo5ZboYGuBn/bbYT/hdLPVSS4NMmiRJdwWhP0IznPwN9AE1JwyGsjSPLC364I0Qh5p+EPkGPNpg==", + "requires": { + "@babel/helper-member-expression-to-functions": "^7.7.4", + "@babel/helper-optimise-call-expression": "^7.7.4", + "@babel/traverse": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.4.tgz", + "integrity": "sha512-guAg1SXFcVr04Guk9eq0S4/rWS++sbmyqosJzVs8+1fH5NI+ZcmkaSkc7dmtAFbHFva6yRJnjW3yAcGxjueDug==", + "requires": { + "@babel/types": "^7.7.4" + } + }, + "@babel/parser": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.4.tgz", + "integrity": "sha512-jIwvLO0zCL+O/LmEJQjWA75MQTWwx3c3u2JOTDK5D3/9egrWRRA0/0hk9XXywYnXZVVpzrBYeIQTmhwUaePI9g==" + }, + "@babel/template": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.4.tgz", + "integrity": "sha512-qUzihgVPguAzXCK7WXw8pqs6cEwi54s3E+HrejlkuWO6ivMKx9hZl3Y2fSXp9i5HgyWmj7RKP+ulaYnKM4yYxw==", + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4" + } + }, + "@babel/traverse": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.7.4.tgz", + "integrity": "sha512-P1L58hQyupn8+ezVA2z5KBm4/Zr4lCC8dwKCMYzsa5jFMDMQAzaBNy9W5VjB+KAmBjb40U7a/H6ao+Xo+9saIw==", + "requires": { + "@babel/code-frame": "^7.5.5", + "@babel/generator": "^7.7.4", + "@babel/helper-function-name": "^7.7.4", + "@babel/helper-split-export-declaration": "^7.7.4", + "@babel/parser": "^7.7.4", + "@babel/types": "^7.7.4", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.4.tgz", + "integrity": "sha512-cz5Ji23KCi4T+YIE/BolWosrJuSmoZeN1EFnRtBwF+KKLi8GG/Z2c2hOJJeCXPk4mwk4QFvTmwIodJowXgttRA==", + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" } } } @@ -923,12 +1087,12 @@ } }, "@babel/preset-typescript": { - "version": "7.6.0", - "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.6.0.tgz", - "integrity": "sha512-4xKw3tTcCm0qApyT6PqM9qniseCE79xGHiUnNdKGdxNsGUc2X7WwZybqIpnTmoukg3nhPceI5KPNzNqLNeIJww==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/preset-typescript/-/preset-typescript-7.7.4.tgz", + "integrity": "sha512-rqrjxfdiHPsnuPur0jKrIIGQCIgoTWMTjlbWE69G4QJ6TIOVnnRnIJhUxNTL/VwDmEAVX08Tq3B1nirer5341w==", "requires": { "@babel/helper-plugin-utils": "^7.0.0", - "@babel/plugin-transform-typescript": "^7.6.0" + "@babel/plugin-transform-typescript": "^7.7.4" } }, "@babel/runtime": { @@ -1509,7 +1673,8 @@ "@mdx-js/react": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/@mdx-js/react/-/react-1.5.1.tgz", - "integrity": "sha512-eF05YysHqtyXerLId0kPKtxmJ3PE60GJJvx1gOguEQndbs94fUeYTVSfBlnXPPAAzvOmVKrZmktIYsBQlVjpOw==" + "integrity": "sha512-eF05YysHqtyXerLId0kPKtxmJ3PE60GJJvx1gOguEQndbs94fUeYTVSfBlnXPPAAzvOmVKrZmktIYsBQlVjpOw==", + "dev": true }, "@mdx-js/util": { "version": "1.5.1", @@ -1638,9 +1803,9 @@ } }, "@types/react": { - "version": "16.9.3", - "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.3.tgz", - "integrity": "sha512-Ogb2nSn+2qQv5opoCv7Ls5yFxtyrdUYxp5G+SWTrlGk7dmFKw331GiezCgEZj9U7QeXJi1CDtws9pdXU1zUL4g==", + "version": "16.9.13", + "resolved": "https://registry.npmjs.org/@types/react/-/react-16.9.13.tgz", + "integrity": "sha512-LikzRslbiufJYHyzbHSW0GrAiff8QYLMBFeZmSxzCYGXKxi8m/1PHX+rsVOwhr7mJNq+VIu2Dhf7U6mjFERK6w==", "requires": { "@types/prop-types": "*", "csstype": "^2.2.0" @@ -1650,6 +1815,7 @@ "version": "16.9.4", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.4.tgz", "integrity": "sha512-fya9xteU/n90tda0s+FtN5Ym4tbgxpq/hb/Af24dvs6uYnYn+fspaxw5USlw0R8apDNwxsqumdRoCoKitckQqw==", + "dev": true, "requires": { "@types/react": "*" } @@ -4952,7 +5118,8 @@ "diff": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz", - "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==" + "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==", + "dev": true }, "diffie-hellman": { "version": "5.0.3", @@ -5666,6 +5833,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-2.7.0.tgz", "integrity": "sha512-CStQYJgALoQBw3FsBzH0VOVDRnJ/ZimUlpLm226U8qgqYJfPOY/CPK6wyRInMxh73HSKg5wyRwdS4BVYYHwokA==", + "dev": true, "requires": { "fast-diff": "^1.1.1", "jest-docblock": "^21.0.0" @@ -6110,7 +6278,8 @@ "fast-diff": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz", - "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==" + "integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==", + "dev": true }, "fast-glob": { "version": "2.2.7", @@ -8629,27 +8798,30 @@ "integrity": "sha512-NnlT0YVsPYS/yQLNebo5Sr+Vp/eYvvxm3IPPQzBcnWZQo0ODaxv7Gi66PoHXEaRxQ1L7SSJQPasCX67kTQR+oQ==" }, "gatsby-plugin-typescript": { - "version": "2.1.12", - "resolved": "https://registry.npmjs.org/gatsby-plugin-typescript/-/gatsby-plugin-typescript-2.1.12.tgz", - "integrity": "sha512-BdtMMAzFzwBGo7MSPZti315tptYBzVZiiIno+X/qPapkPDhhQIkSt4zM1R5atXHvUOqlYKNo3uVAhb/4T1O4Ng==", - "requires": { - "@babel/preset-typescript": "^7.6.0", - "@babel/runtime": "^7.6.3", - "babel-plugin-remove-graphql-queries": "^2.7.11" + "version": "2.1.19", + "resolved": "https://registry.npmjs.org/gatsby-plugin-typescript/-/gatsby-plugin-typescript-2.1.19.tgz", + "integrity": "sha512-SevAhAKUqmZZO+7TNXM2c2BSaHzSx79FBN84UNPCVVq4l7kK1aUdvyYaxjiwYbJzOVjqOkrjLTzjt3I2MUADNA==", + "requires": { + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4", + "@babel/plugin-proposal-numeric-separator": "^7.2.0", + "@babel/plugin-proposal-optional-chaining": "^7.6.0", + "@babel/preset-typescript": "^7.7.2", + "@babel/runtime": "^7.7.2", + "babel-plugin-remove-graphql-queries": "^2.7.16" }, "dependencies": { "@babel/runtime": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.6.3.tgz", - "integrity": "sha512-kq6anf9JGjW8Nt5rYfEuGRaEAaH1mkv3Bbu6rYvLOpPh/RusSJXuKPEAoZ7L7gybZkchE8+NV5g9vKF4AGAtsA==", + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.4.tgz", + "integrity": "sha512-r24eVUUr0QqNZa+qrImUk8fn5SPhHq+IfYvIoIMg0do3GdK9sMdiLKP3GYVVaxpPKORgm8KRKaNTEhAjgIpLMw==", "requires": { "regenerator-runtime": "^0.13.2" } }, "babel-plugin-remove-graphql-queries": { - "version": "2.7.11", - "resolved": "https://registry.npmjs.org/babel-plugin-remove-graphql-queries/-/babel-plugin-remove-graphql-queries-2.7.11.tgz", - "integrity": "sha512-w3PNFlgtn2HIiEb4/67Q1WkRUCPm9o0czT6Ow98E92PtOfeervUgF8z+As66iWXj8snhQCA5nckGzcJ1NEOCsw==" + "version": "2.7.16", + "resolved": "https://registry.npmjs.org/babel-plugin-remove-graphql-queries/-/babel-plugin-remove-graphql-queries-2.7.16.tgz", + "integrity": "sha512-E2/hzXJ4VxxDDptG5ycZlEMoKdi+10NbpbbyYCmNVS1X+RH/baVPZ1x8T91aQauAqpW02uUeHTP0cpqvC2JoLw==" } } }, @@ -10832,7 +11004,8 @@ "jest-docblock": { "version": "21.2.0", "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-21.2.0.tgz", - "integrity": "sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw==" + "integrity": "sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw==", + "dev": true }, "jest-worker": { "version": "23.2.0", @@ -11044,7 +11217,8 @@ "lines-and-columns": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz", - "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=" + "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", + "dev": true }, "load-bmfont": { "version": "1.4.0", @@ -14175,14 +14349,13 @@ } }, "react": { - "version": "16.8.6", - "resolved": "https://registry.npmjs.org/react/-/react-16.8.6.tgz", - "integrity": "sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw==", + "version": "16.12.0", + "resolved": "https://registry.npmjs.org/react/-/react-16.12.0.tgz", + "integrity": "sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA==", "requires": { "loose-envify": "^1.1.0", "object-assign": "^4.1.1", - "prop-types": "^15.6.2", - "scheduler": "^0.13.6" + "prop-types": "^15.6.2" } }, "react-dev-utils": { @@ -16963,9 +17136,10 @@ "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" }, "tslint": { - "version": "5.20.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz", - "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==", + "version": "5.20.1", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.1.tgz", + "integrity": "sha512-EcMxhzCFt8k+/UP5r8waCf/lzmeSyVlqxqMEDQE7rWYiQky8KpIBz1JAoYXfROHrPZ1XXd43q8yQnULOLiBRQg==", + "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "builtin-modules": "^1.1.1", @@ -16985,19 +17159,22 @@ "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true } } }, "tslint-config-prettier": { "version": "1.18.0", "resolved": "https://registry.npmjs.org/tslint-config-prettier/-/tslint-config-prettier-1.18.0.tgz", - "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==" + "integrity": "sha512-xPw9PgNPLG3iKRxmK7DWr+Ea/SzrvfHtjFt5LBl61gk2UBG/DB9kCXRjv+xyIU1rUtnayLeMUVJBcMX8Z17nDg==", + "dev": true }, "tslint-loader": { "version": "3.5.4", "resolved": "https://registry.npmjs.org/tslint-loader/-/tslint-loader-3.5.4.tgz", "integrity": "sha512-jBHNNppXut6SgZ7CsTBh+6oMwVum9n8azbmcYSeMlsABhWWoHwjq631vIFXef3VSd75cCdX3rc6kstsB7rSVVw==", + "dev": true, "requires": { "loader-utils": "^1.0.2", "mkdirp": "^0.5.1", @@ -17010,6 +17187,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/tslint-plugin-prettier/-/tslint-plugin-prettier-2.0.1.tgz", "integrity": "sha512-4FX9JIx/1rKHIPJNfMb+ooX1gPk5Vg3vNi7+dyFYpLO+O57F4g+b/fo1+W/G0SUOkBLHB/YKScxjX/P+7ZT/Tw==", + "dev": true, "requires": { "eslint-plugin-prettier": "^2.2.0", "lines-and-columns": "^1.1.6", @@ -17020,6 +17198,7 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/tslint-react/-/tslint-react-4.1.0.tgz", "integrity": "sha512-Y7CbFn09X7Mpg6rc7t/WPbmjx9xPI8p1RsQyiGCLWgDR6sh3+IBSlT+bEkc0PSZcWwClOkqq2wPsID8Vep6szQ==", + "dev": true, "requires": { "tsutils": "^3.9.1" }, @@ -17028,6 +17207,7 @@ "version": "3.17.1", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.17.1.tgz", "integrity": "sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g==", + "dev": true, "requires": { "tslib": "^1.8.1" } @@ -17038,6 +17218,7 @@ "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, "requires": { "tslib": "^1.8.1" } @@ -17093,9 +17274,10 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, "typescript": { - "version": "3.6.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.4.tgz", - "integrity": "sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==" + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", + "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", + "dev": true }, "ua-parser-js": { "version": "0.7.20", diff --git a/package.json b/package.json index 8e2adfd83..65e74dc51 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,6 @@ "author": "Kyle Mathews ", "dependencies": { "@mdx-js/mdx": "^1.5.1", - "@mdx-js/react": "^1.5.1", - "@types/react": "^16.9.3", - "@types/react-dom": "^16.9.1", "@types/styled-components": "^4.1.19", "gatsby": "^2.13.31", "gatsby-cli": "^2.7.21", @@ -19,25 +16,28 @@ "gatsby-plugin-react-helmet": "^3.1.2", "gatsby-plugin-sharp": "^2.2.8", "gatsby-plugin-tslint": "0.0.2", - "gatsby-plugin-typescript": "^2.1.11", + "gatsby-plugin-typescript": "^2.1.19", "gatsby-source-filesystem": "^2.1.5", "gatsby-transformer-remark": "^2.6.37", "gatsby-transformer-sharp": "^2.2.4", "prop-types": "^15.7.2", - "react": "^16.8.6", + "react": "^16.12.0", "react-dom": "^16.8.6", "react-helmet": "^5.2.1", - "styled-components": "^4.4.0", - "tslint": "^5.20.0", + "styled-components": "^4.4.0" + }, + "devDependencies": { + "@mdx-js/react": "^1.5.1", + "@types/react": "^16.9.13", + "@types/react-dom": "^16.9.4", + "babel-plugin-styled-components": "^1.10.6", + "prettier": "^1.18.2", + "tslint": "^5.20.1", "tslint-config-prettier": "^1.18.0", "tslint-loader": "^3.5.4", "tslint-plugin-prettier": "^2.0.1", "tslint-react": "^4.1.0", - "typescript": "^3.6.3" - }, - "devDependencies": { - "babel-plugin-styled-components": "^1.10.6", - "prettier": "^1.18.2" + "typescript": "^3.7.2" }, "keywords": [ "gatsby" @@ -50,7 +50,8 @@ "start": "npm run develop", "serve": "gatsby serve", "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\"", - "type-check": "tsc --noEmit" + "type-check": "tsc --noEmit", + "lint": "tslint --project ." }, "repository": { "type": "git", diff --git a/src/components/NotFound.tsx b/src/components/NotFound.tsx index b9b648e55..141ded937 100644 --- a/src/components/NotFound.tsx +++ b/src/components/NotFound.tsx @@ -2,11 +2,11 @@ import { Link } from "gatsby"; import React from "react"; export default function NotFound() { - return ( -
- -

I am a NotFound

- -
- ) -}; + return ( +
+ +

I am a NotFound

+ +
+ ); +} diff --git a/src/pages/past-meetups.tsx b/src/pages/past-meetups.tsx index 71bbac65b..b2d0d92ab 100644 --- a/src/pages/past-meetups.tsx +++ b/src/pages/past-meetups.tsx @@ -1,12 +1,8 @@ -import React from "react" -// import Layout from "../components/layout" -import MeetupList from "../components/MeetupList" - +import React from "react"; +import MeetupList from "../components/MeetupList"; const meetupList = () => ( - - - + ) -export default meetupList \ No newline at end of file +export default meetupList; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 1c58f2521..7eae04aff 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,13 @@ { + "rulesDirectory": ["tslint-pluign-prettier"], + "extneds": ["tslint:latest", "tslint-react", "tslint-config-prettier"], + "rules": { + "prettier": true, + "jsx-mo-multiline-js": false, + "jsx-no-lambda": false, + "import-name": false, + "no-boolean-literal-compare": false + }, "compilerOptions": { /* Basic Options */ // "incremental": true, /* Enable incremental compilation */ diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 7753033f6..000000000 --- a/tslint.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"], - "rulesDirectory": ["tslint-plugin-prettier"], - "rules": { - "prettier": true, - "jsx-no-multiline-js": false, - "jsx-no-lambda": false, - "import-name": false, - "no-boolean-literal-compare": false - } -} \ No newline at end of file